Announcement

Collapse
No announcement yet.

SysDateTimePick32 CONTROL CHANGE COLOR

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

  • #21
    Have you tried
    SysDateTimePick32? Your example uses
    SysMonthCal32.
    Try this:



    Code:
    #COMPILE EXE '#Win 9.07#
    #DIM ALL
    #INCLUDE "Win32Api.inc"
    #INCLUDE "CommCtrl.inc"
    
    '#RESOURCE "D:\Basic\Bas\~~PbrDefault00.pbr" 'Need a manifest for CommonControl_6
    #RESOURCE MANIFEST, 1, "XPTheme.xml"
    
    GLOBAL hDlg AS DWORD
    
    %Calendar      = 101
    %OptionTheme   = 201
    %OptionNoTheme = 202
    
    'For ANSI
    'DECLARE FUNCTION SetWindowTheme LIB "UxTheme.dll" ALIAS "SetWindowTheme" _
    '(BYVAL hwnd AS DWORD, pszSubAppName AS ASCIIZ, pszSubIdList AS ASCIIZ) AS LONG
    
    DECLARE FUNCTION SetWindowTheme LIB "UxTheme.dll" ALIAS "SetWindowTheme" _
    (BYVAL hwnd AS DWORD, pszSubAppName AS WSTRINGZ, pszSubIdList AS WSTRINGZ) AS LONG
    '______________________________________________________________________________
    
    CALLBACK FUNCTION MainCallback()
    STATIC hCalendar AS DWORD
    
     SELECT CASE CBMSG
    
       CASE %WM_INITDIALOG
    hCalendar = GetDlgItem(CBHNDL, %Calendar)
    'MSDN: When visual styles are enabled, this message has no effect except when wParam is MCSC_BACKGROUND.
    PostMessage(hCalendar, %MCM_SETCOLOR, %MCSC_BACKGROUND, %RGB_DARKGREEN )
    PostMessage(hCalendar, %MCM_SETCOLOR, %MCSC_MONTHBK, %RGB_PAPAYAWHIP )
    PostMessage(hCalendar, %MCM_SETCOLOR, %MCSC_TITLETEXT, %RGB_DARKSLATEBLUE)
    PostMessage(hCalendar, %MCM_SETCOLOR, %MCSC_TEXT, %RGB_MAROON)
    PostMessage(hCalendar, %MCM_SETCOLOR, %MCSC_TRAILINGTEXT, %RGB_CHOCOLATE )
    
    CASE %WM_COMMAND
         SELECT CASE CBCTL
           CASE %OptionTheme
    IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
    SetWindowTheme(hCalendar, "", "") 'Put back the theme
    END IF
           CASE %OptionNoTheme
    IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
    SetWindowTheme(hCalendar, $SPC, $SPC) 'Remove the theme
    END IF
         END SELECT
    
     END SELECT
    
    END FUNCTION
    '______________________________________________________________________________
    
    FUNCTION PBMAIN()
    LOCAL hIcon AS DWORD
    
     DIALOG FONT "Segoe UI", 9
    DIALOG NEW %HWND_DESKTOP, "Calendar", , , 150, 130, _
     %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_SIZEBOX OR %WS_SYSMENU, 0 TO hDlg
     hIcon = ExtractIcon(GetModuleHandle(""), "%SystemRoot%\system32\PowrProf.dll", 1)
    SetClassLong(hDlg, %GCL_HICON, hIcon)
    
    CONTROL ADD "SysDateTimePick32", hDlg, %Calendar, "", 5, 20, 140, 105, _
     %WS_CHILD OR %WS_VISIBLE OR %WS_BORDER OR %WS_TABSTOP, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING
    
     CONTROL ADD OPTION, hDlg, %OptionTheme, "Themed", 5, 5, 50, 12
    CONTROL ADD OPTION, hDlg, %OptionNoTheme, "Not themed", 70, 5, 80, 12
    CONTROL SET OPTION hDlg, %OptionTheme, %OptionTheme, %OptionNoTheme
    
    DIALOG SHOW MODAL hDlg, CALL MainCallback
    
     DestroyIcon(hIcon)
    
    END FUNCTION
    '______________________________________________________________________________
    '
    
    Perhaps you can see what I'm talking about now.

    Comment


    • #22
      I say again,
      So this is what I gather so far about the
      SysDateTimePick32:
      1) Emanuele was completely right that he could not change the look of that control when a manifest was applied.
      2) When a manifest is applied it cannot reasonably be turned off completely.
      3) The integer values are matching between the include files.
      4) The control options/functionality described by MSDN do not match user experience.



      Conclusion:
      Something is way out of scope here. I guess we are on our own if we plan on using a manifest.

      Comment


      • #23
        This is a modification of your app to show exactly what I'm seeing:


        Code:
        #COMPILE EXE '#Win 9.07#
        #DIM ALL
        #INCLUDE "Win32Api.inc"
        #INCLUDE "CommCtrl.inc"
        
        '#RESOURCE "D:\Basic\Bas\~~PbrDefault00.pbr" 'Need a manifest for CommonControl_6
        #RESOURCE MANIFEST, 1, "XPTheme.xml"
        
        GLOBAL hDlg AS DWORD
        
        %Calendar      = 101
        %OptionTheme   = 201
        %OptionNoTheme = 202
        
        'For ANSI
        'DECLARE FUNCTION SetWindowTheme LIB "UxTheme.dll" ALIAS "SetWindowTheme" _
        '(BYVAL hwnd AS DWORD, pszSubAppName AS ASCIIZ, pszSubIdList AS ASCIIZ) AS LONG
        
        DECLARE FUNCTION SetWindowTheme LIB "UxTheme.dll" ALIAS "SetWindowTheme" _
        (BYVAL hwnd AS DWORD, pszSubAppName AS WSTRINGZ, pszSubIdList AS WSTRINGZ) AS LONG
        '______________________________________________________________________________
        
        CALLBACK FUNCTION MainCallback()
         STATIC hCalendar AS DWORD
        
         SELECT CASE CBMSG
        
           CASE %WM_INITDIALOG
             'hCalendar = GetDlgItem(CBHNDL, %Calendar)
             'MSDN: When visual styles are enabled, this message has no effect except when wParam is MCSC_BACKGROUND.
             'PostMessage(hCalendar, %MCM_SETCOLOR, %MCSC_BACKGROUND, %RGB_DARKGREEN )
             'PostMessage(hCalendar, %MCM_SETCOLOR, %MCSC_MONTHBK, %red) '%RGB_PAPAYAWHIP )
             'PostMessage(hCalendar, %MCM_SETCOLOR, %MCSC_TITLETEXT, %RGB_DARKSLATEBLUE)
             'PostMessage(hCalendar, %MCM_SETCOLOR, %MCSC_TEXT, %RGB_MAROON)
             'PostMessage(hCalendar, %MCM_SETCOLOR, %MCSC_TRAILINGTEXT, %RGB_CHOCOLATE )
        
           'CASE %WM_COMMAND
           '  SELECT CASE CBCTL
           '    CASE %OptionTheme
           '      IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
           '        SetWindowTheme(hCalendar, """", """") 'Put back the theme
           '      END IF
           '    CASE %OptionNoTheme
           '      IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
           '        SetWindowTheme(hCalendar, $$SPC, $$SPC) 'Remove the theme
           '      END IF
           '  END SELECT
        
         END SELECT
        
        END FUNCTION
        '______________________________________________________________________________
        
        FUNCTION PBMAIN()
         LOCAL hIcon AS DWORD
        
         DIALOG FONT "Segoe UI", 9
         DIALOG NEW %HWND_DESKTOP, "Calendar", , , 173, 148, _ 150, 130, _
         %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_SIZEBOX OR %WS_SYSMENU, 0 TO hDlg
         hIcon = ExtractIcon(GetModuleHandle(""), "%SystemRoot%\system32\PowrProf.dll", 1)
         SetClassLong(hDlg, %GCL_HICON, hIcon)
        
         CONTROL ADD "SysDateTimePick32", hDlg, %Calendar, "", 10, 18, 148, 95, _ '5, 20, 140, 105, _
         %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING
        
         DisableXPThemeControl GetDlgItem(hDlg, %Calendar)
        
         CONTROL SEND hDlg, %Calendar, %DTM_SETMCCOLOR, %MCSC_BACKGROUND, %RGB_DARKGREEN
         CONTROL SEND hDlg, %Calendar, %DTM_SETMCCOLOR, %MCSC_MONTHBK, %RED '%RGB_PAPAYAWHIP
         CONTROL SEND hDlg, %Calendar, %DTM_SETMCCOLOR, %MCSC_TITLETEXT, %RGB_DARKSLATEBLUE
         CONTROL SEND hDlg, %Calendar, %DTM_SETMCCOLOR, %MCSC_TEXT, %RGB_MAROON
         CONTROL SEND hDlg, %Calendar, %DTM_SETMCCOLOR, %MCSC_TRAILINGTEXT, %RGB_CHOCOLATE
        
         'CONTROL ADD OPTION, hDlg, %OptionTheme, "Themed", 5, 5, 50, 12
         'CONTROL ADD OPTION, hDlg, %OptionNoTheme, "Not themed", 70, 5, 80, 12
         'CONTROL SET OPTION hDlg, %OptionTheme, %OptionTheme, %OptionNoTheme
        
         DIALOG SHOW MODAL hDlg, CALL MainCallback
        
         DestroyIcon(hIcon)
        
        END FUNCTION
        '______________________________________________________________________________
        '
        '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
        'Purpose: by calling SetWindowTheme with an empty string your control
        '         (button/checkbox/combo etc) will not be painted with the XP Theme.
        '         From Jules Marchildon.
        '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        FUNCTION DisableXPThemeControl(BYVAL hControl AS DWORD) AS LONG
           LOCAL hLib, pProc AS DWORD
           LOCAL lRes AS LONG
           hLib = LoadLibrary("UxTheme.dll")
           IF hLib THEN
              pProc = GetProcAddress(hLib, "SetWindowTheme")
              IF pProc THEN
                 CALL DWORD pProc USING SetWindowTheme(hControl, " ", " ")  TO lRes
                 FUNCTION = lRes
              END IF
              FreeLibrary hLib
           END IF
        END FUNCTION
                                                   

        Comment


        • #24
          This example turns off Theming and sets various colours for the Drop Down Calendar part of a DateTimePicker..
          Code:
          #Compile Exe                ' PBWin10
          #Dim All
          #Include "win32api.inc"
          #Include "UxTheme.inc"
          #Include "CommCtrl.inc"
          #Resource Manifest, 1, "C:\PBWin10\samples\DDT\Address\XPTheme.xml"
          
          %IDC_SDTP  = 101
          %IDC_Label = 100
          '------------------/
          
          CallBack Function DlgProc
            Local SelectedDateVariable$
            Select Case CbMsg
              Case %WM_InitDialog
          
              Case %WM_Notify
                Select Case Long Cb.NmCode
                  Case %DTN_Dropdown
                    Local hCal As Dword
                      hCal = SendMessage(Cb.NmHwnd, %DTM_GetMonthCal, 0, 0)   ' get handle for calendar
                      SetWindowTheme(hCal, " ", " ")                          ' Disable Themeing
                      PostMessage(hCal, %MCM_SETCOLOR, %MCSC_TEXT, %Blue)
                      PostMessage(hCal, %MCM_SETCOLOR, %MCSC_TITLEBK, %Blue)
                      PostMessage(hCal, %MCM_SETCOLOR, %MCSC_TRAILINGTEXT, %Blue)
                      PostMessage(hCal, %MCM_SETCOLOR, %MCSC_MONTHBK, %Yellow)
                      PostMessage(hCal, %MCM_SETCOLOR, %MCSC_TITLETEXT, %Yellow)
                      PostMessage(hCal, %MCM_SETCOLOR, %MCSC_BACKGROUND, %Yellow)
                  Case %DTN_Closeup
                    Control Get Text Cb.Hndl, %IDC_SDTP To SelectedDateVariable
                    Control Set Text Cb.Hndl, %IDC_Label, "Text: " & SelectedDateVariable
                End Select
            End Select
          End Function
          '------------------/
          
          Function PBMain ()
           Local hDlg As Dword
          
            Dialog New 0, "Select a date please:", , , 200, 150, %WS_Caption Or %WS_SysMenu, 0 To hDlg
              Control Add "SysDateTimePick32", hDlg, %IDC_SDTP, "", 25, 10, 130, 15, _
                          %WS_Child Or %WS_Visible Or %WS_TabStop Or %DTS_SHORTDATEFORMAT
              Control Add Label, hDlg, %IDC_Label, "Text: ", 25, 40, 115,12
            Dialog Show Modal hDlg Call DlgProc
          End Function
          '------------------/PBMain
          You might prefer a different color scheme!
          Rgds, Dave

          Comment


          • #25
            Wow Dave!
            That did it. Thanks you so much.

            So it appears that you have to use PostMessage instead of Control Send and Disable the theme just before the SysDateTimePick32 is displayed.


            Code:
            '------------------------------------------------------------------------------
            ' Metastatements
            '------------------------------------------------------------------------------
            #COMPILE EXE
            #DIM ALL
            #RESOURCE MANIFEST, 1, "XPTheme.xml"
            
            '------------------------------------------------------------------------------
            ' Include files
            '------------------------------------------------------------------------------
            #INCLUDE ONCE "Win32API.inc"
            #INCLUDE ONCE "InitCtrl.inc"
            
            '------------------------------------------------------------------------------
            ' Equates
            '------------------------------------------------------------------------------
            %IDC_SDTP  = 101
            %IDC_Label = 100
            
            DECLARE FUNCTION SetWindowTheme LIB "UxTheme.dll" ALIAS "SetWindowTheme" _
            (BYVAL hwnd AS DWORD, pszSubAppName AS WSTRINGZ, pszSubIdList AS WSTRINGZ) AS LONG
            
            
            CALLBACK FUNCTION DlgProc
              LOCAL SelectedDateVariable$
              SELECT CASE CBMSG
                CASE %WM_INITDIALOG
            
                CASE %WM_NOTIFY
                  SELECT CASE LONG CB.NMCODE
                    CASE %DTN_Dropdown
                      LOCAL hCal AS DWORD
                        hCal = SendMessage(CB.NMHWND, %DTM_GetMonthCal, 0, 0)   ' get handle for calendar
                        'SetWindowTheme(hCal, " ", " ")                          ' Disable Themeing
                        DisableXPThemeControl hCal
                        PostMessage(hCal, %MCM_SETCOLOR, %MCSC_TEXT, %RGB_MAROON)
                        PostMessage(hCal, %MCM_SETCOLOR, %MCSC_TITLEBK, %RGB_CYAN)
                        PostMessage(hCal, %MCM_SETCOLOR, %MCSC_TRAILINGTEXT, %RGB_CHOCOLATE)
                        PostMessage(hCal, %MCM_SETCOLOR, %MCSC_MONTHBK, %RGB_PAPAYAWHIP)
                        PostMessage(hCal, %MCM_SETCOLOR, %MCSC_TITLETEXT, %BLACK) '%RGB_DARKSLATEBLUE)
                        PostMessage(hCal, %MCM_SETCOLOR, %MCSC_BACKGROUND, %RGB_LIGHTCYAN)
                    CASE %DTN_Closeup
                      CONTROL GET TEXT CB.HNDL, %IDC_SDTP TO SelectedDateVariable
                      CONTROL SET TEXT CB.HNDL, %IDC_Label, "Text: " & SelectedDateVariable
                  END SELECT
              END SELECT
            END FUNCTION
            '------------------/
            
            FUNCTION PBMAIN ()
             LOCAL hDlg AS DWORD
            
              DIALOG NEW 0, "Select a date please:", , , 200, 150, %WS_CAPTION OR %WS_SYSMENU, 0 TO hDlg
                CONTROL ADD "SysDateTimePick32", hDlg, %IDC_SDTP, "", 25, 10, 130, 15, _
                            %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR %DTS_SHORTDATEFORMAT
                CONTROL ADD LABEL, hDlg, %IDC_Label, "Text: ", 25, 40, 115,12
              DIALOG SHOW MODAL hDlg CALL DlgProc
            END FUNCTION
            '------------------/PBMain
            
            '¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤
            'Purpose: by calling SetWindowTheme with an empty string your control
            '         (button/checkbox/combo etc) will not be painted with the XP Theme.
            '         From Jules Marchildon.
            '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
            FUNCTION DisableXPThemeControl(BYVAL hControl AS DWORD) AS LONG
               LOCAL hLib, pProc AS DWORD
               LOCAL lRes AS LONG
               hLib = LoadLibrary("UxTheme.dll")
               IF hLib THEN
                  pProc = GetProcAddress(hLib, "SetWindowTheme")
                  IF pProc THEN
                     CALL DWORD pProc USING SetWindowTheme(hControl, " ", " ")  TO lRes
                     FUNCTION = lRes
                  END IF
                  FreeLibrary hLib
               END IF
            END FUNCTION
                                                      

            Comment


            • #26
              Hi Jim,
              SysDateTimePick32 and SysMonthCal32 are not the same.
              As you can see SysDateTimePick32 will call SysMonthCal32.
              The colours of the calendar are what we want, not the colour of the picker.

              In your 11.19pm example you send MCM_SETCOLOR to a SysDateTimePick32, DTM_SETMCCOLOR is not the same as MCM_SETCOLOR. 4106 vs 4102.
              You send those messages to the Picker handle, not the calendar handle.
              So the code as posted is unusable and can't be referenced as is.

              In your 12:05 AM example you disable the Picker theme, not the calendar theme.
              So again, this code is unusable as is for the demonstration.

              With Dave's code I think you got the difference between SysDateTimePick32 and SysMonthCal32.

              For the record:
              Emanuele was completely right that he could not change the look of that control when a manifest was applied.
              I hope we can now agree it can be changed when the theme is disabled.

              When a manifest is applied it cannot reasonably be turned off completely.
              The control options/functionality described by MSDN do not match user experience.

              Again, MSDN say: If visual styles are active, this message has no effect except when wParam is MCSC_BACKGROUND.
              So this goes exactly with what I see...

              So it appears that you have to use PostMessage instead of Control Send
              Both Sendmessage and PostMessage could be used. Control Send could be used to with a valid handle and control id.
              The thing is you have to send it to the calendar, not the picker.

              Here is another one using a Picker this time...

              Click image for larger version  Name:	Themes3.png Views:	1 Size:	37.2 KB ID:	774947

              Code:
              #COMPILE EXE
              #DIM ALL
              #INCLUDE "Win32Api.inc"
              #INCLUDE "CommCtrl.inc"
              
              '#RESOURCE ".pbr" 'Need a manifest for CommonControl_6
              #RESOURCE MANIFEST, 1, "XPTheme.xml"
              
              GLOBAL hDlg AS DWORD
              
              %Picker        = 101
              %Calendar      = 102
              %OptionTheme   = 201
              %OptionNoTheme = 202
              %Label         = 301
              
              'ANSI
              'DECLARE FUNCTION SetWindowTheme LIB "UxTheme.dll" ALIAS "SetWindowTheme" _
              '(BYVAL hwnd AS DWORD, pszSubAppName AS ASCIIZ, pszSubIdList AS ASCIIZ) AS LONG
              
              DECLARE FUNCTION SetWindowTheme LIB "UxTheme.dll" ALIAS "SetWindowTheme" _
              (BYVAL hwnd AS DWORD, pszSubAppName AS WSTRINGZ, pszSubIdList AS WSTRINGZ) AS LONG
              '______________________________________________________________________________
              
              THREAD FUNCTION FunctionThread(BYVAL hDlg AS DWORD) AS LONG
               LOCAL  PickerInfo AS DATETIMEPICKERINFO
              
               DO
                 PickerInfo.cbSize = SIZEOF(DATETIMEPICKERINFO)
                 SendDlgItemMessage(hDlg, %Picker, %DTM_GETDATETIMEPICKERINFO, BYVAL 0, VARPTR(PickerInfo))
                 CONTROL SET TEXT hDlg, %Label, "hDrop 0x"     & HEX$(PickerInfo.hwndDropDown)    & $CRLF & _
                                                "hwndEdit 0x"  & HEX$(PickerInfo.hwndEdit)        & $CRLF & _
                                                "hwndUD 0x"    & HEX$(PickerInfo.hwndUD)          & $CRLF & _
                                                "Button "      & HEX$(PickerInfo.stateButton, 8)  & $CRLF & _
                                                "stateCheck "  & HEX$(PickerInfo.stateCheck)      & $CRLF & _
                                                "stateButton " & HEX$(PickerInfo.stateButton)     & $CRLF & _
                                                "rcButton "    & STR$(PickerInfo.rcButton. nLeft) & STR$(PickerInfo.rcButton. nRight)  & _
                                                                 STR$(PickerInfo.rcButton. nTop)  & STR$(PickerInfo.rcButton. nBottom) & $CRLF & _
                                                "rcCheck "     & STR$(PickerInfo.rcCheck. nLeft)  & STR$(PickerInfo.rcCheck. nRight)   & _
                                                                 STR$(PickerInfo.rcCheck. nTop)   & STR$(PickerInfo.rcCheck. nBottom)  & $CRLF
                         'DWORD cbSize;
                         'RECT  rcCheck;      'RECT of checkbox. If a checkbox is displayed and checked, an edit control should be available to update the selected date-time value.
                         'DWORD stateCheck;   'rcCheck status like STATE_SYSTEM_CHECKED or STATE_SYSTEM_INVISIBLE
                         'RECT  rcButton;     'Drop down grid or up/down control rect
                         'DWORD stateButton;  'Bit: STATE_SYSTEM_UNAVAILABLE, STATE_SYSTEM_INVISIBLE, or STATE_SYSTEM_PRESSED. STATE_SYSTEM_INVISIBLE if up/down control in use.
                         'HWND  hwndEdit;     'A handle to the edit control. For information see, Edit Controls.
                         'HWND  hwndUD;       'Handle to the up/down control an alternative to using the drop-down grid (looks like month calendar control)
                         'HWND  hwndDropDown; 'A handle to the drop-down grid.
                 SLEEP 200
                 IF IsWindow(hDlg) = 0 THEN EXIT DO
               LOOP
              
              END FUNCTION
              
              '______________________________________________________________________________
              
              CALLBACK FUNCTION MainCallback()
               LOCAL  PickerInfo AS DATETIMEPICKERINFO
               STATIC hPicker    AS DWORD
               STATIC hCalendar  AS DWORD
               STATIC hThread    AS DWORD
              
               SELECT CASE CBMSG
              
                  CASE %WM_INITDIALOG
                    hPicker = GetDlgItem(hDlg, %Picker)
                    THREAD CREATE FunctionThread(CBHNDL) TO hThread
              
                  CASE %WM_NOTIFY
                    SELECT CASE LONG CBNMCODE
              
                      CASE %DTN_DROPDOWN
                        hCalendar = SendMessage(GetDlgItem(hDlg, %Picker), %DTM_GETMONTHCAL, 0, 0)
                        SetWindowLong(hCalendar, %GWL_STYLE, GetWindowLong(hCalendar, %GWL_STYLE) OR %MCS_NOTODAY)
                        IF IsDlgButtonChecked(hDlg, %OptionNoTheme) THEN
                          SetWindowTheme(hCalendar, " ", " ") 'Remove the theme
                        ELSE
                          SetWindowTheme(hPicker, "", "") 'Put back the theme
                        END IF
                        SendMessage(hCalendar, %MCM_SETCOLOR, %MCSC_TEXT, %RGB_MAROON)
                        SendMessage(hCalendar, %MCM_SETCOLOR, %MCSC_TITLEBK, %RGB_CYAN)
                        SendMessage(hCalendar, %MCM_SETCOLOR, %MCSC_TRAILINGTEXT, %RGB_CHOCOLATE)
                        SendMessage(hCalendar, %MCM_SETCOLOR, %MCSC_MONTHBK, %RGB_PAPAYAWHIP)
                        SendMessage(hCalendar, %MCM_SETCOLOR, %MCSC_TITLETEXT, %BLACK)
                        SendMessage(hCalendar, %MCM_SETCOLOR, %MCSC_BACKGROUND, %RGB_LIGHTCYAN)
              
                        PickerInfo.cbSize = SIZEOF(DATETIMEPICKERINFO)
                        SendMessage(hPicker, %DTM_GETDATETIMEPICKERINFO, BYVAL 0, VARPTR(PickerInfo))
                   END SELECT
              
                 CASE %WM_COMMAND
                   SELECT CASE CBCTL
                     CASE %OptionTheme
                       IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                          SetWindowTheme(hPicker, "", "") 'Put back the theme
                       END IF
                     CASE %OptionNoTheme
                       IF CBCTLMSG = %BN_CLICKED OR CBCTLMSG = 1 THEN
                         SetWindowTheme(hPicker, " ", " ") 'Remove the theme
                         PickerInfo.cbSize = SIZEOF(DATETIMEPICKERINFO) '+ 12 '56
                         SendMessage(hPicker, %DTM_GETDATETIMEPICKERINFO, BYVAL 0, VARPTR(PickerInfo))
                       END IF
                   END SELECT
              
               END SELECT
              
              END FUNCTION
              '______________________________________________________________________________
              
              FUNCTION PBMAIN()
               LOCAL hIcon AS DWORD
              
               DIALOG FONT "Segoe UI", 9
               DIALOG NEW %HWND_DESKTOP, "Calendar", , , 220, 150, _
               %WS_CAPTION OR %WS_MINIMIZEBOX OR %WS_SIZEBOX OR %WS_SYSMENU, 0 TO hDlg
               hIcon = ExtractIcon(GetModuleHandle(""), "%SystemRoot%\system32\PowrProf.dll", 1)
               SetClassLong(hDlg, %GCL_HICON, hIcon)
              
               CONTROL ADD "SysDateTimePick32", hDlg, %Picker, "", 10, 18, 60, 13, _
               %WS_CHILD OR %WS_VISIBLE OR %WS_TABSTOP OR _
               _ %DTS_RIGHTALIGN OR _  'Put a "_ " in front of line to bypass this style
               %DTS_APPCANPARSE OR _   'Put a "_ " in front of line to bypass this style
               _ %DTS_UPDOWN      OR _ 'Put a "_ " in front of line to bypass this style
               %DTS_SHOWNONE    OR _   'Put a "_ " in front of line to bypass this style
               0, %WS_EX_CLIENTEDGE OR %WS_EX_LEFT OR %WS_EX_LTRREADING
               'CONTROL SET COLOR hDlg,  %Picker, %RED, %RED
              
               CONTROL ADD OPTION, hDlg, %OptionTheme, "Themed", 5, 5, 50, 12
               CONTROL ADD OPTION, hDlg, %OptionNoTheme, "Not themed", 70, 5, 80, 12
               CONTROL SET OPTION hDlg, %OptionTheme, %OptionTheme, %OptionNoTheme
              
               CONTROL ADD LABEL, hDlg, %Label, "Calendar", 145, 30, 200, 100, %SS_LEFT OR %SS_NOPREFIX OR %SS_NOTIFY , %WS_EX_LEFT
              
               DIALOG SHOW MODAL hDlg, CALL MainCallback
              
               DestroyIcon(hIcon)
              
              END FUNCTION
              '______________________________________________________________________________
              '
              Last edited by Pierre Bellisle; 17 Sep 2018, 07:12 PM.

              Comment


              • #27
                Hey, Pierre incase you missed it the OP name is... SysDateTimePick32 CONTROL CHANGE COLOR.
                For some reason you were stuck on SysMonthCal32. Not to worry I think we have beat this dead horse in the ground. Hopefully Emanuele will appreciate all the hard work that's been going on here. Yes, you are perfectly correct I was sending the CONTROL SEND commands to the picker not the calender. I was just not thinking there was a difference. Dave helped me out there. At least, I appreciate you guys. Live long and prosper. Drop microphone....

                Comment


                • #28
                  Nope, I did not miss it in any way,
                  I do not think Emanuele wanted to change the colours of this...
                  Click image for larger version

