flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
windwakr 10 Nov 2008, 22:01
Heres the original with all the stuff, before I tried having just a button....it works. Its a mix of the template, iczelion tutorials and my own stuff.
Code: format PE GUI 4.0 entry start include 'win32a.inc' section '.data' data readable writeable ;; wHMain dd ? wHInstance dd ? ;; _class TCHAR 'FASM32',0 _title TCHAR 'Test Program',0 _error TCHAR 'Startup failed.',0 wc WNDCLASS 0,WindowProc,0,0,NULL,NULL,NULL,COLOR_BTNFACE+1,30,_class msg MSG ;; btnclsname db 'button',0 btntxt db 'Click Here!',0 editclsname db 'edit',0 edittxt db "Wow, I'm inside an edit box!",0 editbuffer rb 513 btnhandle dd ? edithandle dd ? btnid equ 100 editid equ 200 sb1 equ 300 sb1h dd ? sb1c dd 0 sbtext db 'Times MessageBox Created: %u',0 sbBuffer rb 512 ;; section '.code' code readable executable start: invoke GetModuleHandle,0 mov [wc.hInstance],eax invoke LoadIcon,0,IDI_APPLICATION mov [wc.hIcon],eax invoke LoadCursor,0,IDC_ARROW mov [wc.hCursor],eax invoke RegisterClass,wc test eax,eax jz error invoke CreateWindowEx,0,_class,_title,WS_VISIBLE+WS_OVERLAPPEDWINDOW,128,128,300,200,NULL,NULL,[wc.hInstance],NULL test eax,eax jz error msg_loop: invoke GetMessage,msg,NULL,0,0 cmp eax,1 jb end_loop jne msg_loop invoke TranslateMessage,msg invoke DispatchMessage,msg jmp msg_loop error: invoke MessageBox,NULL,_error,NULL,MB_OK+MB_ICONERROR end_loop: invoke ExitProcess,[msg.wParam] proc WindowProc hwnd,wmsg,wparam,lparam push ebx esi edi cmp [wmsg],WM_COMMAND je wmcommand cmp [wmsg],WM_CREATE je wmcreate cmp [wmsg],WM_DESTROY je wmdestroy defwndproc: invoke DefWindowProc,[hwnd],[wmsg],[wparam],[lparam] jmp finish wmcreate: invoke CreateWindowEx,WS_EX_CLIENTEDGE,editclsname,NULL,WS_CHILD+WS_VISIBLE+WS_BORDER+ES_LEFT+ES_AUTOHSCROLL,\ 50,35,200,25,[hwnd],editid,[wHInstance],NULL mov [edithandle],eax invoke SetFocus,eax invoke CreateWindowEx,NULL,btnclsname,btntxt,WS_CHILD+WS_VISIBLE+BS_DEFPUSHBUTTON,\ 75,70,140,25,[hwnd],btnid,[wHInstance],NULL mov [btnhandle],eax cinvoke wsprintf,sbBuffer,sbtext,[sb1c] invoke CreateStatusWindow,WS_CHILD+WS_VISIBLE,sbBuffer,[hwnd],sb1 mov [sb1h],eax jmp finish wmcommand: mov eax,[wparam] cmp [lparam],0 je wmcommand_menu cmp ax,btnid je wmcommand_button jmp finish wmcommand_menu: cmp ax,11 je menu_write cmp ax,12 je menu_clear cmp ax,13 je menu_messagebox cmp ax,14 je wmdestroy jmp finish menu_write: invoke SetWindowText,[edithandle],edittxt jmp finish menu_clear: invoke SetWindowText,[edithandle],NULL jmp finish menu_messagebox: inc [sb1c] cinvoke wsprintf,sbBuffer,sbtext,[sb1c] invoke SendMessage,[sb1h],SB_SETTEXT,0,sbBuffer invoke GetWindowText,[edithandle],editbuffer,512 invoke MessageBox,NULL,editbuffer,_title,MB_OK jmp finish wmcommand_button: shr ax,16 cmp ax,0 je button_clicked jmp finish button_clicked: invoke SendMessage,[hwnd],WM_COMMAND,13,0 jmp finish wmdestroy: invoke PostQuitMessage,0 xor eax,eax finish: pop edi esi ebx ret endp section '.idata' import data readable writeable library kernel32,'KERNEL32.DLL',\ user32,'USER32.DLL',\ comctl32,'COMCTL32.DLL' include 'api/kernel32.inc' include 'api/user32.inc' include 'api/comctl32.inc' section '.rsrc' resource data readable directory RT_MENU,appMenu resource appMenu,\ 30,LANG_NEUTRAL,menuMain menu menuMain menuitem '&Test Menu',10,MFR_POPUP or MFR_END menuitem '&Write Something To Textbox',11,MFT_STRING menuitem '&Clear Textbox',12,MFT_STRING menuitem '&MessageBox my text',13,MFT_STRING menuseparator menuitem '&Exit',14,MFR_END |
|||
![]() |
|
bitshifter 11 Nov 2008, 00:07
This change fixes the problem...
Code:
include 'win32a.inc'
|
|||
![]() |
|
windwakr 11 Nov 2008, 00:20
Thank you, I can't believe a single letter was causing me all this frustration!
Ok, does anyone know how to make a list listview, I can't seem to make the iczelion tutorial work at all, even the fasm version. |
|||
![]() |
|
bitshifter 11 Nov 2008, 07:08
Also i just noticed...
Code: end_loop: invoke ExitProcess,[msg.wParam] invoke InitCommonControls You should move this call up to the top... Code:
start:
invoke InitCommonControls
... |
|||
![]() |
|
baldr 11 Nov 2008, 08:01
windwakr,
This one-letter change works because, for example, you define _title as TCHAR and btnclsname as db. Define all string constants as TCHARs, make sure string buffers are big enough and you almost done with Unicode-ready version ("almost" is because SB_SETTEXT = SB_SETTEXTA in COMCTL32.INC). |
|||
![]() |
|
windwakr 11 Nov 2008, 13:20
bitshifter, I read that initcommoncontrols doesn't actually need to be called, just placed anywhere in executable. I think it's only really needed in HLL's.
|
|||
![]() |
|
revolution 11 Nov 2008, 13:45
windwakr wrote: bitshifter, I read that initcommoncontrols doesn't actually need to be called, just placed anywhere in executable. I think it's only really needed in HLL's. |
|||
![]() |
|
bitshifter 12 Nov 2008, 05:38
I think what it really comes down to is... Did the shell register the common control classes when it was invoked by the kernel.
If you can guarantee this, then you dont need to call InitCommonControls. But as we all know, we are talking about Windows, so its better to be safe than sorry and make sure these classes are registered BEFORE we use them. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.