Hi Guys. I'm trying to get back on track. I've been useing resource hacker to make the .rc file. When i assemble it all the resources don't get inside the .EXE file. Why is that. I seem to remember an old fashioned way where every resource had it's own ID but resource hacker doesnt work like that.
can somone help?
Thanks in advance
Its a good tool but probably not the right one for your task. Why not write an RC script ?
http://www.resedit.net
Thanks Hutch. Could you kindly direct me to information needed to write RC scripts? while i search for myuself as well of course.
One Thanks not enough.
be seein you
http://masm32.com/board/index.php?topic=6512.0
that's exactlly what i was looking for. Thanks
Look...i know you've helped me a lot but i still have questions. i made the rc file. No resources are found inside the exe file. why is that?
What am i not doing?
Thanks again in advance
Does the commandline care for the rc and res files? I don't know what IDE or editor you are using...
I'm using ResEd JJ and QEditor for the assedmbly. Isn't that enough? I've been looking into ml and link command line options but see nothing regarding the rc files...
thanks
So.... i found out i need to use the resource compiler but still no resources found in .exe file when i imagelist_loadimage them.
I don't use qEditor regularly, but as far as I remember, the build process includes resources if it finds a rsrc.rc in the path of the source. See in particular \Masm32\menus.ini and \Masm32\bin\bldallc.bat
How did you name your resource file?
Just have a look in the examples, \masm32\examples\dialogs_later\
The default way of using dialogs is to name the RC file rsrc.rc
Here is a very simple example, mainly so you can see the basic techniques for constructing a resource dialog. The RC file can be edited with Ketil Olsen's Resed.
Hi xandaz,
Resource Hacker provides an option to save resources as compiled scripts, .res files.
Well guys... things have adavanced a little and i provided a non-working example for you to see what the heck is wrong, if you please.
The LoadBitmap function returns resource name not found. Also tried the identifier. doesn't work either.
thanks in advance
Hi xandaz,
You should respond the WM_PAINT message to display the bitmap with BitBlt :
Tutorial 25: Simple Bitmap
http://www.interq.or.jp/chubu/r6/masm32/tute/tute025.html
.elseif uMsg==WM_PAINT
invoke BeginPaint,hWnd,addr ps
mov hdc,eax
invoke CreateCompatibleDC,hdc
mov hMemDC,eax
invoke SelectObject,hMemDC,hBitmap
invoke GetClientRect,hWnd,addr rect
invoke BitBlt,hdc,0,0,rect.right,rect.bottom,hMemDC,0,0,SRCCOPY
invoke DeleteDC,hMemDC
invoke EndPaint,hWnd,addr ps
I still remember that part. the thing is that the LoadBitmap function resturns ERRROR_RESOURCE_NAME_NOT_FOUND.
thanks vortex
Hi Xandaz,
Some error checks help to find the culprits:
invoke LoadImage,hInstance,addr MainWindowIcon,IMAGE_ICON,32,32,LR_LOADFROMFILE
deb 4, "LoadImg", eax, $Err$()
...
invoke LoadBitmap,hInstance, addr Bmp
deb 4, "LoadBmp", eax, $Err$()
LoadImg
eax 0
$Err$() Access denied.
LoadBmp
eax 0
$Err$() Impossible finding the name of resource.
With a few changes:
invoke LoadImageW,hInstance,addr MainWindowIcon,IMAGE_ICON,32,32,LR_LOADFROMFILE
deb 4, "LoadImg", eax, $Err$()
...
invoke LoadBitmap,hInstance, 100
deb 4, "LoadBmp", eax, $Err$()
LoadImg
eax 248644207
$Err$() Operation completed.
LoadBmp
eax 285541561
$Err$() Operation completed.
I have added Vortex' code, too. Now it shows a little red circle in the upper left corner.
Note that resources can have names like "bmp". But in general, integers are easier to handle - and you did use an integer in the rc file: #define bmp 100
Thanks JJ. You solved the problem.
Thanks you guys. You're the best.
Well guys a new problem takes place when you use LoadImage instead of loadBitmap. I've tried both the resource name and identifier and it doesn't work. The thing is i wanted to use ImageList_LoadImage to load the images for a toolbar. Any ideas?
Thanks in advance.
Hi xandaz,
You can load a bitmap without creating a resource file :
.IF uMsg==WM_CREATE
invoke LoadImage,0,ADDR filename,\
IMAGE_BITMAP,0,0,LR_LOADFROMFILE
mov hBitmap,eax
invoke GetObject,eax,SIZEOF(BITMAP),ADDR bm
.ELSEIF uMsg==WM_PAINT
invoke BeginPaint,hWnd,ADDR ps
mov hdc,eax
invoke CreateCompatibleDC,eax
mov hMemDC,eax
invoke SelectObject,eax,hBitmap
mov edx,OFFSET bm
xor eax,eax
invoke BitBlt,hdc,eax,eax,\
BITMAP.bmWidth[edx],\
BITMAP.bmHeight[edx],\
hMemDC,eax,eax,SRCCOPY
invoke DeleteDC,hMemDC
invoke EndPaint,hWnd,ADDR ps
Hi xandaz,
Loading a bitmap from a resource, the .rc script :
100 BITMAP logo.bmp
.IF uMsg==WM_CREATE
invoke LoadImage,hInstance,100,\
IMAGE_BITMAP,0,0,0
mov hBitmap,eax
Vortex....tried the same but still not working. take a look if you will....
thanks.
You have this:
invoke LoadImage,hInstance,addr Bmp,IMAGE_BITMAP,64,64,0
Which refers to this:
UCSTR Bmp,"bmp",0
try:
.const
BMP_MYBITMAP EQU 100 ; same ID as defined in the resource
invoke LoadImage, hInstance, BMP_MYBITMAP, IMAGE_BITMAP, 64, 64, 0
Hey guys ... it still dont work. what am i forgetting to do? there's always something....
ty guys
Hi xandaz,
The bitmap handle should not be a local variable :
WndProc PROC hWnd:DWORD,uMsg:DWORD,wParam:DWORD,lParam:DWORD
; local hBitmap:DWORD
.data?
hBitmap dd ?
Modifying the resource script :
100 BITMAP "bmp.bmp"
And this one :
invoke LoadImage,hInstance,100,IMAGE_BITMAP,64,64,0
After building the application, I can see the red ball in the window.
ahhh.... that's right vortex....thanks