flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
Garthower
Generally, all API which work with resources, work and with ID of a resource, and with pointer to line of name of a resource. Here, that is written in MSDN, for example, about LoadMenu:
Syntax HMENU LoadMenu ( HINSTANCE hInstance, LPCTSTR lpMenuName); Parameters: hInstance [in]: Handle to the module containing the menu resource to be loaded. lpMenuName [in]: Pointer to a null-terminated string that contains the name of the menu resource. Alternatively, this parameter can consist of the resource identifier in the low-order word and zero in the high-order word. To create this value, use the MAKEINTRESOURCE macro. I.e., in parameter lpMenuName instead of ID a resource simply you transfer the index to a line containing a name of a resource. That's all ![]() |
|||
![]() |
|
daluca
and from where do i get this "index to a line containing a name of a resource."
can you give a source example with macros? |
|||
![]() |
|
wisepenguin
with the LoadMenu example above, if you use the ID it would be
Code: invoke LoadMenu, hinstance val, MY_ID_THAT_IS_A_CONSTANT but if you want to use your string, like menuname db "my_custom_menu" use Code: invoke LoadMenu, hinstance val, menuname hope that clears it for you |
|||
![]() |
|
daluca
wisepenguin: yes I KNOW how to define strings and pass ID's and pointers to these strigs to API's but the situation is this:
after define a menu with macros like this: Code: directory RT_MENU,menus resource menus,3,LANG_NEUTRAL,MyMenu menu MyMenu menuitem "Test Controls",1,MFR_POPUP or MFR_END menuitem "Get Text", IDM_GETTEXT menuitem "Clear Text", IDM_CLEAR menuitem "E&xit", IDM_EXIT,MFR_END and filling the menu member of the WNDCLASS with pointer to string: Code: mov [wc.lpszMenuName], MenuName how should i define this string?.... Code: MenuName db 'menus',0 MenuName db 'MyMenu',0 MenuName db 'Test Controls',0 or what?.... or maybe with these macros i am limitated to use only ID's and no "names"? Last edited by daluca on 02 Oct 2006, 06:57; edited 1 time in total |
|||
![]() |
|
Garthower
Unfortunately, you cannot work with resources by names, using for a writing of resources delivered with FASM macroses since they are not able to create the menu with names (or I simply don't know, how it to make). For this purpose you need most to write .RC-file, to make of it .RES-file, say, by means of GoRC.EXE, and to insert it inside of the program like this:
Code: section '.rsrc ' resource from ' SignForm64.res' readable Here to you an example: RC-file: Code: MainMenu MENUEX BEGIN POPUP "Your menu",100 BEGIN MENUITEM "Item1",200 MENUITEM "Item2",201 MENUITEM "",,0x00000800 //Separator MENUITEM "Item3",202 END END Load this menu you can so: Code: format PE GUI entry Start .... section '.code' code readable executable Start: ..... invoke GetModuleHandleA mov [wc.hInstance],eax ..... invoke LoadMenuA,[wc.hInstance],MenuName ...... section '.data' data readable writeable MenuName db 'MainMenu',0 wc_start: wc WNDCLASSEX wc_end-wc_start,CS_HREDRAW or CS_VREDRAW,WndProc,0,0,0,0,0,COLOR_WINDOW,0,ClassName,0 wc_end: ..... For simplification of process of creation of files you can use a ResED, download this utility you can from a site http://www.radasm.com. |
|||
![]() |
|
wisepenguin
i do apologise, i misunderstood your question. should have
thought about it more. Garthowers method is correct. if you would rather use the FASM macro version for your project, (from above you have the following definition for menu) Code: resource menus,3,LANG_NEUTRAL,MyMenu menu MyMenu menuitem "Test Controls",1,MFR_POPUP or MFR_END when you need to specify a menu resource, you use a string ref to "MyMenu" or the constant 3. in Garthowers example he used the string. see FASM examples MINIPAD.ASM for using LoadMenu with a constant |
|||
![]() |
|
daluca
Thank you both. that's the answer i was looking for.
i will check the ResED tool. thank you again. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.