home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2001 December (DVD) / VPR0112A.ISO / OLS / TCL230JA95 / tcl230ja95.lzh / source.lzh / exe / pagetaskbar.c < prev    next >
C/C++ Source or Header  |  2001-02-03  |  6KB  |  206 lines

  1. /*-------------------------------------------
  2.   pagetaskbar.c
  3.   "taskbar" page of properties
  4.   Kazubon 1997-1999
  5. ---------------------------------------------*/
  6.  
  7. #include "tclock.h"
  8.  
  9. static void OnInit(HWND hDlg);
  10. static void OnApply(HWND hDlg);
  11. static void OnStartBtnHide(HWND hDlg);
  12. static BOOL IsIE4(void);
  13. static BOOL IsTrayIconsToolbar(void);
  14.  
  15. extern BOOL g_bApplyTaskbar; // propsheet.c
  16.  
  17. __inline void SendPSChanged(HWND hDlg)
  18. {
  19.     g_bApplyTaskbar = TRUE;
  20.     SendMessage(GetParent(hDlg), PSM_CHANGED, (WPARAM)(hDlg), 0);
  21. }
  22.  
  23. /*------------------------------------------------
  24.    dialog procedure of this page
  25. --------------------------------------------------*/
  26. BOOL CALLBACK PageTaskbarProc(HWND hDlg, UINT message,
  27.     WPARAM wParam, LPARAM lParam)
  28. {
  29.     switch(message)
  30.     {
  31.         case WM_INITDIALOG:
  32.             OnInit(hDlg);
  33.             return TRUE;
  34.         case WM_COMMAND:
  35.         {
  36.             WORD id, code;
  37.             id = LOWORD(wParam); code = HIWORD(wParam);
  38.             // checked "Hide Start Button", "Start menu from Clock"
  39.             if(id == IDC_STARTBTNHIDE || id == IDC_STARTMENUCLOCK)
  40.                 OnStartBtnHide(hDlg);
  41.             // checked other boxes
  42.             else if(id == IDC_STARTBTNFLAT || id == IDC_TASKSWITCHFLAT
  43.                 || id == IDC_FLATTRAY || id == IDC_FILLTRAY)
  44.                 SendPSChanged(hDlg);
  45.             // "Transparancy"
  46.             else if(id == IDC_BARTRANS && code == EN_CHANGE)
  47.                 SendPSChanged(hDlg);
  48.             return TRUE;
  49.         }
  50.         case WM_NOTIFY:
  51.             switch(((NMHDR *)lParam)->code)
  52.             {
  53.                 case PSN_APPLY: OnApply(hDlg); break;
  54.                 case PSN_HELP: MyHelp(GetParent(hDlg), 10); break;
  55.             }
  56.             return TRUE;
  57.     }
  58.     return FALSE;
  59. }
  60.  
  61. /*------------------------------------------------
  62.    initialize
  63. --------------------------------------------------*/
  64. void OnInit(HWND hDlg)
  65. {
  66.     BOOL bTrayIconsToolbar;
  67.     DWORD dw;
  68.     
  69.     CheckDlgButton(hDlg, IDC_STARTBTNHIDE,
  70.         GetMyRegLong("", "StartButtonHide", FALSE));
  71.     CheckDlgButton(hDlg, IDC_STARTMENUCLOCK,
  72.         GetMyRegLong("", "StartMenuClock", FALSE));
  73.     OnStartBtnHide(hDlg);
  74.     
  75.     CheckDlgButton(hDlg, IDC_STARTBTNFLAT,
  76.         GetMyRegLong("", "StartButtonFlat", FALSE));
  77.     
  78.     CheckDlgButton(hDlg, IDC_TASKSWITCHFLAT,
  79.         GetMyRegLong("", "TaskSwitchFlat", FALSE));
  80.     EnableDlgItem(hDlg, IDC_TASKSWITCHFLAT, IsIE4());
  81.     
  82.     CheckDlgButton(hDlg, IDC_FLATTRAY,
  83.         GetMyRegLong("", "FlatTray", FALSE));
  84.     
  85.     bTrayIconsToolbar = IsTrayIconsToolbar();
  86.     
  87.     CheckDlgButton(hDlg, IDC_FILLTRAY,
  88.         GetMyRegLong("", "FillTray", FALSE));
  89.     EnableDlgItem(hDlg, IDC_FILLTRAY, bTrayIconsToolbar);
  90.     
  91.     dw = GetVersion();
  92.     if(!(dw & 0x80000000) && LOBYTE(LOWORD(dw)) >= 5) ; // Win2000
  93.     else
  94.     {
  95.         int i;
  96.         for(i = IDC_CAPBARTRANS; i <= IDC_SPINBARTRANS; i++)
  97.             EnableDlgItem(hDlg, i, FALSE);
  98.     }
  99.     
  100.     dw = GetMyRegLong("", "AlphaTaskbar", 0);
  101.     if(dw > 97) dw = 97;
  102.     SendDlgItemMessage(hDlg, IDC_SPINBARTRANS, UDM_SETRANGE, 0,
  103.         MAKELONG(97, 0));
  104.     SendDlgItemMessage(hDlg, IDC_SPINBARTRANS, UDM_SETPOS, 0,
  105.         (int)(short)dw);
  106. }
  107.  
  108. /*------------------------------------------------
  109.   apply - save settings
  110. --------------------------------------------------*/
  111. void OnApply(HWND hDlg)
  112. {
  113.     SetMyRegLong("", "StartButtonHide",
  114.         IsDlgButtonChecked(hDlg, IDC_STARTBTNHIDE));
  115.     SetMyRegLong("", "StartMenuClock",
  116.         IsDlgButtonChecked(hDlg, IDC_STARTMENUCLOCK));
  117.     
  118.     SetMyRegLong("", "StartButtonFlat",
  119.         IsDlgButtonChecked(hDlg, IDC_STARTBTNFLAT));
  120.     
  121.     SetMyRegLong("", "TaskSwitchFlat",
  122.         IsDlgButtonChecked(hDlg, IDC_TASKSWITCHFLAT));
  123.     
  124.     SetMyRegLong("", "FlatTray",
  125.         IsDlgButtonChecked(hDlg, IDC_FLATTRAY));
  126.     
  127.     SetMyRegLong("", "FillTray",
  128.         IsDlgButtonChecked(hDlg, IDC_FILLTRAY));
  129.     
  130.     SetMyRegLong("", "AlphaTaskbar",
  131.         SendDlgItemMessage(hDlg, IDC_SPINBARTRANS, UDM_GETPOS, 0, 0));
  132. }
  133.  
  134. /*------------------------------------------------
  135.   checked "Hide start button"
  136. --------------------------------------------------*/
  137. void OnStartBtnHide(HWND hDlg)
  138. {
  139.     BOOL b;
  140.     
  141.     b = IsDlgButtonChecked(hDlg, IDC_STARTBTNHIDE);
  142.     EnableDlgItem(hDlg, IDC_STARTMENUCLOCK, b);
  143.     SendPSChanged(hDlg);
  144.     
  145.     if(b) b = IsDlgButtonChecked(hDlg, IDC_STARTMENUCLOCK);
  146. }
  147.  
  148. /*------------------------------------------------
  149.   IE 4 or later ?
  150. --------------------------------------------------*/
  151. BOOL IsIE4(void)
  152. {
  153.     HWND hwnd;
  154.     char classname[80];
  155.     DWORD dw;
  156.     
  157.     dw = GetRegLong(HKEY_CURRENT_USER,
  158.         "Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer",
  159.         "ClassicShell", 0);
  160.     if(dw) return TRUE;
  161.     
  162.     hwnd = FindWindow("Shell_TrayWnd", NULL);
  163.     if(hwnd == NULL) return FALSE;
  164.     hwnd = GetWindow(hwnd, GW_CHILD);
  165.     while(hwnd)
  166.     {
  167.         GetClassName(hwnd, classname, 80);
  168.         if(lstrcmpi(classname, "ReBarWindow32") == 0)
  169.             return TRUE;
  170.         hwnd = GetWindow(hwnd, GW_HWNDNEXT);
  171.     }
  172.     return FALSE;
  173. }
  174.  
  175. /*------------------------------------------------
  176.   Is the tray icons "ToolbarWindow32" ?
  177. --------------------------------------------------*/
  178. BOOL IsTrayIconsToolbar(void)
  179. {
  180.     HWND hwnd;
  181.     char classname[80];
  182.     
  183.     hwnd = FindWindow("Shell_TrayWnd", NULL);
  184.     if(hwnd == NULL) return FALSE;
  185.     hwnd = GetWindow(hwnd, GW_CHILD);
  186.     while(hwnd)
  187.     {
  188.         GetClassName(hwnd, classname, 80);
  189.         if(lstrcmpi(classname, "TrayNotifyWnd") == 0)
  190.             break;
  191.         hwnd = GetWindow(hwnd, GW_HWNDNEXT);
  192.     }
  193.     if(hwnd == NULL) return FALSE;
  194.     
  195.     hwnd = GetWindow(hwnd, GW_CHILD);
  196.     while(hwnd)
  197.     {
  198.         GetClassName(hwnd, classname, 80);
  199.         if(lstrcmpi(classname, "ToolbarWindow32") == 0)
  200.             break;
  201.         hwnd = GetWindow(hwnd, GW_HWNDNEXT);
  202.     }
  203.     if(hwnd == NULL) return FALSE;
  204.     return TRUE;
  205. }
  206.