Click here to Skip to main content
15,884,353 members
Home / Discussions / Windows Forms
   

Windows Forms

 
GeneralRe: WaitCursor, again Pin
BillWoodruff9-Sep-11 14:55
professionalBillWoodruff9-Sep-11 14:55 
GeneralRe: WaitCursor, again Pin
lukeer11-Sep-11 23:58
lukeer11-Sep-11 23:58 
GeneralRe: WaitCursor, again Pin
BillWoodruff12-Sep-11 2:04
professionalBillWoodruff12-Sep-11 2:04 
AnswerRe: WaitCursor, again Pin
MicroVirus12-Sep-11 2:51
MicroVirus12-Sep-11 2:51 
AnswerRe: WaitCursor, again Pin
MikeTheFid12-Jan-12 9:12
MikeTheFid12-Jan-12 9:12 
GeneralRe: WaitCursor, again Pin
lukeer16-Jan-12 12:15
lukeer16-Jan-12 12:15 
GeneralRe: WaitCursor, again Pin
MikeTheFid18-Jan-12 9:16
MikeTheFid18-Jan-12 9:16 
Questionadjusting for differences in TitleBar and window border size in Win 7 with some Windows Effects turned on ? Pin
BillWoodruff4-Sep-11 15:31
professionalBillWoodruff4-Sep-11 15:31 
The question: given the variety of visual effects in Vista and Win7 possibly applied to Windows Forms in .NET, depending on system settings, themes, etc., can you algorithmically determine the precise boundaries of the display area of a Form where 'display area' is defined as exclusive of window borders, titlebar height, side-effects of visual settings like 'shadows' on Forms, etc.

And, oh yes, I don't wanna get near importing and using any API stuff ! Smile | :)

Context: WinForm application, Visual Studio 2010 Pro, Win 7 Pro with all updates, 4 gigs of ram, older duo-core Intel CPU. GeForce 7100GS video card. Screen resolution: 1280x768

A concrete example:

only W7 visual effects enabled:
1. desktop composition
2. use visual styles on buttons and windows

In this software/hardware context: creating a "main" WinForm with a size set, in the design-time form editor, to, for example, 816,638, gets you this in the Designer.cs file:
this.ClientSize = new System.Drawing.Size(800, 600);
Now, I add a second Form at run-time to my WinForm app, and I set its owner to be the "main form."

So: I write a re-size event-handler for this added, second, Form, so that I essentially keep it in the client display rectangle of the main Form: here's the way I (now) calculate the revised owner's client rectangle for "out of bounds detection:"
// defined in Form2
    private Rectangle ownerClientRectangle;
    private Rectangle currentClientRectangle;
    private Rectangle intersectRectangle;

    // in the ReSize event for Form2
        ownerClientRectangle = RectangleToScreen(RectangleToClient(this.Owner.Bounds));
        ownerClientRectangle.Inflate(-14, -24);
        ownerClientRectangle.Offset(0, 12);

        currentClientRectangle = this.Bounds;
        intersectRectangle = currentClientRectangle;

        intersectRectangle.Intersect(ownerClientRectangle);
At this point I can be sure ... in this context only ... that if :
intersectRectangle != currentClientRectangle

Then the second Form is outside the boundaries of its owner ("main") Form, and I can 'do the right thing' to re-position it, which is simple.

The problem here is those magic numbers I am using for shrinking (negatively inflating), and off-setting the owner form's Bounds.

Of course I want to derive those inflation factors and offsets by calculation, not 'fiddlin around' Smile | :)

If those W7 graphic effects are turned off: the main Form that in the Designer.cs file is still written out as size 800,600: now appears, in the design-time property editor, with a size of : 808, 627 ... and, of course, the code for keeping the second Form in the boundaries of the first Form no longer works properly.

Appreciate any thoughts or advice !

thanks, Bill
"Is it a fact - or have I dreamt it - that, by means of electricity, the world of matter has become a great nerve, vibrating thousands of miles in a breathless point of time? Rather, the round globe is a vast head, a brain, instinct with intelligence!" - Nathanial Hawthorne, House of the Seven Gables
modified on Sunday, September 4, 2011 10:08 PM

AnswerRe: adjusting for differences in TitleBar and window border size in Win 7 with some Windows Effects turned on ? Pin
Mehdi Gholam5-Sep-11 19:58
Mehdi Gholam5-Sep-11 19:58 
GeneralRe: adjusting for differences in TitleBar and window border size in Win 7 with some Windows Effects turned on ? Pin
BillWoodruff7-Sep-11 5:02
professionalBillWoodruff7-Sep-11 5:02 
GeneralRe: adjusting for differences in TitleBar and window border size in Win 7 with some Windows Effects turned on ? Pin
Mehdi Gholam7-Sep-11 5:09
Mehdi Gholam7-Sep-11 5:09 
AnswerRe: adjusting for differences in TitleBar and window border size in Win 7 with some Windows Effects turned on ? Pin
Mehdi Gholam11-Sep-11 20:49
Mehdi Gholam11-Sep-11 20:49 
GeneralRe: adjusting for differences in TitleBar and window border size in Win 7 with some Windows Effects turned on ? Pin
BillWoodruff12-Sep-11 1:58
professionalBillWoodruff12-Sep-11 1:58 
QuestionGet rid of WaitCursor Pin
lukeer1-Sep-11 21:22
lukeer1-Sep-11 21:22 
AnswerRe: Get rid of WaitCursor Pin
BillWoodruff2-Sep-11 2:37
professionalBillWoodruff2-Sep-11 2:37 
AnswerRe: Get rid of WaitCursor PinPopular
Luc Pattyn2-Sep-11 3:18
sitebuilderLuc Pattyn2-Sep-11 3:18 
GeneralRe: Get rid of WaitCursor Pin
Dave Kreskowiak2-Sep-11 4:16
mveDave Kreskowiak2-Sep-11 4:16 
AnswerRe: Get rid of WaitCursor Pin
Luc Pattyn2-Sep-11 4:28
sitebuilderLuc Pattyn2-Sep-11 4:28 
GeneralRe: Get rid of WaitCursor Pin
BillWoodruff2-Sep-11 5:18
professionalBillWoodruff2-Sep-11 5:18 
AnswerRe: Get rid of WaitCursor Pin
Luc Pattyn2-Sep-11 5:39
sitebuilderLuc Pattyn2-Sep-11 5:39 
GeneralRe: Get rid of WaitCursor Pin
BillWoodruff2-Sep-11 19:08
professionalBillWoodruff2-Sep-11 19:08 
GeneralRe: Get rid of WaitCursor Pin
Luc Pattyn3-Sep-11 2:11
sitebuilderLuc Pattyn3-Sep-11 2:11 
GeneralRe: Get rid of WaitCursor Pin
GParkings3-Sep-11 12:20
GParkings3-Sep-11 12:20 
GeneralRe: Get rid of WaitCursor Pin
Eddy Vluggen3-Sep-11 13:15
professionalEddy Vluggen3-Sep-11 13:15 
GeneralRe: Get rid of WaitCursor Pin
Luc Pattyn3-Sep-11 13:36
sitebuilderLuc Pattyn3-Sep-11 13:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.