|
-
Aug 17th, 2000, 06:36 AM
#1
Does anyone know how I can get the width and height of a form without using.
form1.width & form1.height
The reason I ask is that form1.width and form1.height dont actually include the border of the window and the title bar.
What I need is the size of the window including title bars and borders. I suspect I will need to use API.
Any expects?
-
Aug 17th, 2000, 06:47 AM
#2
Fanatic Member
Try it by using the GetWindowRect API function.
-
Aug 17th, 2000, 06:50 AM
#3
_______
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 17th, 2000, 07:27 AM
#4
Hyperactive Member
just another idea , but I dont have code for it
take a screen shot of the form and get the
Height and width . Im sure theres an easier way though .
-
Aug 17th, 2000, 07:37 AM
#5
Fanatic Member
Originally posted by PRIVATE1
just another idea , but I dont have code for it
take a screen shot of the form and get the
Height and width . Im sure theres an easier way though .
That doesn't helps, because your program isn't resolution independent that way and the user can also change the size of the titlebar.
-
Aug 17th, 2000, 08:24 AM
#6
Try this:
Code:
Private Declare Function GetWindowRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Command1_Click()
Dim rRect As RECT
GetWindowRect hwnd, rRect
Print rRect.Right - rRect.Left 'Width
Print rRect.Bottom - rRect.Top 'Height
End Sub
-
Aug 17th, 2000, 08:36 AM
#7
_______
<?>
Megatron
what is the rec width and height expressed as compared to
the form.width and form.height.
Rec vs Form
320 vs 4800
240 vs 3600
"A myth is not the succession of individual images,
but an integerated meaningful entity,
reflecting a distinct aspect of the real world."
___ Adolf Jensen
-
Aug 17th, 2000, 08:41 AM
#8
-
Aug 17th, 2000, 08:46 AM
#9
If you checked the example and the numbers did not match (even when you set the ScaleMode to pixels) it's because VB's ScaleMode property displays the dimensions of the client area. You can get these numbers too by using the GetClientRect API.
Code:
Private Declare Function GetClientRect Lib "user32" (ByVal hwnd As Long, lpRect As RECT) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Sub Command1_Click()
Dim rRect As RECT
GetClientRect hwnd, rRect
Print rRect.Right - rRect.Left 'Width
Print rRect.Bottom - rRect.Top 'Height
End Sub
-
Aug 17th, 2000, 12:35 PM
#10
Fanatic Member
Is there an API to get the thickness of the borders in Pixels?
Or do you just have to do it the long way by taking the results of GetWindowRect and subtract GetClientRect?
Chemically Formulated As:
Dr. Nitro
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|