忍者ブログ
×

[PR]上記の広告は3ヶ月以上新規記事投稿のないブログに表示されています。新しい記事を書く事で広告が消えます。

●Modal
[OK] ボタンまたは [キャンセル] ボタンによってそのウィンドウを閉じるまで、ユーザーはほかのウィンドウに切り替えることができない。
●Modeless
ほかのウィンドウに切り替えるときに、[OK] または [キャンセル] ボタンによって閉じる必要がない。

●フォームからタイトルバーを消す場合
MaxButton:最大化ボタン…False
MiniButton:最小化ボタン…False
Caption…なし

●タイトルバー非表示でフォームをドラッグする方法
1.WindowsAPIを使う
参考:www.microsoft.com/japan/msdn/vbasic/migration/tips/Movement/


Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" ( _
ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Private Declare Sub ReleaseCapture Lib "user32.dll" ()

Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button And vbLeftButton Then
ReleaseCapture
Call SendMessage(Form1.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If
End Sub

※Form1は動かすフォームの名前

2.APIを使わない方法
参考:homepage1.nifty.com/kurichan/html/tips42.htm


Public intTmpX As Integer
Public intTmpY As Integer

Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'マウスの左ボタンが押下されたフォーム上のX座標、Y座標を変数に保存
    If Button = vbLeftButton Then
        intTmpX = X
        intTmpY = Y
    End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    'マウスの移動量をフォームの Top プロパティ、Left プロパティ に加算
    If Button = vbLeftButton Then
        Form1.Left = Form1.Left + X - intTmpX
        Form1.Top = Form1.Top + Y - intTmpY
     End If
End Sub

●Formを常に最前面にする
参考:
jeanne.wankuma.com/tips/form/topmost.html
homepage1.nifty.com/rucio/main/Samples/Sample063TopMost.htm

' SetWindowPos 関数
Private Declare Function SetWindowPos Lib "USER32.DLL" ( _
    ByVal hWnd            As Long, _
    ByVal hWndInsertAfter As Long, _
    ByVal x               As Long, _
    ByVal y               As Long, _
    ByVal cx              As Long, _
    ByVal cy              As Long, _
    ByVal wFlags          As Long  _
) As Long

' 定数の定義
Private Const HWND_TOPMOST   As Long = -1     ' 最全面に表示する
Private Const HWND_NOTOPMOST As Long = -2     ' 最前面に表示するのをやめる
Private Const SWP_NOSIZE     As Long = &H1    ' サイズを変更しない
Private Const SWP_NOMOVE     As Long = &H2    ' 位置を変更しない

' このフォームを常に最前面に表示する (サイズと位置は変更しない)
Call SetWindowPos(Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)

' 解除したい場合
Call SetWindowPos(Me.hWnd, HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE)
PR
COMMENT
COMMENT FORM
TITLE

NAME

MAIL

URL

PASS
Vodafone絵文字 i-mode絵文字 Ezweb絵文字
COMMENT
TRACKBACK
TRACKBACK ADDRESS
 
カレンダー
05 2025/06 07
S M T W T F S
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30
OTHERS
Powered by 忍者ブログ
Templated by TABLE ENOCH