flat assembler
Message board for the users of flat assembler.
Index
> Windows > resource '.rsrc' issue |
Author |
|
revolution 03 Oct 2018, 19:43
You are missing the "directory".
And how have you defined the underscore character there? Perhaps you need to add this: Code: _ equ ,09h, Edit: since you have edited your post by manually replacing the underscore with ,09, then you will need to do this: Code: menuitem <'&Find' ,09, 'Ctrl+F'>,IDM_FIND,MFR_END |
|||
03 Oct 2018, 19:43 |
|
Ali.Z 04 Oct 2018, 01:15
Code: section '.rsrc' resource data readable directory RT_MENU,menus resource menus,\ IDM_MAIN,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu IDM_MAIN = 101 IDM_FIND = 102 _ equ ,09, menu main_menu menuitem '&Edit',0,MFR_POPUP menuitem '&Find' _ 'Ctrl+F',IDM_FIND,MFR_END still, getting same error. (but this time 'size?05H' wtf!) and it opens resource.inc (shipped with fasm) it highlights this line: resource.inc wrote: macro menu label am i missing something? _________________ Asm For Wise Humans |
|||
04 Oct 2018, 01:15 |
|
revolution 04 Oct 2018, 01:41
Please post a minimal source that we can compile that shows the error.
|
|||
04 Oct 2018, 01:41 |
|
Ali.Z 04 Oct 2018, 14:12
i know i need to handle the message for IDM_FIND, but i dont care i just want to see a menu. (i would be very happy to see my code working)
i might ask later how to handle specific messages, or what actions require specific window_messages. as i mentioned above, i just started learning gui stuff (from examples provided by fasm) and i really wanna make my first gui program. (instead of consoles) Code: format PE GUI 4.0 entry start include 'win32a.inc' section '.text' code readable executable start: invoke GetModuleHandle,0 mov [wc.hInstance],eax invoke LoadIcon,0,IDI_WINLOGO mov [wc.hIcon],eax invoke LoadCursor,0,IDC_IBEAM mov [wc.hCursor],eax xor eax,eax mov [wc.style],CS_DBLCLKS+CS_GLOBALCLASS mov [wc.lpfnWndProc],MainWindow mov [wc.cbClsExtra],eax mov [wc.cbWndExtra],eax mov [wc.hbrBackground],COLOR_WINDOW mov [wc.lpszMenuName],eax mov [wc.lpszClassName],_class invoke RegisterClass,wc invoke LoadMenu,[wc.hInstance],IDM_MAIN invoke CreateWindowEx,0,_class,_caption,WS_OVERLAPPED+WS_THICKFRAME,25,25,244,152,NULL,eax,[wc.hInstance],NULL mov [hwnd_main],eax invoke ShowWindow,eax,SW_SHOWNORMAL invoke UpdateWindow,[hwnd_main] 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 MainWindow hwnd,umsg,wparam,lparam cmp [umsg],WM_DESTROY jz wmdestroy invoke DefWindowProc,[hwnd],[umsg],[wparam],[lparam] jmp finish wmdestroy: invoke PostQuitMessage,0 xor eax,eax finish: ret endp section '.data' data readable writeable _class db 'main',0 _caption db 'gui window',0 wc WNDCLASS msg MSG pt POINT hwnd_main dd ? section '.idata' import data readable library kernel32,'kernel32.dll',\ user32,'user32.dll',\ advapi32,'advapi32.dll',\ shell32,'shell32.dll',\ gdi32,'gdi32.dll',\ comctl32,'comctl32.dll',\ comdlg32,'comdlg32.dll' include 'api\kernel32.inc' include 'api\user32.inc' include 'api\advapi32.inc' include 'api\shell32.inc' include 'api\gdi32.inc' include 'api\comctl32.inc' include 'api\comdlg32.inc' section '.rsrc' resource data readable directory RT_MENU,menus resource menus,\ IDM_MAIN,LANG_ENGLISH+SUBLANG_DEFAULT,main_menu IDM_MAIN = 101 IDM_FIND = 102 _ equ ,09, menu main_menu menuitem '&Edit',0,MFR_POPUP menuitem '&Find' _ 'Ctrl+F',IDM_FIND,MFR_END section '.reloc' fixups data readable discardable _________________ Asm For Wise Humans |
|||
04 Oct 2018, 14:12 |
|
revolution 04 Oct 2018, 14:25
Maybe this:
Code: menu main_menu menuitem '&Edit',0,MFR_POPUP + MFR_END menuitem '&Find' _ 'Ctrl+F',IDM_FIND,MFR_END |
|||
04 Oct 2018, 14:25 |
|
Ali.Z 04 Oct 2018, 16:13
it wooooorked, thanks revvv.
finally i saw a menu, man im so f*cking happy ... my first steps to learn and write gui program. (byebye consoles) but hey, these messages WM_?... where can i find a guide on how to use them and what they are for? there is also FM_?... i dont understand such things, all what i need is a little bit of reading to get the basic things/concept. but failed searching/getting anything useful about them and about WndProc procedure (MainWindow - callback) _________________ Asm For Wise Humans |
|||
04 Oct 2018, 16:13 |
|
revolution 04 Oct 2018, 16:33
The best place for information on the messages Windows generates is the MS website. Or the MSDN docs if you have those.
For example a random message: https://docs.microsoft.com/en-us/windows/desktop/winmsg/wm-destroy |
|||
04 Oct 2018, 16:33 |
|
Ali.Z 04 Oct 2018, 19:57
WM_DESTROY
WM_DESTROY wrote: Sent when a window is being destroyed. It is sent to the window procedure of the window being destroyed after the window is removed from the screen. Code: invoke PostQuitMessage,0 ; but why i have to call 'PostQuitMessage' xor eax,eax ret WM_CLOSE WM_CLOSE wrote: Sent as a signal that a window or an application should terminate. Code: invoke DestroyWindow,hwnd_main ; handle to main window ; question: do i need postquitmessage here? xor eax,eax ret so according to what i understood from MS-Docs, even if i didnt write in window procedure "cmp [umsg],WM_CLOSE" it will be closed just like WM_DESTROY ... but i can use it to confirm the process termination. (show a messagebox or dialog box saying do you wanna quit [yes]/[no] in case yes then terminate otherwise continue) WM_QUIT WM_QUIT wrote: Indicates a request to terminate an application, and is generated when the application calls the PostQuitMessage function. This message causes the GetMessage function to return zero. by just writing here, i got my answer. i asked: but why i have to call 'PostQuitMessage' asnwer: because WM_QUIT is sent to GetMessage ONLY and according to my code if eax = 0 then jump to exit process. but what confuse me now is: do i have to write: Code: invoke PostQuitMessage,0 ; or ; invoke PostQuitMessage,[wparam] and what i said about WM_CLOSE and WM_DESTROY are true/right? _________________ Asm For Wise Humans |
|||
04 Oct 2018, 19:57 |
|
DimonSoft 04 Oct 2018, 21:07
Ali.A wrote: but what confuse me now is: The PostQuitMessage function adds a WM_QUIT message to the message queue of the calling thread with wParam set to its parameter. The message will eventually be retrieved from the queue by GetMessage function which will then return 0. Since the return value of GetMessage is usually used as the message handling loop condition, this will cause the message handling loop termination and the program execution will proceed further where it’ll usually reach program termination. Depends on the code you actually write but you usually write the code recommended by MSDN until you understand what you’re doing. |
|||
04 Oct 2018, 21:07 |
|
Ali.Z 05 Oct 2018, 17:20
how to use these for menu items:
MF_GRAYED MF_DISABLED MFS_GRAYED MFS_DISABLED _________________ Asm For Wise Humans |
|||
05 Oct 2018, 17:20 |
|
Ali.Z 05 Oct 2018, 21:08
ok got it working, opened resource.inc and found the macro saying:
macro menuitem string,id,resinfo,status,type string = menu_item id = ID_EXIT resinfo = MFR_END status = MFS_GRAYED type = MFT_? ... ; currently '0' Code: menu main_menu menuitem '&Menu',0,MFR_POPUP+MFR_END menuitem '&New' _ 'Ctrl+N',IDM_NEW menuseparator menuitem '&Exit' _ 'Ctrl+X',IDM_EXIT,MFR_END,MFS_GRAYED,0 anyhow i have a new question about dialogs, found only two things i dont understand: (in resource.inc) there is: BUTTON -> button to click on EDIT -> edit box STATIC -> string SCROLLBAR -> to scroll up/down the text LISTBOX -> ??? COMBOBOX -> ??? any help! _________________ Asm For Wise Humans |
|||
05 Oct 2018, 21:08 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.