flat assembler
Message board for the users of flat assembler.
Index
> Windows > createwindowex |
Author |
|
pelaillo 07 Apr 2004, 21:19
It looks right but it returns the hwnd of new window if succesful.
In order to help, you need to post more code. |
|||
07 Apr 2004, 21:19 |
|
coconut 07 Apr 2004, 21:24
used the same code from the template, just added a couple lines
also privalov, can ya add a select all to the editor? Code: format PE GUI 4.0 entry start include '%fasminc%\win32a.inc' section '.data' data readable writeable _title db 'acctmgr',0 _class db 'FASMWIN32',0 _lb db 'listbox',0 mainhwnd dd ? hinstance dd ? msg MSG wc WNDCLASS section '.code' code readable executable start: invoke GetModuleHandle,0 mov [hinstance],eax invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax mov [wc.style],0 mov [wc.lpfnWndProc],WindowProc mov [wc.cbClsExtra],0 mov [wc.cbWndExtra],0 mov eax,[hinstance] mov [wc.hInstance],eax mov [wc.hbrBackground],COLOR_BTNFACE+1 mov [wc.lpszMenuName],0 mov [wc.lpszClassName],_class invoke RegisterClass,wc invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_DLGFRAME+WS_SYSMENU,128,128,192,192,NULL,NULL,[hinstance],NULL mov [mainhwnd],eax msg_loop: invoke GetMessage,msg,NULL,0,0 or eax,eax jz end_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop end_loop: invoke ExitProcess,[msg.wParam] proc WindowProc, hwnd,wmsg,wparam,lparam push ebx esi edi cmp [wmsg],WM_DESTROY je wmdestroy cmp [wmsg],WM_CREATE je wmcreate defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp finish wmcreate: invoke CreateWindowEx,0,_lb,0,WS_VISIBLE+WS_CHILD+LBS_STANDARD,150,150,150,150,[mainhwnd],100,[hinstance],NULL or eax,eax jz finish wmdestroy: invoke PostQuitMessage,0 xor eax,eax finish: pop edi esi ebx return endp |
|||
07 Apr 2004, 21:24 |
|
pelaillo 07 Apr 2004, 22:01
Now I see. Check this:
Code: invoke CreateWindowEx,0,_lb,0,WS_VISIBLE+WS_CHILD+LBS_STANDARD,5,5,150,150,[hwnd],0,[hinstance],NULL or eax,eax jne finish |
|||
07 Apr 2004, 22:01 |
|
coconut 07 Apr 2004, 22:18
works thanks, didnt notice [mainhwnd]
why do you jump to finish if not equal? whzt happens if the call fails? |
|||
07 Apr 2004, 22:18 |
|
pelaillo 08 Apr 2004, 21:56
eax becomes zero if the window cannot be created, otherwise it takes the value of new handler.
If eax is zero, the flow of the program continues to wmdestroy and the program just exit. Better if you branch in zero to a complimentary message saying that window could not be generated. |
|||
08 Apr 2004, 21:56 |
|
msmith 25 Jun 2004, 02:50
Why did changing [mainhwnd] to [hwnd] fix this problem?
Why doesn't the use of [hwnd] without previously being declared cause an error? Thanks for any help. |
|||
25 Jun 2004, 02:50 |
|
comrade 25 Jun 2004, 03:03
mainhwnd is only defined after CreateWindowEx
CreateWindowEx calls a nested WM_CREATE thus, while in WM_CREATE, mainhwnd is undefined (zero?) but, hwnd is defined locally, so its always defined to a valid value |
|||
25 Jun 2004, 03:03 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.