Announcement

Collapse
No announcement yet.

Maximized Window

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Eric Pearson
    replied
    Peter --

    I doubt that you'll be able to gray-out a title bar button by using that technique.

    The last code that I posted shows how to create a dialog without a maximize button, so you wouldn't need to make it gray. But it will only work if you don't mind covering the task bar.

    -- Eric


    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited March 08, 2000).]

    Leave a comment:


  • Peter Lameijn
    replied
    Thanks for all solutions. I've used Eric's at the moment. I'm only trying to get the max/restore button to gray-out. (I know the button doesn't work anyway, but it looks nicer) For some reason you can use.
    Code:
    EnableMenuItem GetSystemMenu(hDlg,0), 6, %MF_BYPOSITION Or %MF_GRAYED
    to gray-out some of the system menu items (like close), but not all. (not size/min/max)
    It sure would be nice if there was a clear book describing the Windows (and buttons, ect...) styles and how they interact / which ones can be combined or not. (Combining styles somtimes seems more like 'fuzzy logic' )

    Peter


    ------------------




    [This message has been edited by Peter Lameijn (edited March 08, 2000).]

    Leave a comment:


  • Eric Pearson
    replied
    Yes, that produces some potentially useful effects, too. Of course you've probably anticipated me saying that using the API (SetWindowPos) is not recommended when a DDT function (DIALOG SET SIZE) is available... but it does avoid the pixel-to-dialog-unit calculations.

    Your technique does not really create a window that looks "maximized" because the four window borders are visible. That may or may not be desirable, depending on what the programmer wants.

    One advantage: since you are explicitly setting the window size instead of just telling Windows "maximized", you could use SystemParametersInfo %SPI_GETWORKAREA to fill the desktop instead of covering the task bar. You could also use the API to get the window-border-width (typically 4) and locate/size the window so that the borders did not show (like locating it at -4,-4 and adding 8 to the x and y size).

    Peter isn't saying much... I suspect we've given him more information than he needs.

    If anybody wanted to make a project of it, these discussions have pointed out how valuable a complete written "survey" of all of the window styles would be. The Microsoft Win32.HLP file clearly doesn't describe all of the side-effects of the various %WS_ options.

    -- Eric


    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    Hmmm ... I was burn not yesterday, but never used double-click for restoring window.
    But this code, it seems to me, keeps double-click (it's not better than your, just interesting)
    Code:
    #Compile Exe
    #Include "WIN32API.INC"
    Function PbMain As Long
       Dim hWnd As Local Long
       Dialog New 0,"FIXED",0,0,0,0, %WS_POPUP Or %WS_SYSMENU Or %WS_CAPTION To hWnd
       SetWindowPos hWnd, 0, 0, 0, GetSystemMetrics(%SM_CXSCREEN), GetSystemMetrics(%SM_CYSCREEN), 0
       DeleteMenu GetSystemMenu(hWnd, 0), %SC_MOVE, %MF_BYCOMMAND '<- Not moveable
       DeleteMenu GetSystemMenu(hWnd, 0), %SC_CLOSE, %MF_BYCOMMAND ' No close button
       Dialog Show Modal hWnd
    End Function
    ------------------

    Leave a comment:


  • Eric Pearson
    replied
    Now that I look at it, combining these two techniques might give Peter exactly what he wants, because deleting the %SC_MOVE item makes it possible to create the window without %WS_MAXIMIZEBOX, so the title bar will have just the "x" button and no non-functional max/min buttons...

    Code:
    #INCLUDE "WIN32API.INC"
                 
    CALLBACK FUNCTION MainCallBack AS LONG
        IF CBMSG = %WM_SYSCOMMAND AND (CBWPARAM AND &hFFF0) = %SC_RESTORE THEN
            FUNCTION =1
        END IF
    END FUNCTION
     
    FUNCTION PBMain AS LONG
        DIM hWnd AS LOCAL LONG
        DIALOG NEW 0,"FIXED",1,1,1,1,%WS_SYSMENU OR %WS_MAXIMIZE TO hWnd
        DeleteMenu GetSystemMenu(hWnd, 0), %SC_MOVE, %MF_BYCOMMAND                
        DIALOG SHOW MODAL hWnd CALL MainCallBack
        FUNCTION = 1
    END FUNCTION
    But wait! For some reason, getting rid of %WS_MAXIMIZEBOX causes the window to cover the task bar!

    Isn't it bizarre how some of these Windows options interact?

    -- Eric
    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited March 08, 2000).]

    Leave a comment:


  • Eric Pearson
    replied
    That works too, but it does not keep a double-click on the title bar from restoring the window so it's no better than my first suggestion, which deletes %SC_RESTORE rather than %SC_MOVE.

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>

    Leave a comment:


  • Semen Matusovski
    replied
    Eric, perhaps, EB wanted to say something like this (it's small modification of your code)
    Code:
    #Compile Exe
    #Include "WIN32API.INC"
    Function PbMain As Long
    Dim hWnd As Local Long
    Dialog New 0,"FIXED",0,0,0,0, %WS_MAXIMIZE Or %WS_SYSMENU To hWnd
    DeleteMenu GetSystemMenu(hWnd, 0), %SC_MOVE, %MF_BYCOMMAND
    'DeleteMenu GetSystemMenu(hWnd, 0), %SC_CLOSE, %MF_BYCOMMAND
    Dialog Show Modal hWnd
    End Function
    ------------------

    Leave a comment:


  • Eric Pearson
    replied
    EB --

    > Just set state maximized without declaring the buttons.

    Doing that produces a "draggable" window, which is what Peter is trying to avoid. For some reason, the "no-drag" property seems to be associated with the %WS_MAXIMIZEBOX value.

    -- Eric


    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited March 08, 2000).]

    Leave a comment:


  • Guest's Avatar
    Guest replied
    Just set state maximized without declaring the buttons.


    ------------------

    Leave a comment:


  • Eric Pearson
    replied
    As Peter discovered (apparently about the same time I did ) the code in my previous post still allows the user to restore/maximize by double-clicking on the title bar, even though the title bar button is disabled. Here is an alternate technique that disables both the button and the double-click method.

    Code:
    #INCLUDE "WIN32API.INC"
     
    CALLBACK FUNCTION MainCallBack AS LONG
        IF CBMSG = %WM_SYSCOMMAND AND (CBWPARAM AND &hFFF0) = %SC_RESTORE THEN
            FUNCTION =1
        END IF
    END FUNCTION
     
    FUNCTION PBMain AS LONG
        DIM hWnd AS LOCAL LONG
        DIALOG NEW 0,"FIXED",1,1,1,1,%WS_SYSMENU OR %WS_MAXIMIZE OR %WS_MAXIMIZEBOX TO hWnd
        DIALOG SHOW MODAL hWnd CALL MainCallBack
        FUNCTION = 1
    END FUNCTION
    -- Eric

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited March 07, 2000).]

    Leave a comment:


  • Peter Lameijn
    replied
    Thanks. Both ways work. Eric's is easier, but has one problem: double-clicking on the caption still minimizes the window.....

    ------------------

    Leave a comment:


  • Eric Pearson
    replied
    Peter --

    One way to get an immovable window is to use %WS_MAXIMIZEBOX. But you don't want the maximize box... so you could create the dialog with the maximize box, and then disable it with the DeleteMenu API. The button will still be visible, but it won't do anything.

    Code:
    #INCLUDE "WIN32API.INC"
     
    FUNCTION PBMain AS LONG
     		 
    	DIM hWnd AS LOCAL LONG		 
     
    	DIALOG NEW 0,"FIXED",1,1,1,1,%WS_SYSMENU OR %WS_MAXIMIZE OR %WS_MAXIMIZEBOX TO hWnd
     
    	DeleteMenu GetSystemMenu(hWnd, 0), %SC_RESTORE, %MF_BYCOMMAND
     	
    	DIALOG SHOW MODAL hWnd
      
    	FUNCTION = 1
     
    END FUNCTION
    There may be other ways too...

    -- Eric

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited March 07, 2000).]

    Leave a comment:


  • Semen Matusovski
    replied
    Peter --
    Code:
    #Compile Exe
    #Register None
    #Include "Win32Api.Inc"
    
    Function PbMain()
       Local hDlg As Long
       Dialog New 0 ,"", 0, 0, 0, 0, %WS_POPUP Or %WS_BORDER To hDlg
       SetWindowPos hDlg, 0, 0, 0, GetSystemMetrics(%SM_CXSCREEN), GetSystemMetrics(%SM_CYSCREEN), 0
       Dialog Show Modal hDlg
    End Function
    This is full-screen mode w/o caption.
    If you want with caption - also possible, but it's necessary some additional statements.
    This code is based on Lance' example.

    Code:
    #Compile Exe
    #Dim All
    #Register None
    #Include "win32api.INC"
    
    Global oldproc As Long
    
    CallBack Function DlgProc
      Select Case CbMsg
         Case %WM_COMMAND
            If CbCtl = %IDOK Then Dialog End CbHndl
         Case %WM_DESTROY
            SetWindowLong CbHndl, %GWL_WNDPROC, oldproc
      End Select
    End Function
    
    CallBack Function subclass
       Local Result As Long
       Result = CallWindowProc(oldproc, CbHndl, CbMsg, CbWparam, CbLparam)
       If CbMsg = %WM_NCHITTEST Then _
          If Result <> %HTCLIENT Then Result = %HTNOWHERE
       Function = Result
    End Function
    
    Function PbMain
       Local hDlg As Long
        Dialog New 0, "Move me", , , 100, 100  To hDlg
        Control Add Button, hDlg, %IDOK, "&Quit", 30, 30, 40, 14    
        OldProc = SetWindowLong(hDlg, %GWL_WNDPROC, CodePtr(subclass))
        Dialog Show Modal hDlg, Call DlgProc
    End Function
    You can even add maximized, minimized buttons - a program locked them by processing %WM_NCHITTEST

    [This message has been edited by Semen Matusovski (edited March 07, 2000).]

    Leave a comment:


  • Peter Lameijn
    started a topic Maximized Window

    Maximized Window

    How do I get a maximized, non-movable window? Also the minimize / maximize box must be disabled. (User only may use application maximized). I've tried sewveral styles, but found none to do exactly what I want. If I use

    %WS_SYSMENU Or %WS_CAPTION Or %WS_MAXIMIZE (with disabled min/max box), then you can still drag the maximized window off-screen by clicking on it's caption.
    Peter

Working...
X