The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: qklxtlx on July 18, 2010, 04:18:27 AM

Title: cannot create a window
Post by: qklxtlx on July 18, 2010, 04:18:27 AM

invoke GetModuleHandle, NULL
mov hInstance, eax
...(set wc)
invoke RegisterClassEx, ADDR wc
      invoke CreateWindowEx,WS_EX_LEFT,
                            ADDR szClassName,
                            ADDR szDisplayName,
                            WS_OVERLAPPEDWINDOW,
                            Wtx,Wty,Wwd,Wht,
                            NULL,NULL,
                            hInst,NULL
      mov   hWnd,eax

szClassName, szDisplayName,Wtx, Wty, Wwd, Wht have all been set
complied but no window was created~~~
When debugging, I find that after CreateWindowEx, hWnd(eax) = 000000...
need help~~~
Title: Re: cannot create a window
Post by: sinsi on July 18, 2010, 04:46:08 AM
Is hInst initialised? I noticed hInstance is but no hInst
What does RegisterClassEx return?
If you are using windbg try !gle
Title: Re: cannot create a window
Post by: qklxtlx on July 18, 2010, 04:50:11 AM
sorry because I cut code from two proc together...
hInst = hInstance in fact.
and I tried useinvoke GetLastErrorbut eax = 000000
Title: Re: cannot create a window
Post by: sinsi on July 18, 2010, 05:08:37 AM
Make sure your WM_CREATE handler returns 0

Not enough of your code to know.

edit: try using WS_VISIBLE
Title: Re: cannot create a window
Post by: qklxtlx on July 18, 2010, 05:21:20 AM
      invoke RegisterClassEx, ADDR wc
eax = 0000C1B4(or else~~~not 000000)-->registered

I am new to masm32 and not familiar with win32 api...
Title: Re: cannot create a window
Post by: qklxtlx on July 18, 2010, 05:25:41 AM
invoke GetModuleHandle, NULL
mov hInst, eax

      invoke LoadIcon,hInst,500
      mov hIcon, eax

      mov wc.cbSize,         sizeof WNDCLASSEX
      mov wc.style,          CS_BYTEALIGNWINDOW
      mov wc.lpfnWndProc,    offset WndProc
      mov wc.cbClsExtra,     NULL
      mov wc.cbWndExtra,     NULL
      m2m wc.hInstance,      hInst
      mov wc.hbrBackground,  COLOR_BTNFACE+1
      mov wc.lpszMenuName,   NULL
      mov wc.lpszClassName,  offset szClassName
      m2m wc.hIcon,          hIcon
      invoke LoadCursor,NULL,IDC_ARROW
      mov wc.hCursor,        eax
      m2m wc.hIconSm,        hIcon

      invoke RegisterClassEx, ADDR wc
      ;window size
      mov Wwd, 600
      mov Wht, 700
     ;window top-left
     mov Wtx, 100
    mov Wty, 100

      invoke CreateWindowEx,WS_EX_LEFT, ADDR szClassName, ADDR szDisplayName,WS_OVERLAPPEDWINDOW,Wtx,Wty,Wwd,Wht,NULL,NULL,hInst,NULL
      mov   hWnd,eax
Title: Re: cannot create a window
Post by: qklxtlx on July 18, 2010, 05:33:00 AM
 :bg :bg :bg
Again I find the problem myself...
I lost some code in WndProc proc~~~

thanks a lot~sinsi :bdg :bdg :bdg