Solved

Form on top... vb6

Posted on 2004-09-11
4
1,908 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
Comment Utility
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 33

Author Comment

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

Expert Comment

by:Shauli
Comment Utility
Thanks, Mike, Don't trust too much though :)

S
0
 
LVL 33

Author Comment

by:Mike Eghtebas
Comment Utility
Well, what did I tell you.  It was perfect.

Thanks,

Mike
0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

772 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now