Print Page | Close Window

Move a form without a titlebar

Printed From: Mirage Source
Category: Tutorials
Forum Name: Approved Tutorials
Forum Discription: All tutorials shown to actually work with MSE are moved here.
URL: http://ms.shannaracorp.com/backup-forums/forum_posts.asp?TID=25
Printed Date: 20 December 2006 at 6:00pm
Software Version: Web Wiz Forums 8.01 - http://www.webwizforums.com


Topic: Move a form without a titlebar
Posted By: Sync
Subject: Move a form without a titlebar
Date Posted: 07 February 2006 at 5:07pm
Originally posted by Misunderstood

Just call this function and pass it the form you wish to move. Typically you would fire this code from the mousedown event on a picture box or something similar acting as the titlebar, or the form_mousedown sub.


Private Declare Function ReleaseCapture Lib "user32" () As Long
Private 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

Public Sub MoveForm(f As Form)
    ReleaseCapture
    SendMessage f.hwnd, WM_NCLBUTTONDOWN, 2, 0
End Sub


I take no credit for this but I have seen several people ask for this code so I figure I would post it.

I got it from http://abstractvb.com/code.asp?F=53&P=6&A=671 - http://abstractvb.com/code.asp?F=53&P=6&A=671




Replies:
Posted By: Sync
Date Posted: 07 February 2006 at 5:08pm
Added code/url tags, truncated title, Approved.




Print Page | Close Window

Bulletin Board Software by Web Wiz Forums version 8.01 - http://www.webwizforums.com
Copyright ©2001-2006 Web Wiz Guide - http://www.webwizguide.info