News:

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

GoAsm and RegisterClassEx

Started by PhM, September 30, 2005, 01:52:59 PM

Previous topic - Next topic

PhM

Hi,
First I have to say that I enjoy coming back to Assembly language. I decided to use GoAsm because of the Unicode support which is important for my applications. So many thanks to Jeremy Gordon for the Go Tools and also to KetilO for RadAsm !  :U
I only have one question about GoAsm : how to use RegisterClassEx to give my main dialog a custom class name ?
(instead of the original "#32770").
I did it with Masm32 and it worked fine, but never succeeded to have it work with GoAsm both Ascii or Unicode.
It looks like the class is registered as I have no error but the Dialog just doesn't show ! Same problem with modal or modeless dialogs.
Thank you in advance for any solution,
Philippe Marechal / France



jorgon

Hi PhM, welcome to the forum, and thanks for your comments.

As for your problem with RegisterClassEx, are you having trouble with the CLASS statement in the resource file, or in setting the cbWndExtra member of the WNDCLASSEX structure to DLGWINDOWEXTRA (value 30 decimal)?

Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)

PhM

Thanks for your remply,
Here's the code I use (in the dialog resource editor I fill the "Class" edit box with Custom_Class) :

DATA SECTION
    hInstance   DD    ?
    szClassName DW   "Custom_Class",0      ;this is the custom class name for my dialog...

...

start:
   push   0
   call    [GetModuleHandle]
   mov    [hInstance],eax
   invoke _RegisterClass,[hInstance]
   call    _InitComControls

   ;Dialog creation...
   push   0
   push   offset DlgProc
   push   0
   push   IDD_DLG1
   push   [hInstance]
   call   [DialogBoxParam]
   
   push   0
   call   [ExitProcess]

;This is the function I use to register my custom dialog class...
_RegisterClass FRAME hInst

    LOCAL      wc:WNDCLASSEX
    mov           D[wc.cbSize],sizeof WNDCLASSEX
    mov           D[wc.style],CS_HREDRAW or CS_VREDRAW
    mov           [wc.lpfnWndProc],offset DlgProc
    mov           [wc.cbClsExtra],NULL
    mov           [wc.cbWndExtra],DLGWINDOWEXTRA
    push      [hInst]
    pop           [wc.hInstance]
    invoke       GetSysColorBrush,COLOR_BTNFACE
    mov           [wc.hbrBackground],eax
    mov           [wc.lpszMenuName],NULL
    mov           [wc.lpszClassName],offset szClassName
    invoke       LoadIcon,NULL,IDI_APPLICATION
    mov           [wc.hIcon],eax
    mov           [wc.hIconSm],eax
    invoke       LoadCursor,NULL,IDC_ARROW
    mov           [wc.hCursor],eax
    invoke       RegisterClassEx,addr wc
    ;mov         [wc],eax
    ret

endf

_InitComControls FRAME
   
   local iccex:INITCOMMONCONTROLSEX
   mov   D[iccex.dwSize],SIZEOF INITCOMMONCONTROLSEX
   mov   D[iccex.dwICC],ICC_WIN95_CLASSES
   push   ADDR iccex      
   call   [InitCommonControlsEx]   
   
   RET
   
endf

This solution worked correctly with Masm 32. I always use this solution with my C or C++ Apps.
Thank you very much for your help,
Sincerly,
PhM
   

PhM

Hi jorgon,
I attached a zip of the RadAsm project to this reply, better than making mistakes typing the code !
PhM

[attachment deleted by admin]

jorgon

Hi PhM

In the files you posted, in the INITDIALOG routine, I noticed a spare "pop ebx" just before the jump to exit.  If it is correct that this is not supposed to be there it would be throwing the stack out by 4 bytes at an early stage of dialog-creation probably causing the dialog not to appear.

Sorry I haven't retried your code with this removed, because I do not have my machine set up to use Radasm.
Author of the "Go" tools (GoAsm, GoLink, GoRC, GoBug)