Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

form always on bottom

Posted on 2003-02-26
7
Medium Priority
?
147 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
  • 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
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!

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
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, 22 hours left to enroll

577 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