Beispiel #1
0
INT_PTR CALLBACK PovLegalDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
  DRAWITEMSTRUCT        *d ;
  MEASUREITEMSTRUCT     *m ;
  static HBRUSH         hbr ;

  switch (message)
  {
    case WM_INITDIALOG :
         resize_listbox_dialog (hDlg, IDC_LISTBOX, 79) ;
         CenterWindowRelative ((HWND) lParam, hDlg, true, true) ;
         SetWindowText (hDlg, "POV-Ray License") ;
//       hbr = CreateSolidBrush (GetSysColor (COLOR_BTNFACE)) ;
         fill_listbox (GetDlgItem (hDlg, IDC_LISTBOX)) ;
         return (true) ;

    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
         return (DefWindowProc (hDlg, message, wParam, lParam)) ;

    case WM_COMMAND :
         switch (LOWORD (wParam))
         {
           case IDOK :
//              DeleteObject (hbr) ;
                EndDialog (hDlg, true) ;
                return (true) ;

           default :
                return (true) ;
         }

    case WM_MEASUREITEM :
         if (wParam == IDC_LISTBOX)
         {
           m = (MEASUREITEMSTRUCT *) lParam ;
           m->itemHeight = message_ychar ;
           return (true) ;
         }
         else
           return (false) ;

    case WM_DRAWITEM :
         if (wParam == IDC_LISTBOX)
         {
           d = (DRAWITEMSTRUCT *) lParam ;
           d->itemState &= ~ODS_SELECTED ;
           draw_ordinary_listbox (d, false) ;
           return (true) ;
         }
         else
           return (false) ;
  }
  return (false) ;
}
INT_PTR CALLBACK PovTipDialogProc (HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
  char                  **s ;
  HDC                   hdc ;
  HWND                  hItem ;
  RECT                  rect ;
  HPEN                  hpen ;
  HBRUSH                hbrush ;
  PAINTSTRUCT           ps ;
  WINDOWPLACEMENT       p ;
  static int            tipCount = 0 ;
  static int            tipID ;

  switch (message)
  {
    case WM_INITDIALOG :
         CenterWindowRelative ((HWND) lParam, hDlg, true) ;
         FitWindowInWindow (NULL, hDlg) ;
         tipID = GetPrivateProfileInt ("TipOfTheDay", "NextTip", 0, EngineIniFileName) ;
         if (tipCount == 0)
           for (s = tips ; *s ; s++)
             tipCount++ ;
         if (tipID >= tipCount)
           tipID = 0 ;
         PutPrivateProfileInt ("TipOfTheDay", "NextTip", tipID + 1, EngineIniFileName) ;
         CheckDlgButton (hDlg, IDC_SHOWTIPS, tips_enabled) ;
         return (true) ;

    case WM_PAINT :
         hdc = BeginPaint (hDlg, &ps) ;
         hpen = (HPEN) GetStockObject (BLACK_PEN) ;
//       hbrush = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
//       hbrush = CreateSolidBrush (RGB (255, 255, 128)) ;
         hbrush = CreateSolidBrush (RGB (255, 255, 224)) ;
         hpen = (HPEN) SelectObject (hdc, hpen) ;
         hbrush = (HBRUSH) SelectObject (hdc, hbrush) ;
         hItem = GetDlgItem (hDlg, IDC_TIPFRAME) ;
         p.length = sizeof (WINDOWPLACEMENT) ;
         GetWindowPlacement (hItem, &p) ;
         rect = p.rcNormalPosition ;
         InflateRect (&rect, -5, -5) ;
         Rectangle (hdc, rect.left, rect.top, rect.right, rect.bottom) ;
         InflateRect (&rect, -5, -5) ;
         tip_of_the_day (hdc, &rect, tips [tipID]) ;
         SelectObject (hdc, hpen) ;
         SelectObject (hdc, hbrush) ;
         DeleteObject (hbrush) ;
         EndPaint (hDlg, &ps) ;
         return (true) ;

    case WM_CTLCOLORBTN:
    case WM_CTLCOLORDLG:
    case WM_CTLCOLOREDIT:
    case WM_CTLCOLORLISTBOX:
    case WM_CTLCOLORSCROLLBAR:
    case WM_CTLCOLORSTATIC:
         return(DefWindowProc(hDlg, message, wParam, lParam));

    case WM_COMMAND :
         switch (LOWORD (wParam))
         {
           case IDOK :
           case IDCANCEL :
                EndDialog (hDlg, true) ;
                return (true) ;

           case IDC_SHOWTIPS :
                tips_enabled = (IsDlgButtonChecked (hDlg, IDC_SHOWTIPS) != 0);
                PVCheckMenuItem (CM_TIPOFTHEDAY, tips_enabled ? MF_CHECKED : MF_UNCHECKED) ;
                return (true) ;

           case IDC_NEXTTIP :
                if (++tipID >= tipCount)
                  tipID = 0 ;
                PutPrivateProfileInt ("TipOfTheDay", "NextTip", tipID + 1, EngineIniFileName) ;
                PovInvalidateRect (hDlg, NULL, false) ;
                return (true) ;

           case IDC_PREVIOUSTIP :
                if (tipID-- == 0)
                  tipID = tipCount - 1 ;
                PovInvalidateRect (hDlg, NULL, false) ;
                return (true) ;

           default :
                return (true) ;
         }
  }
  return (false) ;
}