Solved

Form on top... vb6

Posted on 2004-09-11
4
1,919 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Independent Software Vendors: 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

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month10 days, 3 hours left to enroll

624 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