Lately I re examined an old example called Cprintwindow.src, which demonstrates, among other things, how to scroll a window and use the printer.
I encountered ther an expression which I do not understand, in the following bit of code which is the On Size method of
a class derived from CWindow.
CPrintWindow::OnSize(int nType,int cx,int cy),int
{
rect rcClient = GetClientRect(),rectInvalid; <-------- what is this ???
int nPosX = GetSBPos(SBHORZ);
int nPosY = GetSBPos(SBVERT);
SetSBPageSize(SBVERT,rcClient.Bottom);
SetSBPageSize(SBHORZ,rcClient.Right);
if(nPosX != GetSBPos(SBHORZ))
{
rectInvalid = rcClient;
rectInvalid.right = rectInvalid.left + (nPosX - GetSBPos(SBHORZ));
ScrollWindowEx(m_hWnd,(nPosX - GetSBPos(SBHORZ)),0,NULL,rcClient,NULL,NULL,0);
InvalidateRect(m_hWnd,rectInvalid,true);
}
if(nPosY != GetSBPos(SBVERT))
{
rectInvalid = rcClient;
rectInvalid.bottom = rectInvalid.Top + (nPosY - GetSBPos(SBVERT));
ScrollWindowEx(m_hWnd,0,(nPosY - GetSBPos(SBVERT)),NULL,rcClient,NULL,NULL,0);
InvalidateRect(m_hWnd,rectInvalid,true);
}
As I said earlier this code compiles with no errors and runs.
Any explanation would be appreciated.
Haim
It's just a variable declaration for a structure named "RECT" which specifies the coordinates of a rectangle. Think of it like this:
rect rcClient = GetClientRect();
rect rectInvalid;
As with C++, structures are considered to be types; the principal difference is that Aurora isn't case-sensitive, so "RECT", "Rect" and "rect" are all the same thing.
That's correct and why I recommend putting the declarations on separate lines. (It took me a minute to catch the meaning.)
:-[ Thanks guys, for the explanation
I should have seen it by myself, sorry to have bothered you all with this :-[
Haim
No bother - that's why we have a forum.
And besides, although I don't code that way, I didn't know you could do it; so I learned something from your question.
It is a common practice so you will see it in a lot of code. The ',' seperates the definitions and all variable names share the same type.
It makes more sense when you see it with simple operations:
INT a=0, b=5, c=100;
All three variables are defines as integers and set to an initial value.