-2

パネルを介してフォームを移動するこのコードを見つけましたが、このコードを C++ で使用したいのですが、vb で null であるため、ビジュアル C++ で次のコードを変換するのに助けが必要です。

'Constants   
Const HTCAPTION = &H2
Const WM_NCLBUTTONDOWN = &HA1

'API functions   
<DllImport("user32.dll", CharSet:=CharSet.Auto, SetLastError:=True, ExactSpelling:=True)> _
Public Shared Function ReleaseCapture() As Boolean
End Function
Declare Auto Function SendMessage Lib "user32.dll" (ByVal hWnd As IntPtr, ByVal msg As Integer, ByVal wParam As IntPtr, ByVal lParam As IntPtr) As IntPtr


'You could Dock a Panel to the top of your form and use:   


Private Sub Panel1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Panel1.MouseDown

    'This code can be used in the MouseDown event of any control(s) you want to be able to move your form with   
    ReleaseCapture()
    SendMessage(Me.Handle, WM_NCLBUTTONDOWN, HTCAPTION, 0&)

End Sub
4

1 に答える 1

1

あなたのWndProcで:

case WM_LBUTTONDOWN:
    ReleaseCapture ();
    SendMessage (hWnd, WM_NCLBUTTONBUTON, HTCAPTION, 0);
    break;
于 2012-11-02T09:29:57.257 に答える