Advertisement

Bitmaps

Started by April 17, 2002 06:19 PM
7 comments, last by Wachar 22 years, 6 months ago
How would I load a bitmap in the class declaration? ---------------------- Always will be smarter than you, --=ME=-- ----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
LoadImage

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
Advertisement
Then, why won''t this work?


  #define WIN32_LEAN_AND_MEAN#include <windows.h>#include "resource.h"LRESULT CALLBACK WindowProc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam){	PAINTSTRUCT		ps;	HDC				hdc;	switch(msg)	{	case WM_CREATE:		{			return(0);		} break;	case WM_COMMAND:		{			switch(LOWORD(wparam))			{			case ID_MENU_FILE_EXIT:				{					case WM_CLOSE:						{         							int result =  MessageBox(hwnd,										"Are you sure you want to close this application?",                                        "Exit",                                         MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2);                 							if (result == IDYES)							{								PostQuitMessage(0);							} 							else 							return(0);						}								}						case ID_MENU_HELP_ABOUT:				{					MessageBox(hwnd,						"My extrodinary Window!!\nCopyright April 2002",						"About",						MB_OK | MB_ICONINFORMATION);				}			}		}					case WM_PAINT:		{			hdc = BeginPaint(hwnd, &ps);			EndPaint(hwnd, &ps);			return(0);		} break;	case WM_DESTROY:		{			PostQuitMessage(0);			return(0);		} break;	default:break;	}	return(DefWindowProc(hwnd, msg, wparam, lparam));}int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd){	WNDCLASSEX winclass;	HWND		hwnd;	MSG			msg;	winclass.cbSize = sizeof(WNDCLASSEX);	winclass.style = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;	winclass.lpfnWndProc	= WindowProc;	winclass.cbClsExtra		= 0;	winclass.cbWndExtra		= 0;	winclass.hInstance		= hInstance;	winclass.hIcon			= LoadIcon(hInstance, MAKEINTRESOURCE(ID_ICON_ME));	winclass.hCursor		= LoadCursor(hInstance, MAKEINTRESOURCE(ID_CURSOR_ME));	winclass.hbrBackground	= LoadImage(NULL, 							  ID_BITMAP_ME,							  IMAGE_BITMAP,							  0,0,							  LR_LOADFROMFILE | LR_CREATEDIBSECTION);	winclass.lpszMenuName	= MAKEINTRESOURCE(ID_MAIN_MENU);	winclass.lpszClassName	= "WINCLASS1";	winclass.hIconSm		= LoadIcon(hInstance, MAKEINTRESOURCE(ID_ICON_ME));	if(!RegisterClassEx(&winclass))		return(0);		if(!(hwnd = CreateWindowEx(NULL,							  "WINCLASS1",							  "My Awesome Window!",							   WS_OVERLAPPEDWINDOW | WS_VISIBLE,							   0,0,							   GetSystemMetrics(SM_CXSCREEN),GetSystemMetrics(SM_CYSCREEN),							   NULL,							   NULL,							   hInstance,							   NULL)))	return(0);	while(TRUE)	{		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))		{			if(msg.message == WM_QUIT)				break;			TranslateMessage(&msg);			DispatchMessage(&msg);		}	}	return(msg.wParam);}  


----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
Because I said LoadImage, not LoadIcon. Pay attention.

(This thread is virtually a repetition of what you wrote before, here. Your lack of improvement - or effort - is disappointing to say the least.)

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
I did use LoadImage in the hbrBackground declaration!

----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
hbrBackground is a brush, not a bitmap. If you want a background image, you''ll need to get an HDC for your window (GetDC or BeginPaint) and BitBlt the momory DIB to it.

[ GDNet Start Here | GDNet Search Tool | GDNet FAQ | MS RTFM [MSDN] | SGI STL Docs | Google! | Asking Smart Questions | Internet Acronyms ]
Thanks to Kylotan for the idea!
Advertisement
Ok...I don''t know what BitBlt is...

----------------------
Always will be smarter
than you,
--=ME=--
----------------------
Wachar's Eternity <-<-<-<-<- Me own site!
RTFM (MSDN, in this case)
If you don''t know what BitBlt is you might want to get rid of the signature!

Breakaway Games

Former Microsoft XNA and Xbox MVP | Check out my blog for random ramblings on game development

This topic is closed to new replies.

Advertisement