Anish Mistry
May 12th, 1999, 04:49 PM
How would i load a resource bitmap into a CStatic? Thanks.
|
Click to See Complete Forum and Search --> : Loading a bitmap in a CStatic Anish Mistry May 12th, 1999, 04:49 PM How would i load a resource bitmap into a CStatic? Thanks. Jaeyeon Lee May 12th, 1999, 07:50 PM 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. sally May 12th, 1999, 08:41 PM and if I want to do it dynamically? Sally Sally May 12th, 1999, 08:41 PM and if I want to do it dynamically? Sally Jaeyeon Lee May 12th, 1999, 11:25 PM 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. John Holifield May 18th, 1999, 01:22 PM search help for ::LoadImage(). This function does what you want. Mark Wigmore June 22nd, 1999, 11:15 AM 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. Irfan Hamid June 23rd, 1999, 12:46 AM 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 Fabi Pantera June 23rd, 1999, 01:12 AM 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 Irfan Hamid June 23rd, 1999, 06:15 AM fabi's code really hit the spot. it got the job done PRONTO. excellent advice chum. thanx irfan Mark Wigmore June 23rd, 1999, 06:30 AM 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? Anish Mistry June 23rd, 1999, 10:19 PM 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! Fabi Pantera June 24th, 1999, 04:00 AM Send me your e-mail adress to : fabian_toader@hotmail.com. I'll sent you a source code. P.S. Sorry for my late answer. Diferent country, Diferent time zones. Best regards, Fabi codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |