Announcement

Collapse
No announcement yet.

background color

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

  • Guest
    Guest replied
    I didn't notice the flicker, Borje, but I was only pressing the scroll lock key and not moving the mouse.

    It looks pretty good although the sb part could be filled in a little better with SB_GETRECT and FillRect(). I had trouble displaying the text while painting.

    thanks,
    Ron

    Leave a comment:


  • Borje Hagsten
    replied
    Made small DDT sample. Not fully pleased with result, but at least it
    shows a way to do it. Maybe someone knows how to reduce/remove flicker?
    Code:
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Test - ownerdrawn status bar. Works, but background flickers a lot.
    ' Maybe better to subclass statusbar and do drawing in WM_PAINT?
    ' Also, seems like text has to be stored in static/globar variable.
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    %NOANIMATE       = 1 ' Eliminate unnecessary macros in COMMCTRL.INC
    %NOBUTTON        = 1
    %NOCOMBO         = 1
    %NODATETIMEPICK  = 1
    %NODRAGLIST      = 1
    %NOEDIT          = 1
    %NOFLATSBAPIS    = 1
    %NOHEADER        = 1
    %NOHOTKEY        = 1
    %NOIMAGELIST     = 1
    %NOIPADDRESS     = 1
    %NOLIST          = 1
    %NOLISTVIEW      = 1
    %NOMONTHCAL      = 1
    %NONATIVEFONTCTL = 1
    %NOPAGESCROLLER  = 1
    %NOPROGRESS      = 1
    %NOREBAR         = 1
    '%NOSTATUSBAR     = 1
    %NOTABCONTROL    = 1
    %NOTOOLBAR       = 1
    %NOTOOLTIPS      = 1
    %NOTRACKBAR      = 1
    %NOTREEVIEW      = 1
    %NOUPDOWN        = 1
     
    #COMPILE EXE
    #INCLUDE "WIN32API.INC"
    #INCLUDE "COMMCTRL.INC"
    DECLARE CALLBACK FUNCTION DlgProc() AS LONG
    %ID_STATUSBAR = 80
    GLOBAL hStatus AS LONG
    GLOBAL zText AS ASCIIZ * 50, zText2 AS ASCIIZ * 50, zText3 AS ASCIIZ * 50, zText4 AS ASCIIZ * 50
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Create dialog and controls, etc
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    FUNCTION PBMAIN () AS LONG
     LOCAL hDlg AS LONG, rc AS RECT
     
      DIALOG NEW 0, "DDT statusbar test",,, 240, 150, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
      CONTROL ADD BUTTON,  hDlg, %IDCANCEL, "&Cancel", 184, 120,  50,  14
     
       '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       'Create the status bar window    TOOLBARWINDOW32
       '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
       CONTROL ADD "msctls_statusbar32", hDlg, %ID_STATUSBAR, "", 0, 0, 0, 0, _
                                         %WS_CHILD OR %WS_VISIBLE ' OR %SBS_SIZEGRIP
     
       CONTROL HANDLE hDlg, %ID_STATUSBAR TO hStatus
       REDIM prts(3) AS LONG
       GetClientRect hDlg, rc
       prts(0) = rc.nRight / 4     : prts(1) = rc.nRight / 4 * 2
       prts(2) = rc.nRight / 4 * 3 : prts(3) = -1
       Sendmessage hStatus, %SB_SETPARTS, 4, VARPTR(prts(0))
       zText = "Part 1"
       SendMessage hStatus, %SB_SETTEXT, 0 OR %SBT_OWNERDRAW, VARPTR(zText)
       zText2 = "Part 2"
       SendMessage hStatus, %SB_SETTEXT, 1 OR %SBT_OWNERDRAW, VARPTR(zText2)
       zText3 = "Part 3"
       SendMessage hStatus, %SB_SETTEXT, 2 OR %SBT_OWNERDRAW, VARPTR(zText3)
       zText4 = "Part 4"
       SendMessage hStatus, %SB_SETTEXT, 3 OR %SBT_OWNERDRAW, VARPTR(zText4)
     
      DIALOG SHOW MODAL hDlg CALL DlgProc
    END FUNCTION
     
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    ' Main callback
    '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
    CALLBACK FUNCTION DlgProc() AS LONG
      SELECT CASE CBMSG
         CASE %WM_INITDIALOG
            LOCAL hBrush AS LONG
     
         CASE %WM_COMMAND
            IF CBCTLMSG = %BN_CLICKED AND CBCTL = %IDCANCEL THEN
               DIALOG END CBHNDL
            END IF
     
         CASE %WM_MOUSEMOVE
             zText = "x=" + FORMAT$(LOWRD(CBLPARAM))
             SendMessage hStatus, %SB_SETTEXT, 0 OR %SBT_OWNERDRAW, VARPTR(zText)
             zText2 = "y=" + FORMAT$(HIWRD(CBLPARAM))
             SendMessage hStatus, %SB_SETTEXT, 1 OR %SBT_OWNERDRAW, VARPTR(zText2)
     
         CASE %WM_DRAWITEM 'Note: can draw small icon/bitmap here to..
            IF CBWPARAM = %ID_STATUSBAR THEN
               LOCAL lpdis AS DRAWITEMSTRUCT PTR, zp AS ASCIIZ PTR
               lpdis = CBLPARAM
     
               'InflateRect @lpdis.rcItem, -1, -1 'test with smaller rect for "better" look
               DECR @lpdis.rcItem.nRight          'or maybe this is better..?
               DECR @lpdis.rcItem.nBottom
     
               IF @lpdis.itemID = 0 THEN              'FIRST STATUSBAR PART
                  hBrush = CreateSolidBrush(RGB(239,207,0))   'hm, backgrounds flickers..
                  FillRect @lpdis.hDC, @lpdis.rcItem, hBrush
                  SetBkColor @lpdis.hDC, RGB(239,207,0)
                  SetTextColor @lpdis.hDC, RGB(0,0,255)
                  DeleteObject hBrush
               ELSEIF @lpdis.itemID = 1 THEN          'SECOND, ETC..
                  FillRect @lpdis.hDC, @lpdis.rcItem, GetSysColorBrush(%COLOR_3DFACE)
                  SetBkColor @lpdis.hDC, GetSysColor(%COLOR_3DFACE)
                  SetTextColor @lpdis.hDC, GetSysColor(%COLOR_WINDOWTEXT)
               ELSEIF @lpdis.itemID = 2 THEN
                  FillRect @lpdis.hDC, @lpdis.rcItem, GetSysColorBrush(%COLOR_WINDOW)
                  SetBkColor @lpdis.hDC, GetSysColor(%COLOR_WINDOW)
                  SetTextColor @lpdis.hDC, RGB(255,0,0)
               ELSEIF @lpdis.itemID = 3 THEN
                  FillRect @lpdis.hDC, @lpdis.rcItem, GetSysColorBrush(%COLOR_WINDOW)
                  SetBkColor @lpdis.hDC, GetSysColor(%COLOR_WINDOW)
                  SetTextColor @lpdis.hDC, RGB(255,0,255)
               END IF
     
               zp = @lpdis.itemData
               DrawText @lpdis.hDC, @zp, LEN(@zp), @lpdis.rcItem, %DT_CENTER OR %DT_SINGLELINE OR %DT_VCENTER
               FUNCTION = 1 : EXIT FUNCTION
            END IF
     
      END SELECT
    END FUNCTION

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

    Leave a comment:


  • Guest
    Guest replied
    Borje, thank you very much!

    I will let you know how it goes.
    Ron

    Leave a comment:


  • Borje Hagsten
    replied
    Did a quick test in PBnote sample and following works. Needs more work,
    but can at least show way to do it.
    Code:
        CASE %WM_MENUSELECT
          LoadString hInst, wParam, zText, SIZEOF(zText)
          SendMessage hStatus, %SB_SETTEXT, 0 OR %SBT_OWNERDRAW, VARPTR(zText) '0 OR - 0 is part, can be 1, 2..
          FUNCTION = 0 : EXIT FUNCTION
     
         CASE %WM_DRAWITEM
            IF wParam = 200 THEN
               LOCAL lpdis AS DRAWITEMSTRUCT PTR, zp AS ASCIIZ PTR
               lpdis = lParam
     
               FillRect @lpdis.hDC, @lpdis.rcItem, GetSysColorBrush(%COLOR_INFOBK)
               SetBkColor @lpdis.hDC, GetSysColor(%COLOR_INFOBK)
               SetTextColor @lpdis.hDC, GetSysColor(%COLOR_WINDOWTEXT)
               zp = @lpdis.itemData
               DrawText @lpdis.hDC, @zp, LEN(@zp), @lpdis.rcItem, %DT_LEFT OR %DT_SINGLELINE OR %DT_VCENTER
               FUNCTION = 1 : EXIT FUNCTION
            END IF
    ------------------
    Forgot part in %SB_SETTEXT message - now added..


    [This message has been edited by Borje Hagsten (edited October 18, 2001).]

    Leave a comment:


  • Borje Hagsten
    replied
    Can send SB_SETTEXT with SBT_OWNERDRAW to make a part ownerdrawn and then
    trap WM_DRAWITEM in parent, where FillRect and TextOut can paint background
    and text. MS touches it briefly in "Owner-Drawn Status Windows", in win32.hlp.

    Never had need to do it myself, so no sample on that, but there are some for
    handling WM_DRAWITEM in other ownerdrawn controls in source code forum.
    Should not be big difference, I think.


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

    Leave a comment:


  • Guest
    Guest started a topic background color

    background color

    I have a StatusWindow on an app with several parts (panels). I want to use the last panel to store the status of the Scroll Lock key. What i want to accomplish is the ability to change the background and foreground colors of that single panel every time the scroll lock key is pressed. I have created a progress bar with a StatusWindow and painted that successfully. I want the text to remain if possible. Is this doable? I think i have been up too long today.

    Thanks for any help,
    Ron
Working...
X
😀
🥰
🤢
😎
😡
👍
👎