Dynamic Resizing of StatusBar Panes |
Post Reply |
Author | |
stefanadelbert
Groupie Joined: 29 October 2008 Location: Australia Status: Offline Points: 31 |
Post Options
Thanks(0)
Posted: 02 August 2009 at 11:38pm |
I'm trying to get the dynamic sizing of the panes in the StatusBar right, but I'm having trouble making it behave how I would like.
I have a left pane, spacer pane (style set to SBPS_STRETCH, also used for some progress messages) and four panes to the right of that. The left-most and four right-most panes should resize to fit their contents. The space pane should take up the remaining space. This works fine until I put text into the spacer pane that is longer than the width of the pane allows. The panes to the right of the spacer pane appear to get shifted out of the way off to the right. Is there a way to get the spacer pane (style set to SBPS_STRETCH) to truncate its text so that the right-most panes are still visible? Thanks Stefan |
|
stefanadelbert
Groupie Joined: 29 October 2008 Location: Australia Status: Offline Points: 31 |
Post Options
Thanks(0)
|
I'm trying some workaround code here to truncate the string being displayed in the stretched pane. In order to get this working, I need to know the width of the stretched pane. But if I call StatusBarPane.Width, I get very numbers back that are too small.
If StatusBarPane.Style is set = SBPS_STRETCH, can I rely on StatusBarPane.Width? Windows XP SP3 VB6 Codejock Suite 13 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1354 |
Post Options
Thanks(0)
|
Are they too small in Pixels? What I mean is, if your form is using twips, the StatusBarPane might be returning Pixels which would make it seem to small (not sure, but a lot of CJ controls seem to work in pixels exclusively instead of the parent scalemode). Does Width*Screen.TwipsPerPixelX yield the correct result?
|
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
stefanadelbert
Groupie Joined: 29 October 2008 Location: Australia Status: Offline Points: 31 |
Post Options
Thanks(0)
|
I am converting to twips using Screen.TwipsPerPixelX already, so that isn't the problem in this case.
Seems that the StatusBarPane.Width is the width required to display the contents of the Pane if StatusBarPane.Style=SBPS_STRETCH. I need to know the width available so that I can truncate the text as required so that the other panes are not moved around. Any ideas? |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1354 |
Post Options
Thanks(0)
|
Sorry for the delay, I had to make up a sample.
You're right that there doesn't seem to be a way to get the StatusPane visible width when the Style is set to SBPS_STRETCH. The Width property just seems to hold the width required to show the text. Unfortunately, the Handle property always seems to return 0 (I was hoping it might be an Hwnd), so we can't use any APIs on it either. I got close by looping through the panes and adding all of the widths not including the stretched pane width, then subtracting that from the window width, but the gripper throws that calculation off. You could do a really ugly hack by hard-coding the gripper width, but then might have problems with different skins. In any case, that approach would be a second last resort. Another even uglier option might be to use the HitTest method of the StatusBar object in a loop and then test when you first hit the pane, and then when you last hit the pane and subtract those values to get the width. This approach would be the last resort I think. The best option would be to ask CJ if they can expose the actual width for a stretched pane, or perhaps offer a GetRect method for the StatusBarPane object. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1354 |
Post Options
Thanks(0)
|
If you are desperate for a solution, this seems to work:
|
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
stefanadelbert
Groupie Joined: 29 October 2008 Location: Australia Status: Offline Points: 31 |
Post Options
Thanks(0)
|
Thanks for the help, jpbro. I really appreciate the effort. Both of those workarounds are unfortunately clunky, but would both do the trick. I might go for the 2nd option of calculating the width of the StatusBar and subtracting widths of non-stretched panels.
The available width of a stretched panel should be exposed, but even better would be to have an option to automatically truncate panel contents that overrun the available space (if they are text, of course). |
|
jpbro
Senior Member Joined: 12 January 2007 Status: Offline Points: 1354 |
Post Options
Thanks(0)
|
Glad to help, and I think that I just found a better solution. After creating your stretched pane, you can set the margins and padding for that pane:
The negative margin lets the panes to the right remain visible, and then the positive padding ensures that the stretch text gets chopped so there is no overlapping text. You can adjust the -100/100 pixels as required to fit your other panes. |
|
Product: Xtreme SuitePro (ActiveX) version 16.2.6
Platform: Windows XP - SP3 Language: Visual Basic 6.0 SP6 |
|
stefanadelbert
Groupie Joined: 29 October 2008 Location: Australia Status: Offline Points: 31 |
Post Options
Thanks(0)
|
I think I might just use that temporarily. Unfortunately the panes on the left and right are not exactly static. Their contents do change and they should adjust to fit their contents. So I might need to adjust the stretched pane margins dynamically, every time the StatusBar is resized.
Once again, thank you for your help. Stefan |
|
stefanadelbert
Groupie Joined: 29 October 2008 Location: Australia Status: Offline Points: 31 |
Post Options
Thanks(0)
|
The workaround I used for this was to put a custom control, VB.TextBox, in the statusbar by assigning StatusBarPane.Handle to the hWnd of the FlatEdit.
Thanks to jpbro for his effort on this one. Stef |
|
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 |