?
Solved

form always on bottom

Posted on 2003-02-26
7
Medium Priority
?
143 Views
Last Modified: 2010-08-05
There's probably been something about this somewhere else but I can't find it. What I need to know is how to set my form to always be underneath all the other windows. I'm guessing it has something to do with SetWindowPos but I can't find the value I need to set it to. Other methods are also acceptable (or a link). Thanks.
0
Comment
Question by:adidasman2k5
[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
  • 2
7 Comments
 
LVL 5

Expert Comment

by:JohnMcCann
ID: 8030329
HWND_BOTTOM = 1
0
 

Author Comment

by:adidasman2k5
ID: 8030375
I tried that, but it only put it at the bottom once, and if the form took focus, it came back to the top. I need it to stay at the bottom all the time.
0
 
LVL 2

Expert Comment

by:JoaTex
ID: 8030468
Hi

Open a Project.
open a module and put the code Module: in it.
Open a Form and put the code Code: in it.

Run the program and your window will be allways on top.

Module:

Option Explicit
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

Public Const HWND_TOPMOST = -1
Public Const HWND_NOTOPMOST = -2
Public Const SWP_NOSIZE = &H1
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOACTIVATE = &H10
Public Const SWP_SHOWWINDOW = &H40

Code:

Option Explicit
Dim WidthPixels
Dim HeightPixels
Private Sub Form_Load()
      WidthPixels = Me.Width / Screen.TwipsPerPixelX
      HeightPixels = Me.Height / Screen.TwipsPerPixelY
      SetWindowPos Form1.hwnd, -1, 0, 0, WidthPixels, HeightPixels, &H50 'OnTop
End Sub

If you want not on top instead of -1 on SetWindow Pos put -2.
Jo

0
Technology Partners: 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!

 
LVL 5

Accepted Solution

by:
JohnMcCann earned 60 total points
ID: 8030496
I would use the HWND_BOTTOM and in the Form_GotFocus event send back to bottom.  Why do you want a form always on bottom?
0
 

Author Comment

by:adidasman2k5
ID: 8030541
With tweak ui I put moving the mouse over a window gives it focus and made a text form for reminders, kinda like 3m stickies. I want it so that when i click on the form to move the cursor it stays at the bottom so it seems like im writing on my desktop.
0
 

Author Comment

by:adidasman2k5
ID: 8030545
With tweak ui I put moving the mouse over a window gives it focus and made a text form for reminders, kinda like 3m stickies. I want it so that when i click on the form to move the cursor it stays at the bottom so it seems like im writing on my desktop.
0
 

Author Comment

by:adidasman2k5
ID: 8030560
if anyone wants to know, I actually used the mousedown event but it works, so thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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 Month14 days, 20 hours left to enroll

770 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