|
-
Sep 19th, 2001, 10:37 PM
#1
Thread Starter
Junior Member
sdi user interface
I am working on a new app where I would like to maintain a form containing menu options and buttons at the top of the user's screen similar to the look of VB if you enable the SDI setting. The problem I am running into is that if the user clicks the maximize button, the form takes over the entire screen. I don't want the form to take over the screen, but I also don't want to disable the maximize button. Any advice on how to get around this would be greatly appreciated.
-
Sep 19th, 2001, 10:51 PM
#2
Frenzied Member
You can subclass the form and trap the WM_GETMINMAXINFO message. You can also use the activex control posted at the link below.
http://freevbcode.com/ShowCode.Asp?ID=997
VB Code:
'Declarations
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal ByteLen As Long)
Public Const WM_GETMINMAXINFO = &H24
Type POINTAPI
x As Long
Y As Long
End Type
Type MINMAXINFO
ptReserved As POINTAPI
ptMaxSize As POINTAPI
ptMaxPosition As POINTAPI
ptMinTrackSize As POINTAPI
ptMaxTrackSize As POINTAPI
End Type
'Subclassing code. Change the ptMinTrackSize values to what you want
Public Function SubClass1_WndMessage(ByVal hWnd As Long, ByVal msg As Long, ByVal wp As Long, ByVal lp As Long) As Long
If msg = WM_GETMINMAXINFO Then
Dim MinMax As MINMAXINFO
CopyMemory MinMax, ByVal lp, Len(MinMax)
' This is where you set the values of the MinX,MinY,MaxX, and MaxY
' The values placed in the structure must be in pixels. The values
' normally used in Visual Basic are in twips. The conversion is as follows:
' pixels = twips\twipsperpixel
MinMax.ptMinTrackSize.x = 5535 \ Screen.TwipsPerPixelX
MinMax.ptMinTrackSize.Y = 3000 \ Screen.TwipsPerPixelY
MinMax.ptMaxTrackSize.x = Screen.Width \ Screen.TwipsPerPixelX '\ 2
MinMax.ptMaxTrackSize.Y = Screen.Height \ Screen.TwipsPerPixelY
CopyMemory ByVal lp, MinMax, Len(MinMax)
SubClass1_WndMessage = 1
Exit Function
End If
SubClass1_WndMessage = CallWindowProc(OldWindowProc, hWnd, msg, wp, lp)
End Function
If you're not sure about how to subclass a form I'll be happy to help.
Greg
Free VB Add-In - The Reference Librarian
Click Here for screen shot and download link.
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
|