flat assembler
Message board for the users of flat assembler.

Index > Windows > MAKEINTRESOURCE

Author
Thread Post new topic Reply to topic
machinecoder



Joined: 07 Apr 2013
Posts: 27
machinecoder
how do I use this Macro in FASM, I see plenty of examples using this in C++ but cant find a single one for assembler

I want to use it for creating icons for status bar etc...
Post 18 Aug 2013, 12:45
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1419
Location: Toronto, Canada
AsmGuru62
Just pass the ID of a resource as a DWORD.
Sometimes (very rare) resources are named by actual text. In such
case you must pass the string where MAKEINTRESOURCE needed.

P.S. If you look into .H file you will see something like this:
Code:
#define MAKEINTRESOURCE(i)  (LPTSTR) ((DWORD) ((WORD) (i))) 
    
Post 18 Aug 2013, 13:37
View user's profile Send private message Send e-mail Reply with quote
yoshimitsu



Joined: 07 Jul 2011
Posts: 96
yoshimitsu
you can't allocate memory at an address below 10000h, means the high-word-address-part of such resource name-strings you pass to the winapi are always nonzero.
so, there's the case the high-word is nonzero, which means you're passing the resource name as a string and the other case being the high-word is zero, which results in the winapi function using the low-word as an resource ID.

as in asm parameters are simply dwords and you do not have to do type converts simply pass either an ID or a string.
Post 18 Aug 2013, 18:50
View user's profile Send private message Reply with quote
HaHaAnonymous



Joined: 02 Dec 2012
Posts: 1180
Location: Unknown
HaHaAnonymous
[ Post removed by author. ]


Last edited by HaHaAnonymous on 28 Feb 2015, 20:13; edited 1 time in total
Post 18 Aug 2013, 18:56
View user's profile Send private message Reply with quote
machinecoder



Joined: 07 Apr 2013
Posts: 27
machinecoder
AsmGuru62 wrote:
Just pass the ID of a resource as a DWORD.
Sometimes (very rare) resources are named by actual text. In such
case you must pass the string where MAKEINTRESOURCE needed.

P.S. If you look into .H file you will see something like this:
Code:
#define MAKEINTRESOURCE(i)  (LPTSTR) ((DWORD) ((WORD) (i))) 
    


So do you mean this...
Code:
hIcon = LoadImage(   g_hInst,
                           MAKEINTRESOURCE(IDI_MAIN_ICON),
                           IMAGE_ICON,
                           GetSystemMetrics(SM_CXSMICON),
                           GetSystemMetrics(SM_CYSMICON),
                           0);
    


Becomes this

Code:
hIcon = LoadImage(   g_hInst,
                           IDI_MAIN_ICON,
                           IMAGE_ICON,
                           GetSystemMetrics(SM_CXSMICON),
                           GetSystemMetrics(SM_CYSMICON),
                           0);
    




Please help, as I want to put icons on the status bar and every example is in poo-bum 'C++' !

C++ is just a poor mans assembler language, real programmers code in X86
Post 19 Aug 2013, 07:05
View user's profile Send private message Reply with quote
AsmGuru62



Joined: 28 Jan 2004
Posts: 1419
Location: Toronto, Canada
AsmGuru62
Yes, just remove that macro and do not use it - this macro is just a type cast.
Please take a look here:

http://msdn.microsoft.com/en-us/library/windows/desktop/aa381018(v=vs.85).aspx

Notice how the name of a resource can be:
"Unique name or a 16-bit unsigned integer value identifying the resource."

There are also two examples of ICON resources:

Code:
desk1   ICON "desk.ico"
11      ICON "custom.ico"
    

Notice how 1st icon is NAMED "desk1" and the 2nd has an ID as an integer value 11.
So, if your icons are NAMED by a string - you must pass a string instead of MAKEINTRESOURCE() and if it is a value - then pass an integer value:
Code:
ResIcon1        db 'desk1',0
ResIcon2        dd 11
HIcon1          dd 0
HIcon2          dd 0

...

invoke  GetModuleHandleA, 0
mov     esi, eax

invoke  LoadIconA, esi, ResIcon1
mov     [HIcon1], eax

invoke  LoadIconA, esi, [ResIcon2]
mov     [HIcon2], eax
    
Post 19 Aug 2013, 17:46
View user's profile Send private message Send e-mail Reply with quote
xDOBORAx



Joined: 09 Jun 2013
Posts: 24
xDOBORAx
machinecoder wrote:

C++ is just a poor mans assembler language, real programmers code in x86

youre so wrong, real men use punched cards
isnt keyboard and monitor for feeble ?

_________________
Image
Post 03 Sep 2013, 20:37
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 GitHub, YouTube, Twitter.

Website powered by rwasa.