Click here to Skip to main content
15,913,055 members
Home / Discussions / C#
   

C#

 
GeneralRe: Launch application after installtion of MSI Pin
Blumen17-Feb-08 18:31
Blumen17-Feb-08 18:31 
GeneralRe: Launch application after installtion of MSI Pin
Ravenet17-Feb-08 19:45
Ravenet17-Feb-08 19:45 
GeneralShowDialog() issue Pin
Harvey Saayman15-Feb-08 2:04
Harvey Saayman15-Feb-08 2:04 
GeneralRe: ShowDialog() issue Pin
darkelv15-Feb-08 2:07
darkelv15-Feb-08 2:07 
GeneralRe: ShowDialog() issue Pin
Harvey Saayman15-Feb-08 2:12
Harvey Saayman15-Feb-08 2:12 
GeneralRe: ShowDialog() issue Pin
darkelv15-Feb-08 2:29
darkelv15-Feb-08 2:29 
GeneralRe: ShowDialog() issue Pin
Harvey Saayman15-Feb-08 2:32
Harvey Saayman15-Feb-08 2:32 
GeneralRe: ShowDialog() issue [modified] Pin
DaveyM6915-Feb-08 2:43
professionalDaveyM6915-Feb-08 2:43 
The best I can think of is to not have it as a mdiChild but a normal form - use showDialog but pass the MDI Container's child rectangle property to the forms constructor. You can then use the LocationChanged event to disallow movement of the dialog outside of that rectangle.

Passing the ClientRectangle doesn't work, it needs to be
RectangleToClient(ClientRectangle)
or
MdiParent.RectangleToClient(MdiParent.ClientRectangle)
if called from a child.

The X and Y (Top and Left) properties will give negative values so you'll need to subtract them from 0 to get the positive values you need.

This code works in the location changed (I'm sure it could be tidied up/improved but it does the job) where LimitRect is the rectangle passed above.
if (Top < (0 - LimitRect.Top)) // Too high
{
    Top = 0 - LimitRect.Top;
}
if (Left < (0 - LimitRect.Left)) // Too left
{
    Left = 0 - LimitRect.Left;
}
if (Right > LimitRect.Right) // Too right
{
    Left = (LimitRect.Width - LimitRect.Left) - Width;
}
if (Bottom > LimitRect.Bottom) // Too low
{
    Top = (LimitRect.Height - LimitRect.Top) - Height;
}


Dave

GeneralRe: ShowDialog() issue Pin
Harvey Saayman15-Feb-08 3:24
Harvey Saayman15-Feb-08 3:24 
GeneralRe: ShowDialog() issue Pin
Matt12315-Feb-08 11:58
Matt12315-Feb-08 11:58 
GeneralRe: ShowDialog() issue Pin
DaveyM6919-Feb-08 11:43
professionalDaveyM6919-Feb-08 11:43 
GeneralRe: ShowDialog() issue Pin
Harvey Saayman19-Feb-08 21:51
Harvey Saayman19-Feb-08 21:51 
GeneralRe: ShowDialog() issue Solved Pin
DaveyM6919-Feb-08 23:11
professionalDaveyM6919-Feb-08 23:11 
GeneralRe: ShowDialog() issue Pin
darkelv15-Feb-08 2:37
darkelv15-Feb-08 2:37 
GeneralRe: ShowDialog() issue Pin
Harvey Saayman15-Feb-08 3:22
Harvey Saayman15-Feb-08 3:22 
GeneralProblem to Dial a number from COM port in C#.Net Pin
lgauri15-Feb-08 1:49
lgauri15-Feb-08 1:49 
GeneralRe: Problem to Dial a number from COM port in C#.Net Pin
DaveyM6915-Feb-08 2:14
professionalDaveyM6915-Feb-08 2:14 
GeneralRe: Problem to Dial a number from COM port in C#.Net Pin
Manoj Kumar Rai15-Feb-08 3:14
professionalManoj Kumar Rai15-Feb-08 3:14 
Generalreduce precision Pin
Xmen Real 15-Feb-08 1:21
professional Xmen Real 15-Feb-08 1:21 
GeneralRe: reduce precision Pin
phannon8615-Feb-08 1:30
professionalphannon8615-Feb-08 1:30 
GeneralRe: reduce precision Pin
Xmen Real 15-Feb-08 1:34
professional Xmen Real 15-Feb-08 1:34 
GeneralRe: reduce precision Pin
DaveyM6915-Feb-08 1:41
professionalDaveyM6915-Feb-08 1:41 
GeneralRe: reduce precision Pin
Xmen Real 15-Feb-08 1:48
professional Xmen Real 15-Feb-08 1:48 
GeneralRe: reduce precision Pin
Guffa15-Feb-08 10:33
Guffa15-Feb-08 10:33 
GeneralRe: reduce precision Pin
DaveyM6915-Feb-08 10:50
professionalDaveyM6915-Feb-08 10:50 

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.