Results 1 to 10 of 10

Thread: [RESOLVED] problem with status bar and form max button disabled

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Posts
    23

    Resolved [RESOLVED] problem with status bar and form max button disabled

    i have a form with a status bar that i launch it maximized. if i enable the max button, i can see the status bar avobe the Windows bar. if i disable the max button, the status bar still exists but behind my Windows bar. what property of the form or the status bar may i change to solve this problem?

  2. #2

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Posts
    23

    Re: problem with status bar and form max button disabled

    hi bushmobile, thanks for the info but your code almost works. it takes the screen width but dont know why it doesnt take the screen height, there is a small gap. however i need the form to be maximized so the user dont play with the window size.

  4. #4
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: problem with status bar and form max button disabled

    Here's a function I just wrote to size a form to full screen while taking into consideration the taskbar. I'm guessing bushmobile's code does something similar, but since it's a different API call, what the heck. Here ya go:
    Code:
    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 '  message specific
    End Type
    
    Private Declare Function SHAppBarMessage Lib "shell32.dll" (ByVal dwMessage As Long, pData As APPBARDATA) As Long
    
    ' Supply coords (in twips) of usable desktop
    ' which will differ from full screen if the taskbar
    ' is AlwaysOnTop and doesn't autohide
    Public Sub GetDesktop(Left As Long, Top As Long, Width As Long, Height As Long)
        Const ABM_GETSTATE = &H4
        Const ABM_GETTASKBARPOS = &H5
        Const ABS_ALWAYSONTOP = &H2
        Dim typBar As APPBARDATA
        Dim lngState As Long
        
        ' Start with full screen coords
        Left = 0
        Top = 0
        Width = Screen.Width
        Height = Screen.Height
        ' Query the taskbar state
        lngState = SHAppBarMessage(ABM_GETSTATE, typBar)
        ' Now shrink down the side with the taskbar if it infringes on desktop space
        If lngState = ABS_ALWAYSONTOP Then ' AlwaysOnTop and doesn't AutoHide
            lngState = SHAppBarMessage(ABM_GETTASKBARPOS, typBar)
            Select Case typBar.uEdge
                Case 0: Left = typBar.rc.Right * Screen.TwipsPerPixelX
                Case 1: Top = typBar.rc.Bottom * Screen.TwipsPerPixelY
                Case 2: Width = typBar.rc.Left * Screen.TwipsPerPixelX ' this is really right, not width
                Case 3: Height = typBar.rc.Top * Screen.TwipsPerPixelY ' this is really bottom, not height
            End Select
            ' Convert right and bottom to width and height
            Width = Width - Left
            Height = Height - Top
        End If
    End Sub
    Note that instead of the returning a RECT, I modify the passed parameters. I can't really remember why, which is sad because I wrote this just last week.

  5. #5
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: problem with status bar and form max button disabled

    @Zerodyme: should work ok - although i must admit i misread your question slightly - see if the attached form gives the effect you're after

    @Ellis Dee: SPI_GETWORKAREA returns the RECT of the desktop space taking into account any AppBars that may be on screen. I'm assuming that your code only accounts for one AppBar (the window's TaskBar).

    Attached Files Attached Files

  6. #6
    PowerPoster Ellis Dee's Avatar
    Join Date
    Mar 2007
    Location
    New England
    Posts
    3,530

    Re: problem with status bar and form max button disabled

    Great tip, bushmobile, thanks. I'll update my function accordingly. Out of curiosity, what other kind of AppBar is there?
    Quote Originally Posted by Zerodyme
    dont know why it doesnt take the screen height, there is a small gap.
    I just realized what you're talking about. I noticed the same thing, but it isn't actually a gap. That gap is part of your form; it's the darkened shadow part of the 3D border effect of the form.

  7. #7
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: problem with status bar and form max button disabled

    Quote Originally Posted by Ellis Dee
    Great tip, bushmobile, thanks. I'll update my function accordingly. Out of curiosity, what other kind of AppBar is there?
    Any form can be registered as an AppBar.

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Posts
    23

    Re: problem with status bar and form max button disabled

    now it gets the exact size i want with your code. the only but is that i dont want the form to be sizeable by the user. how can i disable this? the problem is not if i launch the window normal or maximized. the problem is when i launch it maximized and the MaxButton is disabled when i cannot see the status bar.
    Last edited by Zerodyme; Mar 28th, 2007 at 05:27 AM.

  9. #9
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: problem with status bar and form max button disabled

    you shouldn't have been able to resize the form i attached - the borderstyle was set to FixedSingle and Moveable was set to False

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Nov 2006
    Posts
    23

    Re: problem with status bar and form max button disabled

    wohoo! its true, i dont know why it was set to Sizeable, now it works perfectly! thanks a bunch!

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