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

x
?
Solved

Ontop

Posted on 1999-07-14
4
Medium Priority
?
223 Views
Last Modified: 2010-05-02
How do I make my form stay always ontop without using any .ocx's?
0
Comment
Question by:mrcool4444
[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
4 Comments
 
LVL 10

Expert Comment

by:caraf_g
ID: 1524860
0
 
LVL 1

Accepted Solution

by:
SiriusP earned 0 total points
ID: 1524861
'Modular Declarations:

Private Declare Function 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) As Long

Private Const HWND_TOPMOST = -1
Private Const SWP_NOSIZE = &H1
Private Const SWP_NOMOVE = &H2

'Form Load event

Private Sub Form_Load()
SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE Or SWP_NOMOVE
End Sub
0
 
LVL 3

Expert Comment

by:Norbert
ID: 1524862
I am to late SiriusP has already answered.
we say both the same
here is my answer:

Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_DRAWFRAME = SWP_FRAMECHANGED
Public Const SWP_FRAMECHANGED = &H20        
Public Const SWP_HIDEWINDOW = &H80
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_NOCOPYBITS = &H100
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOOWNERZORDER = &H200      
Public Const SWP_NOREDRAW = &H8
Public Const SWP_NOREPOSITION = SWP_NOOWNERZORDER
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOZORDER = &H4
Public Const SWP_SHOWWINDOW = &H40
Declare Function SetWindowPos Lib "user32" Alias "SetWindowPos" (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) As Long

Public sub SetTopMost(ShoulBeTopMost as Boolean,Hwnd as long)

dim wFlags as long
dim NotUsed as long
wFlags=SWP_NOMOVE or SWP_NOSIZE
if ShoulBeTopMost then
      NotUsed=SetWindowPos (Hwnd, HWND_TOPMOST,0, 0,0,0, wFlags)
else
      NotUsed=SetWindowPos (Hwnd, HWND_NOTOPMOST,0, 0,0,0, wFlags)
end if

end sub

'To set a form Topmost now just call
SetTopMost TRUE,Form.hwnd
to reset from Topmost state call
SetTopMost FALSE,Form.hwnd

The code above is not tested. I worte it yust now on the fly so may be that there are some errors but I think you should be able to fix them. The constants and the declare are copied using Api Viewer so here should not be a mistake.

0
 

Author Comment

by:mrcool4444
ID: 1524863
Well...I figured it out myself, what you told me didn't work but since I got it I will give you the points.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

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 have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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…
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…
Suggested Courses

705 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