Solved

Form on top... vb6

Posted on 2004-09-11
4
1,915 Views
Last Modified: 2011-10-03
I have a form with close button only.  Is it possible to have it on top always but with minimized button to allow the user either to close or minimized if they need it out of the way.

Btw, I would install a code on resize event to prevent user to resize form boreder.  Somthing like:

Me.Top=vTop
Me.Left=vLeft
Me.Width=vWidth
Me.Height=vHeight

vTop, vLeft, vWidth, and vHeight are global variables set in form load.  Or, add a button labled 'Minimize' and don't worry about resize.

Question:  What do I need to make it popup (not modal, I want user to be able to click on other forms and/ or application bu to have this form always on top).

Thanks
0
Comment
Question by:Mike Eghtebas
  • 2
  • 2
4 Comments
 
LVL 19

Accepted Solution

by:
Shauli earned 500 total points
ID: 12036108
1. To have the form always on top use this code:

'daclaration area
Option Explicit

Const HWND_TOPMOST = -1
Const HWND_NOTOPMOST = -2
Const SWP_NOSIZE = &H1
Const SWP_NOMOVE = &H2
Const SWP_NOACTIVATE = &H10
Const SWP_SHOWWINDOW = &H40
Private Declare Sub 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)

'form activate event
Private Sub Form_Activate()
    SetWindowPos Me.hWnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
End Sub

2. To prevent the user from resizing the form, set its border style to 1 (Fixed Singel) and its MinButton to True. This will both prevent from resizing and alow minimizing.

S
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 12036377
There is no doubt it works.  When Shauli writes, evrybody trusts...
0
 
LVL 19

Expert Comment

by:Shauli
ID: 12036516
Thanks, Mike, Don't trust too much though :)

S
0
 
LVL 34

Author Comment

by:Mike Eghtebas
ID: 12036670
Well, what did I tell you.  It was perfect.

Thanks,

Mike
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question