Print Page | Close Window

[SOLVED]Resize event and GetClientRec fails

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Docking Pane
Forum Description: Topics Related to Codejock Docking Pane
URL: http://forum.codejock.com/forum_posts.asp?TID=15052
Printed Date: 28 September 2024 at 11:12am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: [SOLVED]Resize event and GetClientRec fails
Posted By: iamgtd
Subject: [SOLVED]Resize event and GetClientRec fails
Date Posted: 27 August 2009 at 5:10am

In a form I'm using a ribbonbar and a dockingpane. In the client area should be placed a usercontrol.

The dockingpane is associated with the commandar with the following code:
cjDockingPaneManager.SetCommandBars(this.cjCommandBars.GetDispatch());

The resizing of the usercontrol in the client area sholud be done with:

        private void cjDockingPaneManager_ResizeEvent(object sender, EventArgs e)
        {
            int left, top, right, bottom;
            cjDockingPaneManager.GetClientRect(out left, out top, out right, out bottom);
            userControl.SetBounds(left, top , right - left, bottom - top);
        }

But the resize event occurs only once at the program start and the second thing is that the values from the GetClientRect method delivers wrong values (left and top = 0, right and bottom are the values from this.ClientSize).

I have tried to resize the client usercontrol in an other resize event (form, commandbar). But the GetClientRect method delivers always wrong values. I have also tried to use a richtextbox instead of the usercontrol, but the result is the same.

It seems that the GetClientRect method only work correct if no commandbar is present.

Is there a way to solve this behavior?

-------------------------------
OS: Win XP prof. SP3
Codejock Version 13.1.0
Microsoft Visual Studio 2008 Version 9.0.21022.8 RTM
Microsoft .NET Framework Version 3.5 SP1
Installed Edition: Enterprise
Microsoft Visual C# 2008
-------------------------------



-------------
---------

OS: Win 10 64 bit

Codejock Version 22.1 ActiveX

MS Visual Studio 2022 - C#

---------



Replies:
Posted By: Oleg
Date Posted: 27 August 2009 at 7:23am
Hi,
 
if you have both COmmandBars and DockingPane you need handle only CommandBars_ResizeEvent.


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: iamgtd
Date Posted: 27 August 2009 at 7:50am
many, thanks. problem solved.
 
 
        private void cjCommandBars_ResizeEvent(object sender, EventArgs e)
        {
            int left, top, right, bottom;           
            cjCommandBars.GetClientRect(out left, out top, out right, out bottom);
           
            userControl.SetBounds(left, top, right - left, bottom - top);
        }
 
It's interesting that the resize event of the commandbar reacts to the resizing of panes in the dockingpane, because in this case the size of the commandbar isn't changed.


Posted By: tobi
Date Posted: 21 September 2009 at 12:23pm
I have similar question: In my VB6 app I have a textbox in a docking pane and want to "manually" resize it because I want a little more borders !
So I use this code in the CommandBars_Resize event handler:

Dim Left As Long, Top As Long, Right As Long, Bottom As Long

CommandBars.GetClientRect Left, Top, Right, Bottom
Text1.Move Left, Top, Right - Left, Bottom - Top

DockingPane.GetClientRect Left, Top, Right, Bottom
Text2.Move Left + 5, Top + 5, Right - Left, Bottom - Top

The first Textbox which should cover mainform works right, but the Text2 control, which should fill the docking pane
does not - it is sized to a much smaller size than the docking pane area !?!?!?!

Btw. I created the docking pane by directly attaching Text2.hwnd which is placed on the mainform ! Is this best practice
or should I use a PictureBox where the textbox is placed in ?




Posted By: pate
Date Posted: 05 November 2009 at 4:10pm
A lot of times when I see a control get resized much smaller than I would think it has to do with the scaling.  You may expect twips and are using pixels instead and vice-versa.  Not sure that is the problem, but it has happened to me a number of times in the past.  Getting them on the same scaling usually solved the issue.



Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net