Public Group

is there a way to declare a RECT all in one line.

This topic is 4862 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

meaning decalre the rect and define all the corners in one command?

Share on other sites
RECT r = {1, 2, 3, 4};

Share on other sites
RECT r = {100, 100, 200, 200};  // left, top, right, bottom

edit: damn!

Share on other sites
I thought i tried that and it didn't work. oh well I guess i did something wrong. thanks alot!

Share on other sites
When I try declaring something like that, I often forget the semicolon at the end.
RECT myrect = {1, 1, 2, 2};

Is that what you were doing wrong?

Share on other sites
You can always make your own function:
void    setrect(RECT &r, ... left ...){     r.left = left...}orRECT    makerect(... left ... ){     RECT   rtn;     rtn.left=left;     ...      return(rtn);}

The bottom is likely slower [maybe optimized out] but easier to deal with.

And there's likely a better way than such naive things.

Share on other sites
There already is a win32 function for that
SetRect(&rect, left, top, right, bottom);

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 9
• 9
• 9
• 14
• 12
• Forum Statistics

• Total Topics
633301
• Total Posts
3011268
• Who's Online (See full list)

There are no registered users currently online

×