开发者

How do I measure the dimensions of a form?

i have just designed a business information dashboard for the customer. The initial design was for a 1280x1024 screen res but it now appears that the customer has a 1024 x 768 res. This BI form is a child window of a MDI interface and as such there is a header and statusbar which means if the application is fullsized then it is occupying 1024/768 - the windows taskbar and my form has this available size minus the size of the header and statusbar of the MDI applic开发者_如何学Goation. I can deal with this but i want to make the application customised specifically for the size of screen most frequently used which it happens is his.

Does anyone know of any places within the registry or any tools etc which can tell me the size of the window/form as it is being viewed?

Cheers tim


I've not done any MDI stuff, but from a quick playaround I believe this might help. I put the below into a child form.

label1.Text = this.Parent.ClientRectangle.Width.ToString() + "x" + this.Parent.ClientRectangle.Height.ToString();

It seemed to return the inner size of the MDI parent. As I added more toolstrips and a status strip the height reduced.

Hope this helps.

EDIT: Strange, this doesn't seem to bring back the parent form name (hmm a puzzle).:

label1.Text = this.Parent.Name;

EDIT 2: but this does (note the 2nd Parent - now I'm confused):

label1.Text = this.Parent.Parent.Name;

EDIT 3: Ok, after a couple more tests...

1. this.Parent.ClientRectangle  //this seems to be the size in the MDI form - NOT including toolbars/statusstrips/menustrips etc.

2. this.Parent.Parent.ClientRectangle  //Having TWO parents seems to be the main MDI size - no matter how many strips added in this seems to return the size - not including the window titlebar.

Apologies for the edits.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