VBCE.com - The Premier Website For Visual Basic/CE Developers

 

*Dev Corner

Sample Code
Controls
Workarounds
Tips & Tricks
Q & A
Forums

*Goodies
Downloads
Software
Bookstore


*General
Home
What's New
General Info
Misc. Info


*News Worthy
News
Articles
Editorials
KB Articles
Reviews
Awards

*Miscellaneous
Web Links
Partners
Search
Feedback
Advertising

Sponsors


More...


Modal Forms

Download Code!VBCE 6.0 does not support MODAL forms.  You can simulate this however with a simple API call and setting the original form to disabled.  This is the same functionality can be achieved with the VBCEMisc Control.

modalforms.gif (3774 bytes)

Place the following code in a MODULE:

Option Explicit

'Constants for topmost.
Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40

Declare Function SetWindowPos Lib "Coredll" (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

 

On Form1, place a command button and enter the following code in the click event:

Private Sub Command1_Click()
     Form1.Enabled = False
     Form2.Show
End Sub

On Form2, place a command button and enter the following code in the click event:

Private Sub Command1_Click()
     Form1.Enabled = True
     Me.Hide
End Sub

Private Sub Form_Load()
     '-- Makes this form "Always on Top..."
     '-- Does not make it modal....
     Call SetWindowPos(Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE Or SWP_NOSIZE)
End Sub

 

 

 

VBCE.com is DevX Winner!

Unless otherwise noted, all information on VBCE.com is Copyright 1998 - 2002
Windows, Windows CE, and Visual Basic are trademarks of the Microsoft Corporation.
VBCE.com is not responsible for content on external sites.
Send all feedback to webmaster@vbce.com
Webmasters - feel free to link to
VBCE.com - Premier Website for Visual Basic/CE Development

Buy Books!