Announcement
Collapse
No announcement yet.
LoadImage from resource failure
Collapse
X
-
Michael, the GPF was occurring when the attempt was being made to gain a handle for the resource, initially, when writing the chunk of code, I was using the wrong value to the API to get a handle for the resource, so it died on the API call itself while in the debugger, no means to test validity. In the runtime, there was checks for validity, however, I stripped them all out in constructing my test scenerio.
-
This is a good demo for, "always test the success of an operation e.g., (hBitmap <> %NULL) and stop executing after something has failed."
Continuing after an error is how GPFs happen.
The original code in post #1 tested (Good!) but didn't stop when a failure occurred (GPF!)
Leave a comment:
-
Thank you.
I just knew I was overlooking something terribly simple.
Leave a comment:
-
Originally posted by Edwin Knoppert View PostCB.HNDL ??
You'll need the instance handle.
Use WINMAIN instead of PBMAIN to get the hInstance handle.
Leave a comment:
-
CB.HNDL ??
You'll need the instance handle.
Use WINMAIN instead of PBMAIN to get the hInstance handle.
Leave a comment:
-
I'm sorry, should be including reference code for what I'm doing.
In my RC file I have:Code:IDR_POSITIONTILE BITMAP DISCARDABLE "images\floor0137.bmp"
Code:$POSITIONTILE = "IDR_POSITIONTILE"
Code:LOCAL iName AS ASCIIZ * 80 LOCAL hBitmap, fResource, hResource, lResource AS DWORD iName = $POSITIONTILE GRAPHIC BITMAP LOAD iName, 20,20 TO hBitmap MSGBOX "Graphic Bitmap Load Success = "& FORMAT$(hBitmap) ' returns the ID for the Graphic Control hBitmap = LoadImage(CB.HNDL, iName, %IMAGE_BITMAP, 0, 0, %LR_CREATEDIBSECTION) ' dies in debugger MSGBOX "Load Image Success = "& FORMAT$(hBitmap) ' returns 0 in compiled hBitmap = LoadBitmap(CB.HNDL, iName) ' dies in debugger MSGBOX "Load Bitmap Success = "& FORMAT$(hBitmap) ' returns 0 in compiled fResource = FindResource(0, iName, BYVAL %RT_BITMAP) IF ISTRUE fResource THEN hResource = LoadResource(CB.HNDL, fResource) ' dies in debugger MSGBOX "Load Resource Success " & FORMAT$(hResource) ' a duh on fResource, ISTRUE permitted entry to this point ' returns 0 in compiled IF ISTRUE hResource THEN END IF END IF
Leave a comment:
-
LoadImage from resource failure
I've got a bitmap image in my resource file which I want to load into memory by handle, so far I've not met with success, and to make matters annoying, the debugger will crash when encountering the LoadImage line. Tried going the FindResource and LoadResource route, but they also generate a:
Code:Exception: Memory Access Violation Program tried to read or write an invalid memory address End Debug at 12:47:50 PM on 2/14/2009
Tags: None
Leave a comment: