home *** CD-ROM | disk | FTP | other *** search
/ DOS/V Power Report 2002 December (Special) / DOSV2002_12.iso / utility / tcl230ja95.lzh / source.lzh / dll / startbtn.c < prev    next >
C/C++ Source or Header  |  2001-02-15  |  15KB  |  573 lines

  1. /*-------------------------------------------
  2.   startbtn.c
  3.     customize start button
  4.     Kazubon 1997-1999
  5. ---------------------------------------------*/
  6.  
  7. #include "tcdll.h"
  8.  
  9. extern HANDLE hmod;
  10.  
  11. /*------------------------------------------------
  12.   globals
  13. --------------------------------------------------*/
  14. LRESULT CALLBACK WndProcStart(HWND, UINT, WPARAM, LPARAM);
  15. LRESULT CALLBACK WndProcTask(HWND, UINT, WPARAM, LPARAM);
  16. HWND hwndStart = NULL;
  17. BOOL bStartMenuClock = FALSE;
  18.  
  19. static WNDPROC oldWndProcStart = NULL, oldWndProcTask = NULL;
  20. static HWND hwndTask = NULL, hwndTray = NULL;
  21. static HBITMAP hbmpstart = NULL, hbmpstartold = NULL;
  22. static int wStart = -1, hStart = -1;
  23. static BOOL bCustStartButton = FALSE;
  24. static BOOL bHideStartButton = FALSE;
  25. static BOOL bStartButtonFlat = FALSE;
  26. static BOOL bCursorOnStartButton = FALSE;
  27.  
  28. static void OnPaint(HWND hwnd, HDC hdc);
  29. static void SetStartButtonBmp(void);
  30. static void SetTaskWinPos(void);
  31.  
  32. /*--------------------------------------------------
  33.    initialize
  34. ----------------------------------------------------*/
  35. void SetStartButton(HWND hwndClock)
  36. {
  37.     HANDLE hwnd;
  38.     char classname[80];
  39.     
  40.     EndStartButton();
  41.     
  42.     bStartMenuClock = FALSE;
  43.     if(GetMyRegLong(NULL, "StartButtonHide", FALSE))
  44.         bStartMenuClock = 
  45.             GetMyRegLong(NULL, "StartMenuClock", FALSE);
  46.     
  47.     // "button"と"MSTaskSwWClass"のウィンドウハンドルを得る
  48.     hwndStart = hwndTask = NULL;
  49.     hwndTray = GetParent(hwndClock); // TrayNotifyWnd
  50.     if(hwndTray == NULL)
  51.         return;
  52.     hwnd = GetParent(hwndTray);      // Shell_TrayWnd
  53.     if(hwnd == NULL)
  54.         return;
  55.     
  56.     hwnd = GetWindow(hwnd, GW_CHILD);
  57.     while(hwnd)
  58.     {
  59.         GetClassName(hwnd, classname, 80);
  60.         if(lstrcmpi(classname, "Button") == 0)
  61.             hwndStart = hwnd;
  62.         else if(lstrcmpi(classname, "MSTaskSwWClass") == 0)
  63.             hwndTask = hwnd;
  64.         else if(lstrcmpi(classname, "ReBarWindow32") == 0)
  65.             hwndTask = hwnd;
  66.         hwnd = GetWindow(hwnd, GW_HWNDNEXT);
  67.     }
  68.     if(hwndStart == NULL || hwndTask == NULL)
  69.     {
  70.         hwndStart = hwndTask = NULL; return;
  71.     }
  72.     
  73.     bCustStartButton = GetMyRegLong(NULL, "StartButton", FALSE);
  74.     bHideStartButton = GetMyRegLong(NULL, "StartButtonHide", FALSE);
  75.     bStartButtonFlat = GetMyRegLong(NULL, "StartButtonFlat", FALSE);
  76.     if(!bCustStartButton && !bHideStartButton && !bStartButtonFlat) return;
  77.     
  78.     // サブクラス化
  79.     oldWndProcStart = (WNDPROC)GetWindowLong(hwndStart, GWL_WNDPROC);
  80.     SetWindowLong(hwndStart, GWL_WNDPROC, (LONG)WndProcStart);
  81.     oldWndProcTask = (WNDPROC)GetWindowLong(hwndTask, GWL_WNDPROC);
  82.     SetWindowLong(hwndTask, GWL_WNDPROC, (LONG)WndProcTask);
  83.     
  84.     if(bHideStartButton) // ボタンを隠す
  85.     {
  86.         RECT rc; POINT pt;
  87.         ShowWindow(hwndStart, SW_HIDE);
  88.         wStart = 0; hStart = 0;
  89.         GetWindowRect(hwndTray, &rc);
  90.         pt.x = rc.left; pt.y = rc.top;
  91.         ScreenToClient(GetParent(hwndTray), &pt);
  92.         SetWindowPos(hwndStart, NULL, pt.x, pt.y,
  93.             rc.right - rc.left, rc.bottom - rc.top,
  94.             SWP_NOZORDER|SWP_NOACTIVATE);
  95.     }
  96.     else if(bCustStartButton)
  97.     {
  98.         // ボタン用ビットマップの設定
  99.         SetStartButtonBmp();
  100.     }
  101.     // MSTaskSwWClassの位置・サイズの設定
  102.     if(bCustStartButton || bHideStartButton)
  103.         SetTaskWinPos();
  104. }
  105.  
  106. /*--------------------------------------------------
  107.     reset start button
  108. ----------------------------------------------------*/
  109. void EndStartButton(void)
  110. {
  111.     if(hwndStart && IsWindow(hwndStart))
  112.     {
  113.         if(hbmpstartold != NULL)
  114.         {
  115.             SendMessage(hwndStart, BM_SETIMAGE,
  116.                 0, (LPARAM)hbmpstartold);
  117.             hbmpstartold = NULL;
  118.         }
  119.         if(oldWndProcStart)
  120.             SetWindowLong(hwndStart, GWL_WNDPROC, (LONG)oldWndProcStart);
  121.         oldWndProcStart = NULL;
  122.         SetWindowPos(hwndStart, NULL, 0, 0, 0, 0,
  123.             SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
  124.         ShowWindow(hwndStart, SW_SHOW);
  125.     }
  126.     hwndStart = NULL;
  127.     
  128.     if(hbmpstart) DeleteObject(hbmpstart); hbmpstart = NULL;
  129.     
  130.     if(hwndTask && IsWindow(hwndTask) && oldWndProcTask)
  131.         SetWindowLong(hwndTask, GWL_WNDPROC, (LONG)oldWndProcTask);
  132.     oldWndProcTask = NULL; hwndStart = NULL;
  133.     
  134.     bCustStartButton = bHideStartButton = bStartButtonFlat = FALSE;
  135. }
  136.  
  137. /*------------------------------------------------
  138.    subclass procedure of start button
  139. --------------------------------------------------*/
  140. LRESULT CALLBACK WndProcStart(HWND hwnd, UINT message,
  141.     WPARAM wParam, LPARAM lParam)
  142. {
  143.     switch(message)
  144.     {
  145.         case WM_SYSCOLORCHANGE:  // システムの設定変更
  146.         case WM_WININICHANGE:
  147.             if(bCustStartButton && !bHideStartButton)
  148.                 PostMessage(hwnd, WM_USER+10, 0, 0L);
  149.             return 0;
  150.         case (WM_USER + 10):     // 再初期化
  151.             SetStartButtonBmp();
  152.             return 0;
  153.         case WM_WINDOWPOSCHANGING:  // サイズを変更させない
  154.         {
  155.             LPWINDOWPOS pwp;
  156.             if(!(bCustStartButton || bHideStartButton)) break;
  157.             pwp = (LPWINDOWPOS)lParam;
  158.             if(!(pwp->flags & SWP_NOSIZE))
  159.             {
  160.                 if(wStart > 0) pwp->cx = wStart;
  161.                 if(hStart > 0) pwp->cy = hStart;
  162.             }
  163.             if(bHideStartButton)
  164.             {
  165.                 RECT rc; POINT pt;
  166.                 GetWindowRect(hwndTray, &rc);
  167.                 pt.x = rc.left; pt.y = rc.top;
  168.                 ScreenToClient(GetParent(hwndTray), &pt);
  169.                 pwp->x = pt.x; pwp->y = pt.y;
  170.                 pwp->cx = rc.right - rc.left;
  171.                 pwp->cy = rc.bottom - rc.top;
  172.             }
  173.             break;
  174.         }
  175.         case WM_DESTROY:
  176.             if(hbmpstartold)
  177.                 SendMessage(hwndStart, BM_SETIMAGE,
  178.                     0, (LPARAM)hbmpstartold);
  179.             hbmpstartold = NULL;
  180.             if(hbmpstart) DeleteObject(hbmpstart); hbmpstart = NULL;
  181.             break;
  182.  
  183.         // -------- for "flat start button" -----------
  184.         case WM_PAINT:
  185.         {
  186.             HDC hdc;
  187.             PAINTSTRUCT ps;
  188.             if(!bStartButtonFlat) break;
  189.             hdc = BeginPaint(hwnd, &ps);
  190.             OnPaint(hwnd, hdc);
  191.             EndPaint(hwnd, &ps);
  192.             return 0;
  193.         }
  194.         case BM_SETSTATE:
  195.         {
  196.             LRESULT r;
  197.             HDC hdc;
  198.             if(!bStartButtonFlat) break;
  199.             r = CallWindowProc(oldWndProcStart, hwnd, message, wParam, lParam);
  200.             hdc = GetDC(hwnd);
  201.             OnPaint(hwnd, hdc);
  202.             ReleaseDC(hwnd, hdc);
  203.             return 0;
  204.         }
  205.         case WM_SETFOCUS:
  206.             if(!bStartButtonFlat) break;
  207.             return 0;
  208.         case WM_MOUSEMOVE:
  209.             CheckCursorOnStartButton();
  210.             break;
  211.     }
  212.     return CallWindowProc(oldWndProcStart, hwnd, message, wParam, lParam);
  213. }
  214.  
  215. /*--------------------------------------------------
  216.    subclass procedure of
  217.    "MSTaskSwWClass"/"ReBarWindow32" class window
  218. ----------------------------------------------------*/
  219. LRESULT CALLBACK WndProcTask(HWND hwnd, UINT message,
  220.     WPARAM wParam, LPARAM lParam)
  221. {
  222.     switch(message)
  223.     {
  224.         case WM_WINDOWPOSCHANGING: // 位置・サイズの制限
  225.         {
  226.             LPWINDOWPOS pwp;
  227.             RECT rcBar, rcTray;
  228.             
  229.             if(!(bCustStartButton || bHideStartButton)) break;
  230.             
  231.             pwp = (LPWINDOWPOS)lParam;
  232. //            if((pwp->flags & SWP_NOMOVE) ||
  233. //                wStart < 0 || hStart < 0) break;
  234.             
  235.             GetClientRect(GetParent(hwndStart), &rcBar); // タスクバー
  236.             GetWindowRect(hwndTray, &rcTray); // TrayNotifyWnd
  237.             
  238.             // タスクバーが横置きのとき
  239.             if(rcBar.right > rcBar.bottom)
  240.             {
  241.                 pwp->x = 2 + wStart; // 右位置
  242.                 pwp->cx = rcTray.left - 2 - wStart - 2; // 横幅
  243.                 if(wStart > 0)
  244.                 {
  245.                     pwp->x += 2; pwp->cx -= 2;
  246.                 }
  247.             }
  248.             else // 縦置きのとき
  249.             {
  250.                 if(rcTray.top < pwp->y)
  251.                 {
  252.                     pwp->cy = rcBar.bottom - 2 - hStart - 2; // 高さ
  253.                 }
  254.                 else
  255.                 {
  256.                     pwp->cy = rcTray.top - 2 - hStart - 2; // 高さ
  257.                 }
  258.                 pwp->y = 2 + hStart; // 上位置
  259.                 if(hStart > 0)
  260.                 {
  261.                     pwp->y += 1; pwp->cy -= 2;
  262.                 }
  263.             }
  264.             break;
  265.         }
  266.     }
  267.     return CallWindowProc(oldWndProcTask, hwnd, message, wParam, lParam);
  268. }
  269.  
  270. /*--------------------------------------------------
  271.  スタートボタンのビットマップとサイズの設定
  272. ----------------------------------------------------*/
  273. void SetStartButtonBmp(void)
  274. {
  275.     char s[1024], caption[80];
  276.     HBITMAP hbmpicon, hbmpold;
  277.     HICON hicon;
  278.     HDC hdc, hdcMem;
  279.     HFONT hfont;
  280.     BITMAP bmp;
  281.     int whbmp, hhbmp, cxicon, cyicon;
  282.     
  283.     if(hwndStart == NULL) return;
  284.     
  285.     hbmpicon = NULL; hicon = NULL;
  286.     cxicon = GetSystemMetrics(SM_CXSMICON);
  287.     cyicon = GetSystemMetrics(SM_CYSMICON);
  288.     
  289.     // ファイルからアイコン用ビットマップの読み込み
  290.     if(GetMyRegStr(NULL, "StartButtonIcon", s, 1024, "") > 0)
  291.     {
  292.         char fname[MAX_PATH], head[2];
  293.         HFILE hf;
  294.         
  295.         parse(fname, s, 0);
  296.         hf = _lopen(fname, OF_READ);
  297.         if(hf != HFILE_ERROR)
  298.         {
  299.             _lread(hf, head, 2);
  300.             _lclose(hf);
  301.             if(head[0] == 'B' && head[1] == 'M') //ビットマップの場合
  302.                 hbmpicon = ReadBitmap(hwndStart, fname, TRUE);
  303.             else if(head[0] == 'M' && head[1] == 'Z') //実行ファイルの場合
  304.             {
  305.                 char numstr[10], *p; int n;
  306.                 HICON hiconl;
  307.                 parse(numstr, s, 1);
  308.                 n = 0; p = numstr;
  309.                 while(*p)
  310.                 {
  311.                     if(*p < '0' || '9' < *p) break;
  312.                     n = n * 10 + *p++ - '0';
  313.                 }
  314.                 if(ExtractIconEx(fname, n, &hiconl, &hicon, 1) < 2)
  315.                     hicon = NULL;
  316.                 else DestroyIcon(hiconl);
  317.             }
  318.             else // アイコンの場合
  319.             {
  320.                 hicon = (HICON)LoadImage(hmod, fname,
  321.                     IMAGE_ICON, cxicon, cyicon,
  322.                     LR_DEFAULTCOLOR|LR_LOADFROMFILE);
  323.             }
  324.         }
  325.     }
  326.     
  327.     if(hbmpicon)
  328.     {
  329.         GetObject(hbmpicon, sizeof(BITMAP), (LPVOID)&bmp);
  330.         cxicon = bmp.bmWidth; cyicon = bmp.bmHeight;
  331.     }
  332.  
  333.     // キャプションの取得
  334.     GetMyRegStr(NULL, "StartButtonCaption", caption, 80, "");
  335.     
  336.     hdc = GetDC(hwndStart);
  337.     
  338.     // ボタン用のフォント = タイトルバーのフォント + BOLD
  339.     hfont = NULL;
  340.     whbmp = cxicon; hhbmp = cyicon;
  341.     if(caption[0])
  342.     {
  343.         NONCLIENTMETRICS ncm;
  344.         SIZE sz;
  345.         ncm.cbSize = sizeof(ncm);
  346.         SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &ncm, 0);
  347.         ncm.lfCaptionFont.lfWeight = FW_BOLD;
  348.         hfont =  CreateFontIndirect(&(ncm.lfCaptionFont));
  349.         SelectObject(hdc, hfont);
  350.         
  351.         //キャプションの幅を得る
  352.         GetTextExtentPoint32(hdc, caption, strlen(caption), &sz);
  353.         whbmp = sz.cx;
  354.         if(hbmpicon || hicon) whbmp += cxicon + 2;
  355.         hhbmp = sz.cy;
  356.         if((hbmpicon || hicon) && cyicon > sz.cy)
  357.             hhbmp = cyicon;
  358.         //if(hhbmp < 16) hhbmp = 16;
  359.     }
  360.     
  361.     // ビットマップの作成
  362.     hdcMem = CreateCompatibleDC(hdc);
  363.     hbmpstart = CreateCompatibleBitmap(hdc, whbmp, hhbmp);
  364.     SelectObject(hdcMem, hbmpstart);
  365.     
  366.     { // 背景色で塗りつぶし
  367.         RECT rc; HBRUSH hbr;
  368.         SetRect(&rc, 0, 0, whbmp, hhbmp);
  369.         hbr = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
  370.         FillRect(hdcMem, &rc, hbr);
  371.         DeleteObject(hbr);
  372.     }
  373.     
  374.     // ビットマップにアイコンの絵を描画
  375.     if(hbmpicon)
  376.     {
  377.         HDC hdcicon;
  378.         hdcicon = CreateCompatibleDC(hdc);
  379.         SelectObject(hdcicon, hbmpicon);
  380.         BitBlt(hdcMem, 0, (hhbmp - cyicon)/2,
  381.             cxicon, cyicon, hdcicon, 0, 0, SRCCOPY);
  382.         DeleteDC(hdcicon);
  383.         DeleteObject(hbmpicon);
  384.     }
  385.     if(hicon)
  386.     {
  387.         DrawIconEx(hdcMem, 0, (hhbmp - cyicon)/2,
  388.             hicon, cxicon, cyicon, 0, NULL, DI_NORMAL);
  389.         DestroyIcon(hicon);
  390.     }
  391.     
  392.     // ビットマップにキャプションを書く
  393.     if(caption[0])
  394.     {
  395.         TEXTMETRIC tm;
  396.         int x, y;
  397.  
  398.         GetTextMetrics(hdc, &tm);
  399.         SelectObject(hdcMem, hfont);
  400.         x = 0; if(hbmpicon || hicon) x = cxicon + 2;
  401.         y = (hhbmp - tm.tmHeight) / 2;
  402.         SetBkMode(hdcMem, TRANSPARENT);
  403.         SetTextColor(hdcMem, GetSysColor(COLOR_BTNTEXT));
  404.         TextOut(hdcMem, x, y, caption, strlen(caption));
  405.     }
  406.     
  407.     DeleteDC(hdcMem);
  408.     ReleaseDC(hwndStart, hdc);
  409.     if(hfont) DeleteObject(hfont);
  410.  
  411.     // ボタンにビットマップを設定
  412.     hbmpold = (HBITMAP)SendMessage(hwndStart,
  413.         BM_SETIMAGE, 0, (LPARAM)hbmpstart);
  414.     // 以前のビットマップを保存 / 破棄
  415.     if(hbmpstartold == NULL) hbmpstartold = hbmpold;
  416.     else DeleteObject(hbmpold);
  417.     
  418.     // ボタンのサイズの設定  上限:160x80
  419.     wStart = whbmp + 8;
  420.     if(wStart > 160) wStart = 160;
  421.     hStart = GetSystemMetrics(SM_CYCAPTION) + 3;
  422.     if(hhbmp + 6 > hStart) hStart = hhbmp + 6;
  423.     if(hStart > 80) hStart = 80;
  424.     SetWindowPos(hwndStart, NULL, 0, 0,
  425.         wStart, hStart,
  426.         SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
  427. }
  428.  
  429. /*--------------------------------------------------
  430.  MSTaskSwWClassの位置・サイズの設定
  431. ----------------------------------------------------*/
  432. void SetTaskWinPos(void)
  433. {
  434.     RECT rcBar, rcTask, rcTray;
  435.     POINT pt;
  436.     int x, y, w, h;
  437.  
  438.     GetClientRect(GetParent(hwndStart), &rcBar);  // Shell_TrayWnd
  439.     GetWindowRect(hwndTray, &rcTray); // TrayNotifyWnd
  440.     GetWindowRect(hwndTask, &rcTask);             // MSTaskSwWClass
  441.     
  442.     // MSTaskSwWClassの右上位置
  443.     pt.x = rcTask.left; pt.y = rcTask.top;
  444.     ScreenToClient(GetParent(hwndStart), &pt);
  445.     
  446.     x = pt.x; y = pt.y;
  447.     w = rcTask.right - rcTask.left;
  448.     h = rcTask.bottom - rcTask.top;
  449.     
  450.     // タスクバーが横置きのとき
  451.     if(rcBar.right > rcBar.bottom)
  452.     {
  453.         x = 2 + wStart;
  454.         w = rcTray.left - 2 - wStart - 2;
  455.         if(wStart > 0)
  456.         {
  457.             x += 2; w -= 2;
  458.         }
  459.     }
  460.     else // 縦置きのとき
  461.     {
  462.         y = 2 + hStart;
  463.         h = rcTray.top - 2 - hStart - 2;
  464.         if(hStart > 0)
  465.         {
  466.             y += 1; h -= 2;
  467.         }
  468.     }
  469.     SetWindowPos(hwndTask, NULL, x, y, w, h,
  470.         SWP_NOZORDER|SWP_NOACTIVATE);
  471. }
  472.  
  473. /*--------------------------------------------------
  474.    draw "flat start button"
  475. ----------------------------------------------------*/
  476. void OnPaint(HWND hwnd, HDC hdc)
  477. {
  478.     HDC hdcMem1, hdcMem2;
  479.     HBITMAP hbmp, hbmpTemp;
  480.     HBRUSH hbr;
  481.     BITMAP bmp;
  482.     RECT rc;
  483.     int x, y, w, h;
  484.     BOOL bPushed;
  485.     
  486.     bPushed = (SendMessage(hwnd, BM_GETSTATE, 0, 0) & BST_PUSHED)?1:0;
  487.     
  488.     hdcMem1 = CreateCompatibleDC(hdc);
  489.     hbmp = (HBITMAP)SendMessage(hwnd, BM_GETIMAGE, IMAGE_BITMAP, 0);
  490.     SelectObject(hdcMem1, hbmp);
  491.     GetObject(hbmp, sizeof(BITMAP), (LPVOID)&bmp);
  492.     w = bmp.bmWidth; h = bmp.bmHeight;
  493.     
  494.     hdcMem2 = CreateCompatibleDC(hdc);
  495.     GetClientRect(hwnd, &rc);
  496.     hbmpTemp = CreateCompatibleBitmap(hdc, rc.right, rc.bottom);
  497.     SelectObject(hdcMem2, hbmpTemp);
  498.     
  499.     hbr = CreateSolidBrush(GetSysColor(COLOR_3DFACE));
  500.     FillRect(hdcMem2, &rc, hbr);
  501.     DeleteObject(hbr);
  502.     
  503.     x = (rc.right - w)/2 + (!bCustStartButton ? 2:0) + (int)bPushed;
  504.     y = (rc.bottom - h)/2 + (int)bPushed;
  505.     BitBlt(hdcMem2, x, y, w, h, hdcMem1, 0, 0, SRCCOPY);
  506.  
  507.     if(bPushed || bCursorOnStartButton) // draw frame
  508.     {
  509.         HPEN hpen, hpenold;
  510.         int color;
  511.         
  512.         color = GetSysColor(bPushed?COLOR_3DSHADOW:COLOR_3DHILIGHT);
  513.         hpen = CreatePen(PS_SOLID, 1, color);
  514.         hpenold = SelectObject(hdcMem2, hpen);
  515.         MoveToEx(hdcMem2, 0, 0, NULL);
  516.         LineTo(hdcMem2, rc.right, 0);
  517.         MoveToEx(hdcMem2, 0, 0, NULL);
  518.         LineTo(hdcMem2, 0, rc.bottom);
  519.         SelectObject(hdcMem2, hpenold);
  520.         DeleteObject(hpen);
  521.         
  522.         color = GetSysColor(bPushed?COLOR_3DHILIGHT:COLOR_3DSHADOW);
  523.         hpen = CreatePen(PS_SOLID, 1, color);
  524.         hpenold = SelectObject(hdcMem2, hpen);
  525.         MoveToEx(hdcMem2, rc.right-1, 0, NULL);
  526.         LineTo(hdcMem2, rc.right-1, rc.bottom);
  527.         MoveToEx(hdcMem2, 0, rc.bottom-1, NULL);
  528.         LineTo(hdcMem2, rc.right, rc.bottom-1);
  529.         SelectObject(hdcMem2, hpenold);
  530.         DeleteObject(hpen);
  531.     }
  532.     
  533.     BitBlt(hdc, 0, 0,
  534.         rc.right, rc.bottom, hdcMem2, 0, 0, SRCCOPY);
  535.     
  536.     DeleteDC(hdcMem1);
  537.     DeleteDC(hdcMem2);
  538.     DeleteObject(hbmpTemp);
  539. }
  540.  
  541. /*--------------------------------------------------
  542.    called when clock window receive WM_TIMER.
  543.    check cursor position, and draw "flat start button"
  544. ----------------------------------------------------*/
  545. void CheckCursorOnStartButton(void)
  546. {
  547.     POINT pt;
  548.     RECT rc;
  549.     
  550.     if(hwndStart == NULL) return;
  551.     if(!bStartButtonFlat) return;
  552.     
  553.     GetCursorPos(&pt);
  554.     GetWindowRect(hwndStart, &rc);
  555.     if(PtInRect(&rc, pt))
  556.     {
  557.         if(!bCursorOnStartButton)
  558.         {
  559.             bCursorOnStartButton = TRUE;
  560.             InvalidateRect(hwndStart, NULL, FALSE);
  561.         }
  562.     }
  563.     else
  564.     {
  565.         if(bCursorOnStartButton)
  566.         {
  567.             bCursorOnStartButton = FALSE;
  568.             InvalidateRect(hwndStart, NULL, FALSE);
  569.         }
  570.     }
  571. }
  572.  
  573.