473,395 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Size of unused MDIClient window

Is it possible to find the size of the MDIClient area, excluding the space
already used by docked controls?
I have thought I could perhaps create a new control, set it's Dock property
to Fill and see how big that is, but there must be a better way. I would
have to do this in the Resize event
TIA
Phil.
Aug 1 '07 #1
8 1651
"Phil" <N/A>'s wild thoughts were released on Wed, 1 Aug
2007 14:24:58 +0100 bearing the following fruit:
>Is it possible to find the size of the MDIClient area, excluding the space
already used by docked controls?
I have thought I could perhaps create a new control, set it's Dock property
to Fill and see how big that is, but there must be a better way. I would
have to do this in the Resize event
Can I ask why you need to know? Is it because you fear there
won't be enough space left for a form?
--
Jan Hyde

https://mvp.support.microsoft.com/profile/Jan.Hyde
Aug 1 '07 #2

"Jan Hyde (VB MVP)" <St***********@REMOVE.ME.uboot.comwrote in message
news:v1********************************@4ax.com...
"Phil" <N/A>'s wild thoughts were released on Wed, 1 Aug
2007 14:24:58 +0100 bearing the following fruit:
>>Is it possible to find the size of the MDIClient area, excluding the space
already used by docked controls?
I have thought I could perhaps create a new control, set it's Dock
property
to Fill and see how big that is, but there must be a better way. I would
have to do this in the Resize event

Can I ask why you need to know? Is it because you fear there
won't be enough space left for a form?
The reason I'm asking at the moment is because I want to draw on the
backgound of the MDI form, so I need to be able to identify which parts
aren't covered by other (docked) controls, so that my drawing is not
obscured.
Aug 1 '07 #3
Hi Phil,

Based on my understanding, you have an MDI parent and a control, e.g. a
ListView, which is docked on the MDI parent. You'd like to get the size of
the MdiClient that is not covered by the ListView. If I'm off base, please
feel free to let me know.

In fact, the MdiClient is a control that is contained in an MDI parent. We
can get it by looping the child control collection of the MDI parent. Once
we get the MdiClient control, we know its size. The following is a sample.

Dim mc As MdiClient = Nothing
For Each ctrl As Control In Me.Controls
If (ctrl.GetType().Equals(GetType(MdiClient))) Then
mc = CType(ctrl, MdiClient)
exit For
End If
Next

When we add a control in an MDI parent and dock it to a side, the MdiClient
control won't be covered by the added control, instead, it will take the
rest space of the MDI parent. So we needn't calculate the size of the
MdiClient that is not covered by other control at all.

If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

Aug 2 '07 #4
Based on my understanding, you have an MDI parent and a control, e.g. a
ListView, which is docked on the MDI parent. You'd like to get the size of
the MdiClient that is not covered by the ListView. If I'm off base, please
feel free to let me know.
That's basically it, yes. I actually have a menustrip, a toolstrip and a
couple of panels with other controls on them. These are all docked in the
mdi parent window, and I plan to allow the user to move some of these
around.
>
In fact, the MdiClient is a control that is contained in an MDI parent. We
can get it by looping the child control collection of the MDI parent. Once
we get the MdiClient control, we know its size. The following is a sample.

Dim mc As MdiClient = Nothing
For Each ctrl As Control In Me.Controls
If (ctrl.GetType().Equals(GetType(MdiClient))) Then
mc = CType(ctrl, MdiClient)
exit For
End If
Next
Thanks. This looks like what I need. I had discovered this myself, but it
didn't seem to be giving the right results, but I'll try this again. I had
actually found another way of getting a reference to the MDIClient. like
this:

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
With New Form2
.mdiparent = Me
mc = .Parent
.Dispose()
End With
End Sub

Not sure which way is more efficient?
>
When we add a control in an MDI parent and dock it to a side, the
MdiClient
control won't be covered by the added control, instead, it will take the
rest space of the MDI parent. So we needn't calculate the size of the
MdiClient that is not covered by other control at all.
OK. That seems to work. The following code draws a line from one corner to
the other:

Private Sub mc_Paint(ByVal sender As Object, ByVal e As
System.Windows.Forms.PaintEventArgs) Handles mc.Paint
With e.Graphics
.DrawLine(Pens.White, 0, 0, mc.Width, mc.Height)
End With
End Sub