Name:	Themes3.png
Views:	1
Size:	1.1 KB
ID:	774904
                  but the calendar that come with it, that make sense to me.

                  On the other hand, you missed many things in your previous posts.
                  I don't to start an endless argumentation nor being impolite.
                  But it's hard not to ignore code that is supposed to be a modification of mine and send wrong messages to wrong handles.

                  In any case, I will leave you with this.
                  I'm not a big fan of those "No matter what, I'm always right" kind of games.

                  Take care

                  Comment


                  • #29
                    Sorry, about the way It sounded. Not intended. You are a great wizard. I was merely trying to work through the problem as I typically do and document what I was noticing and asking for help since I was just not seeing what I was doing wrong. I guess PBWIN is in sore need of an update for the sample code to provide more options for color changes. Thanks everyone. See ya

                    P.S. FYI
                    Your post #15
                    CONTROL ADD "SysMonthCal32"
                    Your post #20
                    In the case of a "SysMonthCal32"

                    Note:
                    My modification of your code was to show what I was seeing and to switch it from SysMonthCal32 to SysDateTimePick32. I should have posted the code I was using back in #12 and indicated it was a datetimepicker since my example image was cropped very tightly. Sorry my bad.


                    Your expertise is very important to me. Thank you

                    Comment


                    • #30
                      First of all, thank you all for the time you have dedicated to my problem.
                      Now I have clearer ideas, about things that were completely unknown to me.
                      I still can not change the color of the Edit window of the "SysDateTimePick32" control.
                      I tried to send the message% DTM_GETDATETIMEPICKERINFO, to get the handle from the edit control from the structure, which should be returned in the .hwndEdit member of the DATETIMEPICKERINFO structure, but always returns 0.
                      What I want to do is change the appearance of the edit control as well as the calendar.

                      Click image for larger version

