Can some one convert this VB code to VC++



I found this code to move form through panels, but i want this code in c++, as i am null in vb i need help to convert following code in visual c++.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
'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
Both ReleaseCapture() and SendMessage() are win32 APIs and can be used directly from C/C++ code.
No i mean to directly implement it on visual C++.

But i know nothing about Basic, so please write it in Visual C++.
You're going to need to define your dllimport like so (i did it in a class, but whatever) modify this to fit your dllimport (from msdn)
1
2
3
4
5
6
7
8
9
10
[DllImport("kernel32.dll", SetLastError=true)]
 static Int32 CreateFile(
	 String^ lpFileName
	 ,Int32 dwDesiredAccess
	 ,Int32 dwShareMode
	 ,OptionalAttribute(IntPtr lpSecurityAttributes)
	 ,Int32 dwCreationDisposition
	 ,Int32 dwFlagsAndAttributes
	 ,OptionalAttribute(IntPtr hTemplateFile)
	 );
then call your groovy new dllimported function from your mousedown event handler that you need to create. clear as mud? and someone will have to help me with the constants I believe your &h1 is 0x01 and &HA1 is 0xA1
Last edited on
Please be specific about what you need: Do you want this in C++ or C++/CLI? Because that could make a difference.

I don't know C++/CLI, but I THINK you don't need to P/Invoke Windows functions. You can use them directly just like in regular unmanaged C++ simply by #including the appropriate Windows header.
i need them in C++/CLI ,and thanks for helping through, i nearly completed my quest.
When i'll complete, i'll report here.
Topic archived. No new replies allowed.