News:

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

Question about CreateDialogParam

Started by br0kenpipe, December 20, 2005, 03:42:48 PM

Previous topic - Next topic

br0kenpipe

Hi,
I have a question about CreateDialogParam. I use this code to try and display an About dialog that I have in my resource file:

Invoke CreateDialogParam,hInst,1000,hWnd,ADDR AboutDialogProcedure,NULL
mov dWnd,eax
Invoke ShowWindow,dWnd,SW_SHOWNORMAL
Invoke UpdateWindow,dWnd


CreateDialogParam returns a window handle to my about box, but it never displays. Anyone have any idea why? I've debugged it in OllyDbg, and I can see that the window handle is correct.

Also, another question. What do I need to do to be able to create the dialog using the dialog name, rather than id? Like:

Invoke CreateDialogParam,hInst,IDD_ABOUT,hWnd,ADDR AboutDialogProcedure,NULL
mov dWnd,eax
Invoke ShowWindow,dWnd,SW_SHOWNORMAL
Invoke UpdateWindow,dWnd


Sorry if this have been answered before, but I couldn't find it when I searched.

Best regards,
Anders Pettersson


Edit:
Never mind, it was just the resource file being messed up. Sorry.

MichaelW

Hi Anders, welcome to the forum.

There are several examples of dialogs from a resource file in \masm32\examples\exampl05. The example in \masm32\examples\exampl05\enumkeys uses the name of the dialog box template rather than a resource identifier.

For an alternative method, you might take a look at the "Prebuilt Library Dialog Demo" in \masm32\examples\dialogs\pbddemo. It includes a pre-built in-memory about box dialog.

eschew obfuscation

G`HOST

Try this in your AboutDialogProcedure :
       
    .IF uMsg==WM_INITDIALOG
          Invoke ShowWindow,dWnd,SW_SHOWNORMAL
          Invoke UpdateWindow,dWnd

this thing worried me too ,so (i m just guessing) maybe u r facing the same prob.
Quote
The dialog box procedure is very similar to a window procedure except for the type of return value which is TRUE/FALSE instead of LRESULT.the general rule of thumb is that: if our dialog box procedure processes a message,it MUST return TRUE in eax and if it does not process the message, it must return FALSE in eax. Note that a dialog box procedure doesn't pass the messages it does not process to the DefWindowProc call since it's not a real window procedure.


AboutDialogProcedure proc .......................
.if uMsg==WM_INITDIALOG
    ;Code here
.elseif uMsg== ??
    ;Code here
else
   mov eax,FALSE
   ret
.endif
    mov eax,TRUE
    ret
hope this will help. :U

br0kenpipe

Thanks for your answers! I found out that the reason the dialog didn't show up was because i had managed to screw up the resource file. Redid it, and now it works. But thanks for valuable input. I learnt some new things.   :P