Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Form on top... vb6

Posted on 2004-09-11
4
Medium Priority
?
1,930 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 2000 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

916 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