Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > ActiveX COM > Command Bars
  New Posts New Posts RSS Feed - UserControls and CommandBars
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

UserControls and CommandBars

 Post Reply Post Reply
Author
Message
Geraint P View Drop Down
Newbie
Newbie


Joined: 13 September 2004
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Geraint P Quote  Post ReplyReply Direct Link To This Post Topic: UserControls and CommandBars
    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.

 

 

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2004 at 8:43am
GetClientRect will return the top, left, bottom, and right coordinates of the client area.  
Back to Top
Geraint P View Drop Down
Newbie
Newbie


Joined: 13 September 2004
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Geraint P Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2004 at 9:32am

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.

Back to Top
Geraint P View Drop Down
Newbie
Newbie


Joined: 13 September 2004
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Geraint P Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2004 at 10:21am

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?

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2004 at 10:43am
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.
Back to Top
Geraint P View Drop Down
Newbie
Newbie


Joined: 13 September 2004
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Geraint P Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2004 at 10:59am

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)
    CommandBars.MoveAlignedControl Picture1, Left, Top, Right, Bottom
End Sub

At the moment, no matter where picture1.width is changed, it doesn't seem to affect the control. Am I missing something obvious?

 

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 15 September 2004 at 11:28am
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
Back to Top
Geraint P View Drop Down
Newbie
Newbie


Joined: 13 September 2004
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Geraint P Quote  Post ReplyReply Direct Link To This Post Posted: 16 September 2004 at 5:06am

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.

Back to Top
Geraint P View Drop Down
Newbie
Newbie


Joined: 13 September 2004
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Geraint P Quote  Post ReplyReply Direct Link To This Post Posted: 16 September 2004 at 5:50am

Here's the uploaded project. VERY simple as you'll see. I'll keep plugging away...

2004-09-16_055029_Project1.zip

Back to Top
SuperMario View Drop Down
Admin Group
Admin Group
Avatar

Joined: 14 February 2004
Status: Offline
Points: 18057
Post Options Post Options   Thanks (0) Thanks(0)   Quote SuperMario Quote  Post ReplyReply Direct Link To This Post Posted: 16 September 2004 at 8:29am
Take a look at this:

2004-09-16_082934_Project1.zip
Back to Top
Geraint P View Drop Down
Newbie
Newbie


Joined: 13 September 2004
Status: Offline
Points: 19
Post Options Post Options   Thanks (0) Thanks(0)   Quote Geraint P Quote  Post ReplyReply Direct Link To This Post Posted: 16 September 2004 at 9:13am

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.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.125 seconds.