Function showing BMP doesn't work

Hi,

I'm from Poland so sorry for my bad English.

I was created a function showing a BMP image. But it doesn't work when i try to compilate this (I'm using Dev-C++).

The errors are:
C:\[...]\main.cpp In function 'int show_bmp(char*, int, int, int, int)':
10 2 C:\[...]\main.cpp [Error] 'hdcOkno' was not declared in this scope
10 18 C:\[...]\main.cpp [Error] 'hwnd' was not declared in this scope

C:\[...]\main.cpp In function 'int main()':
23 33 C:\[...]\main.cpp [Warning] deprecated conversion from string constant to
'char*' [-Wwrite-strings]


My code is:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <iostream>
#include <windows.h>

using namespace std;

int show_bmp(char bmp[], int x_bmp, int y_bmp, int width_bmp, int height_bmp)
{
	HBITMAP hbmObraz;
	hbmObraz = (HBITMAP)LoadImage(NULL, bmp, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE);
	hdcOkno = GetDC(hwnd);
	HDC hdcNowy = CreateCompatibleDC(hdcOkno);
	SelectObject(hdcNowy, hbmObraz);
	BITMAP bmInfo;
	GetObject(hbmObraz, sizeof(bmInfo), &bmInfo);
	BitBlt(hdcOkno, x_bmp, y_bmp, width_bmp, height_bmp, hdcNowy, 0, 0, SRCCOPY);
	DeleteObject(hbmObraz);
	DeleteDC(hdcNowy);
	DeleteDC(hdcOkno);
}

int main()
{
	show_bmp("test.BMP", 0, 0, 0, 0);
	
	system("PAUSE");
	
	return 0;
}


Thanks for tips and help, Bartek.
Topic archived. No new replies allowed.