Click here to Skip to main content
15,437,521 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: managing objects derived from the same base class using a container Pin
Calin Cali10-Aug-22 21:25
MemberCalin Cali10-Aug-22 21:25 
GeneralRe: managing objects derived from the same base class using a container Pin
Richard MacCutchan10-Aug-22 21:10
mveRichard MacCutchan10-Aug-22 21:10 
GeneralRe: managing objects derived from the same base class using a container Pin
Calin Cali11-Aug-22 0:38
MemberCalin Cali11-Aug-22 0:38 
GeneralRe: managing objects derived from the same base class using a container Pin
Richard MacCutchan11-Aug-22 0:39
mveRichard MacCutchan11-Aug-22 0:39 
GeneralRe: managing objects derived from the same base class using a container Pin
Calin Cali11-Aug-22 0:57
MemberCalin Cali11-Aug-22 0:57 
GeneralRe: managing objects derived from the same base class using a container Pin
Calin Cali12-Aug-22 18:58
MemberCalin Cali12-Aug-22 18:58 
GeneralRe: managing objects derived from the same base class using a container Pin
Richard MacCutchan12-Aug-22 21:55
mveRichard MacCutchan12-Aug-22 21:55 
Questionmoving graphics in a win32 c++ window Pin
Calin Cali9-Aug-22 8:25
MemberCalin Cali9-Aug-22 8:25 
I`m trying to animate things in a basic window. The code I have should get a rectangle (rc) move to the right however that does not happen, it`s all static.

LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	static RECT rcBmp;
	static HDC hdcCompat;
	static HBITMAP hbmp;
	static RECT rc;
	static RECT rc2;
	static RECT rc3;
	static RECT rc4;
	HBRUSH hbrWhite, hbrGray; 
	const COLORREF SomeColor = RGB(255,255,255);
	const COLORREF SomeColor2 = RGB(0,0,1);
	hbrWhite = CreateSolidBrush(SomeColor); 
	hbrGray  = CreateSolidBrush(SomeColor2); 
	
	int y = 0;
	HDC hdc = (HDC) wParam; 
	

    switch (uMsg)
    {
		case WM_CREATE: 
		
		return 0L; 
 
case WM_ERASEBKGND: 
    
    GetClientRect(hwnd, &rc); 
    SetMapMode(hdc, MM_ANISOTROPIC); 
    SetWindowExtEx(hdc, 100, 100, NULL); 
    SetViewportExtEx(hdc, rc.right, rc.bottom, NULL); 
    FillRect(hdc, &rc, hbrWhite); 
	
    
       
       
    return 0;
  
    case WM_DESTROY:
        PostQuitMessage(0);
        return 0;
	
		
           
    case WM_PAINT:
        {
            PAINTSTRUCT ps;
			
            HDC hdc = BeginPaint(hwnd, &ps);

            

           
			 SetRect(&rc,x, 20, 40, 40); 
			FillRect(hdc, &rc, hbrGray); 
			SetRect(&rc2,60, 60, 80, 80); 
			FillRect(hdc, &rc2, hbrGray); 

            EndPaint(hwnd, &ps);
        }
        return 0;

    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);
}
void GameUpdate()
{
	 
	x = x +1;

}

[Edit] it looks like WM_PAINT isn`t triggered every frame, only if I minimize and then maximize the window a change takes place

modified 9-Aug-22 14:35pm.

AnswerRe: moving graphics in a win32 c++ window Pin
Gerry Schmitz9-Aug-22 9:15
mveGerry Schmitz9-Aug-22 9:15 
AnswerRe: moving graphics in a win32 c++ window Pin
Graham Breach9-Aug-22 20:54
MemberGraham Breach9-Aug-22 20:54 
AnswerRe: moving graphics in a win32 c++ window Pin
Richard MacCutchan9-Aug-22 20:57
mveRichard MacCutchan9-Aug-22 20:57 
GeneralRe: moving graphics in a win32 c++ window Pin
Calin Cali10-Aug-22 1:58
MemberCalin Cali10-Aug-22 1:58 
GeneralRe: moving graphics in a win32 c++ window Pin
Richard MacCutchan10-Aug-22 2:01
mveRichard MacCutchan10-Aug-22 2:01 
QuestionFileMapping book exmple goes in loop Pin
coco2438-Aug-22 8:48
Membercoco2438-Aug-22 8:48 
AnswerRe: FileMapping book exmple goes in loop Pin
Mircea Neacsu8-Aug-22 10:35
mvaMircea Neacsu8-Aug-22 10:35 
GeneralRe: FileMapping book exmple goes in loop Pin
coco2438-Aug-22 11:45
Membercoco2438-Aug-22 11:45 
GeneralRe: FileMapping book exmple goes in loop Pin
Mircea Neacsu8-Aug-22 11:47
mvaMircea Neacsu8-Aug-22 11:47 
Questiondefining a function with #define Pin
coco24330-Jul-22 9:03
Membercoco24330-Jul-22 9:03 
AnswerRe: defining a function with #define Pin
Mircea Neacsu30-Jul-22 9:54
mvaMircea Neacsu30-Jul-22 9:54 
GeneralRe: defining a function with #define Pin
trønderen30-Jul-22 12:46
Membertrønderen30-Jul-22 12:46 
GeneralRe: defining a function with #define Pin
Greg Utas30-Jul-22 13:58
mveGreg Utas30-Jul-22 13:58 
AnswerRe: defining a function with #define Pin
Randor 30-Jul-22 9:55
professional Randor 30-Jul-22 9:55 
GeneralRe: defining a function with #define Pin
coco2433-Aug-22 9:01
Membercoco2433-Aug-22 9:01 
QuestionHow to read an xlsx file using CDatabase Pin
Sampath57927-Jul-22 19:54
MemberSampath57927-Jul-22 19:54 
AnswerRe: How to read an xlsx file using CDatabase Pin
Victor Nijegorodov27-Jul-22 20:07
MemberVictor Nijegorodov27-Jul-22 20:07 

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.