May 01, 2024, 08:01:47 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


A (stupid?) question on GetClientRect()

Started by Haim, December 28, 2006, 05:33:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Haim

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


Mike Stefanik

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.
Mike Stefanik
www.catalyst.com
Catalyst Development Corporation

Bruce Peaslee

That's correct and why I recommend putting the declarations on separate lines. (It took me a minute to catch the meaning.)
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Haim

 :-[ Thanks guys, for the explanation
I should have seen it by myself, sorry to have bothered you all with this   :-[

Haim

Bruce Peaslee

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.
Bruce Peaslee
"Born too loose."
iTired (There's a nap for that.)
Well, I headed for Las Vegas
Only made it out to Needles

Ionic Wind Support Team

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.
Ionic Wind Support Team