A selection of topics on IT and its application to finance.
Send me your comments, questions or suggestions by clicking here
Moving a window or userform that doesn't have a title bar
Ok, so you've learned how to remove the title bar from a window. The next things you'll probably want do are to move or kill said window. Below is how to move it.
Put the following code in the general declaration section
Private 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
Now in your form mousedown event for VB use:
Private sub form1_mousedown(ByVal Button As Integer,Byval Shift as integer,ByVal X as single,ByVal Y as Single)
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION= 2
For VBA we have to obtain the hwnd of our userform to supply as the first parameter to SendMessage. Do this with the code below.
hwnd = IIF(val(application.version) < 9,"ThunderXframe","ThunderDFrame"), Userform1.caption)