Using InvalidateRect to force screen update
-
Hi! I'm new to programming in VC+++, maybe someone here could help me out.Im using an 'InvalidateRect' in my application's 'OnIdle' message handler and it is returning an error. here is the code : InvalidateRect( hwnd, NULL, TRUE); and the error: hwnd : undeclared identifier hwnd seems to be a pointer to the main window? do I have to define it?
-
Hi! I'm new to programming in VC+++, maybe someone here could help me out.Im using an 'InvalidateRect' in my application's 'OnIdle' message handler and it is returning an error. here is the code : InvalidateRect( hwnd, NULL, TRUE); and the error: hwnd : undeclared identifier hwnd seems to be a pointer to the main window? do I have to define it?
mortishroom wrote: hwnd seems to be a pointer to the main window? Probably a window handle, rather than a pointer. mortishroom wrote: do I have to define it? Not to pacify the compiler, but it must be declared. At runtime, it must be defined with a valid value.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
-
Hi! I'm new to programming in VC+++, maybe someone here could help me out.Im using an 'InvalidateRect' in my application's 'OnIdle' message handler and it is returning an error. here is the code : InvalidateRect( hwnd, NULL, TRUE); and the error: hwnd : undeclared identifier hwnd seems to be a pointer to the main window? do I have to define it?
Are you using MFC or win32, The api that you are calling is of win32. For win32 api you need to have a valid window handle to send the notification to. if you are using MFC then first parameter is not required. In win32 you can use IsWindow(HWND) api to check wheather the hWnd is valid or not. Since you say you are biggener, You should check in ur code wheather you are creating any window, if so are you storing the pointer somewhere else. In Windows, The ui are targeted for certain function or api using the windows handle. Simple speaking you need a valide windows handle to call the above api. Hope i clear ur problem.
"Fear not of those who can kill the body and not the soul, rather fear Him who can kill both body and soul" - Bible Prakash, India.
-
Are you using MFC or win32, The api that you are calling is of win32. For win32 api you need to have a valid window handle to send the notification to. if you are using MFC then first parameter is not required. In win32 you can use IsWindow(HWND) api to check wheather the hWnd is valid or not. Since you say you are biggener, You should check in ur code wheather you are creating any window, if so are you storing the pointer somewhere else. In Windows, The ui are targeted for certain function or api using the windows handle. Simple speaking you need a valide windows handle to call the above api. Hope i clear ur problem.
"Fear not of those who can kill the body and not the soul, rather fear Him who can kill both body and soul" - Bible Prakash, India.
Mr.Prakash wrote: Are you using MFC or win32, The api that you are calling is of win32. Im using MFC w/the vc++ mfc app wizard. passing it NULL instead ov hWind worked just fine. thank you.
-
Mr.Prakash wrote: Are you using MFC or win32, The api that you are calling is of win32. Im using MFC w/the vc++ mfc app wizard. passing it NULL instead ov hWind worked just fine. thank you.
Strange, dont know how it works, I need to go back to books to understand that. Is it really working the way you are expecting it?? If you dont mind try replaying the NULL with m_hWnd its a predifined window handle in MFC.
"Fear not of those who can kill the body and not the soul, rather fear Him who can kill both body and soul" - Bible Prakash, India.
-
Strange, dont know how it works, I need to go back to books to understand that. Is it really working the way you are expecting it?? If you dont mind try replaying the NULL with m_hWnd its a predifined window handle in MFC.
"Fear not of those who can kill the body and not the soul, rather fear Him who can kill both body and soul" - Bible Prakash, India.
'm_hWnd' gives me an undeclared identifier error. Null is working exactly how i expected; and my code refreshes the screen at 90 million mph, causing everything to flicker uncontrollably. I geuss the next thing i need to learn is about 'frame rate'. :)
-
'm_hWnd' gives me an undeclared identifier error. Null is working exactly how i expected; and my code refreshes the screen at 90 million mph, causing everything to flicker uncontrollably. I geuss the next thing i need to learn is about 'frame rate'. :)
1. If you pass
InvalidateRect(NULL, rect)
, it invalidates all application windows. So I don't wonder, that it flickers. 2. Where are you calling theInvalidateRect
from? Generally, in MFC you must retrieve a pointer to redrawn window (CWnd*
) and then callCWnd::InvalidateRect(CRect rc, BOOL erase)
. You needn't to deal withHWND
's. Robert-Antonio "CRAY is the only computer, which runs an endless loop in just 4 hours" -
Hi! I'm new to programming in VC+++, maybe someone here could help me out.Im using an 'InvalidateRect' in my application's 'OnIdle' message handler and it is returning an error. here is the code : InvalidateRect( hwnd, NULL, TRUE); and the error: hwnd : undeclared identifier hwnd seems to be a pointer to the main window? do I have to define it?
You can just use this->Invalidate(TRUE); from within the window you want to repaint's loop.
Have you answered an MTQ? Check out the stats!
What's the latest butt-scratch count? Check it out! -
1. If you pass
InvalidateRect(NULL, rect)
, it invalidates all application windows. So I don't wonder, that it flickers. 2. Where are you calling theInvalidateRect
from? Generally, in MFC you must retrieve a pointer to redrawn window (CWnd*
) and then callCWnd::InvalidateRect(CRect rc, BOOL erase)
. You needn't to deal withHWND
's. Robert-Antonio "CRAY is the only computer, which runs an endless loop in just 4 hours"a pointer? hmm. thanks for the info - I'll have to look into it next time I get a chance.
-
You can just use this->Invalidate(TRUE); from within the window you want to repaint's loop.
Have you answered an MTQ? Check out the stats!
What's the latest butt-scratch count? Check it out!this->Invalidate(TRUE); gives me 'Invalidate' : is not a member of 'CMyApp'. I think I am calling it in the wrong place. how do I access one object's members from another object?