Hi everyone
I have a main form which loads a crystal reports preview form.
I want to be able to set the main form to fall behind the reports preview form after it is loaded.
Can anybody help
Thanks
Printable View
Hi everyone
I have a main form which loads a crystal reports preview form.
I want to be able to set the main form to fall behind the reports preview form after it is loaded.
Can anybody help
Thanks
Code:
'How to set a form as bottom of the order and keep it there
'using subClassing
'
'I didn't write this it was handed over to me..I tried it out
'and it does seem to do the trick..however you must end it by
'using dblClick on form..if you use the stop key in VB it will
'crash....so it must be unloaded via code
'bas module code
Public Declare Function SetWindowLong Lib "user32" _
Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Public 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 Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, _
ByVal hWndInsertAfter As Long, ByVal x As Long, _
ByVal y As Long, ByVal cx As Long, ByVal cy As Long, _
ByVal wFlags As Long) As Long
Public Const GWL_WNDPROC = (-4)
Public Const WM_PAINT = &HF
Public Const WM_ACTIVATE = &H6
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const HWND_BOTTOM = 1
Public winProc As Long
Public Function WindowProc(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Dim lFlags As Long
lFlags = SWP_NOSIZE Or SWP_NOMOVE
Select Case wMsg
Case WM_ACTIVATE
SetWindowPos hwnd, HWND_BOTTOM, 0, 0, 0, 0, lFlags
Case Else
WindowProc = CallWindowProc(winProc, hwnd, wMsg, wParam, lParam)
Exit Function
End Select
End Function
Public Sub SubClass(hwnd As Long)
On Error Resume Next
winProc = SetWindowLong(hwnd, GWL_WNDPROC, AddressOf WindowProc)
End Sub
Public Sub UnSubClass(hwnd As Long)
If winProc Then
SetWindowLong hwnd, GWL_WNDPROC, winProc
winProc = 0
End If
End Sub
'Form Event Code
Private Sub Form_Activate()
Me.ClipControls = False
Me.BorderStyle = 0
Me.Caption = ""
Me.Refresh
End Sub
Private Sub Form_DblClick()
UnSubClass Me.hwnd
Unload Me
End Sub
Private Sub Form_Load()
SubClass Me.hwnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
UnSubClass Me.hwnd
End Sub
Thanks HeSaidJoe
I'll try that