WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Forum

Pages: (2) [1] 2   ( Go to first unread post ) Reply to this topicStart new topicStart Poll

LoadBitmap API Function, access the predefined bitmaps used by the Win32 API by setting the hInstance parameter to NULL.

lamer
Posted: Apr 23 2005, 06:23 AM
Quote Post


Very Very Active Member
*****

Group: Members
Posts: 82
Member No.: 1181
Joined: 16-April 05


Hi all!
I am puzzled with LoadBitmap function.
There is a bitmap resource with ID=100
If I create window by CreateWindow - everything is OK, the LoadBitmap works normaly.
But if I use DialogBoxParam, that is, create it from dialog resource - the LoadBitmap just refuses to work, each time returns 0.
Why? :angry:
GetLastError returns "The specified resource name cannot be found in the image file."
Thanks to all - this was just problem with hInstance :D

PMEmail PosterUsers WebsiteICQMSN
Top
SeaFarer
Posted: Jan 2 2008, 01:43 AM
Quote Post


GO NAVY!
******

Group: Admins
Posts: 833
Member No.: 1464
Joined: 2-September 05


Hi,

I did a search of the board and found this topic with respect to having what I believe is the same problem.

Two years later....

Anyone have any suggestions? :lol:
PMUsers Website
Top
akyprian
Posted: Jan 2 2008, 02:32 AM
Quote Post


Administrator
******

Group: Admins
Posts: 1994
Member No.: 1
Joined: 12-May 04


Hi Sea,

As Lamer already pointed out, you need to use the proper value for the hInstance parameter depending on what bitmap you try to load.

I hope it helps
PMEmail PosterUsers Website
Top
Vortex
Posted: Jan 3 2008, 11:34 AM
Quote Post


Very Very Active Member
*****

Group: Moderators
Posts: 85
Member No.: 8
Joined: 13-May 04


Following Iczelion's tutorial #25, I am able to display a bitmap initialized with LoadBitmap inside a dialog box created with DialogBoxParam. Can anyone point me in the right direction if I misundestood the problem?
CODE

   .IF uMsg==WM_INITDIALOG
       
       invoke  LoadBitmap,hModule,ID_BITMAP
       mov     hBitmap,eax

   .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


OS : Win XP Pro Sp2

Attached File ( Number of downloads: 5 )
Attached File  Bitmapdlg.zip
PMEmail PosterUsers Website
Top
akyprian
Posted: Jan 4 2008, 12:01 AM
Quote Post


Administrator
******

Group: Admins
Posts: 1994
Member No.: 1
Joined: 12-May 04


Hi Vortex,

You are able to display the bitmap because you use a proper hModule. In the original post, lamer didn't. I suspect that SeaFarer has got a similar problem.

Thanks for the demo
PMEmail PosterUsers Website
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Pages: (2) [1] 2  Reply to this topicStart new topicStart Poll