flat assembler
Message board for the users of flat assembler.
Index
> Windows > problem with ICZtut 09 |
Author |
|
silkodyssey 29 Nov 2003, 09:49
kain,
Add the MFR_END flag to test console line so it should be like this. Code: menuitem '&Test Controls',0,MFR_POPUP + MFR_END I think this its because is the only Top Level Menu you have to terminate it just like the menu items. I tried running the program but it crashed so I guess there's another problem. _________________ silkodyssey |
|||
29 Nov 2003, 09:49 |
|
silkodyssey 29 Nov 2003, 10:07
kain,
I found the bugs in your code. I will post the code below with comments so you know what I've changed. Code: format PE GUI 4.0 include '%include%\win32ax.inc' ; main window equates include '%include%\macro\if.inc' ; for HLL loops entry start ; you forget to set the entry point for the code ;constants go here ButtonID =10 EditID =11 IDM_MAIN =100 IDM_HELLO =200 IDM_CLEAR =210 IDM_GETTEXT =220 IDM_EXIT =230 section '.data' data readable writeable ClassName db 'SimpleWinClass',0 AppName db 'OurFirstWindow',0 MenuName db 'FirstMenu',0 ButtonClassName db 'button',0 ButtonText db 'My Fist Button',0 EditClassName db 'edit',0 TestString db 'Wow! I''m in an edit box now',0 section '.udata' readable writeable hInstance dd ? CommandLine dd ? hwndButton dd ? hwndEdit dd ? buffer rb 512 section '.text' code readable executable start: invoke GetModuleHandle, NULL mov ptr hInstance, eax invoke GetCommandLine mov ptr CommandLine, eax stdcall WinMain, ptr hInstance, NULL, ptr CommandLine, SW_SHOWDEFAULT invoke ExitProcess, eax proc WinMain, hInst, hPrevInst, CmdLine, CmdShow wc WNDCLASSEX msg MSG hwnd dd ? enter mov ptr wc.cbSize, sizeof.WNDCLASSEX mov ptr wc.style, CS_HREDRAW or CS_VREDRAW mov ptr wc.lpfnWndProc, WndProc mov ptr wc.cbClsExtra,NULL mov ptr wc.cbWndExtra,NULL push ptr hInst pop ptr wc.hInstance mov ptr wc.hbrBackground,COLOR_BTNFACE+1 mov ptr wc.lpszMenuName, NULL mov ptr wc.lpszClassName, ClassName invoke LoadIcon,NULL,IDI_APPLICATION mov ptr wc.hIcon,eax mov ptr wc.hIconSm,eax invoke LoadCursor,NULL,IDC_ARROW mov ptr wc.hCursor,eax lea eax, ptr wc invoke RegisterClassEx, eax invoke LoadMenu,ptr hInstance, IDM_MAIN ; I've added eax to the hmenu parameter ; which is the handle to the menu you ; just loaded invoke CreateWindowEx,WS_EX_CLIENTEDGE,ClassName, \ AppName, WS_OVERLAPPEDWINDOW,\ CW_USEDEFAULT, CW_USEDEFAULT,\ 300,200,NULL,eax, ptr hInst,NULL mov ptr hwnd, eax invoke ShowWindow, ptr hwnd, SW_SHOWNORMAL invoke UpdateWindow, ptr hwnd push ebx ;you need to preserve ebx lea ebx, ptr msg @@: invoke GetMessage, ebx,NULL,0,0 or eax,eax jz @f invoke TranslateMessage, ebx invoke DispatchMessage, ebx jmp @b @@: pop ebx mov eax,ptr msg.wParam return proc WndProc, hWnd, uMsg, wParam, IParam enter .if ptr uMsg,e,WM_DESTROY invoke PostQuitMessage, NULL .elseif ptr uMsg,e,WM_CREATE invoke CreateWindowEx,WS_EX_CLIENTEDGE, EditClassName,NULL,\ WS_CHILD or WS_VISIBLE or WS_BORDER or ES_LEFT or\ ES_AUTOHSCROLL,\ 50,35,200,25,ptr hWnd,8,ptr hInstance,NULL mov ptr hwndEdit,eax invoke SetFocus, ptr hwndEdit invoke CreateWindowEx,NULL, ButtonClassName,ButtonText,\ WS_CHILD or WS_VISIBLE or BS_DEFPUSHBUTTON,\ 75,70,140,25,ptr hWnd,ButtonID,ptr hInstance,NULL mov ptr hwndButton,eax .elseif ptr uMsg,e,WM_COMMAND mov eax, ptr wParam .if ptr IParam,e,0 .if ax,e,IDM_HELLO invoke SetWindowText, ptr hwndEdit, TestString .elseif ax,e,IDM_CLEAR invoke SetWindowText, ptr hwndEdit, NULL .elseif ax,e,IDM_GETTEXT invoke GetWindowText, ptr hwndEdit, buffer, 512 invoke MessageBox, NULL, buffer, AppName, MB_OK .else invoke DestroyWindow, ptr hWnd .endif .else .if ax,e,ButtonID shr eax,16 .if ax,e,BN_CLICKED invoke SendMessage, ptr hWnd, WM_COMMAND, IDM_GETTEXT,0 .endif .endif .endif ;.endif << typo .else invoke DefWindowProc, ptr hWnd, ptr uMsg, ptr wParam, ptr IParam return .endif xor eax, eax return section '.idata' import data readable writeable ; import all the API functions that we used library kernel, 'KERNEL32.DLL', user, 'USER32.DLL' import kernel,\ GetModuleHandle,'GetModuleHandleA',\ GetCommandLine, 'GetCommandLineA',\ ExitProcess, 'ExitProcess' import user,\ RegisterClassEx, 'RegisterClassExA',\ CreateWindowEx, 'CreateWindowExA',\ DefWindowProc, 'DefWindowProcA',\ ShowWindow, 'ShowWindow',\ GetMessage, 'GetMessageA',\ TranslateMessage, 'TranslateMessage',\ DispatchMessage, 'DispatchMessageA',\ LoadCursor, 'LoadCursorA',\ UpdateWindow,'UpdateWindow',\ LoadIcon, 'LoadIconA',\ PostQuitMessage,'PostQuitMessage',\ SendMessage,'SendMessageA',\ DestroyWindow,'DestroyWindow',\ MessageBox,'MessageBoxA',\ LoadMenu,'LoadMenuA',\ SetFocus,'SetFocus',\ GetWindowText,'GetWindowTextA',\ SetWindowText,'SetWindowTextA' section '.rsrc' resource data readable directory RT_MENU, menus resource menus,IDM_MAIN,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu menu main_menu menuitem '&Test Controls',0,MFR_POPUP + MFR_END menuitem '&Say Hello',IDM_HELLO,0 menuitem '&Clear',IDM_CLEAR,0 menuitem '&Get Text',IDM_GETTEXT,0 menuseparator menuitem 'E&xit',IDM_EXIT,MFR_END _________________ silkodyssey |
|||
29 Nov 2003, 10:07 |
|
roticv 29 Nov 2003, 15:47
nay the ebx does not need to be preserved. The reason being that that part of the program is not a callback function. The only reason it need to be preserve is that ebx is used internally in 2k and xp in dispatchmessage if i remmeber correctly.
|
|||
29 Nov 2003, 15:47 |
|
Varchilde 29 Nov 2003, 17:16
the +MFR_END flag has to be added onto the last top-level menu item?
|
|||
29 Nov 2003, 17:16 |
|
Kain 30 Nov 2003, 05:45
Nice! Thanks for the corrections.
|
|||
30 Nov 2003, 05:45 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.