Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dialog Box question

Status
Not open for further replies.

RayWilson

Technical User
Nov 28, 2001
43
GB
Hello,

I am using Visual C++ 6 (quite new :) ). I created a dialog box which appears no problems within the program when it is called. The problem is the images I put on the dialog box do not show!

I used the "Picture" tool and selected bitmap. I then pointed it to the correct bitmap (which are resources of the program) for the options for that picture. It looks fine when I "test" the dialog box.

I was using the resource editor to make it - I haven't manually coded the dialog box.

Can anyone tell me why the pictures don't appear?

Ta

Ray
 
I don't know if this is what ur after, Ray, but...

Go to the Visual Studio page to veiw you dialogue box. Up the top of the screen there is an option "Insert". Within this dropdown, select the resource option. A new popup will appear with a number of options. Click on the "Bitmap" option and then select "Import". Pick the file u want to add as a bitmap, then hit OK. Draw you Image box in the dialogue box as normal, then using the properties option, change the type from frame to bitmap, and use the "Image" tab to select one of the images that will now be listed as a resource. No coding is required, MFC takes care of this for you, and your image should now be visible !

This works for me......
 
Hi, thanks for replying.

I thought this should be the case but still nothing appears. Is it possible that the bitmap resources are not being compiled in to the program or I have a corrupted .rc file? What's the best way to check this?

Thanks again

R
 
Hi,

I just discovered it was a problem in the way i was calling my dialog box. The relevant code is:

DialogBox(NULL, MAKEINTRESOURCE(IDD_SETTINGS), hWnd, (DLGPROC)DlgSettingsProc);

The first parameter, NULL, is the cause of my problem. It is supposed to be the instance (HINSTANCE) of the application.

Is there a function that returns the instance of the application ???

Ta

Ray
 
Try using AfxGetApp(). I'm not sure if this returns a HINSTANCE or not but it can be used to get a pointer to your application object, which may do the trick. You'll probably need to cast the returned pointer to be a pointer to your specific application type:
((MyApp*)AfxGetApp())->

hope this helps

CMR
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top