# C++ Bild anzeigen



## DuffCola (16. Februar 2013)

Wie kann ich hier ein Bild anzeigen lassen.
Habe nicht die geringste Idee wie ich das anstellen kann.


```
//====================================================MAIN_CPP====================================================//

#include <Windows.h>
#include <iostream>

#define KEY_DOWN(vk_code)  ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)
#define KEY_UP(vk_code)    ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)

int			iMainWindow_width			= GetSystemMetrics(SM_CXSCREEN);
int			iMainWindow_height		    = GetSystemMetrics(SM_CYSCREEN);
int			iMainWindow_hor				= 0;
int			iMainWindow_ver				= 0;
const char  szMainWindow_ClassName[]	= "WndClassEx";
char		szMainWindow_Title[]		= "Note Viewer";
WNDCLASSEX	MainWindow_WndClassEx;
HWND		MainWindow_hWnd;

MSG	Global_msg;
LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
bool InitWndClassEx( WNDCLASSEX *WndClassEx, HINSTANCE hInstance, const char* szClassName  );
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR szCmdLine, int iCmdShow )
{

//==================================================== REGISTRIERUNG ====================================================//

	MainWindow_WndClassEx.cbSize		 = sizeof( WNDCLASSEX );
	MainWindow_WndClassEx.style         = NULL;
	MainWindow_WndClassEx.lpfnWndProc   = WndProc; 
	MainWindow_WndClassEx.cbClsExtra    = NULL; 
	MainWindow_WndClassEx.cbWndExtra    = NULL; 
	MainWindow_WndClassEx.hInstance     = hInstance; 
	MainWindow_WndClassEx.hIcon         = LoadIcon (NULL, IDI_WINLOGO); 
	MainWindow_WndClassEx.hCursor       = LoadCursor (NULL, IDC_ARROW); 
	MainWindow_WndClassEx.hbrBackground = (HBRUSH) GetStockObject (BLACK_BRUSH); 
	MainWindow_WndClassEx.lpszMenuName  = NULL; 
	MainWindow_WndClassEx.lpszClassName = szMainWindow_ClassName;	  
	MainWindow_WndClassEx.hIconSm		 = LoadIcon (NULL, IDI_WINLOGO);

	if( !RegisterClassEx( &MainWindow_WndClassEx ) ){
		MessageBox( NULL, "MainWindow_WndClassEx failed.", "Error", MB_OK | MB_ICONERROR );
		return false;
	}

//==================================================== FENSTER ERSTELLEN ====================================================//

	MainWindow_hWnd = CreateWindowEx( WS_EX_TOPMOST,
					szMainWindow_ClassName,
					szMainWindow_Title,
					WS_POPUP,
					iMainWindow_hor,	
					iMainWindow_ver,    
					iMainWindow_width,	
					iMainWindow_height,	
					NULL,
					NULL,
					hInstance,
					NULL );

	if( MainWindow_hWnd == NULL ){
		MessageBox( NULL, "Create MainWindow_hWnd failed.", "Error", MB_OK );
		return 0;
	}


	 ShowWindow(   MainWindow_hWnd, iCmdShow );
	 UpdateWindow( MainWindow_hWnd );


	while( GetMessage( &Global_msg, MainWindow_hWnd, NULL, NULL ) > NULL ){

		TranslateMessage( &Global_msg );	 
		DispatchMessage( &Global_msg );	  

	}

	return 0;

}

LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam ){	  

switch( msg )
{
		case WM_DESTROY: 
				PostQuitMessage(0);
				break;
//==================================================== Tastenabfrage ====================================================//
			case WM_KEYDOWN:
            switch(wParam)
            {
            case VK_ESCAPE:
                  PostMessage(MainWindow_hWnd,WM_CLOSE,0,0);
                  break;
			case VK_SPACE:
				 PostMessage(MainWindow_hWnd,WM_CLOSE,0,0);
				 break;
            }
            break;

			default : 
				return DefWindowProc( hWnd, msg, wParam, lParam );

		}
	return 0;
}
```


----------



## sheel (17. Februar 2013)

Hi und Willkommen bei tutorials.de,

hier die nötigen Ergänzungen, um BMPs anzuzeigen:
http://stackoverflow.com/questions/1748470/how-to-draw-image-on-a-window


----------

