flat assembler
Message board for the users of flat assembler.

Index > Windows > Resource Identifiers

Author
Thread Post new topic Reply to topic
daluca



Joined: 05 Nov 2005
Posts: 86
daluca
hello:
can someone tell me about the resource identifiers when they are names?
I mean: there are some api functions that take a resource identifier that
can be a poiter to a null terminated string or a resource ID.

like:CreateDialogParam,LoadMenu or the menu member of WNDCLASS:lpszMenuName.

i always use ID's,but what if i want tu use poiters to strings?
is it possible with the resource macros? if it is: how exactly do i define
this strings?. they have to be in my data section?.
if it's not possible with the macros, is possible when i include an
external RES file?
Post 26 Sep 2006, 06:43
View user's profile Send private message Reply with quote
Garthower



Joined: 21 Apr 2006
Posts: 158
Location: Ukraine
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 Smile
Post 26 Sep 2006, 08:27
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
daluca



Joined: 05 Nov 2005
Posts: 86
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?
Post 26 Sep 2006, 19:15
View user's profile Send private message Reply with quote
wisepenguin



Joined: 30 Mar 2005
Posts: 129
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
Post 26 Sep 2006, 19:19
View user's profile Send private message Reply with quote
daluca



Joined: 05 Nov 2005
Posts: 86
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
Post 27 Sep 2006, 06:07
View user's profile Send private message Reply with quote
Garthower



Joined: 21 Apr 2006
Posts: 158
Location: Ukraine
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.
Post 27 Sep 2006, 08:37
View user's profile Send private message Visit poster's website MSN Messenger ICQ Number Reply with quote
wisepenguin



Joined: 30 Mar 2005
Posts: 129
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
Post 27 Sep 2006, 11:31
View user's profile Send private message Reply with quote
daluca



Joined: 05 Nov 2005
Posts: 86
daluca
Thank you both. that's the answer i was looking for.
i will check the ResED tool.

thank you again.
Post 27 Sep 2006, 19:15
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-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.