Click here to Skip to main content
15,887,434 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionOpen Forms in a second Monitor Pin
spy_charly6-Jun-06 17:43
spy_charly6-Jun-06 17:43 
Question__LINE__ doesn't work in Visual Studio 2005 Pin
User 2155976-Jun-06 16:43
User 2155976-Jun-06 16:43 
AnswerRe: __LINE__ doesn't work in Visual Studio 2005 Pin
User 2155976-Jun-06 17:01
User 2155976-Jun-06 17:01 
QuestionDifferent CSplitterWnd behaviour needed Pin
Vladimir Svrkota6-Jun-06 14:00
professionalVladimir Svrkota6-Jun-06 14:00 
AnswerRe: Different CSplitterWnd behaviour needed Pin
LeeeNN6-Jun-06 14:37
LeeeNN6-Jun-06 14:37 
GeneralRe: Different CSplitterWnd behaviour needed Pin
Vladimir Svrkota7-Jun-06 16:06
professionalVladimir Svrkota7-Jun-06 16:06 
QuestionOverlapped sockets and completion routines. Pin
luke7276-Jun-06 13:43
luke7276-Jun-06 13:43 
QuestionDrawing a bitmap Pin
Pugman8126-Jun-06 12:12
Pugman8126-Jun-06 12:12 
I am new to c++. i understand programming i am a advanced vb programmer, but i am just havin problems learning and applying all these new keywords. i am a beginnering in c but i have had experience with the very basic fundamental things.
i am reading through a book and they want me to draw a single bitmap on a client window and have it jump around on the window and not go out of the window boundries. The only thing that happens right now is it just draws it over and over all over the screen without removing the previous instance of the bitmap. THIS IS MY CODE.

void Game_Run()<br />
{<br />
	//the is called once ever frame<br />
	//do not include your own loop here!<br />
<br />
	int x = 0, y = 0;<br />
	RECT rect;<br />
	GetClientRect(global_hwnd, &rect);<br />
<br />
	if (rect.right > 0)<br />
	{<br />
		x = rand() % (rect.right - rect.left);<br />
		y = rand() % (rect.bottom - rect.top);<br />
		DrawBitmap(global_hdc, "c.bmp", x, y);<br />
	}<br />
}


void DrawBitmap(HDC hdcDest, char *filename, int x, int y)<br />
{<br />
	HBITMAP image;<br />
	BITMAP bm;<br />
	HDC hdcMem;<br />
<br />
	//load the bitmap image<br />
		image = LoadImage(0,"c.bmp",IMAGE_BITMAP,0,0,LR_LOADFROMFILE);<br />
<br />
	//read the bitmaps properties<br />
	GetObject(image, sizeof(BITMAP), &bm);<br />
<br />
	//create a device context for the bitmap<br />
	hdcMem = CreateCompatibleDC(global_hdc);<br />
	SelectObject(hdcMem, image);<br />
<br />
	//draw the bitmap to the window ( bit block transfer)<br />
	BitBlt(<br />
		global_hdc,					//destination device context<br />
		x,y,						//x,y location on destination<br />
		bm.bmWidth, bm.bmHeight,	//width, height of source bitmap<br />
		hdcMem,						//source bitmap device context<br />
		0,0,						//start x,y on source bitmap	<br />
		SRCCOPY);					//blit method<br />
<br />
	//delete the device context and bitmap<br />
	DeleteDC(hdcMem);<br />
	DeleteObject((HBITMAP)image);<br />
	ShowWindow(global_hwnd, SW_SHOW);<br />
}

all i need it to do is draw once and move around the screen with the rand() function. Any help would be great because this is not a essential task of the book but i like to know how to anything with the language i am learning. THANK YOU.
AnswerRe: Drawing a bitmap Pin
Chris Losinger6-Jun-06 15:46
professionalChris Losinger6-Jun-06 15:46 
GeneralRe: Drawing a bitmap Pin
Pugman8126-Jun-06 23:07
Pugman8126-Jun-06 23:07 
GeneralRe: Drawing a bitmap [modified] Pin
Chris Losinger7-Jun-06 1:13
professionalChris Losinger7-Jun-06 1:13 
Questionwhich function gets color setting of PC? Pin
includeh106-Jun-06 10:27
includeh106-Jun-06 10:27 
AnswerRe: which function gets color setting of PC? Pin
Ryan Binns6-Jun-06 18:25
Ryan Binns6-Jun-06 18:25 
QuestionSocket Connection Pin
SPowers6-Jun-06 8:43
SPowers6-Jun-06 8:43 
QuestionCreateDIBSection Pin
includeh106-Jun-06 8:36
includeh106-Jun-06 8:36 
AnswerRe: CreateDIBSection Pin
valikac6-Jun-06 9:20
valikac6-Jun-06 9:20 
GeneralRe: CreateDIBSection Pin
includeh106-Jun-06 9:30
includeh106-Jun-06 9:30 
AnswerRe: CreateDIBSection Pin
Chris Losinger6-Jun-06 9:53
professionalChris Losinger6-Jun-06 9:53 
GeneralRe: CreateDIBSection Pin
includeh106-Jun-06 10:15
includeh106-Jun-06 10:15 
GeneralRe: CreateDIBSection Pin
Chris Losinger6-Jun-06 11:25
professionalChris Losinger6-Jun-06 11:25 
GeneralRe: CreateDIBSection Pin
includeh106-Jun-06 11:55
includeh106-Jun-06 11:55 
GeneralRe: CreateDIBSection Pin
Chris Losinger6-Jun-06 15:30
professionalChris Losinger6-Jun-06 15:30 
Questionquestion about HBITMAP Pin
includeh106-Jun-06 8:24
includeh106-Jun-06 8:24 
AnswerRe: question about HBITMAP Pin
Chris Losinger6-Jun-06 8:30
professionalChris Losinger6-Jun-06 8:30 
GeneralRe: question about HBITMAP Pin
includeh106-Jun-06 8:44
includeh106-Jun-06 8:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.