![]() |
UserControls and CommandBars |
Post Reply ![]() |
Author | |
Geraint P ![]() Newbie ![]() Joined: 13 September 2004 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() Posted: 15 September 2004 at 8:29am |
This is a similar issue to that raised below ("Problem With ActiveX"). I've taken account of the advice there and the MoveAlignedControl method certain helped me with a lot of my problems! A further issue I have is this though. Our control implements a splitter bar to allow the control to be resized (basically it's a simple MDIpane control). To draw the splitter bar it needs to calculate the X and Y offset. We use the UserControl.Extender.Left & UserControl.Extender.Top properties to obtain the offset and call ClientToScreen (with the parent hWnd) to convert these pixel coordinates into screen coords. Trouble is this doesn't work with a CommandBar present - it doesn't seem to take into account any toolbars that happen to exist above or to the left of our control. Do you have a recommended method of calculating the appropriate coordinates within a usercontrol in these circumstances? I hope that makes sense.
|
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
GetClientRect will return the top, left, bottom, and right coordinates of the client area.
|
|
![]() |
|
Geraint P ![]() Newbie ![]() Joined: 13 September 2004 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
In typical fashion I managed to find a workaround after posting this, with a combination of ClientToScreen and ScreenToClient. Because our control won't necessarily be working with CommandBars present it had to be able to work out the coords without using a call to CommandBars itself. Really I only seem to have one further problem; the user control can't seem to resize itself. The line UserControl.Width = <new width> within our user control doesn't seem to have any effect at all with a CommandBars present. Any ideas? This seems to have something to do with it's interaction with the MoveAlignedControl method. |
|
![]() |
|
Geraint P ![]() Newbie ![]() Joined: 13 September 2004 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
After looking at this a bit further I can probably simplify what I'm asking now. If I have a picturebox aligned to the left of a MDIForm with a width of say, 2000 twips. I use MoveAlignedControls within the CommandBars_RepositionAlignedControls event. If I have a button which increases the width of the picturebox to 4000 twips, then nothing happens - the width stays the same. Is this expected behaviour? |
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
change the width of the picturebox in the movealignedcontrol method
just before it is moved. Also make sure that the commanbars is
using the same scale (twips\pixels) as your MDIform.
|
|
![]() |
|
Geraint P ![]() Newbie ![]() Joined: 13 September 2004 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
Sorry, but I'm not sure I understand exactly where I should be changing the width. Currently I use MoveAlignedControl as you've suggested in other threads. i.e. Private Sub CommandBars_RepositionAlignedControls(Left As Long, Top As Long, Right As Long, Bottom As Long) At the moment, no matter where picture1.width is changed, it doesn't seem to affect the control. Am I missing something obvious?
|
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
Try something like this assuming your picturebox is on the right side of the MDIForm:
Dim NewWidth as Long NewWidth = Right - SliderValue CommandBars1.MoveAlignedControl Picture1, NewWidth, Top, Right, Bottom Edited by SuperMario |
|
![]() |
|
Geraint P ![]() Newbie ![]() Joined: 13 September 2004 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
Nope - no luck at all. I'm finding the MoveAlignedControl method very confusing to be honest. For example, the Right property is described as "The space between the right side of the control and the right side of the container of the control.". Assuming I have a picturebox aligned to the right of the MDIForm, then you'd assume that this should be zero, which it patently isn't in the example above (in RepositionAlignedControls). MoveAlignedControl seems to be doing this - send me the current client area and I'll reposition your aligned control with that and return you the new client area. It moves the control, but can't seem to resize it. Which is fair enough, except of course I can't resize the control any other way either. I'll be uploading a simple example of this a bit later. I'd be grateful if you could take a quick look and see if there's a definite solution. Ta. |
|
![]() |
|
Geraint P ![]() Newbie ![]() Joined: 13 September 2004 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
Here's the uploaded project. VERY simple as you'll see. I'll keep plugging away... |
|
![]() |
|
SuperMario ![]() Admin Group ![]() ![]() Joined: 14 February 2004 Status: Offline Points: 18057 |
![]() ![]() ![]() ![]() ![]() |
![]() |
|
Geraint P ![]() Newbie ![]() Joined: 13 September 2004 Status: Offline Points: 19 |
![]() ![]() ![]() ![]() ![]() |
That's looking better. Added some similar code to our real app now and the usercontrol can indeed resize itself now (as long as we call RecalcLayout afterwards and then use the usercontrol width to adjust the left/right properties of MoveAlignedControl). Thank for all the help so far. Although you may not have seen the last of me. |
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |