Rupert Murdoch
Rupert Murdoch

Reputation: 1

Display Dialog Bitmap

Hi all I am fairly new to win api and am using C. I was wondering how would I display a banner on my dialog application. I have managed to load the application icon with the following code.

LoadIcon(hInstance,MAKEINTRESOURCE(IDI_ICON1));

However am a little unsure on how to do it on dialog. Using visual studio I was able to create the picture control box which gives me IDC_STATIC1 do I use sendmessage to load the bitmap file?

Sorry if its a dumb question I have had a good route on google this morning but no sucess.

Upvotes: 0

Views: 1492

Answers (1)

vulkanino
vulkanino

Reputation: 9124

If you want to load the image from the resources of your app:

hBitmap = (HBITMAP) LoadImage (
    hInst, 
    MAKEINTRESOURCE(id), 
    IMAGE_BITMAP, 
    0, 0, 
    LR_CREATEDIBSECTION);

If you want to load the image from an external file:

hBitmap = (HBITMAP) LoadImage (
    0, 
    path, 
    IMAGE_BITMAP, 
    0, 0, 
    LR_LOADFROMFILE);

Now you want to display an image in the client area of your Dialog Box, well you have to blit it.

HDC hdcDst = CreateCompatibleDC(NULL);
BitBlt(hdcDst, x, y, width, height, sourceDc, xSource, ySource, mode);

Consider that you are doing all this the hard/old way; after the direct SDK calls came Visual C++/MFC/.NET/WPF/...

Upvotes: 1

Related Questions