Announcement

Collapse
No announcement yet.

Any way I can make this dialog "flatter"?

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

  • Any way I can make this dialog "flatter"?

    Creation code:
    Code:
        DIALOG NEW PIXELS, hParent, "", 0, 0, 36, 400, %WS_POPUP OR _
            %WS_CAPTION OR %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN _
            OR %WS_VISIBLE OR %DS_SETFOREGROUND OR %DS_NOFAILCREATE, _
            %WS_EX_TOOLWINDOW OR %WS_EX_TOPMOST, TO _
            hDlg
    
        DIALOG GET CLIENT hDlg TO PositionX, PositionY
        DIALOG  SET COLOR      hDlg, %WHITE, RGB(46, 32, 92)
    
        CONTROL ADD LABEL,     hDlg, %IDL_OPACITYLABEL, "255", 0, 0, _
            PositionX, 24, _
            %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_NOTIFY, _
            %WS_EX_LEFT OR %WS_EX_LTRREADING
        CONTROL SET COLOR      hDlg, %IDL_OPACITYLABEL, %WHITE, RGB(46, 32, 92)
        PositionY = PositionY - 24
    
        CONTROL ADD SCROLLBAR, hDlg, %IDSV_OPACITYADJUST, "Opacity Adjust", _
            0, 24, PositionX, PositionY, %WS_CHILD OR %WS_VISIBLE OR %SBS_VERT
        CONTROL SET COLOR      hDlg, %IDSV_OPACITYADJUST, -1, RGB(46, 32, 92)
    Furcadia, an interesting online MMORPG in which you can create and program your own content.

  • #2
    I think you can trap the WM_GETMINMAX notification message that is sent to every window upon creation and return a minmax structure with a smaller min size.


    Do you mean flatter in size? or in 3d look?
    Last edited by Elias Montoya; 26 Feb 2009, 01:47 PM.

    Comment


    • #3
      Sorry, thought I put that under the original post, ...

      Would like it to be flatter in 3D look, trying to get it to look like the scrollbar is the window itself with the label and a caption bar.
      Furcadia, an interesting online MMORPG in which you can create and program your own content.

      Comment


      • #4
        Code:
        #COMPILE EXE
        #INCLUDE "win32api.inc"
        %IDL_OPACITYLABEL = 100
        %IDSV_OPACITYADJUST = 110
        FUNCTION PBMAIN () AS LONG
             LOCAL hDlg AS LONG, PositionX AS LONG, PositionY AS LONG
             PositionX=0
             PositionY=0
             
        DIALOG NEW PIXELS, 0, "", 0, 0, 36, 400, %WS_POPUP OR _
                %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN _
                OR %WS_VISIBLE OR %DS_SETFOREGROUND OR %DS_NOFAILCREATE, _
                %WS_EX_TOPMOST, TO _
                hDlg
            DIALOG GET CLIENT hDlg TO PositionX, PositionY
        '    DIALOG  SET COLOR      hDlg, %WHITE, RGB(46, 32, 92)
            CONTROL ADD LABEL,     hDlg, %IDL_OPACITYLABEL, "255", 0, 0, _
                PositionX, 24, _
                %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER , _
                %WS_EX_LEFT OR %WS_EX_LTRREADING     ' don't use %SS_NOTIFY so form gets mouse button down
            CONTROL SET COLOR      hDlg, %IDL_OPACITYLABEL, %WHITE, RGB(46, 32, 92)
            PositionY = PositionY - 24
            CONTROL ADD SCROLLBAR, hDlg, %IDSV_OPACITYADJUST, "Opacity Adjust", _
                0, 24, PositionX, PositionY, %WS_CHILD OR %WS_VISIBLE OR %SBS_VERT
            CONTROL SET COLOR      hDlg, %IDSV_OPACITYADJUST, -1, RGB(46, 32, 92)
            DIALOG SHOW MODAL hDlg, CALL MyDlgproc
        END FUNCTION
        CALLBACK FUNCTION MyDlgproc
             SELECT CASE CB.MSG
                  CASE %WM_LBUTTONDOWN
                       DIALOG SEND CB.HNDL, %WM_NCLBUTTONDOWN, %HTCAPTION, %NULL
                       FUNCTION=1
                       EXIT FUNCTION
                  CASE %WM_RBUTTONDOWN
                       DIALOG END CB.HNDL
                  CASE ELSE
             END SELECT
        END FUNCTION
        In the code above, the caption bar and border is removed.
        The label control becomes your caption bar (remove %SS_NOTIFY style so mouse click gets through to dialog) and by processing the WM_LBUTTONDOWN message it sends a fake message to emulate dragging the dialog. A right mouse down on the label will close the dialog.
        Chris Boss
        Computer Workshop
        Developer of "EZGUI"
        http://cwsof.com
        http://twitter.com/EZGUIProGuy

        Comment


        • #5
          Originally posted by Chris Boss View Post
          The label control becomes your caption bar (remove %SS_NOTIFY style so mouse click gets through to dialog) and by processing the WM_LBUTTONDOWN message it sends a fake message to emulate dragging the dialog. A right mouse down on the label will close the dialog.
          That is so cool!

          Though I'm going to need to make a mod, was using a mouse click on the label to send a message to the parent, will have to stick a fake close image into the mix, use left click for move, right click for message to parent.
          Furcadia, an interesting online MMORPG in which you can create and program your own content.

          Comment


          • #6
            Heck with a fake close image when X shows the spot:
            Code:
            %IDL_OPACITYLABEL   = 1002
            %IDSV_OPACITYADJUST = 1001
            %IDL_OPACITYCLOSE   = 1004
            %IDD_SLIDER         = 1003
            
            FUNCTION ShowSLIDER(BYVAL hParent AS DWORD) AS LONG
                LOCAL lRslt  AS LONG
                LOCAL hDlg   AS DWORD
                LOCAL hFont1 AS DWORD
                LOCAL PositionX, PositionY AS LONG
            
                DIALOG NEW PIXELS, hParent, "", 0, 0, 36, 400, %WS_POPUP OR _
                    %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN _
                    OR %WS_VISIBLE OR %DS_SETFOREGROUND OR %DS_NOFAILCREATE, _
                    %WS_EX_TOPMOST, TO _
                    hDlg
            
                DIALOG GET CLIENT hDlg TO PositionX, PositionY
            
                CONTROL ADD LABEL,     hDlg, %IDL_OPACITYLABEL, "255", _
                    0, 0, PositionX - 14, 14, _
                    %WS_CHILD OR %WS_VISIBLE OR %SS_LEFT, _
                    %WS_EX_LEFT OR %WS_EX_LTRREADING
                CONTROL SET COLOR      hDlg, %IDL_OPACITYLABEL, %WHITE, RGB(46, 32, 92)
                CONTROL ADD LABEL,     hDlg, %IDL_OPACITYCLOSE, "X", _
                    PositionX - 14, 0, 14, 14, _
                    %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_NOTIFY, _
                    %WS_EX_LEFT OR %WS_EX_LTRREADING
            
                PositionY = PositionY - 14
            
                CONTROL ADD SCROLLBAR, hDlg, %IDSV_OPACITYADJUST, "Opacity Adjust", _
                    0, 14, PositionX, PositionY, _
                    %WS_CHILD OR %WS_VISIBLE OR %SBS_VERT
                CONTROL SET COLOR      hDlg, %IDSV_OPACITYADJUST, -1, RGB(46, 32, 92)
            
                FONT NEW "MS Sans Serif", 8, 1, 0, 0, 0 TO hFont1
                CONTROL SET FONT hDlg, %IDL_OPACITYLABEL, hFont1
                FONT END hFont1
            
                ShowSlider = hDlg
            END FUNCTION
            
            CALLBACK FUNCTION ShowSLIDERProc()
            LOCAL ScrollX, PositionX, PositionY     AS LONG
            STATIC hParent                          AS DWORD
            
                SELECT CASE AS LONG CB.MSG
                    CASE %WM_INITDIALOG
                        DIALOG SET LOC CB.HNDL, 0, 0
                        WINDOW GET PARENT CB.HNDL TO hParent
                        SCROLLBAR SET RANGE CB.HNDL, %IDSV_OPACITYADJUST, -255, 0
                        SCROLLBAR SET PAGESIZE CB.HNDL, %IDSV_OPACITYADJUST, 1
                        DIALOG SEND hParent, %UM_GETOPACITY, 0, 0 TO ScrollX
                        DECR ScrollX
                        SCROLLBAR SET POS CB.HNDL, %IDSV_OPACITYADJUST, -ScrollX
                        CONTROL SET TEXT CB.HNDL, %IDL_OPACITYLABEL, FORMAT$(ABS(ScrollX))
            
                    CASE %WM_DESTROY
            
                    CASE %WM_NCACTIVATE
                        STATIC hWndSaveFocus AS DWORD
                        IF ISFALSE CB.WPARAM THEN
                            hWndSaveFocus = GetFocus()
                        ELSEIF hWndSaveFocus THEN
                            SetFocus(hWndSaveFocus)
                            hWndSaveFocus = 0
                        END IF
            
                    CASE %WM_VSCROLL
                        SCROLLBAR GET POS CB.HNDL, %IDSV_OPACITYADJUST TO ScrollX
                        SELECT CASE LO(WORD, CB.WPARAM)
                            CASE %SB_LINEUP
                                ScrollX = IIF(ScrollX > -255, ScrollX - 1, ScrollX)
                            CASE %SB_LINEDOWN
                                ScrollX = IIF(ScrollX < 0, ScrollX + 1, ScrollX)
                            CASE %SB_PAGEUP
                                ScrollX = IIF(ScrollX > -246, ScrollX - 10, -255)
                            CASE %SB_PAGEDOWN
                                ScrollX = IIF(ScrollX < -9, ScrollX + 10, 0)
                            CASE %SB_THUMBPOSITION
                                ScrollX = HI(INTEGER, CB.WPARAM)
                            CASE %SB_THUMBTRACK
                                ScrollX = HI(INTEGER, CB.WPARAM)
                        END SELECT
                        SCROLLBAR SET POS CB.HNDL, %IDSV_OPACITYADJUST, ScrollX
                        CONTROL SET TEXT CB.HNDL, %IDL_OPACITYLABEL, FORMAT$(ABS(ScrollX))
                        WINDOW GET PARENT CB.HNDL TO hParent
                        DIALOG POST hParent, %UM_SETOPACITY, ABS(ScrollX), 0
            
                    CASE %UM_SETOPACITY
                        ScrollX = CB.WPARAM
                        SCROLLBAR SET POS CB.HNDL, %IDSV_OPACITYADJUST, -ScrollX
                        CONTROL SET TEXT CB.HNDL, %IDL_OPACITYLABEL, FORMAT$(ScrollX)
            
            
                    CASE %WM_LBUTTONDOWN
                        DIALOG SEND CB.HNDL, %WM_NCLBUTTONDOWN, %HTCAPTION, %NULL
                        FUNCTION = 1
                        EXIT FUNCTION
                    CASE %WM_RBUTTONDOWN
                        SCROLLBAR GET POS CB.HNDL, %IDSV_OPACITYADJUST TO ScrollX
                        DIALOG POST hParent, %UM_SETOPACITY, ABS(ScrollX), 0
            
                    CASE %WM_COMMAND
                        SELECT CASE AS LONG CB.CTL
                            CASE %IDL_OPACITYCLOSE
                                DIALOG END CB.HNDL
                        END SELECT
                END SELECT
            END FUNCTION
            Furcadia, an interesting online MMORPG in which you can create and program your own content.

            Comment


            • #7
              A little tweaking.

              It now sets the label to use the system colors for the caption bar, emulates the red X button and changes the color shade when the dialog loses focus. I also added a flat border (WS_BORDER) to the labels to make them stand out more.

              Code:
              #COMPILE EXE
              #DIM ALL
              #INCLUDE "win32api.inc"
              FUNCTION PBMAIN () AS LONG
                   LOCAL hDlg AS LONG
                   hDlg=ShowSLIDER(0)
                   DIALOG SHOW MODAL hDlg , CALL ShowSLIDERProc
              END FUNCTION
              %UM_SETOPACITY  = %WM_USER +400
              %UM_GETOPACITY  = %WM_USER +401
              %IDL_OPACITYLABEL   = 1002
              %IDSV_OPACITYADJUST = 1001
              %IDL_OPACITYCLOSE   = 1004
              %IDD_SLIDER         = 1003
              FUNCTION ShowSLIDER(BYVAL hParent AS DWORD) AS LONG
                  LOCAL lRslt  AS LONG
                  LOCAL hDlg   AS DWORD
                  LOCAL hFont1 AS DWORD
                  LOCAL PositionX, PositionY AS LONG
                  DIALOG NEW PIXELS, hParent, "", 0, 0, 36, 400, %WS_POPUP OR _
                      %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN _
                      OR %WS_VISIBLE OR %DS_SETFOREGROUND OR %DS_NOFAILCREATE, _
                      %WS_EX_TOPMOST, TO _
                      hDlg
                  DIALOG GET CLIENT hDlg TO PositionX, PositionY
                  CONTROL ADD LABEL,     hDlg, %IDL_OPACITYLABEL, "255", _
                      0, 0, PositionX - 14, 14, _
                      %WS_CHILD OR %WS_VISIBLE OR %SS_LEFT OR %WS_BORDER OR %SS_CENTER, _
                      %WS_EX_LEFT OR %WS_EX_LTRREADING
                  CONTROL SET COLOR      hDlg, %IDL_OPACITYLABEL, GetSysColor(%COLOR_CAPTIONTEXT), GetSysColor(%COLOR_ACTIVECAPTION)
                  CONTROL ADD LABEL,     hDlg, %IDL_OPACITYCLOSE, "X", _
                      PositionX - 14, 0, 14, 14, _
                      %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_NOTIFY OR %WS_BORDER, _
                      %WS_EX_LEFT OR %WS_EX_LTRREADING
                  CONTROL SET COLOR hDlg, %IDL_OPACITYCLOSE, %WHITE, RGB(255,0,0)
                  PositionY = PositionY - 14
                  CONTROL ADD SCROLLBAR, hDlg, %IDSV_OPACITYADJUST, "Opacity Adjust", _
                      0, 14, PositionX, PositionY, _
                      %WS_CHILD OR %WS_VISIBLE OR %SBS_VERT
                  CONTROL SET COLOR      hDlg, %IDSV_OPACITYADJUST, -1, RGB(46, 32, 92)
                  FONT NEW "MS Sans Serif", 8, 1, 0, 0, 0 TO hFont1
                  CONTROL SET FONT hDlg, %IDL_OPACITYLABEL, hFont1
                  FONT END hFont1
                  ShowSlider = hDlg
              END FUNCTION
              CALLBACK FUNCTION ShowSLIDERProc()
              LOCAL ScrollX, PositionX, PositionY     AS LONG
              STATIC hParent                          AS DWORD
                  SELECT CASE AS LONG CB.MSG
                      CASE %WM_INITDIALOG
                          DIALOG SET LOC CB.HNDL, 0, 0
                          WINDOW GET PARENT CB.HNDL TO hParent
                          SCROLLBAR SET RANGE CB.HNDL, %IDSV_OPACITYADJUST, -255, 0
                          SCROLLBAR SET PAGESIZE CB.HNDL, %IDSV_OPACITYADJUST, 1
                          DIALOG SEND hParent, %UM_GETOPACITY, 0, 0 TO ScrollX
                          DECR ScrollX
                          SCROLLBAR SET POS CB.HNDL, %IDSV_OPACITYADJUST, -ScrollX
                          CONTROL SET TEXT CB.HNDL, %IDL_OPACITYLABEL, FORMAT$(ABS(ScrollX))
                      CASE %WM_DESTROY
                      CASE %WM_NCACTIVATE
                          STATIC hWndSaveFocus AS DWORD
                          IF ISFALSE CB.WPARAM THEN
                              hWndSaveFocus = GetFocus()
                              CONTROL SET COLOR CB.HNDL, %IDL_OPACITYLABEL, GetSysColor(%COLOR_CAPTIONTEXT), GetSysColor(%COLOR_INACTIVECAPTION)
                              CONTROL REDRAW CB.HNDL, %IDL_OPACITYLABEL
                              CONTROL SET COLOR CB.HNDL, %IDL_OPACITYCLOSE, %WHITE, RGB(255,128,128)
                              CONTROL REDRAW CB.HNDL, %IDL_OPACITYCLOSE
                          ELSEIF hWndSaveFocus THEN
                              SetFocus(hWndSaveFocus)
                              hWndSaveFocus = 0
                              CONTROL SET COLOR CB.HNDL, %IDL_OPACITYLABEL, GetSysColor(%COLOR_CAPTIONTEXT), GetSysColor(%COLOR_ACTIVECAPTION)
                              CONTROL REDRAW CB.HNDL, %IDL_OPACITYLABEL
                              CONTROL SET COLOR CB.HNDL, %IDL_OPACITYCLOSE, %WHITE, RGB(255,0,0)
                              CONTROL REDRAW CB.HNDL, %IDL_OPACITYCLOSE
                          END IF
                      CASE %WM_VSCROLL
                          SCROLLBAR GET POS CB.HNDL, %IDSV_OPACITYADJUST TO ScrollX
                          SELECT CASE LO(WORD, CB.WPARAM)
                              CASE %SB_LINEUP
                                  ScrollX = IIF(ScrollX > -255, ScrollX - 1, ScrollX)
                              CASE %SB_LINEDOWN
                                  ScrollX = IIF(ScrollX < 0, ScrollX + 1, ScrollX)
                              CASE %SB_PAGEUP
                                  ScrollX = IIF(ScrollX > -246, ScrollX - 10, -255)
                              CASE %SB_PAGEDOWN
                                  ScrollX = IIF(ScrollX < -9, ScrollX + 10, 0)
                              CASE %SB_THUMBPOSITION
                                  ScrollX = HI(INTEGER, CB.WPARAM)
                              CASE %SB_THUMBTRACK
                                  ScrollX = HI(INTEGER, CB.WPARAM)
                          END SELECT
                          SCROLLBAR SET POS CB.HNDL, %IDSV_OPACITYADJUST, ScrollX
                          CONTROL SET TEXT CB.HNDL, %IDL_OPACITYLABEL, FORMAT$(ABS(ScrollX))
                          WINDOW GET PARENT CB.HNDL TO hParent
                          DIALOG POST hParent, %UM_SETOPACITY, ABS(ScrollX), 0
                      CASE %UM_SETOPACITY
                          ScrollX = CB.WPARAM
                          SCROLLBAR SET POS CB.HNDL, %IDSV_OPACITYADJUST, -ScrollX
                          CONTROL SET TEXT CB.HNDL, %IDL_OPACITYLABEL, FORMAT$(ScrollX)
              
                      CASE %WM_LBUTTONDOWN
                          DIALOG SEND CB.HNDL, %WM_NCLBUTTONDOWN, %HTCAPTION, %NULL
                          FUNCTION = 1
                          EXIT FUNCTION
                      CASE %WM_RBUTTONDOWN
                          SCROLLBAR GET POS CB.HNDL, %IDSV_OPACITYADJUST TO ScrollX
                          DIALOG POST hParent, %UM_SETOPACITY, ABS(ScrollX), 0
                      CASE %WM_COMMAND
                          SELECT CASE AS LONG CB.CTL
                              CASE %IDL_OPACITYCLOSE
                                  DIALOG END CB.HNDL
                          END SELECT
                  END SELECT
              END FUNCTION
              Chris Boss
              Computer Workshop
              Developer of "EZGUI"
              http://cwsof.com
              http://twitter.com/EZGUIProGuy

              Comment


              • #8
                That's neat, I like the focus action on the "caption" area, and I was looking at the overall design of the dialog and thought it would look a bit better if it had an outline surrounding it, which dovetailed nicely with the idea of putting borders on the labels, only I didn't, I just adjusted the positions of the elements to give the appearance of borders. And put my hFont1 into the "close" label as well. I also set the foreground color to black, I suppose I could dig out the font color for 3D Objects and apply that. And maybe use the Face Color for them as well for the background color of the "close" button.
                Code:
                FUNCTION ShowSLIDER(BYVAL hParent AS DWORD) AS LONG
                    LOCAL lRslt  AS LONG
                    LOCAL hDlg   AS DWORD
                    LOCAL hFont1 AS DWORD
                    LOCAL PositionX, PositionY AS LONG
                
                    DIALOG NEW PIXELS, hParent, "", 0, 0, [B]40, 402[/B], %WS_POPUP OR _
                        %WS_SYSMENU OR %WS_CLIPSIBLINGS OR %WS_CLIPCHILDREN _
                        OR %WS_VISIBLE OR %DS_SETFOREGROUND OR %DS_NOFAILCREATE, _
                        %WS_EX_TOPMOST, TO _
                        hDlg
                
                [B]    DIALOG SET COLOR hDlg, %WHITE, %BLACK
                    DIALOG GET CLIENT hDlg TO PositionX, PositionY
                    PositionX = PositionX - 2
                    PositionY = PositionY - 2[/B]
                
                    CONTROL ADD LABEL,     hDlg, %IDL_OPACITYLABEL, "255", _
                        [B]1, 1, PositionX - 15, 14[/B], _
                        %WS_CHILD OR %WS_VISIBLE OR %SS_LEFT, _
                        %WS_EX_LEFT OR %WS_EX_LTRREADING
                    CONTROL SET COLOR      hDlg, %IDL_OPACITYLABEL, _
                        GetSysColor(%COLOR_CAPTIONTEXT), GetSysColor(%COLOR_ACTIVECAPTION)
                    CONTROL ADD LABEL,     hDlg, %IDL_OPACITYCLOSE, "X", _
                        [B]PositionX - 13, 2, 13, 13[/B], _
                        %WS_CHILD OR %WS_VISIBLE OR %SS_CENTER OR %SS_NOTIFY, _
                        %WS_EX_LEFT OR %WS_EX_LTRREADING
                    CONTROL SET COLOR hDlg, %IDL_OPACITYCLOSE, %BLACK, RGB(255,0,0)
                
                    PositionY = PositionY - 15
                
                    CONTROL ADD SCROLLBAR, hDlg, %IDSV_OPACITYADJUST, "Opacity Adjust", _
                        [B]1, 16, PositionX, PositionY[/B], _
                        %WS_CHILD OR %WS_VISIBLE OR %SBS_VERT
                    CONTROL SET COLOR      hDlg, %IDSV_OPACITYADJUST, -1, RGB(46, 32, 92)
                
                    FONT NEW "MS Sans Serif", 8, 1, 0, 0, 0 TO hFont1
                    CONTROL SET FONT hDlg, %IDL_OPACITYLABEL, hFont1
                    [B]CONTROL SET FONT hDlg, %IDL_OPACITYCLOSE, hFont1[/B]
                    FONT END hFont1
                
                    ShowSlider = hDlg
                END FUNCTION
                Furcadia, an interesting online MMORPG in which you can create and program your own content.

                Comment


                • #9
                  I think one of the Petzold programs lets you change window styles and click a button to see what the screen will look like now. It may be called "widgets" or something like that.

                  If not.... some ambitious person could always write a utility to provide this service...although I would think most of the "visual designer" products would already include some kind of "preview" feature....
                  Michael Mattias
                  Tal Systems (retired)
                  Port Washington WI USA
                  [email protected]
                  http://www.talsystems.com

                  Comment

                  Working...
                  X