News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Really simple dialogs

Started by jj2007, September 17, 2012, 10:45:51 AM

Previous topic - Next topic

jj2007

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--

These look good JJ, I don't suppose we could have a close button on the unicode dialog ?

jj2007

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--

JJ,

I was more thinking WS_SYSMENU so that you could click the system menu.

jj2007

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--


jj2007

Quote from: hutch-- on September 17, 2012, 12:37:23 PM
Elegant simplicity.

9 files for a really simple dialog ::)

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

hutch--

 :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.

Gunther

Hi Jochen,

Quote from: jj2007 on September 19, 2012, 08:54:11 AM
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


Gunther

Jochen,

you're welcome. Great work.

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

kroz


johnparker29

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.