![]() |
Question about User Form Window Size on Chip Petersons Site
I have a User Form that I need to adjust to fit the users computer. So far I
not found anyway to get the User Form Window to Adjust. I can adjust the User Form sixe, but the Main Window the Form located is in is still bigger than the Screen. I saw on Chip Petersons site exactly what I need. His code allows complete control over the User Form just as if it was a regular window. Can anyone help me with this code? http://www.cpearson.com/Excel/formcontrol.aspx |
Question about User Form Window Size on Chip Petersons Site
There are various ways, this is probably the easiest although it may hide
the task bar Private Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" ( _ ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function ShowWindow Lib "user32" ( _ ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Private Const SW_MAXIMIZE As Long = 3 Private Sub UserForm_Activate() Dim hWnd As Long With Me .Caption = Rnd() hWnd = FindWindow("ThunderDFrame", .Caption) .Caption = "Hello" End With ShowWindow hWnd, SW_MAXIMIZE End Sub Regards, Peter T "Brian" wrote in message ... I have a User Form that I need to adjust to fit the users computer. So far I not found anyway to get the User Form Window to Adjust. I can adjust the User Form sixe, but the Main Window the Form located is in is still bigger than the Screen. I saw on Chip Petersons site exactly what I need. His code allows complete control over the User Form just as if it was a regular window. Can anyone help me with this code? http://www.cpearson.com/Excel/formcontrol.aspx |
Question about User Form Window Size on Chip Petersons Site
Can you please explain exactly what this code is going to do?
My Biggest problem is that my User Form only works on my Display. When I try and use it on any other computer Not only is the User Form to big, but the Main Window the User Form is in goes completely off the screen. I want the User Form Window to act just like any other Window. With Min, Max & Resize, just like a reqular window would do. Thanks for your response. "Peter T" wrote: There are various ways, this is probably the easiest although it may hide the task bar Private Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" ( _ ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function ShowWindow Lib "user32" ( _ ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Private Const SW_MAXIMIZE As Long = 3 Private Sub UserForm_Activate() Dim hWnd As Long With Me .Caption = Rnd() hWnd = FindWindow("ThunderDFrame", .Caption) .Caption = "Hello" End With ShowWindow hWnd, SW_MAXIMIZE End Sub Regards, Peter T "Brian" wrote in message ... I have a User Form that I need to adjust to fit the users computer. So far I not found anyway to get the User Form Window to Adjust. I can adjust the User Form sixe, but the Main Window the Form located is in is still bigger than the Screen. I saw on Chip Petersons site exactly what I need. His code allows complete control over the User Form just as if it was a regular window. Can anyone help me with this code? http://www.cpearson.com/Excel/formcontrol.aspx . |
Question about User Form Window Size on Chip Petersons Site
First, it's Chip Pearson's site.
Second, Chip's code resizes the userform--not the controls on the userform (is that what "main window" means???). You'll have to take care of that yourself--for each control that you want to resize. Third, I'd weasel out and make the userform fit the worst display settings possible. Maybe even redesign it to show less stuff (use multipages instead????). Brian wrote: I have a User Form that I need to adjust to fit the users computer. So far I not found anyway to get the User Form Window to Adjust. I can adjust the User Form sixe, but the Main Window the Form located is in is still bigger than the Screen. I saw on Chip Petersons site exactly what I need. His code allows complete control over the User Form just as if it was a regular window. Can anyone help me with this code? http://www.cpearson.com/Excel/formcontrol.aspx -- Dave Peterson |
Question about User Form Window Size on Chip Petersons Site
Peter T has provided the code you need, but I would suggest that you
rethink whether you really want to always open the form such that it covers the entire screen. As an end user, I would find that rather annoying and frankly a bit rude. I would suggest that you use the code on my web site to add a maximize button to the form's caption bar, enable the form to be resized, and allow the user to maximize the form if he so desires. If you need to support multiple screen resolutions, you'll run into problems when maximizing or resizing the form. Maximizing a form isn't going to do the requisite resizing and/or repositioning the controls that reside on the form. For example, suppose you have a form with four textboxes in the upper region of the form. When you resize or maximize the form, these controls will not move or resize themselves to fit well within the new form size. Instead, they will remain in the same position and have the same size as they had originally. The only thing you get is a much larger form comprised almost completely by empty space. It is possible, but quite difficult, to resize and/or reposition the controls on a form to make them look good on the expanded form. (This type of thing is handled very very well in the WPF/XAML/NET3.5 framework.) When you design a form that is to be used on monitors that may be of different sizes and aspect ratios, it is best to develop for the smallest for that you will support and leave the expanded spaces on higher res screens alone. It is generally save to assume that your users will be on 1024 x 1200 resolution, although you can't really make any assumption about the aspect ratio -- it could be 4:3 for "normal" monitors or 16:9 or 16:10 on widescreens. I saw on Chip Petersons site Who? Cordially, Chip Pearson Microsoft MVP 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com [email on web site] On Thu, 4 Feb 2010 20:42:01 -0800, Brian wrote: I have a User Form that I need to adjust to fit the users computer. So far I not found anyway to get the User Form Window to Adjust. I can adjust the User Form sixe, but the Main Window the Form located is in is still bigger than the Screen. I saw on Chip Petersons site exactly what I need. His code allows complete control over the User Form just as if it was a regular window. Can anyone help me with this code? http://www.cpearson.com/Excel/formcontrol.aspx |
Question about User Form Window Size on Chip Petersons Site
Did you try it, it should maximize the window.
It doesn't include code to add the min/max buttons & enable resize but I assume that's already covered by Chip Pearson's examples. Regards, Peter T "Brian" wrote in message ... Can you please explain exactly what this code is going to do? My Biggest problem is that my User Form only works on my Display. When I try and use it on any other computer Not only is the User Form to big, but the Main Window the User Form is in goes completely off the screen. I want the User Form Window to act just like any other Window. With Min, Max & Resize, just like a reqular window would do. Thanks for your response. "Peter T" wrote: There are various ways, this is probably the easiest although it may hide the task bar Private Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" ( _ ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function ShowWindow Lib "user32" ( _ ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Private Const SW_MAXIMIZE As Long = 3 Private Sub UserForm_Activate() Dim hWnd As Long With Me .Caption = Rnd() hWnd = FindWindow("ThunderDFrame", .Caption) .Caption = "Hello" End With ShowWindow hWnd, SW_MAXIMIZE End Sub Regards, Peter T "Brian" wrote in message ... I have a User Form that I need to adjust to fit the users computer. So far I not found anyway to get the User Form Window to Adjust. I can adjust the User Form sixe, but the Main Window the Form located is in is still bigger than the Screen. I saw on Chip Petersons site exactly what I need. His code allows complete control over the User Form just as if it was a regular window. Can anyone help me with this code? http://www.cpearson.com/Excel/formcontrol.aspx . |
Question about User Form Window Size on Chip Petersons Site
Sorry, omitted an API declaration (although you'll probably already have
that and have obtained the form's handle) Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _ ByVal lpClassName As String, _ ByVal lpWindowName As String) As Long Peter T "Peter T" <peter_t@discussions wrote in message ... There are various ways, this is probably the easiest although it may hide the task bar Private Declare Function SetWindowLong Lib "user32" Alias _ "SetWindowLongA" ( _ ByVal hWnd As Long, ByVal nIndex As Long, _ ByVal dwNewLong As Long) As Long Private Declare Function ShowWindow Lib "user32" ( _ ByVal hWnd As Long, _ ByVal nCmdShow As Long) As Long Private Const SW_MAXIMIZE As Long = 3 Private Sub UserForm_Activate() Dim hWnd As Long With Me .Caption = Rnd() hWnd = FindWindow("ThunderDFrame", .Caption) .Caption = "Hello" End With ShowWindow hWnd, SW_MAXIMIZE End Sub Regards, Peter T "Brian" wrote in message ... I have a User Form that I need to adjust to fit the users computer. So far I not found anyway to get the User Form Window to Adjust. I can adjust the User Form sixe, but the Main Window the Form located is in is still bigger than the Screen. I saw on Chip Petersons site exactly what I need. His code allows complete control over the User Form just as if it was a regular window. Can anyone help me with this code? http://www.cpearson.com/Excel/formcontrol.aspx |
Question about User Form Window Size on Chip Petersons Site
"Chip Pearson" wrote in message
Peter T has provided the code you need, but I would suggest that you rethink whether you really want to always open the form such that it covers the entire screen. As an end user, I would find that rather annoying and frankly a bit rude. Totally agree. Sometimes a maximized form is used as a splash screen, not that I like those much either. The way posted was only to demo. Regards, Peter T |
Question about User Form Window Size on Chip Petersons Site
Chip Pearson wrote: I saw on Chip Petersons site Who? Obviously a smart, good looking, well-spoken young man! |
Question about User Form Window Size on Chip Petersons Site
Believe it or not I still have an old 17" Flat Panel Monitor, that I keep for
a back up just incase I need it. I think if I use the Code on your Page to adjust the Outer User Form Window and add the Min, Max & Resize option. Then adjust the User Form to fit that on the 17" Monitor that should work. What do you think? By the way Sorry about the last Name Error, I had just finished reading a post by Dave Peterson and got confused. Of course that seems to be happening alot more & more these days. "Chip Pearson" wrote: Peter T has provided the code you need, but I would suggest that you rethink whether you really want to always open the form such that it covers the entire screen. As an end user, I would find that rather annoying and frankly a bit rude. I would suggest that you use the code on my web site to add a maximize button to the form's caption bar, enable the form to be resized, and allow the user to maximize the form if he so desires. If you need to support multiple screen resolutions, you'll run into problems when maximizing or resizing the form. Maximizing a form isn't going to do the requisite resizing and/or repositioning the controls that reside on the form. For example, suppose you have a form with four textboxes in the upper region of the form. When you resize or maximize the form, these controls will not move or resize themselves to fit well within the new form size. Instead, they will remain in the same position and have the same size as they had originally. The only thing you get is a much larger form comprised almost completely by empty space. It is possible, but quite difficult, to resize and/or reposition the controls on a form to make them look good on the expanded form. (This type of thing is handled very very well in the WPF/XAML/NET3.5 framework.) When you design a form that is to be used on monitors that may be of different sizes and aspect ratios, it is best to develop for the smallest for that you will support and leave the expanded spaces on higher res screens alone. It is generally save to assume that your users will be on 1024 x 1200 resolution, although you can't really make any assumption about the aspect ratio -- it could be 4:3 for "normal" monitors or 16:9 or 16:10 on widescreens. I saw on Chip Petersons site Who? Cordially, Chip Pearson Microsoft MVP 1998 - 2010 Pearson Software Consulting, LLC www.cpearson.com [email on web site] On Thu, 4 Feb 2010 20:42:01 -0800, Brian wrote: I have a User Form that I need to adjust to fit the users computer. So far I not found anyway to get the User Form Window to Adjust. I can adjust the User Form sixe, but the Main Window the Form located is in is still bigger than the Screen. I saw on Chip Petersons site exactly what I need. His code allows complete control over the User Form just as if it was a regular window. Can anyone help me with this code? http://www.cpearson.com/Excel/formcontrol.aspx . |
All times are GMT +1. The time now is 04:23 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com