flat assembler
Message board for the users of flat assembler.

Index > Windows > LISTBOX, please help

Author
Thread Post new topic Reply to topic
Helg



Joined: 20 Sep 2006
Posts: 2
Helg 17 Feb 2007, 01:52
What is not correct in this code?
Code:
format PE GUI 4.0
entry start

include '%fasminc%\win32a.inc'

section '.data' data readable writeable

caption         db "Listbox example",0
item1           db 'Item1',0
item2           db 'Item2',0
hCursor         dd ?
hInstance       dd ?
hListBox        dd ?
IndexItem       dd ?
buffer          rb 10

section '.text' code readable executable

start:
        invoke  GetModuleHandle, NULL
        mov     [hInstance],eax
        invoke  DialogBoxParam,[hInstance],1000,NULL,DlgProc,NULL
        invoke  ExitProcess,eax

proc DlgProc hWnd, uMsg, wParam, lParam
        
        cmp [uMsg],WM_CLOSE
        jne @f
                invoke  EndDialog,[hWnd],NULL
        jmp rtr

    @@:
        cmp [uMsg],WM_INITDIALOG
        jne @f
                invoke  LoadCursor,0,IDC_CROSS
                mov     [hCursor],eax
                invoke  GetDlgItem,[hWnd],1001
                mov     [hListBox],eax
                invoke  SendMessage,[hListBox],LB_ADDSTRING,0, item1
                invoke  SendMessage,[hListBox],LB_ADDSTRING,0, item2
        jmp rtr

    @@:
        cmp [uMsg],WM_SETCURSOR
        jne @f
                invoke  SetCursor,[hCursor]
        jmp rtr

    @@:
        cmp [uMsg],WM_COMMAND
        jne rtr1
                mov     edx,[wParam]
                shr     edx,16
                        cmp dx,LBN_DBLCLK
                        jne rtr
                            invoke  SendMessage,[hListBox],LB_GETCURSEL,0,0
                            mov     [IndexItem], eax
                            invoke  SendMessage,[hListBox],LB_GETTEXT,[IndexItem],buffer
                            invoke  MessageBox,0,buffer,caption,MB_OK
                        jmp rtr
         rtr1:
                mov     eax,FALSE
                ret
     rtr:
        mov     eax,TRUE
        ret
endp

section '.idata' import data readable writeable

library kernel,'KERNEL32.DLL',\
          user,'USER32.DLL'

  import kernel,\
         GetModuleHandle,'GetModuleHandleA',\
         ExitProcess,'ExitProcess'

 import user,\
          DialogBoxParam,'DialogBoxParamA',\
          GetDlgItemText,'GetDlgItemTextA',\
          MessageBox,'MessageBoxA',\
          EndDialog,'EndDialog',\
          GetDlgItem,'GetDlgItem',\
          SendMessage,'SendMessageA',\
          LoadCursor,'LoadCursorA',\
          SetCursor,'SetCursor'


section '.rsrc' resource data readable
directory RT_DIALOG,dialogs

  resource dialogs,\
           1000,LANG_ENGLISH+SUBLANG_DEFAULT,MyDialog

  dialog MyDialog,'Listbox example',6,6,250,102,WS_SYSMENU + WS_VISIBLE
     dialogitem 'LISTBOX','',1001,50,25,150,50, LBS_HASSTRINGS+WS_EX_CLIENTEDGE+WS_VISIBLE+WS_BORDER+WS_CHILD
     dialogitem 'STATIC', "Double click on listbox items", 1, 50, 5, 154, 13,WS_VISIBLE
  enddialog                                
Post 17 Feb 2007, 01:52
View user's profile Send private message Reply with quote
asmfan



Joined: 11 Aug 2006
Posts: 392
Location: Russian
asmfan 17 Feb 2007, 12:01
You should specify LBS_NOTIFY for LISTBOX.
Post 17 Feb 2007, 12:01
View user's profile Send private message Reply with quote
Helg



Joined: 20 Sep 2006
Posts: 2
Helg 20 Feb 2007, 22:36
thanks
Post 20 Feb 2007, 22:36
View user's profile Send private message 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.