有人可以将这个VB代码转换为VC ++

时间:2012-11-02 06:33:44

标签: vb.net visual-c++

我发现这个代码通过面板移动表单,但是我希望这个代码用c ++编写,因为我在vb中为null我需要帮助在visual 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

1 个答案:

答案 0 :(得分:1)

在你的WndProc:

case WM_LBUTTONDOWN:
    ReleaseCapture ();
    SendMessage (hWnd, WM_NCLBUTTONBUTON, HTCAPTION, 0);
    break;