Author Topic: Really simple dialogs  (Read 15204 times)

jj2007

  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Really simple dialogs
« on: September 17, 2012, 10:45:51 AM »
Hutch has written great macros in dialogs.inc, see demos in \masm32\examples\dialogs_later.
The new MasmBasic macros are inspired by his work but even more "basic", in the sense: the Right ThingTM for beginners. Here is an example showing a prompt for entering data, on exit available in the Dlg$() array for further processing:

include \masm32\MasmBasic\MasmBasic.inc        ; download
  Init
  DlgDefine "Please enter your data, tab for next line:", 0, 0, 150, -4
  DlgControl dcEdit,   "First name", WS_BORDER or WS_TABSTOP, 1, -2              ; first control gets the focus
  DlgControl dcEdit,   "Family name", WS_BORDER or WS_TABSTOP, 1, -4           ; x, y only, the macro will assign width, height and ID
  DlgControl dcStatic,   "Type your first name:", SS_LEFT, 1, -1, 70.0           ; 70 means 70% - the buttons need space
  DlgControl dcButton,   "OK", BS_DEFPUSHBUTTON or WS_TABSTOP, 71.0, -1, 12.0, , IDOK        ; x=71%, y, width=14%, height, ID
  DlgControl dcButton,   "Quit", BS_PUSHBUTTON or WS_TABSTOP, 84.0, -1, 16.0, , IDCANCEL
  DlgControl dcStatic,   wCat$("Type your family name: (it's "+wTime$+" now)"), SS_LEFT, 1, -3
; DlgHandler MyHandler        ; optional - PM me for details
  DlgShow
  .if eax==IDOK
       wMsgBox 0, wCat$(Dlg$(0)+wCrLf$+Dlg$(1)), "Please confirm::", MB_OKCANCEL
  .endif
  Exit
end start

Another example showing how easy it is to code a Unicode dialog:

include \masm32\MasmBasic\MasmBasic.inc   ; download
  Init
  DlgDefine "Simpler than that is difficult:", 0, 0, 87, 82, DS_CENTER, 14   ; text, x, y, width, height [, style] [, font size] [, font face]
  DlgControl dcStatic, "... but why make it simple when you could code complicate stuff, too?", SS_LEFT, 2, 2, , 30
  DlgControl dcEdit, wCat$(wRes$(3)+wCrLf$+wRes$(403)+wCrLf$+wRes$(803)+wCrLf$+wRes$(1203)) , ES_MULTILINE or WS_BORDER, 3, 33, , 38
  DlgShow
  Exit
end start

I attach the sources and executables, plus a simple RTF viever coded in 54 lines. You need the MasmBasic version of today 17 September to assemble the examples.

Enjoy, jj

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10572
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Really simple dialogs
« Reply #1 on: September 17, 2012, 10:48:40 AM »
These look good JJ, I don't suppose we could have a close button on the unicode dialog ?
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: Really simple dialogs
« Reply #2 on: September 17, 2012, 10:57:08 AM »
Hutch,

DS_CENTER or WS_OVERLAPPEDWINDOW would do the job, as we all know  :biggrin:

However, I find hitting Escape Really SimpleTM, that's why I left it with DS_CENTER ;-)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10572
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Really simple dialogs
« Reply #3 on: September 17, 2012, 11:03:02 AM »
JJ,

I was more thinking WS_SYSMENU so that you could click the system menu.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: Really simple dialogs
« Reply #4 on: September 17, 2012, 11:32:54 AM »
Hutch,

Actually I think the style is pretty useless ;-)

Of course, you could be more explicit:

  DlgDefine "Simple?", 0, 0, 118, 69, DS_CENTER or WS_SYSMENU, 20, "Times New Roman"       ; x, y, width, height [, style] [, font size] [, font face]

But the simple solution does the job, too:

include \masm32\MasmBasic\MasmBasic.inc   ; download
  Init
  DlgDefine "Simpler than that is difficult:", 0, 0, 118, 69
  DlgControl dcStatic, "... but why make it simple when you could code complicate stuff, too?", SS_CENTER, 1, 0, , 20   ; x, y, ?, height
  DlgControl dcEdit, wCat$(wRes$(3)+wCrLf$+wRes$(403)+wCrLf$+wRes$(803)+wCrLf$+wRes$(1203)) , ES_MULTILINE, 2, 20, , 36
  DlgShow
  Exit
end start

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10572
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Really simple dialogs
« Reply #5 on: September 17, 2012, 12:37:23 PM »
Elegant simplicity.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: Really simple dialogs
« Reply #6 on: September 19, 2012, 08:54:11 AM »
Elegant simplicity.

9 files for a really simple dialog ::)

How do you define simplicity? My definition is here - with some mysteries ;-)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 10572
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Re: Really simple dialogs
« Reply #7 on: September 19, 2012, 09:09:03 AM »
 :biggrin:

I blame Microsoft for it, source file, mainfest file, RC file with version control block, an icon and a batch file to build it without needing an editor/IDE. The rest are binaries built by the assembler/linker and the resource compiler.
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

Gunther

  • Member
  • *****
  • Posts: 4178
  • Forgive your enemies, but never forget their names
Re: Really simple dialogs
« Reply #8 on: September 20, 2012, 02:01:39 AM »
Hi Jochen,

How do you define simplicity? My definition is here - with some mysteries ;-)

That's real simplicity and very impressive.  :t

Gunther
You have to know the facts before you can distort them.

jj2007

  • Member
  • *****
  • Posts: 13871
  • Assembly is fun ;-)
    • MasmBasic
Re: Really simple dialogs
« Reply #9 on: September 20, 2012, 02:50:32 AM »
That's real simplicity and very impressive.  :t

Danke  :biggrin:

Gunther

  • Member
  • *****
  • Posts: 4178
  • Forgive your enemies, but never forget their names
Re: Really simple dialogs
« Reply #10 on: September 21, 2012, 05:17:50 AM »
Jochen,

you're welcome. Great work.

Gunther
You have to know the facts before you can distort them.

kroz

  • Guest
Re: Really simple dialogs
« Reply #11 on: September 21, 2012, 11:27:54 AM »
very nice :)

johnparker29

  • Guest
Re: Really simple dialogs
« Reply #12 on: September 30, 2012, 11:40:31 PM »
I fault Microsoft for it, source computer file, mainfest computer file, RC computer file with edition control block, an symbol and a set computer file to build it without requiring an editor/IDE. The rest are binaries built by the assembler/linker and the resource compiler.