@@ -12,6 +12,7 @@ ShortcutDlg::ShortcutDlg(HINSTANCE hInst, NppData& nppData, const TCHAR *scriptD
1212 m_hListMenuItems(NULL ),
1313 m_hListToolbarItems(NULL ),
1414 m_hComboInitialisation(NULL ),
15+ m_hButtonColor(NULL ),
1516 m_hImageList(NULL ),
1617 m_hDefaultImageIndex(0 ),
1718 m_hIcons(NULL ),
@@ -74,6 +75,19 @@ INT_PTR CALLBACK ShortcutDlg::run_dlgProc(UINT message, WPARAM wParam, LPARAM lP
7475 return TRUE ;
7576
7677 case WM_COMMAND:
78+ switch (LOWORD (wParam))
79+ {
80+ case IDC_COLORCHOOSER:
81+ ctrlOnClick ();
82+ break ;
83+ case IDC_CHECKCOLORIZEOUTPUT:
84+ if (HIWORD (wParam) == BN_CLICKED)
85+ {
86+ size_t result = SendMessage (reinterpret_cast <HWND>(lParam), BM_GETCHECK, 0 , 0 );
87+ EnableWindow (m_hButtonColor, (result == BST_CHECKED) ? true : false );
88+ }
89+ break ;
90+ }
7791 switch (wParam)
7892 {
7993 case IDOK:
@@ -208,6 +222,7 @@ void ShortcutDlg::onInitDialog()
208222 m_hListMenuItems = ::GetDlgItem (_hSelf, IDC_MENUITEMLIST);
209223 m_hListToolbarItems = ::GetDlgItem (_hSelf, IDC_TOOLBARITEMLIST2);
210224 m_hComboInitialisation = ::GetDlgItem (_hSelf, IDC_COMBOINITIALISATION);
225+ m_hButtonColor = ::GetDlgItem (_hSelf, IDC_COLORCHOOSER);
211226 InitCommonControls ();
212227 HICON hIcon; // handle to icon
213228
@@ -507,7 +522,8 @@ void ShortcutDlg::populateCurrentItems()
507522 CheckDlgButton (_hSelf, IDC_CHECKADDEXTRALINETOOUTPUT, addExtraLine ? BST_CHECKED : BST_UNCHECKED);
508523
509524 bool colorOutput = (configFile->getSetting (_T (" COLORIZEOUTPUT" )) >= _T (" 0" ));
510- CheckDlgButton (_hSelf, IDC_CHECKCOLORIZEOUTPUT, colorOutput ? BST_CHECKED : BST_UNCHECKED);
525+ CheckDlgButton (_hSelf, IDC_CHECKCOLORIZEOUTPUT, colorOutput ? BST_CHECKED : BST_UNCHECKED);
526+ EnableWindow (m_hButtonColor, colorOutput);
511527
512528 bool openOnError = (configFile->getSetting (_T (" OPENCONSOLEONERROR" )) == _T (" 1" ));
513529 CheckDlgButton (_hSelf, IDC_CHECKOPENCONSOLEONERROR, openOnError ? BST_CHECKED : BST_UNCHECKED);
@@ -544,7 +560,7 @@ void ShortcutDlg::saveConfig()
544560 configFile->setSetting (_T (" ADDEXTRALINETOOUTPUT" ), addExtraLine ? _T (" 1" ): _T (" 0" ));
545561
546562 bool colorOutput = (BST_CHECKED == IsDlgButtonChecked (_hSelf, IDC_CHECKCOLORIZEOUTPUT));
547- configFile->setSetting (_T (" COLORIZEOUTPUT" ), colorOutput ? _T (" 1234567 " ) : _T (" -1" ));
563+ configFile->setSetting (_T (" COLORIZEOUTPUT" ), colorOutput ? ConfigFile::getInstance ()-> getSetting ( _T (" COLORIZEOUTPUT " ) ) : _T (" -1" ));
548564
549565 bool openOnError = (BST_CHECKED == IsDlgButtonChecked (_hSelf, IDC_CHECKOPENCONSOLEONERROR));
550566 configFile->setSetting (_T (" OPENCONSOLEONERROR" ), openOnError ? _T (" 1" ) : _T (" 0" ));
@@ -595,3 +611,29 @@ void ShortcutDlg::toolbarSetIcon()
595611 }
596612 }
597613}
614+
615+ void ShortcutDlg::ctrlOnClick ()
616+ {
617+ CHOOSECOLOR cc;
618+ static COLORREF acrCustClr[16 ];
619+ for (int i = 0 ; i < 16 ; i++)
620+ {
621+ acrCustClr[i] = RGB (255 ,255 ,255 );
622+ }
623+ const tstring strRGBCurrent = ConfigFile::getInstance ()->getSetting (_T (" COLORIZEOUTPUT" ));
624+ static DWORD rgbCurrent = (strRGBCurrent == _T (" -1" )) ? RGB (135 ,214 ,18 ) : stoi (strRGBCurrent);
625+
626+ ZeroMemory (&cc, sizeof (cc));
627+ cc.lStructSize = sizeof (cc);
628+ cc.hwndOwner = _hSelf;
629+ cc.lpCustColors = (LPDWORD)acrCustClr;
630+ cc.rgbResult = rgbCurrent;
631+ cc.Flags = CC_FULLOPEN | CC_RGBINIT;
632+
633+ if (ChooseColor (&cc) == TRUE )
634+ {
635+ rgbCurrent = cc.rgbResult ;
636+ ConfigFile::getInstance ()->setSetting (_T (" COLORIZEOUTPUT" ), std::to_wstring (rgbCurrent));
637+ }
638+
639+ }
0 commit comments