From: Kevin Provance on

"David Kerber" <dkerber(a)WarrenRogersAssociates.invalid> wrote in message
news:MPG.268974cf47c3d10b98968f(a)news.eternal-september.org...
:
: I do that in most of my apps, only I do it in form_close, rather than
: form_resize.

Form_close? What version of VB you using?

Or did you mean Form_Unload?


--
Customer Hatred Knows No Bounds at MSFT
Free usenet access at http://www.eternal-september.org
ClassicVB Users Regroup! comp.lang.basic.visual.misc

Bawwk! Paulie want a dingleball, bawwk!

From: mp on

"Bob Butler" <noway(a)nospam.ever> wrote in message
news:TSOTn.40709$7d5.20913(a)newsfe17.iad...
>
> "mp" <nospam(a)thanks.com> wrote in message
> news:hvo5pt$5gq$1(a)news.eternal-september.org...
>>
>> "Larry Serflaten" <serflaten(a)gmail.com> wrote in message
>> news:hvnkj2$d1v$1(a)news.eternal-september.org...
>>>
>>> "mp" <nospam(a)Thanks.com> wrote
>>>> it doesn't appear to,
>>>> how else can i know when a form was moved by user clicking in titlebar
>>>> and
>>>> dragging to new position?
>>>
>>> Why do _you_ need to know?
>>> When do you _need_ to know?
>>>
>>> Think about those, with an open mind of course, and perhaps you'll
>>> see clear to another solution....
>>>
>>> LFS
>>>
>>>
>>
>> well, i was trying in Form_Terminate but that was calling Form_Load again
>> (on calls to Me.Left etc)
>> must be _Unload is the trick? will try
>
> form_unload is a good choice
>
> be careful that you don't save the size if the window is minimized or
> maximized; you can call GetWindowPlacement to get the normal window
> rectangle regardless of the current state.
>

thanks for the tip
mark


From: mp on

"Karl E. Peterson" <karl(a)exmvps.org> wrote in message
news:hvoecm$o3b$1(a)news.eternal-september.org...
> Bob Butler formulated the question :
>> "mp" <nospam(a)thanks.com> wrote in message
>> news:hvo5pt$5gq$1(a)news.eternal-september.org...
>>>
>>> "Larry Serflaten" <serflaten(a)gmail.com> wrote in message
>>> news:hvnkj2$d1v$1(a)news.eternal-september.org...
>>>>
>>>> "mp" <nospam(a)Thanks.com> wrote
>>>>> it doesn't appear to,
>>>>> how else can i know when a form was moved by user clicking in titlebar
>>>>> and
>>>>> dragging to new position?
>>>>
>>>> Why do _you_ need to know?
>>>> When do you _need_ to know?
>>>>
>>>> Think about those, with an open mind of course, and perhaps you'll
>>>> see clear to another solution....
>>>>
>>>> LFS
>>>>
>>>>
>>>
>>> well, i was trying in Form_Terminate but that was calling Form_Load
>>> again (on calls to Me.Left etc)
>>> must be _Unload is the trick? will try
>>
>> form_unload is a good choice
>>
>> be careful that you don't save the size if the window is minimized or
>> maximized; you can call GetWindowPlacement to get the normal window
>> rectangle regardless of the current state.
>
> Another thing that *really* irritates me is folks who don't check to see
> if the form is off the visible screen(s) when they restore a saved
> position! Dumb, dumb dumb, DUMB!
>
> --
> .NET: It's About Trust! http://vfred.mvps.org
> Customer Hatred Knows No Bounds at MSFT
> ClassicVB Users Regroup! comp.lang.basic.visual.misc
> Free usenet access at http://www.eternal-september.org
>
>

yes, someone mentioned that also, will have to research how to tell.
thanks
mark


From: Karl E. Peterson on
mp wrote :
>>> be careful that you don't save the size if the window is minimized or
>>> maximized; you can call GetWindowPlacement to get the normal window
>>> rectangle regardless of the current state.
>>
>> Another thing that *really* irritates me is folks who don't check to see if
>> the form is off the visible screen(s) when they restore a saved position!
>> Dumb, dumb dumb, DUMB!
>
> yes, someone mentioned that also, will have to research how to tell.
> thanks

