PDA

Click to See Complete Forum and Search --> : Show Window


fearless_marko
Oct 26th, 1999, 04:53 AM
How do i make a windows show its contents while being dragged, without setting the windows property "show windows contents while dragging" to true. i notice programs like winamp are able to do this...is it possible in vb to do for my program

many thanks

TheLeeMan
Oct 27th, 1999, 04:10 AM
There is an API method to do this - someone asked this question here before. Not sure what the answer was - search through the messages of about 1.5 weeks ago to find it.


------------------
TheLeeMan

atjs
Oct 27th, 1999, 08:05 AM
The reason why the window contents are shown when the form is being dragged, is that the window dragging is not handled by Windows. You could try searching VB-World for "How to move a form without a title bar". This method moves the window instead of dragging it, and Windows does not hide the contents.

Aaron Young
Oct 28th, 1999, 04:03 AM
Try This:

In a Module..

Private Type POINTAPI
x As Long
y As Long
End Type

Private Declare Function GetCursorPos Lib "user32" (lpPoint As POINTAPI) As Long

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Const GWL_WNDPROC = (-4)
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const WM_MOVING = &H216

Public lPrevWnd As Long

Public Function SubClassedWindow(ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Static tStart As POINTAPI
Dim tPos As POINTAPI
If Msg = WM_NCLBUTTONDOWN Then
Call GetCursorPos(tStart)
tStart.x = tStart.x - Form1.ScaleX(Form1.Left, vbTwips, vbPixels)
tStart.y = tStart.y - Form1.ScaleY(Form1.Top, vbTwips, vbPixels)
ElseIf Msg = WM_MOVING Then
Call GetCursorPos(tPos)
Form1.Move Form1.ScaleX(tPos.x - tStart.x, vbPixels, vbTwips), Form1.ScaleY(tPos.y - tStart.y, vbPixels, vbTwips)
End If
SubClassedWindow = CallWindowProc(lPrevWnd, hwnd, Msg, wParam, lParam)
End Function

In the Form..

Private Sub Form_Load()
lPrevWnd = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf SubClassedWindow)
End Sub

Private Sub Form_Unload(Cancel As Integer)
Call SetWindowLong(hwnd, GWL_WNDPROC, lPrevWnd)
End Sub



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net

DrBrain
Oct 28th, 1999, 11:21 AM
I got an example. Witch allso snaps. The downside is that you can't use windows' titlebar. You'll have to make a fake one.