News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Custom MessageBox Button Text

Started by dedndave, August 16, 2011, 11:16:09 PM

Previous topic - Next topic

dedndave

it's an old design paradigm of mine i like to call "maybe logic"

maybe it will......
....but then again, maybe it won't   :bg

"possibly" just shifts the odds a little

(which pretty much describes how well my little routine is working)

hutch--

 :bg

Dve,

This exercise in tweaking a system message box must be being done for amusement or perhaps academia, here is a quick scruffy 4 button dialog that coded up in a few minutes.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

....and it didn't work

:bg

i had to add InitCommonControls

but - that is a lot of code for 1 box
the routine i am writing can be used over and over in the same program to make several types of boxes
that is the real advantage of using MessageBox or MessageBoxIndirect
the system does a lot of the work for you

p.s. i didn't think you were old enough to remember Greta Garbo   :P
back in the day, i always had a thing for Gene Tierney and June Allyson

dedndave

i suppose, if you learned your way around the templates, you could do something similar with dialog boxes
you could write a routine that builds the template on the stack
and let the user create a small structure to define the outine and point to button strings
pass that to a function and let it make the box
the buttons could have the same ID every time - like messagebox
no need for more than 4 buttons - usually 3 is plenty

i must admit, the messagebox functions give you some stuff that isn't very usable in a generic way   :P

hutch--

Funny enough I originally had "InitCommonControls()" but it worked without it so I removed it.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

i think a good rue of thumb is - if you have a manifest, it needs it


jj2007

Quote from: hutch-- on August 19, 2011, 05:02:43 AM
Funny enough I originally had "InitCommonControls()" but it worked without it so I removed it.

I had to add it, too. Without it, the code assembles and links fine, it runs but even a call to a simple MsgBox does not show anything.
start:
print "I am a console app", 13, 10
invoke MessageBox, 0, str$(eax), chr$("Result"), MB_OK
print "... and there should have been a MsgBox", 13, 10

Text comes over clearly, provided you used console assembly, but no MsgBox...
If, however, you comment out the manifest in rsrc.rc...
//1 24 "manifest.xml"
... it works like a charm even without InitCommonControls. So Dave is absolutely right :U

hutch--

What fascinates me with this variation is I use a normal installation of a US edition of XP SP3 with no MS updates and it runs everything. Same with my Win7 64 bit. The 2 editions are respectively XP SP3 Professional and Win7 64 bit Ultimate edition.

I used to routinely enable all common controls but Erol found that his Turkish version would not run if they were all enabled but not used.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

the ms updates must be the difference
i have a pretty complete set of them on this machine, up to dotNOT 4.0, which gives XP MCE fits

QuoteErol found that his Turkish version would not run if they were all enabled but not used.

makes you wonder how they knew which ones you were going to use - lol
it must be that some just plain did not work correctly on that machine

hutch--

See if this one works, it ony enables the win95 controls.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dedndave

first time   :bg

ICC_WIN95_CLASSES includes a lot of stuff

dedndave

it would probably be more correct to say...

if your manifest file specifies a version of CommonControls, the program should include InitCommonControls/Ex

dedndave

ok - question, Hutch

in the resource file for the "multibutton" example you posted earlier...
100 DIALOGEX 327,117,334,88
CAPTION " Make A Decision"
FONT 8,"MS Shell Dlg",0,0,0
STYLE WS_POPUP|WS_VISIBLE|WS_CAPTION|WS_SYSMENU|DS_CENTER|DS_MODALFRAME
BEGIN
  CONTROL "Yes",IDC_BTN1,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,86,62,56,14
  CONTROL "No",IDC_BTN2,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,146,62,56,14
  CONTROL "Who Cares",IDC_BTN3,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,206,62,56,14
  CONTROL "Outa Here",IDC_BTN4,"Button",WS_CHILDWINDOW|WS_VISIBLE|WS_TABSTOP,266,62,56,14
  CONTROL "",IDC_IMG1,"Static",WS_CHILDWINDOW|WS_VISIBLE|SS_CENTERIMAGE|SS_ICON,14,12,64,64
  CONTROL "IDC_STC",IDC_STC1,"Static",WS_CHILDWINDOW|WS_VISIBLE,88,12,232,44
END


not sure i understand that last one
i do not see IDC_STC or IDC_STC1 referenced anywhere in the asm source
is that how you position the "message" text ?

seems like a lot of overhead for ms to create a control to put text in there - lol

ok - i did find it in the asm source as "106" - hLabel

Gunner

He references it by number in code - 106


        case WM_INITDIALOG
          m2m hWnd, hWin    ; Copy hWin to GLOBAL variable
          invoke SendMessage,hWin,WM_SETICON,1,FUNC(LoadIcon,hInstance,500)

        ; --------------------------------
        ; Get the handle for each control
        ; --------------------------------
          mov hButn1,    rv(GetDlgItem,hWin,101)
          mov hButn2,    rv(GetDlgItem,hWin,102)
          mov hButn3,    rv(GetDlgItem,hWin,103)
          mov hButn4,    rv(GetDlgItem,hWin,104)
          mov hImage,    rv(GetDlgItem,hWin,105)
          mov hLabel,    rv(GetDlgItem,hWin,106)
~Rob (Gunner)
- IE Zone Editor
- Gunners File Type Editor
http://www.gunnerinc.com