Name:	Themes3.png
Views:	1
Size:	1.1 KB
ID:	774904

                      Thanks again for your effort.

                      Comment


                      • #31
                        Hey Emanuele,
                        Perhaps you will need to do that part OwnerDrawn. I have not checked to see if that control qualifies. At least it's something to entertain.

                        Comment


                        • #32
                          Jim,
                          Seems that Emanuele wanted to change the picker color also,
                          my asumpsion was wrong, my apology, you where right on this part.

                          Comment


                          • #33
                            Emanuele,
                            You got many colours option for the calendar sub control of the picker.
                            Note that the calendar will be created and destroyed on demand from the picker,
                            you got to wait the right time to send messages.

                            On the picker side, it is easy to remove the theme as showed in the updated code above.
                            There is no owner draw for it.
                            There is no implementation of any sort from Microsoft to change the picker colour.
                            What you call the edit is not always an edit, it may change from the context the control is in.
                            Try the code above and click on various part to see what I mean.

                            Comment


                            • #34
                              Or, just get the job done, and you need color. Use 3 IMGBUTTONXs, 2 TEXTBOXs and a calendar. The IMGBUTTONXs are because regular buttons also don't take coloring easily. Make 2 "down arrow" images one square, one half as high to keep the amount of stretch the same horizontally and vertically, and one half height "up arrow". Color the arrows and background as you want and put in as #RESOURCE BITMAPs.

                              ((personally, I do not prefer the calendar control, I use two COMBOBOXes (day, month) and a TEXTBOX (year))).

                              Learning to do it the "right" way is better, but Windows can make it darned hard for some controls.

                              Cheers,
                              Dale

                              Comment

                              Working...
                              X