In VB, you can create a window without a system title bar by setting the properties of the form. However, because of the loss of the system title bar, how to use the mouse to drag the window becomes a thorny issue. In fact, with the help of API functions ReleaseCapture and SendMessage, this problem can be solved.
First, add the following declaration statement to the module file:
Declare Sub ReleaseCapture Lib"User"()
Declare Function SendMessage Lib"User"(ByVal hWnd _
As Integer,ByVal wMsg As Integer,ByVal wParam As Integer,_lParam As Any)As Long
Public Const WM_SYSCOMMAND=&H112
Public Const SC_MOVE=&HF010
Public Const HTCAPTION=2
然后,在Form的MouseDown事件中加入下列代码:
ReleaseCapture
Ret&=SendMessage(Me.hWnd,WM_SYSCOMMAND,_SC_MOVE+HTCAPTION,0)
……
When the program is running, you can drag the window as soon as the cursor falls in the form area while holding down the left mouse button. In the design of programs that require a lively interface, developers often want a unique title bar in their own style to meet the requirements of the entire interface. By this method, you can make homemade title bar to achieve the point of genuine. However, a control that is used as a homemade title bar must have a MouseDown event to display the above code.