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


Botto of the form with title bar

Posted on 2003-03-16
Medium Priority
Last Modified: 2010-05-01
How can I get the exact bottom of the form. I would like something like

scrollbar.top = me.height - vscrollbar.height - titllebar.height

But there is no such thing as titlebar.height. I could use GetSystemMetrics(SM_CYCAPTION), however I does not work, becuse different windows has different title bar height.

Is there any way to establish exact bottom of the form at runtime.
Question by:sasot

Expert Comment

ID: 8147997
I think you are looking for something like

Private Type RECT
   Left As Long
   Top As Long
   Right As Long
   Bottom As Long
End Type

Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long

Private Sub Form_Load()
Dim rectMyPos As RECT

   GetWindowRect Me.hWnd, rectMyPos
   Debug.Print rectMyPos.Bottom 'This is the bottom of the form in Pixels
End Sub

Accepted Solution

TrueIdiot earned 1000 total points
ID: 8148864
What are you trying to do? if you want to align someting with the form then you could always use the ScaleHeight property:

Text1.height = me.scaleheight * .9 'the height of the textbox is now 90% that of the form

or you could use the everclassic:

intBottomOfForm = me.Top + me.Height 'it's + since the coordinate system counts from the top left

Out of curiosity, why do you ask?

Expert Comment

ID: 8149123
I think "TrueIdiot" is correct.  ScaleHeight and ScaleWidth are the height and width of the form not counting the decoration (like the title bar).

Author Comment

ID: 8150387

you are right in the first part of your answer, where you use .scaleheight (why I ditnt think of that?)

Why I ask is because:

intBottomOfForm = me.Top + me.Height

does not work. intBottom is below the bottom of the form, however

intBottomOfForm = me.Top + me.ScaleHeight

is OK. So you helped me out and here are your points.


Expert Comment

ID: 8156051
Well, I'm glad I helped, even if I kinda missed the question. Thanks.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
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…
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…
Suggested Courses
Course of the Month11 days, 2 hours left to enroll

571 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