News:

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

cannot create a window

Started by qklxtlx, July 18, 2010, 04:18:27 AM

Previous topic - Next topic

qklxtlx


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~~~

sinsi

Is hInst initialised? I noticed hInstance is but no hInst
What does RegisterClassEx return?
If you are using windbg try !gle
Light travels faster than sound, that's why some people seem bright until you hear them.

qklxtlx

sorry because I cut code from two proc together...
hInst = hInstance in fact.
and I tried useinvoke GetLastErrorbut eax = 000000

sinsi

Make sure your WM_CREATE handler returns 0

Not enough of your code to know.

edit: try using WS_VISIBLE
Light travels faster than sound, that's why some people seem bright until you hear them.

qklxtlx

      invoke RegisterClassEx, ADDR wc
eax = 0000C1B4(or else~~~not 000000)-->registered

I am new to masm32 and not familiar with win32 api...

qklxtlx

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

qklxtlx

 :bg :bg :bg
Again I find the problem myself...
I lost some code in WndProc proc~~~

thanks a lot~sinsi :bdg :bdg :bdg