Private Sub Form1_Resize(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Resize
Refresh()
End Sub
If you have any question, please feel free to let me know.
Thanks. I changed the code above to call DrawImage instead of DrawLine. I
want the image to be on the right hand side. So I used the following, but
the image is placed too far to the right, and get's clipped:

.DrawImage(Image, mc.Width - Image.Width, 0)

Not sure what I'm doing wrong here. Are the units of the image width
different from that of the MDIClient window?

Cheers,
Phil.
Aug 2 '07 #5
>If you have any question, please feel free to let me know.

Thanks. I changed the code above to call DrawImage instead of DrawLine. I
want the image to be on the right hand side. So I used the following, but
the image is placed too far to the right, and get's clipped:

.DrawImage(Image, mc.Width - Image.Width, 0)

Not sure what I'm doing wrong here. Are the units of the image width
different from that of the MDIClient window?
I've had a bit more of a play, and it seems that DrawImage is actually
drawing the image bigger than it should be, so it was in the right place all
along. If I explicitly set the width and height it works fine:

.DrawImage(Image, mc.Width - Image.Width, 0, Image.Width, Image.Height)

The help says "Draws the specified image, using its original physical size".
This is obviously not the physical size in terms of pixels. Presumably it is
taking into account the HorizontalResolution and VerticalResolution property
values?
Aug 2 '07 #6
Hi Phil,

Thank you for your reply.

I download the JPG file you provided and perform a test in my project. I do
see the JPG picture is clipped on the right side and the clipped part is
not a few pixels.

I look up Graphics.DrawImage Method (Image, Int32, Int32) in MSDN and find
the following remark:

"(This method)Draws the specified image, using its original physical size,
at the location specified by a coordinate pair. "

"An Image stores a value for pixel width and a value for horizontal
resolution (dots per inch). The physical width, measured in inches, of an
image is the pixel width divided by the horizontal resolution. Similar
remarks apply to pixel height and physical height."

Since the term of the physical width and height is different from that of
Width and Height property of the Image, it explains why the JPG picture is
clipped in the MdiClient within our projects.

It's correct to use the overload method Graphics.DrawImage Method (Image,
Int32, Int32, Int32, Int32) to specify the width and height in pixel to
address this problem.

Hope this helps.
If you have any question, please feel free to let me know.
Sincerely,
Linda Liu
Microsoft Online Community Support

Aug 7 '07 #7
Hi Phil,

How about the problem now?

If you have any question, please feel free to let me know.

Thank you for choosing Microsoft!

Sincerely,
Linda Liu
Microsoft Online Community Support

Aug 10 '07 #8
>
How about the problem now?
I think this one's all sorted now.
Thanks a lot for your help.
Aug 10 '07 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bart Torbert | last post by:
Hello, I am starting to examine using SQLServer instead of Oracle. I went through the SQLServer import utility to copy tables from Oracle into SQLServer. I then checked the size of the...
1
by: BillCo | last post by:
Windows API not my strong point... can anyone give me the idiots guide to getting the MDIClient window height (bottom of menu bar to top of status bar) ? Basically I need a form to open up to the...
1
by: John F | last post by:
Is there a way to place controls on the surface of MdiClient and have it always stay in the background when new child forms are loaded into the MDI? When I place controls on the surface of an MDI...
5
by: MuZZy | last post by:
Hi, I'm developing an MDI application and i am having a problem: how do i know the state of MdiClient; what i mean is: when i maximize a MDI child, then close it and then open a new MDI child,...
1
by: pigeonrandle | last post by:
Hello. I hope you are all well. I've been trying to get the text from an MDICLIENT window (recognised by SPY++ as 'WindowsForms10.MDICLIENT.app3'). When i try to get the text using...
2
by: Brian Tkatch | last post by:
Not sure if this is the way it's supposed to be, but after a Layout event on an MDI form, the form's new width is set, but the MDIClient's width is not. As an example, start a new Windows...
0
by: gilbert | last post by:
Hello. I am using .Net 2.0, C#. and am trying to put a MdiClient control into a SplitPanel of a SplitContainer. First, I put a SplitContainer called splitContainer1 into the form. In the...
6
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
Is there any way to change or turn off the border of an Windows.Forms.MdiClient control? In my opinion the 3D bevel that the control uses is outdated and looks poor in my app. The best would be a...
4
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
Is there any way to enable double buffering in an MdiClient control? I have a case where I need to hide all of the MdiClient forms and interactively draw a custom background in an MdiClient...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.