|
-
Apr 5th, 2008, 07:44 AM
#1
Thread Starter
Fanatic Member
Maximize Form BUT maintain original width...
Hi Guys and gals
Been a long time. Right I need to maximize a form but only by height and not width.
For example, if the form is sitting in the middle of the screen and it's width and height are 33% of the screens width and height, then when the user clicks the maximize button the form resizes so that its width is still 33% of the screen width, but the forms height is now 100% of the screens height.
The percentages aren't important. The important thing is that the width is maintained.
Also the Maximized button (top right of the form) needs to indicate its been maxmized and once clikced it resizes back to the original size (33% width and height in the example).
There something nice and easy for a saturday afternoon.
Laters
Mindcrime : )
ICQ 24003332
VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8
-
Apr 5th, 2008, 07:56 AM
#2
Re: Maximize Form BUT maintain original width...
I'd use subclassing to define a maximum width of the form. I think this will take care of the maximize button behaving like you want it to also, but will have to test it first.
Lots of code on here and elsewhere on the internet for "subclassing max form width" etc. One example:
http://www.vb-helper.com/howto_restrict_form_size.html
More:
http://www.google.com/search?hl=en&q...=Google+Search
-
Apr 5th, 2008, 07:58 AM
#3
Frenzied Member
Re: Maximize Form BUT maintain original width...
simplest way
Code:
Me.Height = Screen.Height - 500
Me.Top = 0
here the 500 is the height of the task bar given manually. This is for my screen res. There should be a way to capture the task bar widow handle and get its height. Thats bit hard but possible.
-
Apr 5th, 2008, 05:34 PM
#4
Thread Starter
Fanatic Member
Re: Maximize Form BUT maintain original width...
Cheers ZeeZee, that would work fine for the first line of my post
Mindcrime : )
ICQ 24003332
VB 5.0, VB 6.0 SP5, COM, DCOM, VB.NET Beta 2, Oracle 8
-
Apr 5th, 2008, 09:52 PM
#5
Frenzied Member
Re: Maximize Form BUT maintain original width...
Thanks, but for your second part , you would need to use what DigiRev has given. 
In that, you can keep the form width same and when maximizing, get (screen height - Taskbar Height) as form height.
This code does it
Code:
Option Explicit
Private Const ABM_GETTASKBARPOS = &H5
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Type APPBARDATA
cbSize As Long
hwnd As Long
uCallbackMessage As Long
uEdge As Long
rc As RECT
lParam As Long
End Type
Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
Function GetTaskBarSize()
Dim ABD As APPBARDATA
SHAppBarMessage ABM_GETTASKBARPOS, ABD
MsgBox "Width:" & ABD.rc.Right - ABD.rc.Left
MsgBox " Height:" & ABD.rc.Bottom - ABD.rc.Top
End Function
Function GetTaskBarHeight() As Double
Dim ABD As APPBARDATA
SHAppBarMessage ABM_GETTASKBARPOS, ABD
GetTaskBarHeight = (ABD.rc.Bottom - ABD.rc.Top) * Screen.TwipsPerPixelY
'MsgBox "Width:" & ABD.rc.Right - ABD.rc.Left
'MsgBox " Height:" & ABD.rc.Bottom - ABD.rc.Top
End Function
Private Sub Command1_Click()
Me.Height = Screen.Height - GetTaskBarHeight
Me.Top = 0
Me.Left = 0
End Sub
taken from http://www.daniweb.com/forums/thread93101.html
Also check this
http://forums.devx.com/showthread.php?t=42548
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
|