FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

setBounds suggestion

 
Post new topic   Reply to topic     Forum Index -> DFL
View previous topic :: View next topic  
Author Message
tim



Joined: 24 Jul 2005
Posts: 26

PostPosted: Wed Aug 03, 2005 5:48 am    Post subject: setBounds suggestion Reply with quote

I often want to set more than one property, but less than all four. It would be nice if you could do something like:

setBounds(newX, -1, newWidth, -1);

... where -1 means "keep the current value".
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Wed Aug 03, 2005 7:16 am    Post subject: Re: setBounds suggestion Reply with quote

tim wrote:
I often want to set more than one property, but less than all four.


setBounds() has an extra optional parameter of type BoundsSpecified which lets you specify which of the other parameters are valid. e.g.
Code:

setBounds(10, 0, 100, 100, BoundsSpecified.X | BoundsSpecified.SIZE);

which sets x, width and height. But since that's actually more work, you might want to do what I do and just use the current control's bounds values to fill in the ones you don't want to change:
Code:

setBounds(left, 10, width, 100);

which only updates y and height. DFL is pretty good at caching values so doing that doesn't cause any extra Windows API function calls.
Back to top
View user's profile Send private message
tim



Joined: 24 Jul 2005
Posts: 26

PostPosted: Wed Aug 03, 2005 7:44 am    Post subject: Reply with quote

Too verbose.

with(myControl)
setBounds(left, top, width, 150)

... is much longer than

myControl.setBounds(-1, -1, -1, 150);
Back to top
View user's profile Send private message
Chris Miller



Joined: 27 Mar 2004
Posts: 514
Location: The Internet

PostPosted: Wed Aug 03, 2005 7:53 am    Post subject: Reply with quote

tim wrote:
Too verbose.

with(myControl)
setBounds(left, top, width, 150)

for that you can simply use:
myControl.height = 150;

Quote:

myControl.setBounds(-1, -1, -1, 150);

-1 are valid x and y positions.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic     Forum Index -> DFL All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group