|
-
May 12th, 1999, 04:49 PM
#1
Loading a bitmap in a CStatic
How would i load a resource bitmap into a CStatic? Thanks.
-
May 12th, 1999, 07:50 PM
#2
Re: Loading a bitmap in a CStatic
1. Lay a static control to a dialog box.
2. At property setting, change the Type attribute to "Bitmap".
3. Assign resource ID to Image attribute.
-
May 12th, 1999, 08:41 PM
#3
Re: Loading a bitmap in a CStatic
and if I want to do it dynamically?
Sally
-
May 12th, 1999, 11:25 PM
#4
Re: Loading a bitmap in a CStatic
You can SetBitmap function of CStatic class.
You can associate your static control to a member veriable of CStatic class at "Member Variables"
section of Class Wizard.
-
May 18th, 1999, 01:22 PM
#5
Re: Loading a bitmap in a CStatic
search help for ::LoadImage(). This function does what you want.
-
June 22nd, 1999, 11:15 AM
#6
Re: Loading a bitmap in a CStatic
I have just tried using your suggestion for a modal dialog box, but get an ASSERTion failure (NULL hWnd) from SetBitmap(). My code is:
HBITMAP hBitmap = ::GetTrackSymbol( tempBitmap, PPLI_AIR, tempStr );
d_Filters->m_Page1.m_ppli_air.SetBitmap( hBitmap );
if(d_Filters->DoModal()==IDOK) {
This is in the event handler for the menu item to open the dialog. GetTrackSymbol() returns a handle to either the built-in resource or a bitmap in a file in the folder named in tempStr.
-
June 23rd, 1999, 12:46 AM
#7
Re: Loading a bitmap in a CStatic
what i would like 2 know is how do i change the image in a CStatic (bitmap) as a result of some event in the dialog box (eg: different radio buttons). i have tried everything. somebody help me
-
June 23rd, 1999, 01:12 AM
#8
Re: Loading a bitmap in a CStatic
Try this on your event procedure :
[CBitmap bitmap;
bitmap.LoadBitmap(IDB_YOUR_SPECIAL_BITMAP);
m_static.SetBitmap((HBITMAP)bitmap);]
Please let me know if it works
Regards,
Fabi
-
June 23rd, 1999, 06:15 AM
#9
Re: Loading a bitmap in a CStatic
fabi's code really hit the spot. it got the job done PRONTO. excellent advice chum.
thanx
irfan
-
June 23rd, 1999, 06:30 AM
#10
Re: Loading a bitmap in a CStatic
If you want to load the bitmap from a file use:
hBitmap = (HBITMAP) ::LoadImage(AfxGetInstanceHandle(), iconPath, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE | LR_CREATEDIBSECTION);
then use SetBitmap(hBitmap)
The problem I'm having is that I am unable to free the resources when the dialog containing the CStatics are destroyed. Calling DeleteObject()
also deletes the bitmap of which hBitmap is the handle. This is not what I want as that bitmap is used in the main part of the app.
Does anyone know how to free resources after a SetBitmap call?
-
June 23rd, 1999, 10:19 PM
#11
Re: Loading a bitmap in a CStatic
I used your code for changing the bitmap in the static control and the static control changes to the new image size, but the control is blank. Help!
-
June 24th, 1999, 04:00 AM
#12
Re: Loading a bitmap in a CStatic
Send me your e-mail adress to : [email protected]. I'll sent you a source code.
P.S. Sorry for my late answer. Diferent country, Diferent time zones.
Best regards,
Fabi
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|