flat assembler
Message board for the users of flat assembler.

Index > Windows > createwindowex

Author
Thread Post new topic Reply to topic
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 07 Apr 2004, 20:38
trying to create a listbox onto the win32 template example window included with fasm. the following code isnt working, can anyone tell me why?

Code:
 wmcreate:
        invoke  CreateWindowEx,0,_lb,0,WS_VISIBLE+WS_CHILD+LBS_STANDARD,150,150,150,150,[mainhwnd],100,[hinstance],NULL
        or      eax,eax ;eax should be 1 if succesful?
        jz      finish 
    



thanks
Post 07 Apr 2004, 20:38
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
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.
Post 07 Apr 2004, 21:19
View user's profile Send private message Yahoo Messenger Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
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    
[/code]
Post 07 Apr 2004, 21:24
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
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
    
Post 07 Apr 2004, 22:01
View user's profile Send private message Yahoo Messenger Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
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?
Post 07 Apr 2004, 22:18
View user's profile Send private message Reply with quote
pelaillo
Missing in inaction


Joined: 19 Jun 2003
Posts: 878
Location: Colombia
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.
Post 08 Apr 2004, 21:56
View user's profile Send private message Yahoo Messenger Reply with quote
msmith



Joined: 22 Jun 2003
Posts: 40
Location: Missouri
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.
Post 25 Jun 2004, 02:50
View user's profile Send private message Reply with quote
comrade



Joined: 16 Jun 2003
Posts: 1150
Location: Russian Federation
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

_________________
comrade (comrade64@live.com; http://comrade.ownz.com/)
Post 25 Jun 2004, 03:03
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.