Here ya go:

Karl Peterson Shows How to Make a More Considerate UI
http://visualstudiomagazine.com/articles/2009/08/25/its-the-little-things.aspx

and/or:

http://vb.mvps.org/samples/Monitors

:-)

--
..NET: It's About Trust! http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org


From: Karl E. Peterson on
Karl E. Peterson was thinking very hard :
> mp wrote :
>>>> be careful that you don't save the size if the window is minimized or
>>>> maximized; you can call GetWindowPlacement to get the normal window
>>>> rectangle regardless of the current state.
>>>
>>> Another thing that *really* irritates me is folks who don't check to see
>>> if the form is off the visible screen(s) when they restore a saved
>>> position! Dumb, dumb dumb, DUMB!
>>
>> yes, someone mentioned that also, will have to research how to tell.
>> thanks
>
> Here ya go:
>
> Karl Peterson Shows How to Make a More Considerate UI
> http://visualstudiomagazine.com/articles/2009/08/25/its-the-little-things.aspx
>
> and/or:
>
> http://vb.mvps.org/samples/Monitors
>
> :-)

In a nutshell, this routine will test whether a given window is fully
or partially onscreen, and optionally slide it onto the nearest
position that is if it isn't...

Public Function WindowOffscreen(ByVal hWnd As Long, Optional
OverlapOK As Boolean = True, Optional ForceOnscreen As Boolean = True)
As Boolean
Dim rW As RECT, rM As RECT, rU As RECT
Dim Overlapped As Boolean
' Collection needs to be initialized.
If (Monitors Is Nothing) Then MonitorsRefresh

' Test whether the specified window is actually within
' the visible display area.
rW = WindowRectAbsolute(hWnd)
rM = MonitorRect(0)

' Do a quick union to see if window is entirely contained on
desktop.
Call UnionRect(rU, rM, rW)
If EqualRect(rU, rM) Then Exit Function

' Next quick test is whether rectangle partially intersects
desktop.
If IntersectRect(rU, rM, rW) Then
If OverlapOK Then Exit Function
End If

' ' Make sure window isn't larger than screen.
' If OverlapOK = False Then
' If (rW.Right - rW.Left) > (rM.Right - rM.Left) Then
' rW.Right = rW.Left + (rM.Right - rM.Left)
' End If
' If (rW.Bottom - rW.Top) > (rM.Bottom - rM.Top) Then
' rW.Bottom = rW.Top + (rM.Bottom - rM.Top)
' End If
' End If

' Assume window is wholly within the visible region.
' Check each edge, and slide into screen as necessary.
' Prefer top/left by setting it last.
If rW.Right > rM.Right Then
Call OffsetRect(rW, (rM.Right - rW.Right), 0)
End If
If rW.Bottom > rM.Bottom Then
Call OffsetRect(rW, 0, rM.Bottom - rW.Bottom)
End If
If rW.Left < rM.Left Then
Call OffsetRect(rW, (rM.Left - rW.Left), 0)
'rW.Right = rM.Left + (rW.Right - rW.Left)
'rW.Left = rM.Left
End If
If rW.Top < rM.Top Then
Call OffsetRect(rW, 0, (rM.Top - rW.Top))
End If

' If rW has not changed, then it was entirely onscreen before.
If Not EqualRect(rW, WindowRectAbsolute(hWnd)) Then
WindowOffscreen = True
If ForceOnscreen Then
Call WindowMove(hWnd, rW)
End If
End If
End Function

Public Function WindowRectAbsolute(ByVal hWnd As Long) As RECT
' Supply absolute screen coordinates of window.
Call GetWindowRect(hWnd, WindowRectAbsolute)
End Function

But note this also relies on a collection of CMonitor objects, based on
the class that's downloadable at the link above.

--
..NET: It's About Trust! http://vfred.mvps.org
Customer Hatred Knows No Bounds at MSFT
ClassicVB Users Regroup! comp.lang.basic.visual.misc
Free usenet access at http://www.eternal-september.org


First  |  Prev  |  Next  |  Last
Pages: 1 2 3 4 5
Prev: Happy Birthday
Next: Print to a specific printer