Click here to Skip to main content
15,895,256 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I have created an win32 dialog following this link:http://www.functionx.com/win32/Lesson02.htm[^]

and it is working fine and a small window is coming as described.

now I want to add an small image inside this this dialog, say a banner image type;

can any one give me idea how can I add it in this window;

thanks
Posted
Updated 27-Mar-13 7:02am
v2
Comments
Style-7 27-Mar-13 12:54pm    
What do you mean: Dialog Box or Window?

1 solution

Hi,

Try this code below,

declare these variables globally, and the code that follows inside WinProc()

C++
HBITMAP bitmap;
HDC hdcMem;

	case WM_PAINT:
		hdc = BeginPaint(hWnd, &ps);
		hdcMem = CreateCompatibleDC(hdc);
		SelectObject(hdcMem, bitmap);
		StretchBlt(
			hdc,
			0,
			0,
			1000,
			1000,
			hdcMem,
			0,
			0,
			1000,
			1000,
			SRCCOPY);
		
		EndPaint(hWnd, &ps);
		break;


	case WM_CREATE:
		bitmap=(HBITMAP)LoadImage(NULL,"C:\\Wallpaper.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);
		break;


In my example, i have kept a image file in "C:\\Wallpaper.bmp", so change as per your location.

Inside the api "StretchBlt" give appropriate dimensions as per your requirement.

Hope this will help you.

Bye.
 
Share this answer
 
Comments
Style-7 27-Mar-13 13:33pm    
static HBITMAP bitmap;
//use BitBlt if dx1=dx2 and dy1=dy2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900