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

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
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…
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…
Suggested Courses
Course of the Month13 days, 10 hours left to enroll

800 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