I have program where multiple forms remaine open at a time. I dont want user to move away from last opened form unless he closes that form. i.e last opened form should not lose focus by clicking on other forms unless active form is closed. How it can be done.
You cant show a MDI child as vbModal... you need to use API to keep the "screen on top"
Add the following in a module -
Private Const GWL_HWNDPARENT = (-8)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal wNewLong As Long) As Long
Public Sub KeepScreenVisible(frm As Form)
'if the form is to stay on top, frm.hwnd will get the name of the form
Dim KeepScreenOnTop As Long
KeepScreenOnTop = SetWindowLong(frm.hwnd, GWL_HWNDPARENT, [hl]frmMain[/hl].hwnd)
In your form -
You can also simulate vbModal by setting the other form(s) to Enabled = False
If more than one form, run a loop to disable all other except the one you are working on.:)