投稿日 | : 2006/09/28(Thu) 16:49 |
投稿者 | : シーモア |
Eメール | : |
URL | : |
タイトル | : タイトルドラッグ移動で画面をプライマリモニタから「はみだし禁止」にしたい |
『サイズの小さい画面をタイトルをドラッグして、移動したときに、
画面の右端が消える位置まで来たら移動できないようにしたい』
つまり、
『常にプライマリ画面の中に納まる位置を保持し、
画面全体が見えるようにしたい』
のですが、後述のようにタイマーで、位置を戻す処理では
いったりきたりで、ちらちらする状態になってしまいます
APIなりなんなり、ちらつかずスマートに「はみだし禁止」
にすることはできないでしょうか?
Private Sub Timer1_Timer()
Dim mRect As RECT
Dim lngRet As Long
Dim lngAzoomTop As Long
lngRet = GetWindowRect(Me.hwnd, mRect)
If mRect.Left < 0 Or mRect.Top < 0 Or mRect.Right > G_MonitorW Or mRect.Bottom > G_MonitorH Then
If mRect.Left < 0 Then
FrmAZoom.Left = 0
End If
If mRect.Top < 0 Then
FrmAZoom.Top = 0
End If
If mRect.Right > G_MonitorW Then
FrmAZoom.Left = (G_MonitorW * Screen.TwipsPerPixelX) - FrmAZoom.Width
End If
If mRect.Bottom > G_MonitorH Then
lngAzoomTop = mRect.Bottom - G_MonitorH
FrmAZoom.Top = FrmAZoom.Top - lngAzoomTop * Screen.TwipsPerPixelY
End If
End If
End Sub