Here's a bit of simple VB6 code that puts a shangle (resizing handle) on a form. The actual code I use has been re-written as a user control, but this code is the minimum simple representation of the concept.
What's the best way to do the same thing in .Net? Should I be using API calls at all, or can I do the same thing directly with net framework?
I do realise that I can still use the VB6 user control under .net, but that would defeat the purpose of the exercise, which is to learn .net.
This is the heart of the (VB6) code:
VB Code:
Option Explicit Declare Function ReleaseCapture Lib "user32" () As Long Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long Const WM_NCLBUTTONDOWN = &HA1 Const HTBOTTOMRIGHT = 17 Sub DriveShangle(f As Form) 'PURPOSE: Negate VB's call to SetCapture, and tell Windows ' that the user is trying to resize the form. 'Cancel the capture on the label ReleaseCapture 'Set the capture on the form's bottom-right grab-handle instead SendMessage f.hwnd, WM_NCLBUTTONDOWN, HTBOTTOMRIGHT, ByVal 0& End Sub
A complete running example (VB6) is attached.




Reply With Quote