I need to determine if the Form has a titlebar or not. If it has a titlebar then how to check for the titlebar's height? Also, I need to check if the Form has borders and if it does the thickness of the borders.
I need to determine if the Form has a titlebar or not. If it has a titlebar then how to check for the titlebar's height? Also, I need to check if the Form has borders and if it does the thickness of the borders.
The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved
When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day
try like this to know the border widths
Code:Private Sub FindBorderStyle(FormName As Form) Dim FormBorderVertical As Single Dim FormBorderHorizontal As Single Dim FormBorderStyle As Single FormBorderStyle = FormName.BorderStyle FormBorderVertical = FormName.Width 'Keep first width FormBorderHorizontal = FormName.Height 'Keep second width FormName.BorderStyle = 0: FormName.Caption = FormName.Caption FormBorderVertical = FormBorderVertical - FormName.Width 'First form width - Second form width FormBorderHorizontal = FormBorderHorizontal - FormName.Height 'First form height - Second form height FormName.BorderStyle = FormBorderStyle: FormName.Caption = FormName.Caption MsgBox "BorderStyle: " & FormBorderStyle & vbNewLine & "Vertical Border Width: " & FormBorderVertical & vbNewLine & "Horizontal Border Width: " & FormBorderHorizontal End Sub Private Sub Command1_Click() FindBorderStyle Me End Sub
if horizontal border > 0 then has title bar and horizontal borders
if vertical border > 0 thn has vertical borders
Last edited by Max187Boucher; Aug 20th, 2012 at 02:32 PM.
Max, it's not the width of the border I need; it's the thickness of the borders and the height of the titlebar. Also I don't understand what you say about
if horizontal border > 0 then has title bar and horizontal borders
if vertical border > 0 thn has vertical borders
It is not horizontal or vertical borders; it is always both horizontal and vertical or it's neither.
Last edited by jmsrickland; Aug 20th, 2012 at 03:03 PM.
The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved
When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day
I just gave you the answer and you say thats not what you want?
again here
Code:Private Sub FindBorderStyle(FormName As Form) Dim FormBorderVertical As Single Dim FormBorderHorizontal As Single Dim FormBorderStyle As Single FormBorderStyle = FormName.BorderStyle FormBorderVertical = FormName.Width 'Keep first width FormBorderHorizontal = FormName.Height 'Keep second width FormName.BorderStyle = 0: FormName.Caption = FormName.Caption FormBorderVertical = FormBorderVertical - FormName.Width 'First form width - Second form width FormBorderHorizontal = FormBorderHorizontal - FormName.Height 'First form height - Second form height FormName.BorderStyle = FormBorderStyle: FormName.Caption = FormName.Caption MsgBox "BorderStyle: " & FormBorderStyle & vbNewLine & "Vertical Border Width: " & FormBorderVertical & vbNewLine & "Horizontal Border Width: " & FormBorderHorizontal MsgBox "Title Bar HEIGHT (or thickness in you words): " & FormBorderHorizontal - (FormBorderVertical / 2) MsgBox "Each Side EXCEPT title bars's THICKNESS is: " & (FormBorderVertical / 2) End Sub Private Sub Command1_Click() FindBorderStyle Me End Sub
hopefully you understand this now... and when i said if horizontal border (FormBorderHorizontal) > 0 it means if its 0 then it has no borders or titlebar.
if it is more then 0 it means there is borders
sorry if you did not understand i thought i explained properly but i guess not
Edit: just for the record its in Twips and not Pixels or any other scalemode
Last edited by Max187Boucher; Aug 20th, 2012 at 02:55 PM.
each border is 120 and the rest so if horizal total is 570 then top border is 120 and bottom is 120 what is the tittle bar (alone) height its 570 - 120 - 120 = 330 ... i wrote the top border with tittlebar height SORRY
I'm not sure you understand. See attached image.
The border, if there is one is all around the Form so it's both horizontal and vertical. That's what confused me when you if vertical border > 0 then has vertical borders because it will always have vertical border if it has a horizontal border so why test for both?
You say it's in Twips but that has nothing to do with the thickness. The thickness is probably 2 but I do not know for sure and if all Border styles have the same thickness. The titlebar height is probably the same for all styles but what is it's height. That's what I asked for.
The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved
When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day
Test all borderstyles with my code and youll see if they are the same change borderstyle and then execute my code it will show you each side thickness
OK, I can see about the thickness of the borders. They are 4-pixels. 4 * Screen.TwipsPerPixelX = 60 and that is what your message box says.
What confused me was your code says the titlebar's height is 345 which is the sum of the titlebar's height plus the top border thickness of 4 plus 1 which equals 23 and 23 * Screen.TwipsPerPixelY = 345. But your messagebox says
Title Bar HEIGHT (or thickness in you words): 345
and that is not exactly correct. It should have said 270 which is 18 pixels (I counted them in a large size picture of the Form).
Although I understand what your code is doing now I didn't understan it before because that 345 didn't make any sense to me as the height of the titlebar which is really 270 in Twips or 18 in Pixels.
The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved
When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day
I had to go so i couldnt explain more... Do you understand how it works now? I usd it in
Y explorer program and it works good for me
Yes, I understand except your titlebar height was incorrect.
Thanks for your help. I appreciate it.
The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved
When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day
I saw your attached picture after i didnt realize you wanted the top border and titlebar seperate im glad we finally understand each other