How to load BMP from file to static control??

Hi!

I have no idea to do this!
here is a function to do it

"pic1.bmp" needs to be in the same directory as the executable

test.cpp

1
2
3
4
5
6
7
8
9
10
11
12
void	makeGUI(HWND hwnd)
{
	static1 = CreateWindow("STATIC","",WS_CHILD | SS_BITMAP,
						100,100,150,150,
						hwnd,(HMENU) STATIC1,hInst,NULL);

	ShowWindow(static1,SW_SHOW);

	bmp1 = (HBITMAP) LoadImage(hInst,"pic1.bmp",IMAGE_BITMAP,100,100,LR_LOADFROMFILE);

	SendMessage(static1,STM_SETIMAGE,(WPARAM) IMAGE_BITMAP,(LPARAM) bmp1);
}


add following to your header {test.h}

1
2
3
4
5
6
7
8
9
#include	<windows.h>

#define		STATIC1		0x1001

        void	        	makeGUI(HWND hwnd);

        HINSTANCE      hInst;
	HWND		static1;
	HBITMAP		bmp1;


you will also need

hInst = hInstance {first line in Winmain function}
Thanks very much, it works!!!
Topic archived. No new replies allowed.