The MASM Forum Archive 2004 to 2012

Project Support Forums => GoAsm Assembler and Tools => Topic started by: PhM on September 30, 2005, 01:52:59 PM

Title: GoAsm and RegisterClassEx
Post by: PhM on September 30, 2005, 01:52:59 PM
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


Title: Re: GoAsm and RegisterClassEx
Post by: jorgon on September 30, 2005, 02:36:04 PM
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)?

Title: Re: GoAsm and RegisterClassEx
Post by: PhM on September 30, 2005, 04:02:35 PM
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
   
Title: Re: GoAsm and RegisterClassEx
Post by: PhM on September 30, 2005, 04:25:33 PM
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]
Title: Re: GoAsm and RegisterClassEx
Post by: jorgon on October 01, 2005, 08:57:17 AM
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.