Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Form on top... vb6

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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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

704 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