Results 1 to 2 of 2

Thread: sdi user interface

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Aug 2001
    Location
    New Hampshire
    Posts
    18

    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.

  2. #2
    Frenzied Member
    Join Date
    Aug 2001
    Posts
    1,075
    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:
    1. 'Declarations
    2. Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSource As Any, ByVal ByteLen As Long)
    3.  
    4. Public Const WM_GETMINMAXINFO = &H24
    5.  
    6. Type POINTAPI
    7.      x As Long
    8.      Y As Long
    9. End Type
    10.  
    11. Type MINMAXINFO
    12.         ptReserved As POINTAPI
    13.         ptMaxSize As POINTAPI
    14.         ptMaxPosition As POINTAPI
    15.         ptMinTrackSize As POINTAPI
    16.         ptMaxTrackSize As POINTAPI
    17. End Type
    18.  
    19.     'Subclassing code. Change the ptMinTrackSize values to what you want
    20. Public Function SubClass1_WndMessage(ByVal hWnd As Long, ByVal msg As Long, ByVal wp As Long, ByVal lp As Long) As Long
    21.    
    22.     If msg = WM_GETMINMAXINFO Then
    23.  
    24.         Dim MinMax As MINMAXINFO
    25.        
    26.         CopyMemory MinMax, ByVal lp, Len(MinMax)
    27.        
    28.         ' This is where you set the values of the MinX,MinY,MaxX, and MaxY
    29.         ' The values placed in the structure must be in pixels. The values
    30.         ' normally used in Visual Basic are in twips. The conversion is as follows:
    31.         ' pixels = twips\twipsperpixel
    32.         MinMax.ptMinTrackSize.x = 5535 \ Screen.TwipsPerPixelX
    33.         MinMax.ptMinTrackSize.Y = 3000 \ Screen.TwipsPerPixelY
    34.         MinMax.ptMaxTrackSize.x = Screen.Width \ Screen.TwipsPerPixelX '\ 2
    35.         MinMax.ptMaxTrackSize.Y = Screen.Height \ Screen.TwipsPerPixelY
    36.        
    37.         CopyMemory ByVal lp, MinMax, Len(MinMax)
    38.        
    39.         SubClass1_WndMessage = 1
    40.         Exit Function
    41.                
    42.     End If
    43.        
    44.     SubClass1_WndMessage = CallWindowProc(OldWindowProc, hWnd, msg, wp, lp)
    45.        
    46. 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
  •  



Click Here to Expand Forum to Full Width