IonicWind Software

Aurora Compiler => Coding Help - Aurora 101 => Topic started by: Haim on December 28, 2006, 05:33:10 AM

Title: A (stupid?) question on GetClientRect()
Post by: Haim on December 28, 2006, 05:33:10 AM
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

Title: Re: A (stupid?) question on GetClientRect()
Post by: Mike Stefanik on December 28, 2006, 05:50:50 AM
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.
Title: Re: A (stupid?) question on GetClientRect()
Post by: Bruce Peaslee on December 28, 2006, 10:01:42 AM
That's correct and why I recommend putting the declarations on separate lines. (It took me a minute to catch the meaning.)
Title: Re: A (stupid?) question on GetClientRect()
Post by: Haim on December 28, 2006, 11:30:21 PM
 :-[ Thanks guys, for the explanation
I should have seen it by myself, sorry to have bothered you all with this   :-[

Haim
Title: Re: A (stupid?) question on GetClientRect()
Post by: Bruce Peaslee on December 29, 2006, 10:09:29 AM
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.
Title: Re: A (stupid?) question on GetClientRect()
Post by: Ionic Wind Support Team on December 29, 2006, 12:26:07 PM
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.