Changeset 496


Ignore:
Timestamp:
Aug 14, 1999, 6:13:16 PM (26 years ago)
Author:
cbratschi
Message:

wine-990731 update

Location:
trunk/src/comctl32
Files:
25 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/comctl32/animate.c

    r94 r496  
    1 /* $Id: animate.c,v 1.3 1999-06-10 16:21:57 achimha Exp $ */
     1/* $Id: animate.c,v 1.4 1999-08-14 16:13:09 cbratschi Exp $ */
    22/*
    33 * Animation control
     
    3434    hrsrc = FindResourceA (hInst, lpName, "AVI");
    3535    if (!hrsrc)
    36         return FALSE;
     36        return FALSE;
    3737
    3838    handle = LoadResource (hInst, hrsrc);
    3939    if (!handle)
    40         return FALSE;
     40        return FALSE;
    4141
    4242    infoPtr->lpAvi = LockResource (handle);
    4343    if (!infoPtr->lpAvi)
    44         return FALSE;
     44        return FALSE;
    4545
    4646    return TRUE;
     
    5454
    5555    infoPtr->hFile =
    56         CreateFileA (lpName, GENERIC_READ, 0, NULL, OPEN_EXISTING,
    57                        FILE_ATTRIBUTE_NORMAL, 0);
     56        CreateFileA (lpName, GENERIC_READ, 0, NULL, OPEN_EXISTING,
     57                       FILE_ATTRIBUTE_NORMAL, 0);
    5858    if (!infoPtr->hFile)
    59         return FALSE;
     59        return FALSE;
    6060
    6161    handle =
    62         CreateFileMappingA (infoPtr->hFile, NULL, PAGE_READONLY | SEC_COMMIT,
    63                               0, 0, NULL);
     62        CreateFileMappingA (infoPtr->hFile, NULL, PAGE_READONLY | SEC_COMMIT,
     63                              0, 0, NULL);
    6464    if (!handle) {
    65         CloseHandle (infoPtr->hFile);
    66         infoPtr->hFile = 0;
    67         return FALSE;
     65        CloseHandle (infoPtr->hFile);
     66        infoPtr->hFile = 0;
     67        return FALSE;
    6868    }
    6969
    7070    infoPtr->lpAvi = MapViewOfFile (handle, FILE_MAP_READ, 0, 0, 0);
    7171    if (!infoPtr->lpAvi) {
    72         CloseHandle (infoPtr->hFile);
    73         infoPtr->hFile = 0;
    74         return FALSE;
     72        CloseHandle (infoPtr->hFile);
     73        infoPtr->hFile = 0;
     74        return FALSE;
    7575    }
    7676
     
    8383{
    8484    if (infoPtr->hFile) {
    85         UnmapViewOfFile (infoPtr->lpAvi);
    86         CloseHandle (infoPtr->hFile);
    87         infoPtr->lpAvi = NULL;
     85        UnmapViewOfFile (infoPtr->lpAvi);
     86        CloseHandle (infoPtr->hFile);
     87        infoPtr->lpAvi = NULL;
    8888    }
    8989    else {
    90         GlobalFree ((HGLOBAL)infoPtr->lpAvi);
    91         infoPtr->lpAvi = NULL;
     90        GlobalFree ((HGLOBAL)infoPtr->lpAvi);
     91        infoPtr->lpAvi = NULL;
    9292    }
    9393}
     
    111111
    112112    if (!lParam) {
    113 //      TRACE (animate, "closing avi!\n");
    114         return TRUE;
    115     }
    116    
     113//      TRACE (animate, "closing avi!\n");
     114        return TRUE;
     115    }
     116
    117117    if (HIWORD(lParam)) {
    118 //      FIXME (animate, "(\"%s\") empty stub!\n", (LPSTR)lParam);
    119 
    120         if (ANIMATE_LoadResA (infoPtr, hInstance, (LPSTR)lParam)) {
    121 
    122 //          FIXME (animate, "AVI resource found!\n");
    123 
    124         }
    125         else {
    126 //          FIXME (animate, "No AVI resource found!\n");
    127             if (ANIMATE_LoadFileA (infoPtr, (LPSTR)lParam)) {
    128 //              FIXME (animate, "AVI file found!\n");
    129             }
    130             else {
    131 //              FIXME (animate, "No AVI file found!\n");
    132                 return FALSE;
    133             }
    134         }
     118//      FIXME (animate, "(\"%s\") empty stub!\n", (LPSTR)lParam);
     119
     120        if (ANIMATE_LoadResA (infoPtr, hInstance, (LPSTR)lParam)) {
     121
     122//          FIXME (animate, "AVI resource found!\n");
     123
     124        }
     125        else {
     126//          FIXME (animate, "No AVI resource found!\n");
     127            if (ANIMATE_LoadFileA (infoPtr, (LPSTR)lParam)) {
     128//              FIXME (animate, "AVI file found!\n");
     129            }
     130            else {
     131//              FIXME (animate, "No AVI file found!\n");
     132                return FALSE;
     133            }
     134        }
    135135    }
    136136    else {
    137 //      FIXME (animate, "(%u) empty stub!\n", (WORD)LOWORD(lParam));
    138 
    139         if (ANIMATE_LoadResA (infoPtr, hInstance,
    140                                 MAKEINTRESOURCEA((INT)lParam))) {
    141 //          FIXME (animate, "AVI resource found!\n");
    142         }
    143         else {
    144 //          FIXME (animate, "No AVI resource found!\n");
    145             return FALSE;
    146         }
     137//      FIXME (animate, "(%u) empty stub!\n", (WORD)LOWORD(lParam));
     138
     139        if (ANIMATE_LoadResA (infoPtr, hInstance,
     140                                MAKEINTRESOURCEA((INT)lParam))) {
     141//          FIXME (animate, "AVI resource found!\n");
     142        }
     143        else {
     144//          FIXME (animate, "No AVI resource found!\n");
     145            return FALSE;
     146        }
    147147    }
    148148
     
    167167    /* nothing opened */
    168168    if (...)
    169         return FALSE;
     169        return FALSE;
    170170#endif
    171    
     171
    172172    if (nRepeat == -1) {
    173173
    174 //      FIXME (animate, "(loop from=%d to=%d) empty stub!\n",
    175 //             nFrom, nTo);
     174//      FIXME (animate, "(loop from=%d to=%d) empty stub!\n",
     175//             nFrom, nTo);
    176176
    177177    }
    178178    else {
    179179
    180 //      FIXME (animate, "(repeat=%d from=%d to=%d) empty stub!\n",
    181 //             nRepeat, nFrom, nTo);
     180//      FIXME (animate, "(repeat=%d from=%d to=%d) empty stub!\n",
     181//             nRepeat, nFrom, nTo);
    182182
    183183    }
     
    196196    /* nothing opened */
    197197    if (...)
    198         return FALSE;
     198        return FALSE;
    199199#endif
    200    
     200
    201201    return TRUE;
    202202}
     
    212212    infoPtr = (ANIMATE_INFO *)COMCTL32_Alloc (sizeof(ANIMATE_INFO));
    213213    if (!infoPtr) {
    214 //      ERR (animate, "could not allocate info memory!\n");
    215         return 0;
     214//      ERR (animate, "could not allocate info memory!\n");
     215        return 0;
    216216    }
    217217
     
    262262
    263263
    264 LRESULT WINAPI
     264static LRESULT WINAPI
    265265ANIMATE_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    266266{
    267267    switch (uMsg)
    268268    {
    269         case ACM_OPENA:
    270             return ANIMATE_OpenA (hwnd, wParam, lParam);
    271 
    272 /*      case ACM_OPEN32W: */
    273 /*          return ANIMATE_Open32W (hwnd, wParam, lParam); */
     269        case ACM_OPENA:
     270            return ANIMATE_OpenA (hwnd, wParam, lParam);
     271
     272/*      case ACM_OPEN32W: */
     273/*          return ANIMATE_Open32W (hwnd, wParam, lParam); */
    274274
    275275        case ACM_PLAY:
    276276            return ANIMATE_Play (hwnd, wParam, lParam);
    277277
    278         case ACM_STOP:
    279             return ANIMATE_Stop (hwnd, wParam, lParam);
    280 
    281 
    282         case WM_CREATE:
    283             return ANIMATE_Create (hwnd, wParam, lParam);
    284 
    285         case WM_DESTROY:
    286             return ANIMATE_Destroy (hwnd, wParam, lParam);
    287 
    288 /*      case WM_ERASEBKGND: */
    289 /*          return ANIMATE_EraseBackground (hwnd, wParam, lParam); */
    290 
    291 /*      case WM_NCCREATE: */
    292 /*      case WM_NCHITTEST: */
    293 /*      case WM_PAINT: */
    294 /*      case WM_SIZE: */
    295 /*      case WM_STYLECHANGED: */
    296 /*      case WM_TIMER: */
    297 
    298         default:
    299 //          if (uMsg >= WM_USER)
    300 //              ERR (animate, "unknown msg %04x wp=%08x lp=%08lx\n",
    301 //                   uMsg, wParam, lParam);
    302             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     278        case ACM_STOP:
     279            return ANIMATE_Stop (hwnd, wParam, lParam);
     280
     281
     282        case WM_CREATE:
     283            return ANIMATE_Create (hwnd, wParam, lParam);
     284
     285        case WM_DESTROY:
     286            return ANIMATE_Destroy (hwnd, wParam, lParam);
     287
     288/*      case WM_ERASEBKGND: */
     289/*          return ANIMATE_EraseBackground (hwnd, wParam, lParam); */
     290
     291/*      case WM_NCCREATE: */
     292/*      case WM_NCHITTEST: */
     293/*      case WM_PAINT: */
     294/*      case WM_SIZE: */
     295/*      case WM_STYLECHANGED: */
     296/*      case WM_TIMER: */
     297
     298        default:
     299//          if (uMsg >= WM_USER)
     300//              ERR (animate, "unknown msg %04x wp=%08x lp=%08lx\n",
     301//                   uMsg, wParam, lParam);
     302            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    303303    }
    304304    return 0;
     
    321321    wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1);
    322322    wndClass.lpszClassName = ANIMATE_CLASSA;
    323  
     323
    324324    RegisterClassA (&wndClass);
    325325}
     
    330330{
    331331    if (GlobalFindAtomA (ANIMATE_CLASSA))
    332         UnregisterClassA (ANIMATE_CLASSA, (HINSTANCE)NULL);
    333 }
    334 
     332        UnregisterClassA (ANIMATE_CLASSA, (HINSTANCE)NULL);
     333}
     334
  • TabularUnified trunk/src/comctl32/comboex.c

    r94 r496  
    1 /* $Id: comboex.c,v 1.3 1999-06-10 16:21:57 achimha Exp $ */
     1/* $Id: comboex.c,v 1.4 1999-08-14 16:13:09 cbratschi Exp $ */
    22/*
    33 * ComboBoxEx control
     
    1616 *
    1717 * FIXME:
    18  *   - should include "combo.h" 
     18 *   - should include "combo.h"
    1919 */
    2020
     
    5050
    5151    if ((GetWindowLongA (hwnd, GWL_STYLE) & CBS_DROPDOWNLIST) != CBS_DROPDOWN)
    52         return 0;
     52        return 0;
    5353
    5454//    TRACE (comboex, "-- 0x%x\n", GetDlgItem (infoPtr->hwndCombo, ID_CB_EDIT));
     
    103103
    104104    if ((DWORD)wParam) {
    105         infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
     105        infoPtr->dwExtStyle = (infoPtr->dwExtStyle & ~(DWORD)wParam) | (DWORD)lParam;
    106106    }
    107107    else
    108         infoPtr->dwExtStyle = (DWORD)lParam;
     108        infoPtr->dwExtStyle = (DWORD)lParam;
    109109
    110110    /* FIXME: repaint?? */
     
    150150//    FIXME (comboex, "(0x%x 0x%x 0x%lx): stub\n", uMsg, wParam, lParam);
    151151
    152     if (infoPtr->hwndCombo)   
    153         return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
     152    if (infoPtr->hwndCombo)
     153        return SendMessageA (infoPtr->hwndCombo, uMsg, wParam, lParam);
    154154
    155155    return 0;
     
    166166    infoPtr = (COMBOEX_INFO *)COMCTL32_Alloc (sizeof(COMBOEX_INFO));
    167167    if (infoPtr == NULL) {
    168 //      ERR (comboex, "could not allocate info memory!\n");
    169         return 0;
     168//      ERR (comboex, "could not allocate info memory!\n");
     169        return 0;
    170170    }
    171171
     
    178178    /* create combo box */
    179179    dwComboStyle = GetWindowLongA (hwnd, GWL_STYLE) &
    180                         (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
     180                        (CBS_SIMPLE|CBS_DROPDOWN|CBS_DROPDOWNLIST|WS_CHILD);
    181181
    182182    infoPtr->hwndCombo = CreateWindowA ("ComboBox", "",
    183                         WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
    184                         0, 0, 0, 0, hwnd, (HMENU)1,
    185                         GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     183                        WS_CHILD | WS_VISIBLE | CBS_OWNERDRAWFIXED | dwComboStyle,
     184                        0, 0, 0, 0, hwnd, (HMENU)1,
     185                        GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
    186186
    187187    return 0;
     
    196196
    197197    if (infoPtr->hwndCombo)
    198         DestroyWindow (infoPtr->hwndCombo);
     198        DestroyWindow (infoPtr->hwndCombo);
    199199
    200200
     
    217217
    218218    MoveWindow (infoPtr->hwndCombo, 0, 0, rect.right -rect.left,
    219                   rect.bottom - rect.top, TRUE);
    220 
    221     return 0;
    222 }
    223 
    224 
    225 LRESULT WINAPI
     219                  rect.bottom - rect.top, TRUE);
     220
     221    return 0;
     222}
     223
     224
     225static LRESULT WINAPI
    226226COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    227227{
    228228    switch (uMsg)
    229229    {
    230 /*      case CBEM_DELETEITEM: */
    231 
    232         case CBEM_GETCOMBOCONTROL:
    233             return COMBOEX_GetComboControl (hwnd, wParam, lParam);
    234 
    235         case CBEM_GETEDITCONTROL:
    236             return COMBOEX_GetEditControl (hwnd, wParam, lParam);
    237 
    238         case CBEM_GETEXTENDEDSTYLE:
    239             return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
    240 
    241         case CBEM_GETIMAGELIST:
    242             return COMBOEX_GetImageList (hwnd, wParam, lParam);
    243 
    244 /*      case CBEM_GETITEM32A:
    245         case CBEM_GETITEM32W:
    246         case CBEM_GETUNICODEFORMAT:
    247         case CBEM_HASEDITCHANGED:
     230/*      case CBEM_DELETEITEM: */
     231
     232        case CBEM_GETCOMBOCONTROL:
     233            return COMBOEX_GetComboControl (hwnd, wParam, lParam);
     234
     235        case CBEM_GETEDITCONTROL:
     236            return COMBOEX_GetEditControl (hwnd, wParam, lParam);
     237
     238        case CBEM_GETEXTENDEDSTYLE:
     239            return COMBOEX_GetExtendedStyle (hwnd, wParam, lParam);
     240
     241        case CBEM_GETIMAGELIST:
     242            return COMBOEX_GetImageList (hwnd, wParam, lParam);
     243
     244/*      case CBEM_GETITEM32A:
     245        case CBEM_GETITEM32W:
     246        case CBEM_GETUNICODEFORMAT:
     247        case CBEM_HASEDITCHANGED:
    248248*/
    249249
    250         case CBEM_INSERTITEMA:
    251             return COMBOEX_InsertItemA (hwnd, wParam, lParam);
    252 
    253 /*      case CBEM_INSERTITEM32W: */
    254 
    255         case CBEM_SETEXTENDEDSTYLE:
    256             return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
    257 
    258         case CBEM_SETIMAGELIST:
    259             return COMBOEX_SetImageList (hwnd, wParam, lParam);
    260 
    261         case CBEM_SETITEMA:
    262             return COMBOEX_SetItemA (hwnd, wParam, lParam);
    263 
    264 /*      case CBEM_SETITEM32W:
    265         case CBEM_SETUNICODEFORMAT:
     250        case CBEM_INSERTITEMA:
     251            return COMBOEX_InsertItemA (hwnd, wParam, lParam);
     252
     253/*      case CBEM_INSERTITEM32W: */
     254
     255        case CBEM_SETEXTENDEDSTYLE:
     256            return COMBOEX_SetExtendedStyle (hwnd, wParam, lParam);
     257
     258        case CBEM_SETIMAGELIST:
     259            return COMBOEX_SetImageList (hwnd, wParam, lParam);
     260
     261        case CBEM_SETITEMA:
     262            return COMBOEX_SetItemA (hwnd, wParam, lParam);
     263
     264/*      case CBEM_SETITEM32W:
     265        case CBEM_SETUNICODEFORMAT:
    266266*/
    267267
    268         case CB_DELETESTRING:
    269         case CB_FINDSTRINGEXACT:
    270         case CB_GETCOUNT:
    271         case CB_GETCURSEL:
    272         case CB_GETDROPPEDCONTROLRECT:
    273         case CB_GETDROPPEDSTATE:
    274         case CB_GETITEMDATA:
    275         case CB_GETITEMHEIGHT:
    276         case CB_GETLBTEXT:
    277         case CB_GETLBTEXTLEN:
    278         case CB_GETEXTENDEDUI:
    279         case CB_LIMITTEXT:
    280         case CB_RESETCONTENT:
    281         case CB_SELECTSTRING:
    282         case CB_SETCURSEL:
    283         case CB_SETDROPPEDWIDTH:
    284         case CB_SETEXTENDEDUI:
    285         case CB_SETITEMDATA:
    286         case CB_SETITEMHEIGHT:
    287         case CB_SHOWDROPDOWN:
    288             return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
    289 
    290 
    291         case WM_CREATE:
    292             return COMBOEX_Create (hwnd, wParam, lParam);
    293 
    294         case WM_DESTROY:
    295             return COMBOEX_Destroy (hwnd, wParam, lParam);
    296 
    297         case WM_SIZE:
    298             return COMBOEX_Size (hwnd, wParam, lParam);
    299 
    300         default:
    301 //          if (uMsg >= WM_USER)
    302 //              ERR (comboex, "unknown msg %04x wp=%08x lp=%08lx\n",
    303 //                   uMsg, wParam, lParam);
    304             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     268        case CB_DELETESTRING:
     269        case CB_FINDSTRINGEXACT:
     270        case CB_GETCOUNT:
     271        case CB_GETCURSEL:
     272        case CB_GETDROPPEDCONTROLRECT:
     273        case CB_GETDROPPEDSTATE:
     274        case CB_GETITEMDATA:
     275        case CB_GETITEMHEIGHT:
     276        case CB_GETLBTEXT:
     277        case CB_GETLBTEXTLEN:
     278        case CB_GETEXTENDEDUI:
     279        case CB_LIMITTEXT:
     280        case CB_RESETCONTENT:
     281        case CB_SELECTSTRING:
     282        case CB_SETCURSEL:
     283        case CB_SETDROPPEDWIDTH:
     284        case CB_SETEXTENDEDUI:
     285        case CB_SETITEMDATA:
     286        case CB_SETITEMHEIGHT:
     287        case CB_SHOWDROPDOWN:
     288            return COMBOEX_Forward (hwnd, uMsg, wParam, lParam);
     289
     290
     291        case WM_CREATE:
     292            return COMBOEX_Create (hwnd, wParam, lParam);
     293
     294        case WM_DESTROY:
     295            return COMBOEX_Destroy (hwnd, wParam, lParam);
     296
     297        case WM_SIZE:
     298            return COMBOEX_Size (hwnd, wParam, lParam);
     299
     300        default:
     301//          if (uMsg >= WM_USER)
     302//              ERR (comboex, "unknown msg %04x wp=%08x lp=%08lx\n",
     303//                   uMsg, wParam, lParam);
     304            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    305305    }
    306306    return 0;
     
    323323    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    324324    wndClass.lpszClassName = WC_COMBOBOXEXA;
    325  
     325
    326326    RegisterClassA (&wndClass);
    327327}
     
    332332{
    333333    if (GlobalFindAtomA (WC_COMBOBOXEXA))
    334         UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);
    335 }
    336 
     334        UnregisterClassA (WC_COMBOBOXEXA, (HINSTANCE)NULL);
     335}
     336
  • TabularUnified trunk/src/comctl32/comctl32.def

    r144 r496  
    1 ; $Id: comctl32.def,v 1.10 1999-06-21 13:59:00 sandervl Exp $
     1; $Id: comctl32.def,v 1.11 1999-08-14 16:13:09 cbratschi Exp $
    22LIBRARY COMCTL32 INITINSTANCE
    33DESCRIPTION 'COMCTL32 Common Controls Library'
     
    9999  DSA_InsertItem      = _DSA_InsertItem@12         @325
    100100  DSA_DeleteItem      = _DSA_DeleteItem@8          @326
    101   DSA_DeleteAllItems  = _DSA_DeleteAllItems@4      @327 
     101  DSA_DeleteAllItems  = _DSA_DeleteAllItems@4      @327
    102102
    103103  DPA_Create          = _DPA_Create@4              @328
     
    136136  StrStrW             = _COMCTL32_StrStrW@8        @362
    137137  StrSpnW             = _COMCTL32_StrSpnW@8        @364
     138
     139  comctl32_410        = _comctl32_410@16           @410
     140  InitMUILanguage     = _InitMUILanguage@4         @500 ;should be 70
  • TabularUnified trunk/src/comctl32/comctl32.h

    r94 r496  
    1 /* $Id: comctl32.h,v 1.6 1999-06-10 16:21:58 achimha Exp $ */
     1/* $Id: comctl32.h,v 1.7 1999-08-14 16:13:10 cbratschi Exp $ */
    22/*
    33 * Win32 common controls implementation
     
    6767#define IDC_MOVEDN_BTN      207
    6868
     69/* Toolbar imagelist bitmaps */
     70#define IDB_STD_SMALL       120
     71#define IDB_STD_LARGE       121
     72#define IDB_VIEW_SMALL      124
     73#define IDB_VIEW_LARGE      125
     74#define IDB_HIST_SMALL      130
     75#define IDB_HIST_LARGE      131
     76
     77
     78/* Month calendar month menu popup */
     79#define IDD_MCMONTHMENU     300
     80
     81#define IDM_JAN                         301
     82#define IDM_FEB                         302
     83#define IDM_MAR                         303
     84#define IDM_APR                         304
     85#define IDM_MAY                         305
     86#define IDM_JUN                         306
     87#define IDM_JUL                         307
     88#define IDM_AUG                         308
     89#define IDM_SEP                         309
     90#define IDM_OCT                         310
     91#define IDM_NOV                         311
     92#define IDM_DEC                         312
    6993
    7094#endif /* _H_COMCTL32 */
  • TabularUnified trunk/src/comctl32/comctl32undoc.c

    r403 r496  
    1 /* $Id: comctl32undoc.c,v 1.9 1999-08-03 15:49:58 cbratschi Exp $ */
     1/* $Id: comctl32undoc.c,v 1.10 1999-08-14 16:13:10 cbratschi Exp $ */
    22/*
    33 * Undocumented functions from COMCTL32.DLL
     
    4545           PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam)
    4646{
     47    INT nCount;
     48
     49#if 0    /* these go with the "incomplete implementation" below */
    4750    LPVOID pWork1, pWork2;
    4851    INT nResult;
    49     INT nCount, nIndex;
     52    INT nIndex;
    5053    INT nNewItems;
     54#endif
    5155
    5256//    TRACE (commctrl, "(%p %p %08lx %p %p %08lx): stub!\n",
     
    18941898//  return (INT)(lpLoop-lpStr);
    18951899}
     1900
     1901/**************************************************************************
     1902 * comctl32_410 [COMCTL32.410]
     1903 *
     1904 * FIXME: What's this supposed to do?
     1905 *        Parameter 1 is an HWND, you're on your own for the rest.
     1906 */
     1907
     1908BOOL WINAPI comctl32_410( HWND hw, DWORD b, DWORD c, DWORD d) {
     1909
     1910   //FIXME_(commctrl)("(%x, %lx, %lx, %lx): stub!\n", hw, b, c, d);
     1911
     1912   return TRUE;
     1913}
     1914
     1915/*************************************************************************
     1916 * InitMUILanguage [COMCTL32.70]
     1917 *
     1918 * FIXME: What's this supposed to do?  Apparently some i18n thing.
     1919 *
     1920 */
     1921
     1922BOOL WINAPI InitMUILanguage( DWORD a ) {
     1923
     1924   //FIXME_(commctrl)("(%lx): stub!\n", a);
     1925
     1926   return TRUE;
     1927}
     1928
  • TabularUnified trunk/src/comctl32/datetime.c

    r94 r496  
    1 /* $Id: datetime.c,v 1.3 1999-06-10 16:21:58 achimha Exp $ */
     1/* $Id: datetime.c,v 1.4 1999-08-14 16:13:10 cbratschi Exp $ */
    22/*
    33 * Date and time picker control
    44 *
    55 * Copyright 1998, 1999 Eric Kohl
     6 * Copyright 1999 Alex Priem <alexp@sci.kun.nl>
    67 * Copyright 1999 Achim Hasenmueller
     8 * Copyright 1999 Christoph Bratschi
    79 *
    8  * NOTES
    9  *   This is just a dummy control. An author is needed! Any volunteers?
    10  *   I will only improve this control once in a while.
    11  *     Eric <ekohl@abo.rhein-zeitung.de>
    1210 *
    1311 * TODO:
     
    2018#include "commctrl.h"
    2119#include "datetime.h"
    22 
     20#include "monthcal.h"
     21#include <string.h>
     22#include <stdio.h>
    2323
    2424
    2525#define DATETIME_GetInfoPtr(hwnd) ((DATETIME_INFO *)GetWindowLongA (hwnd, 0))
     26static BOOL
     27
     28DATETIME_SendSimpleNotify (HWND hwnd, UINT code);
     29
     30static char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
     31                       "Thursday", "Friday", "Saturday", NULL};
     32
     33static char *monthtxt[] = {"January", "February", "March", "April", "May",
     34                           "June", "July", "August", "September", "October",
     35                           "November", "December"};
     36
     37static LRESULT
     38DATETIME_GetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam )
     39{
     40  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     41  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     42  SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
     43
     44  if (!lParam) return GDT_NONE;
     45
     46  if ((dwStyle & DTS_SHOWNONE) &&
     47       (SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0)))
     48        return GDT_NONE;
     49
     50  MONTHCAL_CopyTime (&infoPtr->date, lprgSysTimeArray);
     51
     52  return GDT_VALID;
     53}
     54
     55
     56static LRESULT
     57DATETIME_SetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam )
     58{
     59  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     60  SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
     61
     62  if (!lParam) return 0;
     63
     64  if (lParam==GDT_VALID)
     65        MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date);
     66  if (lParam==GDT_NONE) {
     67        infoPtr->dateValid=FALSE;
     68    SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 0, 0);
     69        }
     70  return 1;
     71}
     72
     73
     74static LRESULT
     75DATETIME_GetMonthCalColor (HWND hwnd, WPARAM wParam)
     76{
     77  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     78
     79  return SendMessageA (infoPtr->hMonthCal, MCM_GETCOLOR, wParam, 0);
     80}
     81
     82static LRESULT
     83DATETIME_SetMonthCalColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
     84{
     85  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     86
     87  return SendMessageA (infoPtr->hMonthCal, MCM_SETCOLOR, wParam, lParam);
     88}
     89
     90
     91/* FIXME: need to get way to force font into monthcal structure */
     92
     93static LRESULT
     94DATETIME_GetMonthCal (HWND hwnd)
     95{
     96  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     97
     98  return infoPtr->hMonthCal;
     99}
     100
     101
     102
     103/* FIXME: need to get way to force font into monthcal structure */
     104
     105static LRESULT
     106DATETIME_GetMonthCalFont (HWND hwnd)
     107{
     108
     109  return 0;
     110}
     111
     112static LRESULT
     113DATETIME_SetMonthCalFont (HWND hwnd, WPARAM wParam, LPARAM lParam)
     114{
     115
     116  return 0;
     117}
     118
     119
     120static void DATETIME_Refresh (HWND hwnd, HDC hdc)
     121
     122{
     123  DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     124  RECT *daytxt   = &infoPtr->daytxt;
     125  RECT *daynumtxt= &infoPtr->daynumtxt;
     126  RECT *rmonthtxt= &infoPtr->rmonthtxt;
     127  RECT *yeartxt  = &infoPtr->yeartxt;
     128  RECT *calbutton= &infoPtr->calbutton;
     129  RECT *checkbox = &infoPtr->checkbox;
     130  RECT *rect     = &infoPtr->rect;
     131  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     132  SYSTEMTIME date = infoPtr->date;
     133  SIZE size;
     134  BOOL prssed=FALSE;
     135  COLORREF oldBk;
     136
     137
     138
     139  if (infoPtr->dateValid) {
     140    char txt[80];
     141        HFONT oldFont;
     142        oldFont = SelectObject (hdc, infoPtr->hFont);
     143
     144        GetClientRect (hwnd, rect);
     145
     146        sprintf (txt,"%s,",days[date.wDayOfWeek]);
     147        GetTextExtentPoint32A (hdc, txt, strlen (txt), &size);
     148        rect->bottom=size.cy+2;
     149
     150        checkbox->left  = 0;
     151        checkbox->right = 0;
     152        checkbox->top   = rect->top;
     153        checkbox->bottom= rect->bottom;
     154    if (dwStyle & DTS_SHOWNONE) {    /* FIXME: draw checkbox */
     155                checkbox->right=18;
     156                }
     157
     158
     159        if (infoPtr->select==(DTHT_DAY|DTHT_GOTFOCUS))
     160                oldBk=SetBkColor (hdc, COLOR_GRAYTEXT);
     161       daytxt->left  = checkbox->right;
     162       daytxt->right = checkbox->right+size.cx;
     163       daytxt->top   = rect->top;
     164       daytxt->bottom= rect->bottom;
     165       DrawTextA ( hdc, txt, strlen(txt), daytxt,
     166                         DT_LEFT | DT_VCENTER | DT_SINGLELINE );
     167        if (infoPtr->select==(DTHT_DAY|DTHT_GOTFOCUS))
     168                SetBkColor (hdc, oldBk);
     169
     170        if (infoPtr->select==(DTHT_MONTH|DTHT_GOTFOCUS))
     171                oldBk=SetBkColor (hdc, COLOR_GRAYTEXT);
     172        strcpy (txt, monthtxt[date.wMonth]);
     173        GetTextExtentPoint32A (hdc, "September", 9, &size);
     174       rmonthtxt->left  = daytxt->right;
     175       rmonthtxt->right = daytxt->right+size.cx;
     176        rmonthtxt->top   = rect->top;
     177        rmonthtxt->bottom= rect->bottom;
     178        DrawTextA ( hdc, txt, strlen(txt), rmonthtxt,
     179                         DT_CENTER | DT_VCENTER | DT_SINGLELINE );
     180        if (infoPtr->select==(DTHT_MONTH|DTHT_GOTFOCUS))
     181                SetBkColor (hdc, oldBk);
     182
     183        if (infoPtr->select==(DTHT_DAYNUM|DTHT_GOTFOCUS))
     184                oldBk=SetBkColor (hdc, COLOR_GRAYTEXT);
     185        sprintf (txt,"%d,",date.wDay);
     186        GetTextExtentPoint32A (hdc, "31,", 3, &size);
     187       daynumtxt->left  = rmonthtxt->right;
     188       daynumtxt->right = rmonthtxt->right+size.cx;
     189        daynumtxt->top   = rect->top;
     190        daynumtxt->bottom= rect->bottom;
     191        DrawTextA ( hdc, txt, strlen(txt), daynumtxt,
     192                         DT_RIGHT | DT_VCENTER | DT_SINGLELINE );
     193        if (infoPtr->select==(DTHT_DAYNUM|DTHT_GOTFOCUS))
     194                SetBkColor (hdc, oldBk);
     195
     196        if (infoPtr->select==(DTHT_YEAR|DTHT_GOTFOCUS))
     197                oldBk=SetBkColor (hdc, COLOR_GRAYTEXT);
     198        sprintf (txt,"%d",date.wYear);
     199        GetTextExtentPoint32A (hdc, "2000", 5, &size);
     200       yeartxt->left  = daynumtxt->right;
     201       yeartxt->right = daynumtxt->right+size.cx;
     202        yeartxt->top   = rect->top;
     203        yeartxt->bottom= rect->bottom;
     204        DrawTextA ( hdc, txt, strlen(txt), yeartxt,
     205                         DT_RIGHT | DT_VCENTER | DT_SINGLELINE );
     206        if (infoPtr->select==(DTHT_YEAR|DTHT_GOTFOCUS))
     207                SetBkColor (hdc, oldBk);
     208
     209        SelectObject (hdc, oldFont);
     210        }
     211
     212        if (!(dwStyle & DTS_UPDOWN)) {
     213
     214                calbutton->right = rect->right;
     215                calbutton->left  = rect->right-15;
     216                calbutton->top   = rect->top;
     217                calbutton->bottom= rect->bottom;
     218
     219        DrawFrameControl(hdc, calbutton, DFC_SCROLL,
     220                DFCS_SCROLLDOWN | (prssed ? DFCS_PUSHED : 0) |
     221                (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
     222        }
     223
     224}
     225
     226static LRESULT
     227DATETIME_HitTest (HWND hwnd, DATETIME_INFO *infoPtr, POINT pt)
     228{
     229  //TRACE ("%ld, %ld\n",pt.x,pt.y);
     230
     231  if (PtInRect (&infoPtr->calbutton, pt)) return DTHT_MCPOPUP;
     232  if (PtInRect (&infoPtr->yeartxt, pt))   return DTHT_YEAR;
     233  if (PtInRect (&infoPtr->daynumtxt, pt)) return DTHT_DAYNUM;
     234  if (PtInRect (&infoPtr->rmonthtxt, pt)) return DTHT_MONTH;
     235  if (PtInRect (&infoPtr->daytxt, pt))    return DTHT_DAY;
     236  if (PtInRect (&infoPtr->checkbox, pt))  return DTHT_CHECKBOX;
     237
     238  return 0;
     239}
     240
     241static LRESULT
     242DATETIME_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
     243{
     244    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     245        POINT pt;
     246        int old;
     247
     248    //TRACE ("\n");
     249
     250        old=infoPtr->select;
     251    pt.x=(INT)LOWORD(lParam);
     252    pt.y=(INT)HIWORD(lParam);
     253    infoPtr->select=DATETIME_HitTest (hwnd, infoPtr, pt);
     254
     255        if (infoPtr->select!=old) {
     256                HDC hdc;
     257
     258                SetFocus (hwnd);
     259                hdc=GetDC (hwnd);
     260                DATETIME_Refresh (hwnd,hdc);
     261        ReleaseDC (hwnd, hdc);
     262    }
     263        if (infoPtr->select==DTHT_MCPOPUP) {
     264                        POINT pt;
     265
     266                        pt.x=8;
     267                        pt.y=infoPtr->rect.bottom+5;
     268                        ClientToScreen (hwnd, &pt);
     269                        infoPtr->hMonthCal=CreateWindowExA (0,"SysMonthCal32", 0,
     270                                WS_POPUP | WS_BORDER,
     271                                pt.x,pt.y,145,150,
     272                                GetParent (hwnd),
     273                                0,0,0);
     274
     275                      //TRACE ("dt:%x mc:%x mc parent:%x, desktop:%x, mcpp:%x\n",
     276                      //hwnd,infoPtr->hMonthCal,
     277                      //GetParent (infoPtr->hMonthCal),
     278                      //GetDesktopWindow (),
     279                      //GetParent (GetParent (infoPtr->hMonthCal)));
     280
     281                        SetFocus (hwnd);
     282                        DATETIME_SendSimpleNotify (hwnd, DTN_DROPDOWN);
     283        }
     284    return 0;
     285}
     286
     287
     288static LRESULT
     289DATETIME_Paint (HWND hwnd, WPARAM wParam)
     290{
     291    HDC hdc;
     292    PAINTSTRUCT ps;
     293
     294    hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
     295    DATETIME_Refresh (hwnd, hdc);
     296    if(!wParam)
     297    EndPaint (hwnd, &ps);
     298    return 0;
     299}
     300
     301static LRESULT
     302DATETIME_ParentNotify (HWND hwnd, WPARAM wParam, LPARAM lParam)
     303{
     304    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     305        LPNMHDR lpnmh=(LPNMHDR) lParam;
     306
     307        //TRACE ("%x,%lx\n",wParam, lParam);
     308        //TRACE ("Got notification %x from %x\n", lpnmh->code, lpnmh->hwndFrom);
     309        //TRACE ("info: %x %x %x\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown);
     310        return 0;
     311}
     312
     313static LRESULT
     314DATETIME_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam)
     315
     316{
     317    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     318        LPNMHDR lpnmh=(LPNMHDR) lParam;
     319
     320        //TRACE ("%x,%lx\n",wParam, lParam);
     321        //TRACE ("Got notification %x from %x\n", lpnmh->code, lpnmh->hwndFrom);
     322        //TRACE ("info: %x %x %x\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown);
     323        return 0;
     324}
     325
     326static LRESULT
     327DATETIME_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
     328{
     329    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     330    HDC hdc;
     331
     332    //TRACE ("\n");
     333
     334        if (infoPtr->select) {
     335                        DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS);
     336                        infoPtr->select&= ~DTHT_GOTFOCUS;
     337        }
     338    hdc = GetDC (hwnd);
     339    DATETIME_Refresh (hwnd, hdc);
     340    ReleaseDC (hwnd, hdc);
     341    InvalidateRect (hwnd, NULL, TRUE);
     342
     343    return 0;
     344}
     345
     346
     347static LRESULT
     348DATETIME_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
     349{
     350    HDC hdc;
     351    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
     352
     353    //TRACE ("\n");
     354
     355        if (infoPtr->select) {
     356                        DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS);
     357                        infoPtr->select|=DTHT_GOTFOCUS;
     358        }
     359    hdc = GetDC (hwnd);
     360    DATETIME_Refresh (hwnd, hdc);
     361    ReleaseDC (hwnd, hdc);
     362
     363    return 0;
     364}
     365
     366
     367static BOOL
     368DATETIME_SendSimpleNotify (HWND hwnd, UINT code)
     369{
     370    NMHDR nmhdr;
     371
     372    //TRACE("%x\n",code);
     373    nmhdr.hwndFrom = hwnd;
     374    nmhdr.idFrom   = GetWindowLongA( hwnd, GWL_ID);
     375    nmhdr.code     = code;
     376
     377    return (BOOL) SendMessageA (GetParent (hwnd), WM_NOTIFY,
     378                                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     379}
    26380
    27381
     
    33387DATETIME_Create (HWND hwnd, WPARAM wParam, LPARAM lParam)
    34388{
    35     DATETIME_INFO *infoPtr;
     389  DATETIME_INFO *infoPtr;
     390  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    36391
    37392    /* allocate memory for info structure */
    38393    infoPtr = (DATETIME_INFO *)COMCTL32_Alloc (sizeof(DATETIME_INFO));
    39394    if (infoPtr == NULL) {
    40 //      ERR (datetime, "could not allocate info memory!\n");
    41         return 0;
     395        //ERR("could not allocate info memory!\n");
     396        return 0;
    42397    }
    43398
    44399    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
    45400
     401        if (dwStyle & DTS_SHOWNONE) {
     402                infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0,
     403                                WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX,
     404                                2,2,13,13,
     405                                hwnd,
     406                0, GetWindowLongA  (hwnd, GWL_HINSTANCE), 0);
     407                SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0);
     408        }
     409
     410        if (dwStyle & DTS_UPDOWN) {
     411
     412                        infoPtr->hUpdown=CreateUpDownControl (
     413                                WS_CHILD | WS_BORDER | WS_VISIBLE,
     414                                120,1,20,20,
     415                                hwnd,1,0,0,
     416                                UD_MAXVAL, UD_MINVAL, 0);
     417        }
    46418
    47419    /* initialize info structure */
    48 
    49 
    50 
     420        infoPtr->hMonthCal=0;
     421        GetSystemTime (&infoPtr->date);
     422        infoPtr->dateValid = TRUE;
     423        infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT);
    51424    return 0;
    52425}
     
    58431    DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd);
    59432
    60     /* free datetime info data */
    61433    COMCTL32_Free (infoPtr);
    62 
    63     return 0;
    64 }
    65 
    66 
    67 
    68 
    69 LRESULT WINAPI
     434    return 0;
     435}
     436
     437
     438
     439
     440
     441static LRESULT WINAPI
    70442DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    71443{
     444
    72445    switch (uMsg)
    73446    {
    74447
    75448    case DTM_GETSYSTEMTIME:
    76 //        FIXME (datetime, "Unimplemented msg DTM_GETSYSTEMTIME\n");
    77         return GDT_VALID;
     449                DATETIME_GetSystemTime (hwnd, wParam, lParam);
    78450
    79451    case DTM_SETSYSTEMTIME:
    80 //        FIXME (datetime, "Unimplemented msg DTM_SETSYSTEMTIME\n");
     452                DATETIME_SetSystemTime (hwnd, wParam, lParam);
     453
     454    case DTM_GETRANGE:
     455        //FIXME("Unimplemented msg DTM_GETRANGE\n");
     456        return 0;
     457
     458    case DTM_SETRANGE:
     459        //FIXME("Unimplemented msg DTM_SETRANGE\n");
    81460        return 1;
    82461
    83     case DTM_GETRANGE:
    84 //        FIXME (datetime, "Unimplemented msg DTM_GETRANGE\n");
    85         return 0;
    86 
    87     case DTM_SETRANGE:
    88 //        FIXME (datetime, "Unimplemented msg DTM_SETRANGE\n");
     462    case DTM_SETFORMATA:
     463        //FIXME("Unimplemented msg DTM_SETFORMAT32A\n");
    89464        return 1;
    90465
    91     case DTM_SETFORMATA:
    92 //        FIXME (datetime, "Unimplemented msg DTM_SETFORMAT32A\n");
     466    case DTM_SETFORMATW:
     467        //FIXME("Unimplemented msg DTM_SETFORMAT32W\n");
    93468        return 1;
    94469
    95     case DTM_SETFORMATW:
    96 //        FIXME (datetime, "Unimplemented msg DTM_SETFORMAT32W\n");
    97         return 1;
    98 
    99470    case DTM_SETMCCOLOR:
    100 //        FIXME (datetime, "Unimplemented msg DTM_SETMCCOLOR\n");
    101         return 0;
     471        return DATETIME_SetMonthCalColor (hwnd, wParam, lParam);
    102472
    103473    case DTM_GETMCCOLOR:
    104 //        FIXME (datetime, "Unimplemented msg DTM_GETMCCOLOR\n");
    105         return 0;
     474        return DATETIME_GetMonthCalColor (hwnd, wParam);
    106475
    107476    case DTM_GETMONTHCAL:
    108 //        FIXME (datetime, "Unimplemented msg DTM_GETMONTHCAL\n");
    109         return 0;
     477        return DATETIME_GetMonthCal (hwnd);
    110478
    111479    case DTM_SETMCFONT:
    112 //        FIXME (datetime, "Unimplemented msg DTM_SETMCFONT\n");
    113         return 0;
     480        return DATETIME_SetMonthCalFont (hwnd, wParam, lParam);
    114481
    115482    case DTM_GETMCFONT:
    116 //        FIXME (datetime, "Unimplemented msg DTM_GETMCFONT\n");
    117         return 0;
    118 
    119         case WM_CREATE:
    120             return DATETIME_Create (hwnd, wParam, lParam);
    121 
    122         case WM_DESTROY:
    123             return DATETIME_Destroy (hwnd, wParam, lParam);
    124 
    125         default:
    126 //          if (uMsg >= WM_USER)
    127 //              ERR (datetime, "unknown msg %04x wp=%08x lp=%08lx\n",
    128 //                   uMsg, wParam, lParam);
    129             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     483        return DATETIME_GetMonthCalFont (hwnd);
     484
     485        case WM_PARENTNOTIFY:
     486                return DATETIME_ParentNotify (hwnd, wParam, lParam);
     487
     488        case WM_NOTIFY:
     489                return DATETIME_Notify (hwnd, wParam, lParam);
     490
     491    case WM_PAINT:
     492        return DATETIME_Paint (hwnd, wParam);
     493
     494    case WM_KILLFOCUS:
     495        return DATETIME_KillFocus (hwnd, wParam, lParam);
     496
     497    case WM_SETFOCUS:
     498        return DATETIME_SetFocus (hwnd, wParam, lParam);
     499
     500    case WM_LBUTTONDOWN:
     501        return DATETIME_LButtonDown (hwnd, wParam, lParam);
     502
     503        case WM_CREATE:
     504            return DATETIME_Create (hwnd, wParam, lParam);
     505
     506        case WM_DESTROY:
     507            return DATETIME_Destroy (hwnd, wParam, lParam);
     508
     509        default:
     510            //if (uMsg >= WM_USER)
     511                //ERR("unknown msg %04x wp=%08x lp=%08lx\n",
     512                //     uMsg, wParam, lParam);
     513            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    130514    }
    131515    return 0;
     
    134518
    135519VOID
    136 DATETIME_Register (VOID)
     520DATETIME_Register (void)
    137521{
    138522    WNDCLASSA wndClass;
     
    148532    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    149533    wndClass.lpszClassName = DATETIMEPICK_CLASSA;
    150  
     534
    151535    RegisterClassA (&wndClass);
    152536}
     
    154538
    155539VOID
    156 DATETIME_Unregister (VOID)
     540DATETIME_Unregister (void)
    157541{
    158542    if (GlobalFindAtomA (DATETIMEPICK_CLASSA))
    159         UnregisterClassA (DATETIMEPICK_CLASSA, (HINSTANCE)NULL);
    160 }
    161 
     543        UnregisterClassA (DATETIMEPICK_CLASSA, (HINSTANCE)NULL);
     544}
     545
  • TabularUnified trunk/src/comctl32/flatsb.c

    r94 r496  
    1 /* $Id: flatsb.c,v 1.3 1999-06-10 16:21:58 achimha Exp $ */
     1/* $Id: flatsb.c,v 1.4 1999-08-14 16:13:10 cbratschi Exp $ */
    22/*
    33 * Flat Scrollbar control
     
    2020#include "winbase.h"
    2121#include "commctrl.h"
    22 #include "flatsb.h" 
     22#include "flatsb.h"
    2323
    2424
     
    2626
    2727
    28 BOOL WINAPI 
     28BOOL WINAPI
    2929FlatSB_EnableScrollBar(HWND hwnd, INT dummy, UINT dummy2)
    3030{
     
    3333}
    3434
    35 BOOL WINAPI 
     35BOOL WINAPI
    3636FlatSB_ShowScrollBar(HWND hwnd, INT code, BOOL flag)
    3737{
     
    4040}
    4141
    42 BOOL WINAPI 
     42BOOL WINAPI
    4343FlatSB_GetScrollRange(HWND hwnd, INT code, LPINT min, LPINT max)
    4444{
     
    4747}
    4848
    49 BOOL WINAPI 
     49BOOL WINAPI
    5050FlatSB_GetScrollInfo(HWND hwnd, INT code, LPSCROLLINFO info)
    5151{
     
    5454}
    5555
    56 INT WINAPI 
     56INT WINAPI
    5757FlatSB_GetScrollPos(HWND hwnd, INT code)
    5858{
     
    6161}
    6262
    63 BOOL WINAPI 
     63BOOL WINAPI
    6464FlatSB_GetScrollProp(HWND hwnd, INT propIndex, LPINT prop)
    6565{
     
    6969
    7070
    71 INT WINAPI 
     71INT WINAPI
    7272FlatSB_SetScrollPos(HWND hwnd, INT code, INT pos, BOOL fRedraw)
    7373{
     
    7676}
    7777
    78 INT WINAPI 
     78INT WINAPI
    7979FlatSB_SetScrollInfo(HWND hwnd, INT code, LPSCROLLINFO info, BOOL fRedraw)
    8080{
     
    8383}
    8484
    85 INT WINAPI 
     85INT WINAPI
    8686FlatSB_SetScrollRange(HWND hwnd, INT code, INT min, INT max, BOOL fRedraw)
    8787{
     
    9090}
    9191
    92 BOOL WINAPI 
     92BOOL WINAPI
    9393FlatSB_SetScrollProp(HWND hwnd, UINT index, INT newValue, BOOL flag)
    9494{
     
    128128
    129129
    130 LRESULT WINAPI
     130static LRESULT WINAPI
    131131FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    132132{
     
    134134    {
    135135
    136         case WM_CREATE:
    137             return FlatSB_Create (hwnd, wParam, lParam);
     136        case WM_CREATE:
     137            return FlatSB_Create (hwnd, wParam, lParam);
    138138
    139         case WM_DESTROY:
    140             return FlatSB_Destroy (hwnd, wParam, lParam);
     139        case WM_DESTROY:
     140            return FlatSB_Destroy (hwnd, wParam, lParam);
    141141
    142         default:
    143 //          if (uMsg >= WM_USER)
    144 //              ERR_(datetime)("unknown msg %04x wp=%08x lp=%08lx\n",
    145 //                   uMsg, wParam, lParam);
    146             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     142        default:
     143//          if (uMsg >= WM_USER)
     144//              ERR_(datetime)("unknown msg %04x wp=%08x lp=%08lx\n",
     145//                   uMsg, wParam, lParam);
     146            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    147147    }
    148148    return 0;
     
    165165    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    166166    wndClass.lpszClassName = FLATSB_CLASSA;
    167  
     167
    168168    RegisterClassA (&wndClass);
    169169}
     
    174174{
    175175    if (GlobalFindAtomA (FLATSB_CLASSA))
    176         UnregisterClassA (FLATSB_CLASSA, (HINSTANCE)NULL);
     176        UnregisterClassA (FLATSB_CLASSA, (HINSTANCE)NULL);
    177177}
    178178
  • TabularUnified trunk/src/comctl32/header.c

    r252 r496  
    1 /* $Id: header.c,v 1.7 1999-06-30 15:52:16 cbratschi Exp $ */
     1/* $Id: header.c,v 1.8 1999-08-14 16:13:10 cbratschi Exp $ */
    22/*
    33 *  Header control
     
    14441444
    14451445
    1446 LRESULT WINAPI
     1446static LRESULT WINAPI
    14471447HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    14481448{
  • TabularUnified trunk/src/comctl32/hotkey.c

    r94 r496  
    1 /* $Id: hotkey.c,v 1.3 1999-06-10 16:21:59 achimha Exp $ */
     1/* $Id: hotkey.c,v 1.4 1999-08-14 16:13:10 cbratschi Exp $ */
    22/*
    33 * Hotkey control
     
    7979
    8080    hBrush =
    81         (HBRUSH)SendMessageA (GetParent (hwnd), WM_CTLCOLOREDIT,
    82                                 wParam, (LPARAM)hwnd);
     81        (HBRUSH)SendMessageA (GetParent (hwnd), WM_CTLCOLOREDIT,
     82                                wParam, (LPARAM)hwnd);
    8383    if (hBrush)
    84         hBrush = (HBRUSH)GetStockObject (WHITE_BRUSH);
     84        hBrush = (HBRUSH)GetStockObject (WHITE_BRUSH);
    8585    GetClientRect (hwnd, &rc);
    8686
     
    106106
    107107    switch (wParam) {
    108         case VK_RETURN:
    109         case VK_TAB:
    110         case VK_SPACE:
    111         case VK_DELETE:
    112         case VK_ESCAPE:
    113         case VK_BACK:
    114             return DefWindowProcA (hwnd, WM_KEYDOWN, wParam, lParam);
    115 
    116         case VK_SHIFT:
    117         case VK_CONTROL:
    118         case VK_MENU:
    119 //          FIXME (hotkey, "modifier key pressed!\n");
    120             break;
    121 
    122         default:
    123 //          FIXME (hotkey, " %d\n", wParam);
    124             break;
     108        case VK_RETURN:
     109        case VK_TAB:
     110        case VK_SPACE:
     111        case VK_DELETE:
     112        case VK_ESCAPE:
     113        case VK_BACK:
     114            return DefWindowProcA (hwnd, WM_KEYDOWN, wParam, lParam);
     115
     116        case VK_SHIFT:
     117        case VK_CONTROL:
     118        case VK_MENU:
     119//          FIXME (hotkey, "modifier key pressed!\n");
     120            break;
     121
     122        default:
     123//          FIXME (hotkey, " %d\n", wParam);
     124            break;
    125125    }
    126126
     
    206206    hdc = GetDC (hwnd);
    207207    if (infoPtr->hFont)
    208         hOldFont = SelectObject (hdc, infoPtr->hFont);
     208        hOldFont = SelectObject (hdc, infoPtr->hFont);
    209209
    210210    GetTextMetricsA (hdc, &tm);
     
    212212
    213213    if (infoPtr->hFont)
    214         SelectObject (hdc, hOldFont);
     214        SelectObject (hdc, hOldFont);
    215215    ReleaseDC (hwnd, hdc);
    216216
    217217    if (LOWORD(lParam)) {
    218218
    219 //      FIXME (hotkey, "force redraw!\n");
     219//      FIXME (hotkey, "force redraw!\n");
    220220
    221221    }
     
    231231
    232232    switch (wParam) {
    233         case VK_RETURN:
    234         case VK_TAB:
    235         case VK_SPACE:
    236         case VK_DELETE:
    237         case VK_ESCAPE:
    238         case VK_BACK:
    239             return DefWindowProcA (hwnd, WM_SYSKEYDOWN, wParam, lParam);
    240 
    241         case VK_SHIFT:
    242         case VK_CONTROL:
    243         case VK_MENU:
    244 //          FIXME (hotkey, "modifier key pressed!\n");
    245             break;
    246 
    247         default:
    248 //          FIXME (hotkey, " %d\n", wParam);
    249             break;
     233        case VK_RETURN:
     234        case VK_TAB:
     235        case VK_SPACE:
     236        case VK_DELETE:
     237        case VK_ESCAPE:
     238        case VK_BACK:
     239            return DefWindowProcA (hwnd, WM_SYSKEYDOWN, wParam, lParam);
     240
     241        case VK_SHIFT:
     242        case VK_CONTROL:
     243        case VK_MENU:
     244//          FIXME (hotkey, "modifier key pressed!\n");
     245            break;
     246
     247        default:
     248//          FIXME (hotkey, " %d\n", wParam);
     249            break;
    250250    }
    251251
     
    266266
    267267
    268 LRESULT WINAPI
     268static LRESULT WINAPI
    269269HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    270270{
    271271    switch (uMsg)
    272272    {
    273 /*      case HKM_GETHOTKEY: */
    274 /*      case HKM_SETHOTKEY: */
    275 /*      case HKM_SETRULES: */
    276 
    277 /*      case WM_CHAR: */
    278 
    279         case WM_CREATE:
    280             return HOTKEY_Create (hwnd, wParam, lParam);
    281 
    282         case WM_DESTROY:
    283             return HOTKEY_Destroy (hwnd, wParam, lParam);
    284 
    285         case WM_ERASEBKGND:
    286             return HOTKEY_EraseBackground (hwnd, wParam, lParam);
    287 
    288         case WM_GETDLGCODE:
    289             return DLGC_WANTCHARS | DLGC_WANTARROWS;
    290 
    291         case WM_GETFONT:
    292             return HOTKEY_GetFont (hwnd, wParam, lParam);
    293 
    294         case WM_KEYDOWN:
    295         case WM_SYSKEYDOWN:
    296             return HOTKEY_KeyDown (hwnd, wParam, lParam);
    297 
    298         case WM_KEYUP:
    299         case WM_SYSKEYUP:
    300             return HOTKEY_KeyUp (hwnd, wParam, lParam);
    301 
    302         case WM_KILLFOCUS:
    303             return HOTKEY_KillFocus (hwnd, wParam, lParam);
    304 
    305         case WM_LBUTTONDOWN:
    306             return HOTKEY_LButtonDown (hwnd, wParam, lParam);
    307 
    308         case WM_NCCREATE:
    309             return HOTKEY_NCCreate (hwnd, wParam, lParam);
    310 
    311 /*      case WM_PAINT: */
    312 
    313         case WM_SETFOCUS:
    314             return HOTKEY_SetFocus (hwnd, wParam, lParam);
    315 
    316         case WM_SETFONT:
    317             return HOTKEY_SetFont (hwnd, wParam, lParam);
    318 
    319 /*      case WM_SYSCHAR: */
    320 
    321         default:
    322 //          if (uMsg >= WM_USER)
    323 //              ERR (hotkey, "unknown msg %04x wp=%08x lp=%08lx\n",
    324 //                   uMsg, wParam, lParam);
    325             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     273/*      case HKM_GETHOTKEY: */
     274/*      case HKM_SETHOTKEY: */
     275/*      case HKM_SETRULES: */
     276
     277/*      case WM_CHAR: */
     278
     279        case WM_CREATE:
     280            return HOTKEY_Create (hwnd, wParam, lParam);
     281
     282        case WM_DESTROY:
     283            return HOTKEY_Destroy (hwnd, wParam, lParam);
     284
     285        case WM_ERASEBKGND:
     286            return HOTKEY_EraseBackground (hwnd, wParam, lParam);
     287
     288        case WM_GETDLGCODE:
     289            return DLGC_WANTCHARS | DLGC_WANTARROWS;
     290
     291        case WM_GETFONT:
     292            return HOTKEY_GetFont (hwnd, wParam, lParam);
     293
     294        case WM_KEYDOWN:
     295        case WM_SYSKEYDOWN:
     296            return HOTKEY_KeyDown (hwnd, wParam, lParam);
     297
     298        case WM_KEYUP:
     299        case WM_SYSKEYUP:
     300            return HOTKEY_KeyUp (hwnd, wParam, lParam);
     301
     302        case WM_KILLFOCUS:
     303            return HOTKEY_KillFocus (hwnd, wParam, lParam);
     304
     305        case WM_LBUTTONDOWN:
     306            return HOTKEY_LButtonDown (hwnd, wParam, lParam);
     307
     308        case WM_NCCREATE:
     309            return HOTKEY_NCCreate (hwnd, wParam, lParam);
     310
     311/*      case WM_PAINT: */
     312
     313        case WM_SETFOCUS:
     314            return HOTKEY_SetFocus (hwnd, wParam, lParam);
     315
     316        case WM_SETFONT:
     317            return HOTKEY_SetFont (hwnd, wParam, lParam);
     318
     319/*      case WM_SYSCHAR: */
     320
     321        default:
     322//          if (uMsg >= WM_USER)
     323//              ERR (hotkey, "unknown msg %04x wp=%08x lp=%08lx\n",
     324//                   uMsg, wParam, lParam);
     325            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    326326    }
    327327    return 0;
     
    344344    wndClass.hbrBackground = 0;
    345345    wndClass.lpszClassName = HOTKEY_CLASSA;
    346  
     346
    347347    RegisterClassA (&wndClass);
    348348}
     
    353353{
    354354    if (GlobalFindAtomA (HOTKEY_CLASSA))
    355         UnregisterClassA (HOTKEY_CLASSA, (HINSTANCE)NULL);
    356 }
    357 
     355        UnregisterClassA (HOTKEY_CLASSA, (HINSTANCE)NULL);
     356}
     357
  • TabularUnified trunk/src/comctl32/imagelist.c

    r295 r496  
    1 /* $Id: imagelist.c,v 1.5 1999-07-12 15:58:47 cbratschi Exp $ */
     1/* $Id: imagelist.c,v 1.6 1999-08-14 16:13:11 cbratschi Exp $ */
    22/*
    33 *  ImageList implementation
     
    7676 *     This function can NOT be used to reduce the number of images.
    7777 */
    78 
    7978static VOID
    8079IMAGELIST_InternalExpandBitmaps (HIMAGELIST himl, INT nImageCount)
     
    142141 */
    143142
     143
     144/*************************************************************************
     145 * IMAGELIST_InternalDraw [Internal]
     146 *
     147 * Draws the image in the ImageList (without the mask)
     148 *
     149 * PARAMS
     150 *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
     151 *     cx            [I] the width of the image to display
     152 *     cy............[I] the height of the image to display
     153 *
     154 * RETURNS
     155 *     nothing
     156 *
     157 * NOTES
     158 *     This functions is used by ImageList_DrawIndirect, when it is
     159 *     required to draw only the Image (without the mask) to the screen.
     160 *
     161 *     Blending and Overlays styles are accomplised by another function
     162 */
     163static VOID
     164IMAGELIST_InternalDraw(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
     165{
     166    HDC hImageDC;
     167    HBITMAP hOldBitmap;
     168    hImageDC = CreateCompatibleDC(0);
     169    hOldBitmap = SelectObject(hImageDC, pimldp->himl->hbmImage);
     170    BitBlt(pimldp->hdcDst,
     171        pimldp->x, pimldp->y, cx, cy,
     172        hImageDC,
     173        pimldp->himl->cx * pimldp->i, 0,
     174        SRCCOPY);
     175
     176    SelectObject(hImageDC, hOldBitmap);
     177    DeleteDC(hImageDC);
     178}
     179
     180
     181/*************************************************************************
     182 * IMAGELIST_InternalDrawMask [Internal]
     183 *
     184 * Draws the image in the ImageList witht the mask
     185 *
     186 * PARAMS
     187 *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
     188 *     cx            [I] the width of the image to display
     189 *     cy............[I] the height of the image to display
     190 *
     191 * RETURNS
     192 *     nothing
     193 *
     194 * NOTES
     195 *     This functions is used by ImageList_DrawIndirect, when it is
     196 *     required to draw the Image with the mask to the screen.
     197 *
     198 *     Blending and Overlays styles are accomplised by another function.
     199 */
     200static VOID
     201IMAGELIST_InternalDrawMask(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
     202{
     203    HDC     hMaskDC, hImageDC;
     204    BOOL bUseCustomBackground, bBlendFlag;
     205    HBRUSH hBrush, hOldBrush;
     206    HBITMAP hOldBitmapImage, hOldBitmapMask;
     207    HIMAGELIST himlLocal = pimldp->himl;
     208
     209    bUseCustomBackground = (himlLocal->clrBk != CLR_NONE);
     210    bBlendFlag = (pimldp->fStyle & ILD_BLEND50 )
     211        || (pimldp->fStyle & ILD_BLEND25);
     212
     213    hImageDC = CreateCompatibleDC(0);
     214    hMaskDC = CreateCompatibleDC(0);
     215
     216    hOldBitmapImage = SelectObject(hImageDC, himlLocal->hbmImage);
     217    hOldBitmapMask = SelectObject(hMaskDC, himlLocal->hbmMask);
     218    /* Draw the Background for the appropriate Styles
     219    */
     220    if( bUseCustomBackground && (pimldp->fStyle == ILD_NORMAL
     221          || pimldp->fStyle & ILD_IMAGE
     222          || bBlendFlag))
     223    {
     224        hBrush = CreateSolidBrush (himlLocal->clrBk);
     225        hOldBrush = SelectObject (pimldp->hdcDst, hBrush);
     226        PatBlt (pimldp->hdcDst,
     227            pimldp->x, pimldp->y, cx, cy,
     228            PATCOPY);
     229
     230        DeleteObject (SelectObject (pimldp->hdcDst, hOldBrush));
     231    }
     232
     233    /* Draw Image Transparently over the current background
     234    */
     235    if(pimldp->fStyle == ILD_NORMAL
     236        || pimldp->fStyle & ILD_TRANSPARENT
     237        || ((pimldp->fStyle & ILD_IMAGE) && bUseCustomBackground)
     238        || bBlendFlag)
     239    {
     240        BitBlt(pimldp->hdcDst,
     241            pimldp->x, pimldp->y, cx, cy,
     242            hMaskDC,
     243            himlLocal->cx * pimldp->i, 0,
     244            SRCAND);
     245
     246        BitBlt(pimldp->hdcDst,
     247            pimldp->x, pimldp->y, cx, cy,
     248            hImageDC,
     249            himlLocal->cx * pimldp->i, 0,
     250            SRCPAINT);
     251    }
     252    /* Draw the image when no Background is specified
     253    */
     254    else if(pimldp->fStyle & ILD_IMAGE && !bUseCustomBackground)
     255    {
     256        BitBlt(pimldp->hdcDst,
     257            pimldp->x, pimldp->y, cx, cy,
     258            hImageDC,
     259            himlLocal->cx * pimldp->i, 0,
     260            SRCCOPY);
     261    }
     262    /* Draw the mask with or without a background
     263    */
     264    else if(pimldp->fStyle & ILD_MASK)
     265    {
     266        BitBlt(pimldp->hdcDst,
     267            pimldp->x, pimldp->y, cx, cy,
     268            hMaskDC,
     269            himlLocal->cx * pimldp->i, 0,
     270            bUseCustomBackground ? SRCCOPY : SRCAND);
     271    }
     272    SelectObject(hImageDC, hOldBitmapImage);
     273    SelectObject(hMaskDC, hOldBitmapMask);
     274    DeleteDC(hImageDC);
     275    DeleteDC(hMaskDC);
     276}
     277
     278/*************************************************************************
     279 * IMAGELIST_InternalDrawBlend [Internal]
     280 *
     281 * Draws the Blend over the current image
     282 *
     283 * PARAMS
     284 *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
     285 *     cx            [I] the width of the image to display
     286 *     cy............[I] the height of the image to display
     287 *
     288 * RETURNS
     289 *     nothing
     290 *
     291 * NOTES
     292 *     This functions is used by ImageList_DrawIndirect, when it is
     293 *     required to add the blend to the current image.
     294 *
     295 */
     296static VOID
     297IMAGELIST_InternalDrawBlend(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
     298{
     299
     300    HDC         hBlendMaskDC,hMaskDC;
     301    HBRUSH      hBlendColorBrush, hBlendBrush, hOldBrush;
     302    HBITMAP     hBlendMaskBitmap, hOldBitmap;
     303    COLORREF    clrBlend, OldTextColor, OldBkColor;
     304    HIMAGELIST  himlLocal = pimldp->himl;
     305
     306    clrBlend = GetSysColor (COLOR_HIGHLIGHT);
     307    if (!(pimldp->rgbFg == CLR_DEFAULT))
     308    {
     309        clrBlend = pimldp->rgbFg;
     310    }
     311    /* Create the blend Mask
     312    */
     313    hBlendMaskDC = CreateCompatibleDC(0);
     314    hBlendBrush = pimldp->fStyle & ILD_BLEND50 ?
     315        himlLocal->hbrBlend50 : himlLocal->hbrBlend25;
     316
     317    hBlendMaskBitmap = CreateBitmap(cx, cy, 1, 1, NULL);
     318    hOldBitmap = SelectObject(hBlendMaskDC, hBlendMaskBitmap);
     319
     320    hOldBrush = (HBRUSH) SelectObject(hBlendMaskDC, hBlendBrush);
     321    PatBlt(hBlendMaskDC, 0, 0, cx, cy, PATCOPY);
     322    SelectObject(hBlendMaskDC, hOldBrush);
     323
     324    /* Modify the blend mask if an Image Mask exist
     325    */
     326    if(pimldp->himl->hbmMask != 0)
     327    {
     328        HBITMAP hOldMaskBitmap;
     329        hMaskDC = CreateCompatibleDC(0);
     330        hOldMaskBitmap = (HBITMAP) SelectObject(hMaskDC, himlLocal->hbmMask);
     331
     332        BitBlt(hBlendMaskDC,
     333            0,0, cx, cy,
     334            hMaskDC,
     335            himlLocal->cx * pimldp->i,0,
     336            0x220326); /* NOTSRCAND */
     337
     338        BitBlt(hBlendMaskDC,
     339            0,0, cx, cy,
     340            hBlendMaskDC,
     341            0,0,
     342            NOTSRCCOPY);
     343
     344        SelectObject(hMaskDC, hOldMaskBitmap);
     345        DeleteDC(hMaskDC);
     346
     347    }
     348    /* Apply blend to the current image given the BlendMask
     349    */
     350    OldTextColor = SetTextColor(pimldp->hdcDst, 0);
     351    OldBkColor = SetBkColor(pimldp->hdcDst, RGB(255,255,255));
     352    hBlendColorBrush = CreateSolidBrush(clrBlend);
     353    hOldBrush = (HBRUSH) SelectObject (pimldp->hdcDst, hBlendColorBrush);
     354
     355    BitBlt (pimldp->hdcDst,
     356        pimldp->x, pimldp->y, cx, cy,
     357        hBlendMaskDC,
     358        0, 0,
     359        0xB8074A); /* PSDPxax */
     360
     361    SelectObject(pimldp->hdcDst, hOldBrush);
     362    SetTextColor(pimldp->hdcDst, OldTextColor);
     363    SetBkColor(pimldp->hdcDst, OldBkColor);
     364    SelectObject(hBlendMaskDC, hOldBitmap);
     365    DeleteDC(hBlendMaskDC);
     366    DeleteObject(hBlendMaskBitmap);
     367    DeleteObject(hBlendColorBrush);
     368}
     369
     370/*************************************************************************
     371 * IMAGELIST_InternalDrawOverlay [Internal]
     372 *
     373 * Draws the overlay image
     374 *
     375 * PARAMS
     376 *     pimldp        [I] pointer to IMAGELISTDRAWPARAMS structure.
     377 *     cx            [I] the width of the image to display
     378 *     cy............[I] the height of the image to display
     379 *
     380 * RETURNS
     381 *     nothing
     382 *
     383 * NOTES
     384 *     This functions is used by ImageList_DrawIndirect, when it is
     385 *     required to draw the overlay
     386 *
     387 *
     388 */
     389static VOID
     390IMAGELIST_InternalDrawOverlay(IMAGELISTDRAWPARAMS *pimldp, INT cx, INT cy)
     391{
     392    INT     nOvlIdx;
     393    HDC     hImageDC;
     394    HBITMAP hOldBitmap;
     395
     396    nOvlIdx = (pimldp->fStyle & 0x0700) >> 8;
     397    if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE))
     398    {
     399        nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1];
     400        if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage))
     401        {
     402            hImageDC = CreateCompatibleDC(0);
     403            if (pimldp->himl->hbmMask)
     404            {
     405                hOldBitmap = (HBITMAP) SelectObject (hImageDC,
     406                    pimldp->himl->hbmMask);
     407
     408                BitBlt (pimldp->hdcDst,
     409                    pimldp->x, pimldp->y, cx, cy,
     410                    hImageDC, pimldp->himl->cx * nOvlIdx, 0,
     411                    SRCAND);
     412
     413                SelectObject(hImageDC, hOldBitmap);
     414            }
     415            hOldBitmap = (HBITMAP) SelectObject (hImageDC,
     416                pimldp->himl->hbmImage);
     417
     418            BitBlt (pimldp->hdcDst,
     419                pimldp->x, pimldp->y, cx, cy,
     420                hImageDC,
     421                pimldp->himl->cx * nOvlIdx, 0,
     422                SRCPAINT);
     423
     424            SelectObject(hImageDC, hOldBitmap);
     425            DeleteDC(hImageDC);
     426        }
     427    }
     428}
     429
     430
     431
     432
     433
    144434INT WINAPI
    145435ImageList_Add (HIMAGELIST himl, HBITMAP hbmImage, HBITMAP hbmMask)
    146436{
    147     HDC    hdcSrc, hdcDst;
    148     INT    nFirstIndex, nImageCount;
    149     INT    nStartX;
    150     BITMAP bmp;
     437    HDC     hdcImage, hdcBitmap;
     438    INT     nFirstIndex, nImageCount;
     439    INT     nStartX;
     440    BITMAP  bmp;
     441    HBITMAP hOldBitmapImage, hOldBitmap;
    151442
    152443    if (!himl || !hbmImage)
    153         return -1;
     444      return -1;
    154445
    155446    GetObjectA (hbmImage, sizeof(BITMAP), (LPVOID)&bmp);
     
    161452    nStartX = himl->cCurImage * himl->cx;
    162453
    163     hdcSrc = CreateCompatibleDC (0);
    164     hdcDst = CreateCompatibleDC (0);
    165 
    166     /* copy image bitmap */
    167     SelectObject (hdcDst, himl->hbmImage);
    168     SelectObject (hdcSrc, hbmImage);
    169     BitBlt (hdcDst, himl->cCurImage * himl->cx, 0,
    170               bmp.bmWidth, himl->cy, hdcSrc, 0, 0, SRCCOPY);
    171 
    172     if (himl->hbmMask) {
    173         if (hbmMask) {
    174             /* copy mask bitmap */
    175             SelectObject (hdcDst, himl->hbmMask);
    176             SelectObject (hdcSrc, hbmMask);
    177             BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy,
    178                       hdcSrc, 0, 0, SRCCOPY);
    179         }
    180         else {
    181             /* copy monochrome image to the mask bitmap */
    182             SelectObject (hdcDst, himl->hbmMask);
    183             SelectObject (hdcSrc, hbmImage);
    184             SetBkColor (hdcSrc, GetNearestColor (hdcSrc,
    185                           GetPixel (hdcSrc, 0, 0)));
    186             BitBlt (hdcDst, nStartX, 0, bmp.bmWidth, himl->cy,
    187                       hdcSrc, nStartX, 0, SRCCOPY);
    188         }
    189     }
    190 
    191     DeleteDC (hdcSrc);
    192     DeleteDC (hdcDst);
     454    hdcImage  = CreateCompatibleDC(0);
     455    hdcBitmap = CreateCompatibleDC(0);
     456
     457    hOldBitmapImage = SelectObject(hdcImage, himl->hbmImage);
     458    hOldBitmap = SelectObject(hdcBitmap, hbmImage);
     459
     460    /* Copy result to the imagelist
     461    */
     462    BitBlt (hdcImage, nStartX, 0, bmp.bmWidth, himl->cy,
     463        hdcBitmap, 0, 0, SRCCOPY);
     464
     465    if(himl->hbmMask)
     466    {
     467        HDC hdcMask, hdcTemp, hOldBitmapMask, hOldBitmapTemp;
     468
     469        hdcMask   = CreateCompatibleDC (0);
     470        hdcTemp   = CreateCompatibleDC(0);
     471        hOldBitmapMask = (HBITMAP) SelectObject(hdcMask, himl->hbmMask);
     472        hOldBitmapTemp = (HBITMAP) SelectObject(hdcTemp, hbmMask);
     473
     474        BitBlt (hdcMask,
     475            nStartX, 0, bmp.bmWidth, himl->cy,
     476            hdcTemp,
     477            0, 0,
     478            SRCCOPY);
     479
     480        SelectObject(hdcTemp, hOldBitmapTemp);
     481        DeleteDC(hdcTemp);
     482
     483        /* Remove the background from the image
     484        */
     485        BitBlt (hdcImage,
     486            nStartX, 0, bmp.bmWidth, himl->cy,
     487            hdcMask,
     488            nStartX, 0,
     489            0x220326); /* NOTSRCAND */
     490
     491        SelectObject(hdcMask, hOldBitmapMask);
     492        DeleteDC(hdcMask);
     493    }
     494
     495    SelectObject(hdcImage, hOldBitmapImage);
     496    SelectObject(hdcBitmap, hOldBitmap);
     497    DeleteDC(hdcImage);
     498    DeleteDC(hdcBitmap);
    193499
    194500    nFirstIndex = himl->cCurImage;
     
    240546{
    241547    HDC    hdcImage, hdcMask, hdcBitmap;
    242     INT    nIndex, nImageCount;
     548    INT    nIndex, nImageCount, nMaskXOffset=0;
    243549    BITMAP bmp;
     550    HBITMAP hOldBitmap, hOldBitmapMask, hOldBitmapImage;
     551    HBITMAP hMaskBitmap=0;
     552    COLORREF bkColor;
    244553
    245554    if (himl == NULL)
     
    252561
    253562    if (himl->cCurImage + nImageCount >= himl->cMaxImage)
     563    {
    254564        IMAGELIST_InternalExpandBitmaps (himl, nImageCount);
     565    }
    255566
    256567    nIndex = himl->cCurImage;
    257568    himl->cCurImage += nImageCount;
    258569
    259     hdcImage  = CreateCompatibleDC (0);
    260     hdcBitmap = CreateCompatibleDC (0);
    261 
    262     SelectObject (hdcBitmap, hBitmap);
    263     SelectObject (hdcImage, himl->hbmImage);
    264     BitBlt (hdcImage, nIndex * himl->cx, 0, bmp.bmWidth, himl->cy,
    265               hdcBitmap, 0, 0, SRCCOPY);
    266 
    267     if (himl->hbmMask) {
    268         COLORREF bkColor = (clrMask != CLR_DEFAULT) ? clrMask :
    269             GetNearestColor (hdcBitmap, GetPixel (hdcBitmap, 0, 0));
    270 
    271         /* create mask from image */
    272         hdcMask = CreateCompatibleDC (0);
    273         SelectObject (hdcMask, himl->hbmMask);
    274 
    275         /* create monochrome image to the mask bitmap */
    276         SetBkColor (hdcBitmap, bkColor);
    277         BitBlt (hdcMask, nIndex * himl->cx, 0, bmp.bmWidth, himl->cy,
    278                   hdcBitmap, 0, 0, SRCCOPY);
    279 
    280         DeleteDC (hdcMask);
    281     }
    282 
    283     DeleteDC (hdcImage);
    284     DeleteDC (hdcBitmap);
     570    hdcMask   = CreateCompatibleDC (0);
     571    hdcImage  = CreateCompatibleDC(0);
     572    hdcBitmap = CreateCompatibleDC(0);
     573
     574
     575    hOldBitmapImage = SelectObject(hdcImage, himl->hbmImage);
     576    hOldBitmap = SelectObject(hdcBitmap, hBitmap);
     577    if(himl->hbmMask)
     578    {
     579        hOldBitmapMask = SelectObject(hdcMask, himl->hbmMask);
     580        nMaskXOffset = nIndex * himl->cx;
     581    }
     582    else
     583    {
     584        /*
     585            Create a temp Mask so we can remove the background of
     586            the Image (Windows does this even if there is no mask)
     587        */
     588        hMaskBitmap = CreateBitmap(bmp.bmWidth, himl->cy, 1, 1, NULL);
     589        hOldBitmapMask = SelectObject(hdcMask, hMaskBitmap);
     590        nMaskXOffset = 0;
     591    }
     592    /* create monochrome image to the mask bitmap */
     593    bkColor = (clrMask != CLR_DEFAULT) ? clrMask :
     594        GetPixel (hdcBitmap, 0, 0);
     595    SetBkColor (hdcBitmap, bkColor);
     596    BitBlt (hdcMask,
     597        nMaskXOffset, 0, bmp.bmWidth, himl->cy,
     598        hdcBitmap, 0, 0,
     599        SRCCOPY);
     600
     601    SetBkColor(hdcBitmap, RGB(255,255,255));
     602    /*Remove the background from the image
     603    */
     604    /*
     605        WINDOWS BUG ALERT!!!!!!
     606        The statement below should not be done in common practice
     607        but this is how ImageList_AddMasked works in Windows.
     608        It overwrites the original bitmap passed, this was discovered
     609        by using the same bitmap to itterated the different styles
     610        on windows where it failed (BUT ImageList_Add is OK)
     611        This is here in case some apps really on this bug
     612    */
     613    BitBlt(hdcBitmap,
     614        0, 0, bmp.bmWidth, himl->cy,
     615        hdcMask,
     616        nMaskXOffset, 0,
     617        0x220326); /* NOTSRCAND */
     618    /* Copy result to the imagelist
     619    */
     620    BitBlt (hdcImage,
     621        nIndex * himl->cx, 0, bmp.bmWidth, himl->cy,
     622        hdcBitmap,
     623        0, 0,
     624        SRCCOPY);
     625    /* Clean up
     626    */
     627    SelectObject(hdcMask,hOldBitmapMask);
     628    SelectObject(hdcImage, hOldBitmapImage);
     629    SelectObject(hdcBitmap, hOldBitmap);
     630    DeleteDC(hdcMask);
     631    DeleteDC(hdcImage);
     632    DeleteDC(hdcBitmap);
     633    if(!himl->hbmMask)
     634    {
     635        DeleteObject(hMaskBitmap);
     636    }
    285637
    286638    return nIndex;
     
    8781230ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp)
    8791231{
    880     HIMAGELIST himlLocal;
    881     HDC      hdcImageList, hdcTempImage;
    882     HBITMAP  hbmTempImage;
    883     HBRUSH   hBrush, hOldBrush;
    8841232    INT      cx, cy;
    885     INT      nOvlIdx;
    886     COLORREF   clrBlend;
    887     BOOL     bImage;       /* draw image ? */
    888     BOOL     bImageTrans;  /* draw image transparent ? */
    889     BOOL     bMask;        /* draw mask ? */
    890     BOOL     bMaskTrans;   /* draw mask transparent ? */
    891     BOOL     bBlend25;
    892     BOOL     bBlend50;
    893 
     1233    /*
     1234        Do some Error Checking
     1235    */
    8941236    if (pimldp == NULL)
    8951237        return FALSE;
     
    9001242    if ((pimldp->i < 0) || (pimldp->i > pimldp->himl->cCurImage))
    9011243        return FALSE;
    902 
    903     himlLocal = pimldp->himl;
    904 
    905     cx = (pimldp->cx == 0) ? himlLocal->cx : pimldp->cx;
    906     cy = (pimldp->cy == 0) ? himlLocal->cy : pimldp->cy;
    907 
    908     /* ILD_NORMAL state */
    909     bImage      = TRUE;
    910     bImageTrans = FALSE;
    911     bMask       = FALSE;
    912     bMaskTrans  = FALSE;
    913     bBlend25    = FALSE;
    914     bBlend50    = FALSE;
    915     if ((himlLocal->clrBk == CLR_NONE) && (himlLocal->hbmMask))
     1244    /*
     1245        Get the Height and Width to display
     1246    */
     1247    cx = (pimldp->cx == 0) ? pimldp->himl->cx : pimldp->cx;
     1248    cy = (pimldp->cy == 0) ? pimldp->himl->cy : pimldp->cy;
     1249    /*
     1250        Draw the image
     1251    */
     1252    if(pimldp->himl->hbmMask != 0)
    9161253    {
    917         bImageTrans = TRUE;
    918         bMask = TRUE;
    919         bMaskTrans = TRUE;
    920     }
    921 
    922     /* ILD_IMAGE state (changes) */
    923     if (pimldp->fStyle & ILD_IMAGE)
     1254        IMAGELIST_InternalDrawMask(pimldp, cx, cy);
     1255    }
     1256    else
    9241257    {
    925         bMask = FALSE;
    926         bImage = TRUE;
    927         bImageTrans = FALSE;
    928     }
    929 
    930     /* ILD_MASK state (changes) */
    931     if ((pimldp->fStyle & ILD_MASK) && (himlLocal->hbmMask))
     1258        IMAGELIST_InternalDraw(pimldp, cx, cy);
     1259    }
     1260    /*
     1261        Apply the blend if needed to the Image
     1262    */
     1263    if((pimldp->fStyle & ILD_BLEND50)
     1264        || (pimldp->fStyle & ILD_BLEND25))
    9321265    {
    933         bMask  = TRUE;
    934         bMaskTrans = FALSE;
    935         bImage = FALSE;
    936     }
    937     if ((pimldp->fStyle & ILD_TRANSPARENT) && (himlLocal->hbmMask))
     1266        IMAGELIST_InternalDrawBlend(pimldp, cx, cy);
     1267    }
     1268    /*
     1269        Apply the Overlay if needed
     1270    */
     1271    if (pimldp->fStyle & 0x0700)
    9381272    {
    939         bMaskTrans = TRUE;
    940         bImageTrans = TRUE;
    941     }
    942     if ((himlLocal->clrBk == CLR_NONE) && (himlLocal->hbmMask))
    943         bMaskTrans = TRUE;
    944 
    945     if (pimldp->fStyle & ILD_BLEND50)
    946         bBlend50 = TRUE;
    947     else if (pimldp->fStyle & ILD_BLEND25)
    948         bBlend25 = TRUE;
    949 
    950     hdcImageList = CreateCompatibleDC (0);
    951 
    952     if (bMask)
    953     {
    954         /* draw the mask */
    955         SelectObject (hdcImageList, himlLocal->hbmMask);
    956         SetBkColor (hdcImageList, RGB(255, 255, 255));
    957         SetTextColor (hdcImageList, RGB(0, 0, 0));
    958         BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
    959                   hdcImageList, himlLocal->cx * pimldp->i, 0,
    960                   bMaskTrans ? SRCAND : SRCCOPY);
    961     }
    962 
    963     if (bImage)
    964     {
    965         /* draw the image */
    966         SelectObject (hdcImageList, himlLocal->hbmImage);
    967 
    968         if (!bImageTrans)
    969         {
    970             hBrush = CreateSolidBrush (himlLocal->clrBk);
    971             hOldBrush = SelectObject (pimldp->hdcDst, hBrush);
    972             PatBlt (pimldp->hdcDst, pimldp->x, pimldp->y,
    973                       cx, cy, PATCOPY);
    974             DeleteObject (SelectObject (pimldp->hdcDst, hOldBrush));
    975         }
    976 
    977         BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
    978                   hdcImageList, himlLocal->cx * pimldp->i, 0, SRCPAINT);
    979 
    980         if (bBlend25 || bBlend50)
    981         {
    982             if (pimldp->rgbFg == CLR_DEFAULT)
    983                 clrBlend = GetSysColor (COLOR_HIGHLIGHT);
    984             else
    985                 clrBlend = pimldp->rgbFg;
    986 
    987             hdcTempImage = CreateCompatibleDC (0);
    988             hbmTempImage = CreateBitmap (himlLocal->cx, himlLocal->cy,
    989                                            1, himlLocal->uBitsPixel, NULL);
    990             SelectObject (hdcTempImage, hbmTempImage);
    991 
    992 
    993             /* mask */
    994             SelectObject (hdcTempImage,
    995                             bBlend50 ? himlLocal->hbrBlend50 : himlLocal->hbrBlend25);
    996             PatBlt (hdcTempImage, 0, 0, himlLocal->cx, himlLocal->cy, PATCOPY);
    997 
    998             SelectObject (hdcImageList, himlLocal->hbmMask);
    999             BitBlt (hdcTempImage, 0, 0, himlLocal->cx,
    1000                       himlLocal->cy, hdcImageList,
    1001                       pimldp->i * himlLocal->cx, 0, SRCPAINT);
    1002 
    1003             BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
    1004                       hdcTempImage, 0, 0, SRCAND);
    1005 
    1006             /* fill */
    1007             hBrush = CreateSolidBrush (clrBlend);
    1008             SelectObject (hdcTempImage, hBrush);
    1009             PatBlt (hdcTempImage, 0, 0, himlLocal->cx, himlLocal->cy, PATCOPY);
    1010             DeleteObject (hBrush);
    1011 
    1012             SelectObject (hdcTempImage,
    1013                             bBlend50 ? himlLocal->hbrBlend50 : himlLocal->hbrBlend25);
    1014             PatBlt (hdcTempImage, 0, 0, himlLocal->cx, himlLocal->cy, 0x0A0329);
    1015 
    1016             SelectObject (hdcImageList, himlLocal->hbmMask);
    1017             BitBlt (hdcTempImage, 0, 0, himlLocal->cx,
    1018                       himlLocal->cy, hdcImageList,
    1019                       pimldp->i * himlLocal->cx, 0, SRCPAINT);
    1020 
    1021             BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
    1022                       hdcTempImage, 0, 0, SRCPAINT);
    1023 
    1024             DeleteObject (hbmTempImage);
    1025             DeleteDC (hdcTempImage);
    1026         }
    1027     }
    1028 
    1029     /* Draw overlay image */
    1030     if (pimldp->fStyle & 0x0700) {
    1031         nOvlIdx = (pimldp->fStyle & 0x0700) >> 8;
    1032         if ((nOvlIdx >= 1) && (nOvlIdx <= MAX_OVERLAYIMAGE)) {
    1033             nOvlIdx = pimldp->himl->nOvlIdx[nOvlIdx - 1];
    1034             if ((nOvlIdx >= 0) && (nOvlIdx <= pimldp->himl->cCurImage)) {
    1035                 if (pimldp->himl->hbmMask) {
    1036                     SelectObject (hdcImageList, pimldp->himl->hbmMask);
    1037                     BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy,
    1038                               hdcImageList, pimldp->himl->cx * nOvlIdx, 0,
    1039                               SRCAND);
    1040                 }
    1041                 SelectObject (hdcImageList, pimldp->himl->hbmImage);
    1042                 BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y,
    1043                           cx, cy, hdcImageList,
    1044                           pimldp->himl->cx * nOvlIdx, 0, SRCPAINT);
    1045             }
    1046         }
    1047     }
    1048 
    1049     DeleteDC (hdcImageList);
     1273        IMAGELIST_InternalDrawOverlay(pimldp, cx, cy);
     1274    }
    10501275
    10511276    return TRUE;
     
    12111436    ICONINFO ii;
    12121437    HICON  hIcon;
     1438    HBITMAP hOldSrcBitmap,hOldDstBitmap;
    12131439    HDC    hdcSrc, hdcDst;
    12141440
    12151441    if ((himl == NULL) || (i < 0) || (i >= himl->cCurImage))
    1216         return 0;
     1442        return 0;
    12171443
    12181444    hdcSrc = CreateCompatibleDC(0);
     
    12211447    ii.fIcon = TRUE;
    12221448    ii.hbmMask  = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy);
    1223     ii.hbmColor = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy);
    1224 
    12251449
    12261450    /* draw mask*/
    1227     SelectObject (hdcDst, ii.hbmMask);
     1451    hOldDstBitmap = (HBITMAP)SelectObject (hdcDst, ii.hbmMask);
    12281452    if (himl->hbmMask) {
    1229         SelectObject (hdcSrc, himl->hbmMask);
    1230         BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1231                   hdcSrc, i * himl->cx, 0, SRCCOPY);
     1453        SelectObject (hdcSrc, himl->hbmMask);
     1454        BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
     1455                  hdcSrc, i * himl->cx, 0, SRCCOPY);
    12321456    }
    12331457    else
    1234         PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS);
     1458        PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS);
    12351459
    12361460    /* draw image*/
     1461    hOldSrcBitmap = (HBITMAP)SelectObject (hdcSrc, himl->hbmImage);
     1462    ii.hbmColor = CreateCompatibleBitmap (hdcSrc, himl->cx, himl->cy);
    12371463    SelectObject (hdcDst, ii.hbmColor);
    1238     SelectObject (hdcSrc, himl->hbmImage);
    12391464    BitBlt (hdcDst, 0, 0, himl->cx, himl->cy,
    1240               hdcSrc, i * himl->cx, 0, SRCCOPY);
     1465              hdcSrc, i * himl->cx, 0, SRCCOPY);
     1466
     1467    /*
     1468     * CreateIconIndirect requires us to deselect the bitmaps from
     1469     * the DCs before calling
     1470     */
     1471    SelectObject(hdcSrc, hOldSrcBitmap);
     1472    SelectObject(hdcDst, hOldDstBitmap);
    12411473
    12421474    hIcon = CreateIconIndirect (&ii);
  • TabularUnified trunk/src/comctl32/ipaddress.c

    r295 r496  
    1 /* $Id: ipaddress.c,v 1.6 1999-07-12 15:58:47 cbratschi Exp $ */
     1/* $Id: ipaddress.c,v 1.7 1999-08-14 16:13:11 cbratschi Exp $ */
    22/*
    33 * IP Address control
     
    597597}
    598598
    599 LRESULT WINAPI
     599static LRESULT WINAPI
    600600IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    601601{
  • TabularUnified trunk/src/comctl32/listview.c

    r295 r496  
    22 * Listview control
    33 *
    4  * Copyright 1998 Eric Kohl
     4 * Copyright 1998, 1999 Eric Kohl
    55 * Copyright 1999 Luc Tourangeau
    66 * Copyright 1999 Achim Hasenmueller
     
    1313 *   1. No horizontal scrolling when header is larger than the client area.
    1414 *   2. Drawing optimizations.
     15 *   3. Hot item handling.
    1516 *
    1617 * Notifications:
     
    2122 *
    2223 * Unicode:
    23  *   LISTVIEW_SetItem32W : no unicode support
    24  *   LISTVIEW_InsertItem32W : no unicode support
    25  *   LISTVIEW_InsertColumn32W : no unicode support
     24 *   LISTVIEW_SetItemW : no unicode support
     25 *   LISTVIEW_InsertItemW : no unicode support
     26 *   LISTVIEW_InsertColumnW : no unicode support
    2627 *   LISTVIEW_GetColumnW : no unicode support
     28 *   LISTVIEW_SetColumnW : no unicode support
    2729 *
    2830 * Advanced functionality:
    2931 *   LISTVIEW_GetNumberOfWorkAreas : not implemented
    3032 *   LISTVIEW_GetHotCursor : not implemented
    31  *   LISTVIEW_GetHotItem : not implemented
    3233 *   LISTVIEW_GetHoverTime : not implemented
    3334 *   LISTVIEW_GetISearchString : not implemented
     
    3536 *   LISTVIEW_EditLabel : REPORT (need to implement a timer)
    3637 *   LISTVIEW_GetColumnOrderArray : not implemented
     38 *   LISTVIEW_SetColumnOrderArray : not implemented
    3739 *   LISTVIEW_Arrange : empty stub
    3840 *   LISTVIEW_ApproximateViewRect : incomplete
     
    31573159
    31583160/* LISTVIEW_GetEditControl */
    3159 /* LISTVIEW_GetExtendedListViewStyle */
     3161
     3162/***
     3163 * DESCRIPTION:
     3164 * Retrieves the extended listview style.
     3165 *
     3166 * PARAMETERS:
     3167 * [I] HWND  : window handle
     3168 *
     3169 * RETURN:
     3170 *   SUCCESS : previous style
     3171 *   FAILURE : 0
     3172 */
     3173static LRESULT LISTVIEW_GetExtendedListViewStyle(HWND hwnd)
     3174{
     3175    LISTVIEW_INFO *infoPtr;
     3176    /* make sure we can get the listview info */
     3177    if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0)))
     3178        return (0);
     3179    return (infoPtr->dwExStyle);
     3180}
    31603181
    31613182/***
     
    34123433/* LISTVIEW_GetItemW */
    34133434/* LISTVIEW_GetHotCursor */
    3414 /* LISTVIEW_GetHotItem */
    3415 /* LISTVIEW_GetHoverTime> */
     3435
     3436/***
     3437 * DESCRIPTION:
     3438 * Retrieves the index of the hot item.
     3439 *
     3440 * PARAMETERS:
     3441 * [I] HWND  : window handle
     3442 *
     3443 * RETURN:
     3444 *   SUCCESS : hot item index
     3445 *   FAILURE : -1 (no hot item)
     3446 */
     3447static LRESULT LISTVIEW_GetHotItem(HWND hwnd)
     3448{
     3449    LISTVIEW_INFO *infoPtr;
     3450    /* make sure we can get the listview info */
     3451    if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0)))
     3452        return (-1);
     3453    return (infoPtr->nHotItem);
     3454}
     3455
     3456/* LISTVIEW_GetHoverTime */
    34163457
    34173458/***
     
    46284669}
    46294670
     4671/* LISTVIEW_SetBkImage */
     4672
    46304673/***
    46314674 * DESCRIPTION:
     
    47584801}
    47594802
     4803/* LISTVIEW_SetColumnW */
     4804/* LISTVIEW_SetColumnOrderArray */
     4805
    47604806/***
    47614807 * DESCRIPTION:
     
    48094855/***
    48104856 * DESCRIPTION:
     4857 * Sets the extended listview style.
     4858 *
     4859 * PARAMETERS:
     4860 * [I] HWND  : window handle
     4861 * [I] DWORD : mask
     4862 * [I] DWORD : style
     4863 *
     4864 * RETURN:
     4865 *   SUCCESS : previous style
     4866 *   FAILURE : 0
     4867 */
     4868static LRESULT LISTVIEW_SetExtendedListViewStyle(HWND hwnd, DWORD dwMask, DWORD dwStyle)
     4869{
     4870    LISTVIEW_INFO *infoPtr;
     4871    DWORD dwOldStyle;
     4872    /* make sure we can get the listview info */
     4873    if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0)))
     4874        return (0);
     4875    /* store previous style */
     4876    dwOldStyle = infoPtr->dwExStyle;
     4877    /* set new style */
     4878    infoPtr->dwExStyle = (dwOldStyle & ~dwMask) | (dwStyle & dwMask);
     4879    return (dwOldStyle);
     4880}
     4881
     4882/* LISTVIEW_SetHotCursor */
     4883
     4884/***
     4885 * DESCRIPTION:
     4886 * Sets the hot item index.
     4887 *
     4888 * PARAMETERS:
     4889 * [I] HWND  : window handle
     4890 * [I] INT   : index
     4891 *
     4892 * RETURN:
     4893 *   SUCCESS : previous hot item index
     4894 *   FAILURE : -1 (no hot item)
     4895 */
     4896static LRESULT LISTVIEW_SetHotItem(HWND hwnd, INT iIndex)
     4897{
     4898    LISTVIEW_INFO *infoPtr;
     4899    INT iOldIndex;
     4900    /* make sure we can get the listview info */
     4901    if (!(infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0)))
     4902        return (-1);
     4903    /* store previous index */
     4904    iOldIndex = infoPtr->nHotItem;
     4905    /* set new style */
     4906    infoPtr->nHotItem = iIndex;
     4907    return (iOldIndex);
     4908}
     4909
     4910/* LISTVIEW_SetIconSpacing */
     4911
     4912/***
     4913 * DESCRIPTION:
    48114914 * Sets image lists.
    48124915 *
     
    48934996 * [I] HWND : window handle
    48944997 * [I] INT : item count (prjected number of items)
    4895  *
    4896  * RETURN:
    4897  * None
    4898  */
    4899 static VOID LISTVIEW_SetItemCount(HWND hwnd, INT nItemCount)
    4900 {
    4901   FIXME("empty stub!\n");
     4998 * [I] DWORD : update flags
     4999 *
     5000 * RETURN:
     5001 *   SUCCESS : TRUE
     5002 *   FAILURE : FALSE
     5003 */
     5004static BOOL LISTVIEW_SetItemCount(HWND hwnd, INT nItems, DWORD dwFlags)
     5005{
     5006  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO*)GetWindowLongA(hwnd, 0);
     5007  FIXME("(%d %08lx)empty stub!\n", nItems, dwFlags);
     5008  if (nItems == 0)
     5009    return LISTVIEW_DeleteAllItems (hwnd);
     5010  if (nItems > GETITEMCOUNT(infoPtr))
     5011{
     5012    /* append items */
     5013    FIXME("append items\n");
     5014  }
     5015  else if (nItems < GETITEMCOUNT(infoPtr))
     5016  {
     5017    /* remove items */
     5018    FIXME("remove items\n");
     5019  }
     5020  return TRUE;
    49025021}
    49035022
     
    49475066  return bResult;
    49485067}
     5068
     5069/* LISTVIEW_SetItemPosition32 */
    49495070
    49505071/***
     
    50315152}
    50325153
     5154/* LISTVIEW_SetItemTextW */
     5155
     5156/***
     5157 * DESCRIPTION:
     5158 * Set item index that marks the start of a multiple selection.
     5159 *
     5160 * PARAMETER(S):
     5161 * [I] HWND : window handle
     5162 * [I] INT  : index
     5163 *
     5164 * RETURN:
     5165 * Index number or -1 if there is no selection mark.
     5166 */
     5167static LRESULT LISTVIEW_SetSelectionMark(HWND hwnd, INT nIndex)
     5168{
     5169  LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongA(hwnd, 0);
     5170  INT nOldIndex = infoPtr->nSelectionMark;
     5171  infoPtr->nSelectionMark = nIndex;
     5172  return nOldIndex;
     5173}
     5174
    50335175/***
    50345176 * DESCRIPTION:
     
    50755217}
    50765218
     5219/* LISTVIEW_SetToolTips */
     5220/* LISTVIEW_SetUnicodeFormat */
     5221/* LISTVIEW_SetWorkAreas */
    50775222
    50785223/***
     
    51635308}
    51645309
     5310/* LISTVIEW_SubItemHitTest */
     5311
    51655312/***
    51665313 * DESCRIPTION:
     
    52415388  infoPtr->nFocusedItem = -1;
    52425389  infoPtr->nSelectionMark = -1;
     5390  infoPtr->nHotItem = -1;
    52435391  infoPtr->iconSpacing.cx = GetSystemMetrics(SM_CXICONSPACING);
    52445392  infoPtr->iconSpacing.cy = GetSystemMetrics(SM_CYICONSPACING);
     
    64336581 *
    64346582 */
    6435 LRESULT WINAPI LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
     6583static LRESULT WINAPI LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam,
    64366584                                   LPARAM lParam)
    64376585{
     
    64756623
    64766624/*      case LVM_GETCOLUMNW: */
    6477 /*      case LVM_GETCOLUMNORDERARRAY: */
     6625
     6626  case LVM_GETCOLUMNORDERARRAY:
     6627    //FIXME("Unimplemented msg LVM_GETCOLUMNORDERARRAY\n");
     6628    return 0;
     6629
    64786630
    64796631  case LVM_GETCOLUMNWIDTH:
     
    64846636
    64856637/*      case LVM_GETEDITCONTROL: */
    6486 /*      case LVM_GETEXTENDEDLISTVIEWSTYLE: */
     6638  case LVM_GETEXTENDEDLISTVIEWSTYLE:
     6639    return LISTVIEW_GetExtendedListViewStyle(hwnd);
    64876640
    64886641  case LVM_GETHEADER:
     
    64906643
    64916644/*      case LVM_GETHOTCURSOR: */
    6492 /*      case LVM_GETHOTITEM: */
     6645
     6646  case LVM_GETHOTITEM:
     6647    return LISTVIEW_GetHotItem(hwnd);
     6648
    64936649/*      case LVM_GETHOVERTIME: */
    64946650
     
    65936749    return LISTVIEW_SetColumnA(hwnd, (INT)wParam, (LPLVCOLUMNA)lParam);
    65946750
    6595 /*      case LVM_SETCOLUMNW: */
    6596 /*      case LVM_SETCOLUMNORDERARRAY: */
     6751  case LVM_SETCOLUMNW:
     6752    //FIXME("Unimplemented msg LVM_SETCOLUMNW\n");
     6753    return 0;
     6754
     6755  case LVM_SETCOLUMNORDERARRAY:
     6756    //FIXME("Unimplemented msg LVM_SETCOLUMNORDERARRAY\n");
     6757    return 0;
    65976758
    65986759  case LVM_SETCOLUMNWIDTH:
    65996760    return LISTVIEW_SetColumnWidth(hwnd, (INT)wParam, (INT)lParam);
    66006761
    6601 /*      case LVM_SETEXTENDEDLISTVIEWSTYLE: */
     6762  case LVM_SETEXTENDEDLISTVIEWSTYLE:
     6763    return LISTVIEW_SetExtendedListViewStyle(hwnd, (DWORD)wParam, (DWORD)lParam);
     6764
    66026765/*      case LVM_SETHOTCURSOR: */
    6603 /*      case LVM_SETHOTITEM: */
     6766
     6767  case LVM_SETHOTITEM:
     6768    return LISTVIEW_SetHotItem(hwnd, (INT)wParam);
     6769
    66046770/*      case LVM_SETHOVERTIME: */
    66056771/*      case LVM_SETICONSPACING: */
     
    66146780
    66156781  case LVM_SETITEMCOUNT:
    6616     LISTVIEW_SetItemCount(hwnd, (INT)wParam);
    6617     break;
     6782    return LISTVIEW_SetItemCount(hwnd, (INT)wParam, (DWORD)lParam);
    66186783
    66196784  case LVM_SETITEMPOSITION:
     
    66216786                                    (INT)HIWORD(lParam));
    66226787
    6623 /*      case LVM_SETITEMPOSITION: */
     6788/*      case LVM_SETITEMPOSITION32: */
    66246789
    66256790  case LVM_SETITEMSTATE:
     
    66296794    return LISTVIEW_SetItemTextA(hwnd, (INT)wParam, (LPLVITEMA)lParam);
    66306795
    6631 /*      case LVM_SETSELECTIONMARK: */
     6796/*      case LVM_SETITEMTEXTW: */
     6797
     6798  case LVM_SETSELECTIONMARK:
     6799    return LISTVIEW_SetSelectionMark(hwnd, (INT)lParam);
    66326800
    66336801  case LVM_SETTEXTBKCOLOR:
  • TabularUnified trunk/src/comctl32/monthcal.c

    r94 r496  
    1 /* $Id: monthcal.c,v 1.3 1999-06-10 16:22:01 achimha Exp $ */
    2 /*
    3  * Month calendar control
     1
     2/* Month calendar control
     3
     4
    45 *
    5  * Copyright 1998, 1999 Eric Kohl
    6  * Copyright 1999 Achim Hasenmueller
    7  *
    8  * NOTES
    9  *   This is just a dummy control. An author is needed! Any volunteers?
    10  *   I will only improve this control once in a while.
    11  *     Eric <ekohl@abo.rhein-zeitung.de>
     6 * Copyright 1998, 1999 Eric Kohl (ekohl@abo.rhein-zeitung.de)
     7 * Copyright 1999  Alex Priem (alexp@sci.kun.nl)
     8 * Copyright 1999 Christoph Bratschi
    129 *
    1310 * TODO:
    14  *   - All messages.
    15  *   - All notifications.
     11 *   - Notifications.
    1612 *
     13 *
     14 *  FIXME: refresh should ask for rect of required length. (?)
     15 *  FIXME: we refresh to often; especially in LButtonDown/MouseMove.
     16 *  FIXME: handle resources better (doesn't work now); also take care
     17           of internationalization.
     18 *  FIXME: keyboard handling.
    1719 */
    1820
    1921#include "winbase.h"
     22#include "win.h"
    2023#include "commctrl.h"
     24#include "comctl32.h"
    2125#include "monthcal.h"
    22 
     26#include "winnls.h"
     27#include <stdio.h>
     28#include <string.h>
     29#include <stdlib.h>
     30
     31//DEFAULT_DEBUG_CHANNEL(monthcal)
     32
     33/* take #days/month from ole/parsedt.c;
     34 * we want full month-names, and abbreviated weekdays, so these are
     35 * defined here */
    2336
    2437#define MONTHCAL_GetInfoPtr(hwnd) ((MONTHCAL_INFO *)GetWindowLongA (hwnd, 0))
    2538
    26 
    27 
    28 
     39/* helper functions
     40 * MONTHCAL_ValidateTime: is time a valid date/time combo?
     41 */
     42
     43int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0};
     44
     45int DayOfWeekTable[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4};
     46
     47static char *daytxt[] = {"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun" };
     48
     49static char *monthtxt[] = {"January", "February", "March", "April", "May",
     50                           "June", "July", "August", "September", "October",
     51                           "November", "December"};
     52
     53/* CHECKME: all these validations OK? */
     54
     55static int MONTHCAL_ValidateTime (SYSTEMTIME time)
     56
     57{
     58 if (time.wMonth > 12) return FALSE;
     59 if (time.wDayOfWeek > 6) return FALSE;
     60 if (time.wDay > mdays[time.wMonth]) return FALSE;
     61 if (time.wMonth > 23) return FALSE;
     62 if (time.wMinute > 60) return FALSE;
     63 if (time.wSecond > 60) return FALSE;
     64 if (time.wMilliseconds > 100) return FALSE;
     65 return TRUE;
     66}
     67
     68void MONTHCAL_CopyTime (const SYSTEMTIME *from, SYSTEMTIME *to)
     69
     70{
     71 to->wYear=from->wYear;
     72 to->wMonth=from->wMonth;
     73 to->wDayOfWeek=from->wDayOfWeek;
     74 to->wDay=from->wDay;
     75 to->wHour=from->wHour;
     76 to->wMinute=from->wMinute;
     77 to->wSecond=from->wSecond;
     78 to->wMilliseconds=from->wMilliseconds;
     79}
     80
     81
     82/* Note:Depending on DST, this may be offset by a day.
     83   Need to find out if we're on a DST place & adjust the clock accordingly.
     84   Above function assumes we have a valid data.
     85   Valid for year>1752;  d <= 1 <= 31, 1 <= m <= 12.
     86   0=Monday.
     87*/
     88
     89
     90int MONTHCAL_CalculateDayOfWeek (DWORD day, DWORD month, DWORD year)
     91
     92{
     93 year -= month < 3;
     94 return (year + year/4 - year/100 + year/400 +
     95         DayOfWeekTable[month-1] + day - 1 ) % 7;
     96}
     97
     98
     99static int MONTHCAL_CalcDayFromPos (MONTHCAL_INFO *infoPtr, int x, int y)
     100
     101{
     102    int daypos,weekpos,retval,firstDay;
     103
     104    daypos=(x - infoPtr->prevmonth.left) / infoPtr->textWidth ;
     105    weekpos=(y - infoPtr->days.bottom - infoPtr->rcClient.top) /
     106                     (infoPtr->textHeight*1.25);
     107        firstDay=MONTHCAL_CalculateDayOfWeek (1,infoPtr->currentMonth,infoPtr->currentYear);
     108    retval=daypos + 7*weekpos - firstDay;
     109        //TRACE ("%d %d %d\n",daypos,weekpos,retval);
     110        return retval;
     111}
     112
     113
     114static void MONTHCAL_CalcDayXY (MONTHCAL_INFO *infoPtr, int day, int month,
     115                                 int *x, int *y)
     116
     117{
     118  int firstDay,prevMonth;
     119
     120  firstDay=MONTHCAL_CalculateDayOfWeek (1,infoPtr->currentMonth,infoPtr->currentYear);
     121
     122  if (month==infoPtr->currentMonth) {
     123        *x=(day+firstDay) & 7;
     124        *y=(day+firstDay-*x) / 7;
     125                return;
     126        }
     127  if (month < infoPtr->currentMonth) {
     128                prevMonth=month - 1;
     129                if (prevMonth==0) prevMonth=11;
     130        *x=(mdays[prevMonth]-firstDay) & 7;
     131                *y=0;
     132        }
     133
     134  *y=mdays[month] / 7;
     135  *x=(day+firstDay+mdays[month]) & 7;
     136}
     137
     138
     139static void MONTHCAL_CalcDayRect (MONTHCAL_INFO *infoPtr, RECT *r, int x, int y)
     140{
     141  r->left   = infoPtr->prevmonth.left + x * infoPtr->textWidth;
     142  r->right  = r->left + infoPtr->textWidth;
     143  r->top    = infoPtr->rcClient.top + y * 1.25 * infoPtr->textHeight
     144                                   + infoPtr->days.bottom;
     145  r->bottom = r->top + infoPtr->textHeight;
     146
     147}
     148
     149static void MONTHCAL_CalcPosFromDay (MONTHCAL_INFO *infoPtr,
     150                                            int day, int month, RECT *r)
     151
     152{
     153  int x,y;
     154
     155  MONTHCAL_CalcDayXY (infoPtr, day, month, &x, &y);
     156  MONTHCAL_CalcDayRect (infoPtr, r, x, y);
     157}
     158
     159
     160
     161
     162static void MONTHCAL_CircleDay (HDC hdc, MONTHCAL_INFO *infoPtr, int i, int j)
     163
     164{
     165        HPEN hRedPen = CreatePen(PS_SOLID, 2, RGB (255,0,0) );
     166    HPEN hOldPen2 = SelectObject( hdc, hRedPen );
     167        POINT points[7];
     168        int x,y;
     169
     170 /* use prevmonth to calculate position because it contains the extra width
     171  * from MCS_WEEKNUMBERS
     172  */
     173
     174        x=infoPtr->prevmonth.left + (i+0.5)*infoPtr->textWidth;
     175        y=infoPtr->rcClient.top + 1.25*(j+0.5)*infoPtr->textHeight + infoPtr->days.bottom;
     176        points[0].x = x;
     177        points[0].y = y-0.25*infoPtr->textHeight;
     178        points[1].x = x-1.0*infoPtr->textWidth;
     179        points[1].y = y;
     180        points[2].x = x;
     181        points[2].y = y+0.6*infoPtr->textHeight;
     182        points[3].x = x+0.5*infoPtr->textWidth;
     183        points[3].y = y;
     184        points[4].x = x+0.3*infoPtr->textWidth;
     185        points[4].y = y-0.5*infoPtr->textHeight;
     186        points[5].x = x-0.25*infoPtr->textWidth;
     187        points[5].y = y-0.5*infoPtr->textHeight;
     188        points[6].x = x-0.5*infoPtr->textWidth;
     189        points[6].y = y-0.45*infoPtr->textHeight;
     190
     191        PolyBezier (hdc,points,4);
     192        PolyBezier (hdc,points+3,4);
     193    DeleteObject (hRedPen);
     194        SelectObject (hdc, hOldPen2);
     195}
     196
     197
     198
     199
     200
     201static void MONTHCAL_DrawDay (HDC hdc, MONTHCAL_INFO *infoPtr,
     202                                                        int day, int month, int x, int y, int bold)
     203
     204{
     205  char buf[10];
     206  RECT r;
     207  static int haveBoldFont,haveSelectedDay=FALSE;
     208  HBRUSH hbr;
     209  COLORREF oldCol,oldBk;
     210
     211  sprintf (buf,"%d",day);
     212
     213
     214
     215/* No need to check styles: when selection is not valid, it is set to zero.
     216 * 1<day<31, so evertyhing's OK.
     217 */
     218
     219  MONTHCAL_CalcDayRect (infoPtr, &r, x, y);
     220
     221  if ((day>=infoPtr->minSel.wDay) && (day<=infoPtr->maxSel.wDay)
     222      && (month==infoPtr->currentMonth)) {
     223                HRGN hrgn;
     224                RECT r2;
     225
     226                //TRACE ("%d %d %d\n",day,infoPtr->minSel.wDay,infoPtr->maxSel.wDay);
     227                //TRACE ("%d %d %d %d\n", r.left, r.top, r.right, r.bottom);
     228                oldCol=SetTextColor (hdc, infoPtr->monthbk);
     229                oldBk=SetBkColor (hdc,infoPtr->trailingtxt);
     230                hbr= GetSysColorBrush (COLOR_GRAYTEXT);
     231                hrgn=CreateEllipticRgn (r.left,r.top, r.right,r.bottom);
     232                FillRgn (hdc,hrgn,hbr);
     233
     234                r2.left   = r.left-0.25*infoPtr->textWidth;
     235                r2.top    = r.top;
     236                r2.right  = r.left+0.5*infoPtr->textWidth;
     237                r2.bottom = r.bottom;
     238                if (haveSelectedDay) FillRect (hdc,&r2,hbr);
     239                haveSelectedDay=TRUE;
     240        } else {
     241                haveSelectedDay=FALSE;
     242        }
     243
     244
     245
     246/* need to add some code for multiple selections */
     247
     248  if ((bold) && (!haveBoldFont)) {
     249        SelectObject (hdc, infoPtr->hBoldFont);
     250                haveBoldFont=TRUE;
     251        }
     252  if ((!bold) && (haveBoldFont)) {
     253        SelectObject (hdc, infoPtr->hFont);
     254                haveBoldFont=FALSE;
     255        }
     256
     257
     258
     259  DrawTextA ( hdc, buf, lstrlenA(buf), &r,
     260                         DT_CENTER | DT_VCENTER | DT_SINGLELINE );
     261  if (haveSelectedDay) {
     262                SetTextColor(hdc, oldCol);
     263                SetBkColor (hdc, oldBk);
     264        }
     265
     266  if ((day==infoPtr->curSelDay) && (month==infoPtr->currentMonth)) {
     267                HPEN hNewPen, hOldPen;
     268
     269                hNewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );
     270                hbr= GetSysColorBrush (COLOR_WINDOWTEXT);
     271                hOldPen = SelectObject( hdc, hNewPen );
     272                r.left+=2;
     273                r.right-=2;
     274                r.top-=1;
     275                r.bottom+=1;
     276                FrameRect (hdc, &r, hbr);
     277                SelectObject( hdc, hOldPen );
     278  }
     279}
     280
     281
     282/* CHECKME: For `todays date', do we need to check the locale?*/
     283/* CHECKME: For `todays date', how do is Y2K handled?*/
     284/* FIXME:  todays date circle */
     285
     286static void MONTHCAL_Refresh (HWND hwnd, HDC hdc)
     287
     288{
     289    MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     290        RECT *rcClient=&infoPtr->rcClient;
     291        RECT *title=&infoPtr->title;
     292        RECT *prev=&infoPtr->titlebtnprev;
     293        RECT *next=&infoPtr->titlebtnnext;
     294        RECT *titlemonth=&infoPtr->titlemonth;
     295        RECT *titleyear=&infoPtr->titleyear;
     296        RECT *prevmonth=&infoPtr->prevmonth;
     297        RECT *nextmonth=&infoPtr->nextmonth;
     298        RECT *days=&infoPtr->days;
     299        RECT *weeknums=&infoPtr->weeknums;
     300        RECT *rtoday=&infoPtr->today;
     301    int i,j,m,mask,day,firstDay, weeknum,prevMonth;
     302    int textHeight,textWidth;
     303        SIZE size;
     304        HBRUSH hbr;
     305    HFONT currentFont;
     306        TEXTMETRICA tm;
     307/*    LOGFONTA logFont; */
     308        char buf[20],*thisMonthtxt;
     309    COLORREF oldTextColor,oldBkColor;
     310    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     311        BOOL prssed;
     312
     313
     314    oldTextColor = SetTextColor(hdc, GetSysColor( COLOR_WINDOWTEXT));
     315
     316    currentFont = SelectObject (hdc, infoPtr->hFont);
     317
     318        /* FIXME: need a way to determine current font, without setting it */
     319/*
     320        if (infoPtr->hFont!=currentFont) {
     321        SelectObject (hdc, currentFont);
     322                infoPtr->hFont=currentFont;
     323                GetObjectA (currentFont, sizeof (LOGFONTA), &logFont);
     324        logFont.lfWeight=FW_BOLD;
     325        infoPtr->hBoldFont = CreateFontIndirectA (&logFont);
     326        }
     327*/
     328
     329        GetTextMetricsA (hdc, &tm);
     330        infoPtr->textHeight=textHeight=tm.tmHeight + tm.tmExternalLeading;
     331    GetTextExtentPoint32A (hdc, "Sun",3, &size);
     332        infoPtr->textWidth=textWidth=size.cx+2;
     333
     334    GetClientRect (hwnd, rcClient);
     335    hbr =  CreateSolidBrush (RGB(255,255,255));
     336    DrawEdge (hdc, rcClient, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
     337    FillRect (hdc, rcClient, hbr);
     338    DeleteObject (hbr);
     339
     340/* calculate whole client area & title area */
     341
     342        infoPtr->rcClient.right=7*infoPtr->textWidth;
     343        if (dwStyle & MCS_WEEKNUMBERS)
     344          infoPtr->rcClient.right+=infoPtr->textWidth;
     345
     346        title->top    = rcClient->top + 1;
     347        title->bottom = title->top + 2*textHeight + 4;
     348        title->left   = rcClient->left + 1;
     349        title->right  = rcClient->right - 1;
     350        infoPtr->rcClient.bottom=title->bottom + 6*textHeight;
     351
     352
     353/* draw header */
     354
     355    hbr =  CreateSolidBrush (infoPtr->titlebk);
     356    FillRect (hdc, title, hbr);
     357
     358        prev->top                 = next->top        = title->top + 6;
     359        prev->bottom      = next->bottom     = title->top + 2*textHeight - 3;
     360        prev->right       = title->left  + 28;
     361        prev->left        = title->left  + 4;
     362        next->left        = title->right - 28;
     363        next->right       = title->right - 4;
     364        titlemonth->bottom= titleyear->bottom = prev->top + 2*textHeight - 3;
     365        titlemonth->top   = titleyear->top    = title->top + 6;
     366        titlemonth->left  = title->left;
     367        titlemonth->right = title->right;
     368        prssed=FALSE;
     369
     370        if (!(infoPtr->status & MC_PREVPRESSED))
     371           DrawFrameControl(hdc, prev, DFC_SCROLL,
     372                        DFCS_SCROLLLEFT | (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
     373
     374        if (!(infoPtr->status & MC_NEXTPRESSED))
     375        DrawFrameControl(hdc, next, DFC_SCROLL,
     376                DFCS_SCROLLRIGHT | (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) );
     377
     378    oldBkColor=SetBkColor (hdc,infoPtr->titlebk);
     379    SetTextColor(hdc, infoPtr->titletxt);
     380        SelectObject (hdc, infoPtr->hBoldFont);
     381
     382        thisMonthtxt=monthtxt[infoPtr->currentMonth - 1];
     383        sprintf (buf,"%s %ld",thisMonthtxt,infoPtr->currentYear);
     384    DrawTextA ( hdc, buf, strlen(buf), titlemonth,
     385                        DT_CENTER | DT_VCENTER | DT_SINGLELINE );
     386        SelectObject (hdc, infoPtr->hFont);
     387
     388 /* titlemonth left/right contained rect for whole titletxt ('June  1999')
     389  * MCM_HitTestInfo wants month & year rects, so prepare these now.
     390  * (no, we can't draw them separately; the whole text is centered)
     391  */
     392
     393    GetTextExtentPoint32A (hdc, buf,lstrlenA (buf), &size);
     394        titlemonth->left = title->right/2 - size.cx/2;
     395        titleyear->right = title->right/2 + size.cx/2;
     396    GetTextExtentPoint32A (hdc, thisMonthtxt,lstrlenA (thisMonthtxt), &size);
     397    titlemonth->right= titlemonth->left+size.cx;
     398    titleyear->right = titlemonth->right;
     399
     400/* draw line under day abbreviatons */
     401
     402         if (dwStyle & MCS_WEEKNUMBERS)
     403                MoveToEx (hdc, rcClient->left+textWidth+3,
     404                       title->bottom + textHeight + 2, NULL);
     405         else
     406                MoveToEx (hdc, rcClient->left+3, title->bottom + textHeight + 2, NULL);
     407     LineTo   (hdc, rcClient->right-3, title->bottom + textHeight + 2);
     408
     409/* draw day abbreviations */
     410
     411    SetBkColor (hdc, infoPtr->monthbk);
     412    SetTextColor(hdc, infoPtr->trailingtxt);
     413
     414        days->left   = rcClient->left;
     415        if (dwStyle & MCS_WEEKNUMBERS) days->left+=textWidth;
     416    days->right  = days->left + textWidth;
     417    days->top    = title->bottom + 2;
     418    days->bottom = title->bottom + textHeight + 2;
     419        i=infoPtr->firstDay;
     420
     421        for (j=0; j<7; j++) {
     422            DrawTextA ( hdc, daytxt[i], strlen(daytxt[i]), days,
     423                         DT_CENTER | DT_VCENTER | DT_SINGLELINE );
     424                        i++;
     425                        if (i>7) i-=7;
     426                        days->left+=textWidth;
     427                        days->right+=textWidth;
     428        }
     429
     430        days->left   = rcClient->left + j;
     431        if (dwStyle & MCS_WEEKNUMBERS) days->left+=textWidth;
     432    days->right  = rcClient->left + (j+1)*textWidth-2;
     433
     434/* draw day numbers; first, the previous month */
     435
     436        prevmonth->left=0;
     437        if (dwStyle & MCS_WEEKNUMBERS) prevmonth->left=textWidth;
     438
     439        firstDay=MONTHCAL_CalculateDayOfWeek (1,infoPtr->currentMonth,infoPtr->currentYear);
     440        prevMonth=infoPtr->currentMonth-1;
     441        if (prevMonth==0) prevMonth=11;
     442        day=mdays[prevMonth]-firstDay;
     443        mask=1<<(day-1);
     444
     445        i=0;
     446        m=0;
     447        while (day<=mdays[prevMonth]) {
     448                        MONTHCAL_DrawDay (hdc, infoPtr, day, prevMonth, i, 0,
     449                                                infoPtr->monthdayState[m] & mask);
     450                        mask<<=1;
     451                        day++;
     452                        i++;
     453        }
     454
     455        prevmonth->right = prevmonth->left+i*textWidth;
     456        prevmonth->top   = days->bottom;
     457        prevmonth->bottom= prevmonth->top + textHeight;
     458
     459/* draw `current' month  */
     460
     461        day=1;
     462        infoPtr->firstDayplace=i;
     463    SetTextColor(hdc, infoPtr->txt);
     464        m++;
     465        mask=1;
     466        while (i<7) {
     467                        MONTHCAL_DrawDay (hdc, infoPtr, day, infoPtr->currentMonth, i, 0,
     468                                                infoPtr->monthdayState[m] & mask);
     469                        if ((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
     470                (day==infoPtr->todaysDate.wDay))
     471                                        MONTHCAL_CircleDay (hdc, infoPtr, i,j);
     472                        mask<<=1;
     473                        day++;
     474                        i++;
     475                }
     476
     477        j=1;
     478        i=0;
     479        while (day<=mdays[infoPtr->currentMonth]) {
     480                        MONTHCAL_DrawDay (hdc, infoPtr, day, infoPtr->currentMonth, i, j,
     481                                                infoPtr->monthdayState[m] & mask);
     482                        if ((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) &&
     483                (day==infoPtr->todaysDate.wDay))
     484                                        MONTHCAL_CircleDay (hdc, infoPtr, i,j);
     485                        mask<<=1;
     486                        day++;
     487                        i++;
     488                        if (i>6) {
     489                                i=0;
     490                                j++;
     491                        }
     492        }
     493
     494/*  draw `next' month */
     495
     496/* note: the nextmonth rect only hints for the `half-week' that needs to be
     497 * drawn to complete the current week. An eventual next week that needs to
     498 * be drawn to complete the month calendar is not taken into account in
     499 * this rect -- HitTest knows about this.*/
     500
     501
     502
     503        nextmonth->left   = prevmonth->left+i*textWidth;
     504        nextmonth->right  = rcClient->right;
     505        nextmonth->top    = days->bottom+(j+1)*textHeight;
     506        nextmonth->bottom = nextmonth->top + textHeight;
     507
     508        day=1;
     509        m++;
     510        mask=1;
     511    SetTextColor(hdc, infoPtr->trailingtxt);
     512        while ((i<7) && (j<6)) {
     513                        MONTHCAL_DrawDay (hdc, infoPtr, day, infoPtr->currentMonth+1, i, j,
     514                                                infoPtr->monthdayState[m] & mask);
     515                        mask<<=1;
     516                        day++;
     517                        i++;
     518                        if (i==7) {
     519                                i=0;
     520                                j++;
     521                        }
     522        }
     523    SetTextColor(hdc, infoPtr->txt);
     524
     525
     526
     527/* draw `today' date if style allows it, and draw a circle before today's
     528 * date if necessairy */
     529
     530        if (!( dwStyle & MCS_NOTODAY))  {
     531        int offset=0;
     532        if (!( dwStyle & MCS_NOTODAYCIRCLE))  {
     533                        MONTHCAL_CircleDay (hdc, infoPtr, 0, 6);
     534                        offset+=textWidth;
     535                }
     536
     537                MONTHCAL_CalcDayRect (infoPtr, rtoday, offset==textWidth, 6);
     538                sprintf (buf,"Today: %d/%d/%d",infoPtr->todaysDate.wMonth,
     539                        infoPtr->todaysDate.wDay, infoPtr->todaysDate.wYear-1900);
     540                rtoday->right  = rcClient->right;
     541        SelectObject (hdc, infoPtr->hBoldFont);
     542            DrawTextA ( hdc, buf, lstrlenA(buf), rtoday,
     543                         DT_LEFT | DT_VCENTER | DT_SINGLELINE );
     544        SelectObject (hdc, infoPtr->hFont);
     545        }
     546
     547        if (dwStyle & MCS_WEEKNUMBERS)  {
     548                        /* display weeknumbers*/
     549
     550                weeknums->left   = 0;
     551                weeknums->right  = textWidth;
     552                weeknums->top    = days->bottom + 2;
     553                weeknums->bottom = days->bottom + 2 + textHeight;
     554
     555                weeknum=0;
     556                for (i=0; i<infoPtr->currentMonth-1; i++)
     557                        weeknum+=mdays[i];
     558
     559                weeknum/=7;
     560                for (i=0; i<6; i++) {
     561                        sprintf (buf,"%d",weeknum+i);
     562                DrawTextA ( hdc, buf, lstrlenA(buf), weeknums,
     563                         DT_CENTER | DT_BOTTOM | DT_SINGLELINE );
     564                        weeknums->top+=textHeight*1.25;
     565                        weeknums->bottom+=textHeight*1.25;
     566                }
     567
     568            MoveToEx (hdc, weeknums->right, days->bottom+5 , NULL);
     569        LineTo   (hdc, weeknums->right, weeknums->bottom-1.25*textHeight-5);
     570
     571        }
     572
     573                                 /* currentFont was font at entering Refresh */
     574
     575    SetBkColor (hdc, oldBkColor);
     576    SelectObject (hdc, currentFont);
     577    SetTextColor (hdc, oldTextColor);
     578}
     579
     580
     581static LRESULT
     582MONTHCAL_GetMinReqRect (HWND hwnd, WPARAM wParam, LPARAM lParam)
     583
     584{
     585    MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     586        LPRECT lpRect=(LPRECT) lParam;
     587        //TRACE ("%x %lx\n",wParam,lParam);
     588
     589  /* validate parameters */
     590
     591    if ( (infoPtr==NULL) || (lpRect == NULL) ) return FALSE;
     592
     593        lpRect->left=infoPtr->rcClient.left;
     594        lpRect->right=infoPtr->rcClient.right;
     595        lpRect->top=infoPtr->rcClient.top;
     596        lpRect->bottom=infoPtr->rcClient.bottom;
     597        return TRUE;
     598}
     599
     600static LRESULT
     601MONTHCAL_GetColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
     602
     603{
     604    MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     605
     606        //TRACE ("%x %lx\n",wParam,lParam);
     607
     608        switch ((int)wParam) {
     609                case MCSC_BACKGROUND:
     610                        return infoPtr->bk;
     611                case MCSC_TEXT:
     612                        return infoPtr->txt;
     613                case MCSC_TITLEBK:
     614                        return infoPtr->titlebk;
     615                case MCSC_TITLETEXT:
     616                        return infoPtr->titletxt;
     617                case MCSC_MONTHBK:
     618                        return infoPtr->monthbk;
     619                case MCSC_TRAILINGTEXT:
     620                        return infoPtr->trailingtxt;
     621        }
     622
     623 return -1;
     624}
     625
     626static LRESULT
     627MONTHCAL_SetColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
     628
     629{
     630    MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     631        int prev=-1;
     632
     633        //TRACE ("%x %lx\n",wParam,lParam);
     634
     635        switch ((int)wParam) {
     636                case MCSC_BACKGROUND:
     637                        prev=infoPtr->bk;
     638                        infoPtr->bk=(COLORREF) lParam;
     639                        break;
     640                case MCSC_TEXT:
     641                        prev=infoPtr->txt;
     642                        infoPtr->txt=(COLORREF) lParam;
     643                        break;
     644                case MCSC_TITLEBK:
     645                        prev=infoPtr->titlebk;
     646                        infoPtr->titlebk=(COLORREF) lParam;
     647                        break;
     648                case MCSC_TITLETEXT:
     649                        prev=infoPtr->titletxt;
     650                        infoPtr->titletxt=(COLORREF) lParam;
     651                        break;
     652                case MCSC_MONTHBK:
     653                        prev=infoPtr->monthbk;
     654                        infoPtr->monthbk=(COLORREF) lParam;
     655                        break;
     656                case MCSC_TRAILINGTEXT:
     657                        prev=infoPtr->trailingtxt;
     658                        infoPtr->trailingtxt=(COLORREF) lParam;
     659                        break;
     660        }
     661
     662 return prev;
     663}
     664
     665static LRESULT
     666MONTHCAL_GetMonthDelta (HWND hwnd, WPARAM wParam, LPARAM lParam)
     667
     668{
     669    MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     670
     671        //TRACE ("%x %lx\n",wParam,lParam);
     672
     673        if (infoPtr->delta) return infoPtr->delta;
     674        else return infoPtr->visible;
     675}
     676
     677static LRESULT
     678MONTHCAL_SetMonthDelta (HWND hwnd, WPARAM wParam, LPARAM lParam)
     679
     680{
     681    MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     682    int prev=infoPtr->delta;
     683
     684        //TRACE ("%x %lx\n",wParam,lParam);
     685
     686        infoPtr->delta=(int) wParam;
     687        return prev;
     688}
     689
     690
     691
     692static LRESULT
     693MONTHCAL_GetFirstDayOfWeek (HWND hwnd, WPARAM wParam, LPARAM lParam)
     694{
     695    MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     696
     697        return infoPtr->firstDay;
     698}
     699
     700/* FIXME: we need more error checking here */
     701
     702static LRESULT
     703MONTHCAL_SetFirstDayOfWeek (HWND hwnd, WPARAM wParam, LPARAM lParam)
     704
     705{
     706    MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     707    int prev=infoPtr->firstDay;
     708        char buf[40];
     709        int day;
     710
     711        //TRACE ("%x %lx\n",wParam,lParam);
     712
     713        if ((lParam>=0) && (lParam<7)) {
     714                        infoPtr->firstDay=(int) lParam;
     715                        GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK,
     716                buf, sizeof(buf));
     717                //TRACE ("%s %d\n",buf,strlen(buf));
     718            if ((sscanf(buf,"%d",&day)==1) && (infoPtr->firstDay!=day))
     719                                infoPtr->firstDay|=HIWORD(TRUE);
     720
     721        }
     722    return prev;
     723}
     724
     725
     726
     727/* FIXME: fill this in */
     728
     729static LRESULT
     730MONTHCAL_GetMonthRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
     731{
     732  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     733
     734  //TRACE ("%x %lx\n",wParam,lParam);
     735
     736  return infoPtr->monthRange;
     737}
     738
     739static LRESULT
     740MONTHCAL_GetMaxTodayWidth (HWND hwnd)
     741
     742{
     743 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     744
     745 return (infoPtr->today.right-infoPtr->today.left);
     746}
     747
     748/* FIXME: are validated times taken from current date/time or simply
     749 * copied?
     750 * FIXME:    check whether MCM_GETMONTHRANGE shows correct result after
     751 *            adjusting range with MCM_SETRANGE
     752 */
     753
     754static LRESULT
     755MONTHCAL_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
     756{
     757  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     758  SYSTEMTIME lprgSysTimeArray[1];
     759  int prev;
     760
     761  //TRACE ("%x %lx\n",wParam,lParam);
     762
     763  if (wParam & GDTR_MAX) {
     764                if (MONTHCAL_ValidateTime(lprgSysTimeArray[1])){
     765                        MONTHCAL_CopyTime (&lprgSysTimeArray[1],&infoPtr->maxDate);
     766                        infoPtr->rangeValid|=GDTR_MAX;
     767                } else  {
     768                        GetSystemTime (&infoPtr->todaysDate);
     769                        MONTHCAL_CopyTime (&infoPtr->todaysDate,&infoPtr->maxDate);
     770                        }
     771                }
     772  if (wParam & GDTR_MIN) {
     773                if (MONTHCAL_ValidateTime(lprgSysTimeArray[0])) {
     774                        MONTHCAL_CopyTime (&lprgSysTimeArray[0],&infoPtr->maxDate);
     775                        infoPtr->rangeValid|=GDTR_MIN;
     776                } else {
     777                        GetSystemTime (&infoPtr->todaysDate);
     778                        MONTHCAL_CopyTime (&infoPtr->todaysDate,&infoPtr->maxDate);
     779                        }
     780            }
     781
     782  prev=infoPtr->monthRange;
     783  infoPtr->monthRange=infoPtr->maxDate.wMonth-infoPtr->minDate.wMonth;
     784  if (infoPtr->monthRange!=prev)
     785        COMCTL32_ReAlloc (infoPtr->monthdayState,
     786                infoPtr->monthRange*sizeof(MONTHDAYSTATE));
     787
     788  return 1;
     789}
     790
     791
     792/* CHECKME: At the moment, we copy ranges anyway,regardless of
     793 * infoPtr->rangeValid; a invalid range is simply filled with zeros in
     794 * SetRange.  Is this the right behavior?
     795*/
     796
     797static LRESULT
     798MONTHCAL_GetRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
     799{
     800  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     801  SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
     802
     803  /* validate parameters */
     804
     805  if ( (infoPtr==NULL) || (lprgSysTimeArray==NULL) ) return FALSE;
     806
     807  MONTHCAL_CopyTime (&infoPtr->maxDate,&lprgSysTimeArray[1]);
     808  MONTHCAL_CopyTime (&infoPtr->minDate,&lprgSysTimeArray[0]);
     809
     810  return infoPtr->rangeValid;
     811}
     812
     813static LRESULT
     814MONTHCAL_SetDayState (HWND hwnd, WPARAM wParam, LPARAM lParam)
     815
     816{
     817  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     818  int i,iMonths=(int) wParam;
     819  MONTHDAYSTATE *dayStates=(LPMONTHDAYSTATE) lParam;
     820
     821  //TRACE ("%x %lx\n",wParam,lParam);
     822  if (iMonths!=infoPtr->monthRange) return 0;
     823
     824  for (i=0; i<iMonths; i++)
     825                infoPtr->monthdayState[i]=dayStates[i];
     826  return 1;
     827}
     828
     829static LRESULT
     830MONTHCAL_GetCurSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
     831{
     832  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     833  SYSTEMTIME *lpSel=(SYSTEMTIME *) lParam;
     834
     835  //TRACE ("%x %lx\n",wParam,lParam);
     836  if ( (infoPtr==NULL) || (lpSel==NULL) ) return FALSE;
     837  if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT) return FALSE;
     838
     839  MONTHCAL_CopyTime (&infoPtr->minSel,lpSel);
     840  return TRUE;
     841}
     842
     843
     844/* FIXME: if the specified date is not visible, make it visible */
     845/* FIXME: redraw? */
     846
     847static LRESULT
     848MONTHCAL_SetCurSel (HWND hwnd, WPARAM wParam, LPARAM lParam)
     849{
     850  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     851  SYSTEMTIME *lpSel=(SYSTEMTIME *) lParam;
     852
     853  //TRACE ("%x %lx\n",wParam,lParam);
     854  if ( (infoPtr==NULL) || (lpSel==NULL) ) return FALSE;
     855  if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT) return FALSE;
     856
     857  //TRACE ("%d %d\n",lpSel->wMonth,lpSel->wDay);
     858
     859  MONTHCAL_CopyTime (lpSel,&infoPtr->minSel);
     860  MONTHCAL_CopyTime (lpSel,&infoPtr->maxSel);
     861
     862  return TRUE;
     863}
     864
     865static LRESULT
     866MONTHCAL_GetMaxSelCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
     867{
     868  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     869
     870  //TRACE ("%x %lx\n",wParam,lParam);
     871  return infoPtr->maxSelCount;
     872}
     873
     874static LRESULT
     875MONTHCAL_SetMaxSelCount (HWND hwnd, WPARAM wParam, LPARAM lParam)
     876{
     877  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     878
     879  //TRACE ("%x %lx\n",wParam,lParam);
     880  if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT)  {
     881                infoPtr->maxSelCount=wParam;
     882  }
     883
     884  return TRUE;
     885}
     886
     887
     888static LRESULT
     889MONTHCAL_GetSelRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
     890{
     891  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     892  SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
     893
     894  //TRACE ("%x %lx\n",wParam,lParam);
     895
     896  /* validate parameters */
     897
     898  if ( (infoPtr==NULL) || (lprgSysTimeArray==NULL) ) return FALSE;
     899
     900  if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT)  {
     901                MONTHCAL_CopyTime (&infoPtr->maxSel,&lprgSysTimeArray[1]);
     902        MONTHCAL_CopyTime (&infoPtr->minSel,&lprgSysTimeArray[0]);
     903                //TRACE ("[min,max]=[%d %d]\n",infoPtr->minSel.wDay,infoPtr->maxSel.wDay);
     904        return TRUE;
     905  }
     906
     907  return FALSE;
     908}
     909
     910static LRESULT
     911MONTHCAL_SetSelRange (HWND hwnd, WPARAM wParam, LPARAM lParam)
     912{
     913  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     914  SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam;
     915
     916  //TRACE ("%x %lx\n",wParam,lParam);
     917
     918  /* validate parameters */
     919
     920  if ( (infoPtr==NULL) || (lprgSysTimeArray==NULL) ) return FALSE;
     921
     922  if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT)  {
     923                MONTHCAL_CopyTime (&lprgSysTimeArray[1],&infoPtr->maxSel);
     924        MONTHCAL_CopyTime (&lprgSysTimeArray[0],&infoPtr->minSel);
     925                //TRACE ("[min,max]=[%d %d]\n",infoPtr->minSel.wDay,infoPtr->maxSel.wDay);
     926        return TRUE;
     927  }
     928
     929  return FALSE;
     930}
     931
     932
     933
     934
     935static LRESULT
     936MONTHCAL_GetToday (HWND hwnd, WPARAM wParam, LPARAM lParam)
     937{
     938  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     939  SYSTEMTIME *lpToday=(SYSTEMTIME *) lParam;
     940
     941  //TRACE ("%x %lx\n",wParam,lParam);
     942
     943  /* validate parameters */
     944
     945  if ( (infoPtr==NULL) || (lpToday==NULL) ) return FALSE;
     946  MONTHCAL_CopyTime (&infoPtr->todaysDate,lpToday);
     947  return TRUE;
     948}
     949
     950
     951static LRESULT
     952MONTHCAL_SetToday (HWND hwnd, WPARAM wParam, LPARAM lParam)
     953{
     954  MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     955  SYSTEMTIME *lpToday=(SYSTEMTIME *) lParam;
     956
     957  //TRACE ("%x %lx\n",wParam,lParam);
     958
     959  /* validate parameters */
     960
     961  if ( (infoPtr==NULL) || (lpToday==NULL) ) return FALSE;
     962  MONTHCAL_CopyTime (lpToday, &infoPtr->todaysDate);
     963  return TRUE;
     964}
     965
     966
     967
     968
     969static LRESULT
     970MONTHCAL_HitTest (HWND hwnd, LPARAM lParam)
     971{
     972 MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd);
     973 PMCHITTESTINFO lpht=(PMCHITTESTINFO) lParam;
     974 UINT x,y;
     975 DWORD retval;
     976
     977 x=lpht->pt.x;
     978 y=lpht->pt.y;
     979 retval=MCHT_NOWHERE;
     980
     981
     982        /* are we in the header? */
     983
     984 if (PtInRect (&infoPtr->title, lpht->pt)) {
     985
     986                if (PtInRect (&infoPtr->titlebtnprev, lpht->pt)) {
     987                        retval=MCHT_TITLEBTNPREV;
     988                        goto done;
     989                }
     990                if (PtInRect (&infoPtr->titlebtnnext, lpht->pt)) {
     991                        retval=MCHT_TITLEBTNNEXT;
     992                        goto done;
     993                }
     994                if (PtInRect (&infoPtr->titlemonth, lpht->pt)) {
     995                        retval=MCHT_TITLEMONTH;
     996                        goto done;
     997                }
     998                if (PtInRect (&infoPtr->titleyear, lpht->pt)) {
     999                        retval=MCHT_TITLEYEAR;
     1000                        goto done;
     1001                }
     1002                retval=MCHT_TITLE;
     1003                goto done;
     1004        }
     1005
     1006 if (PtInRect (&infoPtr->days, lpht->pt)) {
     1007                retval=MCHT_CALENDARDAY;  /* FIXME: find out which day we're on */
     1008                goto done;
     1009        }
     1010 if (PtInRect (&infoPtr->weeknums, lpht->pt)) {
     1011                retval=MCHT_CALENDARWEEKNUM;/* FIXME: find out which day we're on */
     1012                goto done;
     1013        }
     1014 if (PtInRect (&infoPtr->prevmonth, lpht->pt)) {
     1015                retval=MCHT_CALENDARDATEPREV;
     1016                goto done;
     1017        }
     1018 if (PtInRect (&infoPtr->nextmonth, lpht->pt) ||
     1019    ((x>infoPtr->nextmonth.left) && (x<infoPtr->nextmonth.right) &&
     1020     (y>infoPtr->nextmonth.bottom) && (y<infoPtr->today.top ))) {
     1021                retval=MCHT_CALENDARDATENEXT;
     1022                goto done;
     1023        }
     1024
     1025
     1026 if (PtInRect (&infoPtr->today, lpht->pt)) {
     1027                retval=MCHT_TODAYLINK;
     1028                goto done;
     1029        }
     1030
     1031/* MCHT_CALENDARDATE determination: since the next & previous month have
     1032 * been handled already (MCHT_CALENDARDATEPREV/NEXT), we only have to check
     1033 * whether we're in the calendar area. infoPtr->prevMonth.left handles the
     1034 * MCS_WEEKNUMBERS style nicely.
     1035 */
     1036
     1037
     1038 //TRACE ("%d %d [%d %d %d %d] [%d %d %d %d]\n",x,y,
     1039 //       infoPtr->prevmonth.left, infoPtr->prevmonth.right,
     1040 //       infoPtr->prevmonth.top, infoPtr->prevmonth.bottom,
     1041 //       infoPtr->nextmonth.left, infoPtr->nextmonth.right,
     1042 //       infoPtr->nextmonth.top, infoPtr->nextmonth.bottom);
     1043
     1044 if ((x>infoPtr->prevmonth.left) && (x<infoPtr->nextmonth.right) &&
     1045         (y>infoPtr->prevmonth.top) && (y<infoPtr->nextmonth.bottom))  {
     1046                lpht->st.wYear=infoPtr->currentYear;
     1047                lpht->st.wMonth=infoPtr->currentMonth;
     1048
     1049                lpht->st.wDay=MONTHCAL_CalcDayFromPos (infoPtr,x,y);
     1050
     1051                //TRACE ("day hit: %d\n",lpht->st.wDay);
     1052                retval=MCHT_CALENDARDATE;
     1053                goto done;
     1054
     1055        }
     1056
     1057        /* Hit nothing special? What's left must be background :-) */
     1058
     1059  retval=MCHT_CALENDARBK;
     1060 done:
     1061  lpht->uHit=retval;
     1062  return retval;
     1063}
     1064
     1065
     1066
     1067static void MONTHCAL_GoToNextMonth (HWND hwnd,  MONTHCAL_INFO *infoPtr)
     1068{
     1069    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     1070
     1071        //TRACE ("\n");
     1072
     1073        infoPtr->currentMonth++;
     1074        if (infoPtr->currentMonth>12) {
     1075                infoPtr->currentYear++;
     1076                infoPtr->currentMonth=1;
     1077        }
     1078
     1079        if (dwStyle & MCS_DAYSTATE) {
     1080                NMDAYSTATE nmds;
     1081                int i;
     1082
     1083        nmds.nmhdr.hwndFrom = hwnd;
     1084                nmds.nmhdr.idFrom   = GetWindowLongA( hwnd, GWL_ID);
     1085                nmds.nmhdr.code     = MCN_GETDAYSTATE;
     1086                nmds.cDayState          = infoPtr->monthRange;
     1087                nmds.prgDayState        = COMCTL32_Alloc
     1088                                 (infoPtr->monthRange*sizeof(MONTHDAYSTATE));
     1089
     1090                SendMessageA (GetParent (hwnd), WM_NOTIFY,
     1091                                  (WPARAM)nmds.nmhdr.idFrom, (LPARAM)&nmds);
     1092                for (i=0; i<infoPtr->monthRange; i++)
     1093                infoPtr->monthdayState[i]=nmds.prgDayState[i];
     1094        }
     1095
     1096}
     1097
     1098
     1099static void MONTHCAL_GoToPrevMonth (HWND hwnd,  MONTHCAL_INFO *infoPtr)
     1100{
     1101    DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     1102
     1103        //TRACE ("\n");
     1104
     1105        infoPtr->currentMonth--;
     1106        if (infoPtr->currentMonth<1) {
     1107                infoPtr->currentYear--;
     1108                infoPtr->currentMonth=12;
     1109        }
     1110
     1111        if (dwStyle & MCS_DAYSTATE) {
     1112                NMDAYSTATE nmds;
     1113                int i;
     1114
     1115        nmds.nmhdr.hwndFrom = hwnd;
     1116                nmds.nmhdr.idFrom   = GetWindowLongA( hwnd, GWL_ID);
     1117                nmds.nmhdr.code     = MCN_GETDAYSTATE;
     1118                nmds.cDayState          = infoPtr->monthRange;
     1119                nmds.prgDayState        = COMCTL32_Alloc
     1120                                 (infoPtr->monthRange*sizeof(MONTHDAYSTATE));
     1121
     1122                SendMessageA (GetParent (hwnd), WM_NOTIFY,
     1123                                 (WPARAM)nmds.nmhdr.idFrom, (LPARAM)&nmds);
     1124                for (i=0; i<infoPtr->monthRange; i++)
     1125                infoPtr->monthdayState[i]=nmds.prgDayState[i];
     1126        }
     1127}
     1128
     1129
     1130static LRESULT
     1131MONTHCAL_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1132
     1133{
     1134    MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd);
     1135        MCHITTESTINFO ht;
     1136        HDC hdc;
     1137        DWORD hit;
     1138        HMENU hMenu;
     1139        HWND retval;
     1140
     1141
     1142        //TRACE ("%x %lx\n",wParam,lParam);
     1143
     1144    ht.pt.x = (INT)LOWORD(lParam);
     1145    ht.pt.y = (INT)HIWORD(lParam);
     1146    hit=MONTHCAL_HitTest (hwnd, (LPARAM) &ht);
     1147
     1148    hdc=GetDC (hwnd);
     1149
     1150        if (hit & MCHT_NEXT){
     1151                MONTHCAL_GoToNextMonth (hwnd, infoPtr);
     1152                infoPtr->status=MC_NEXTPRESSED;
     1153                SetTimer (hwnd, MC_NEXTMONTHTIMER, MC_NEXTMONTHDELAY,0);
     1154        }
     1155        if (hit & MCHT_PREV) {
     1156                MONTHCAL_GoToPrevMonth (hwnd, infoPtr);
     1157                infoPtr->status=MC_PREVPRESSED;
     1158                SetTimer (hwnd, MC_PREVMONTHTIMER, MC_NEXTMONTHDELAY,0);
     1159        }
     1160
     1161        if (hit == MCHT_TITLEMONTH) {
     1162/*
     1163                HRSRC hrsrc = FindResourceA( COMCTL32_hModule, MAKEINTRESOURCEA(IDD_MCMONTHMENU), RT_MENUA );
     1164        if (!hrsrc) {
     1165                        TRACE ("returning zero\n");
     1166                        return 0;
     1167                }
     1168                TRACE ("resource is:%x\n",hrsrc);
     1169        hMenu=LoadMenuIndirectA( (LPCVOID)LoadResource( COMCTL32_hModule, hrsrc ));
     1170
     1171                TRACE ("menu is:%x\n",hMenu);
     1172*/
     1173
     1174                hMenu=CreateMenu ();
     1175        AppendMenuA (hMenu,MF_STRING,IDM_JAN,"January");
     1176        AppendMenuA (hMenu,MF_STRING,IDM_FEB,"February");
     1177        AppendMenuA (hMenu,MF_STRING,IDM_MAR,"March");
     1178
     1179                retval=CreateWindowA (POPUPMENU_CLASS_ATOM, NULL,
     1180                        WS_CHILD | WS_VISIBLE,
     1181                        0,0,100,220,
     1182                        hwnd, hMenu, GetWindowLongA (hwnd, GWL_HINSTANCE), NULL);
     1183                //TRACE ("hwnd returned:%x\n",retval);
     1184
     1185        }
     1186        if (hit == MCHT_TITLEYEAR) {
     1187                        //FIXME ("create updown for yearselection\n");
     1188        }
     1189        if (hit == MCHT_TODAYLINK) {
     1190                        //FIXME ("set currentday\n");
     1191        }
     1192        if (hit == MCHT_CALENDARDATE) {
     1193                        SYSTEMTIME selArray[2];
     1194                        NMSELCHANGE nmsc;
     1195
     1196                        //TRACE ("\n");
     1197                    nmsc.nmhdr.hwndFrom = hwnd;
     1198                nmsc.nmhdr.idFrom   = GetWindowLongA( hwnd, GWL_ID);
     1199                nmsc.nmhdr.code     = MCN_SELCHANGE;
     1200                        MONTHCAL_CopyTime (&nmsc.stSelStart, &infoPtr->minSel);
     1201                        MONTHCAL_CopyTime (&nmsc.stSelEnd, &infoPtr->maxSel);
     1202
     1203                SendMessageA (GetParent (hwnd), WM_NOTIFY,
     1204                                   (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
     1205
     1206                        MONTHCAL_CopyTime (&ht.st, &selArray[0]);
     1207                        MONTHCAL_CopyTime (&ht.st, &selArray[1]);
     1208                        MONTHCAL_SetSelRange (hwnd,0,(LPARAM) &selArray);
     1209
     1210                        infoPtr->firstSelDay=ht.st.wDay;
     1211                        infoPtr->curSelDay=ht.st.wDay;
     1212                        infoPtr->status=MC_SEL_LBUTDOWN;
     1213        }
     1214
     1215        MONTHCAL_Refresh (hwnd,hdc);
     1216        ReleaseDC (hwnd,hdc);
     1217        return 0;
     1218}
     1219
     1220static LRESULT
     1221MONTHCAL_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1222
     1223{
     1224    MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd);
     1225        NMSELCHANGE nmsc;
     1226    NMHDR nmhdr;
     1227        HDC hdc;
     1228
     1229        //TRACE ("\n");
     1230
     1231        if (infoPtr->status & MC_NEXTPRESSED)
     1232                        KillTimer (hwnd, MC_NEXTMONTHTIMER);
     1233        if (infoPtr->status & MC_PREVPRESSED)
     1234                        KillTimer (hwnd, MC_PREVMONTHTIMER);
     1235        infoPtr->status=MC_SEL_LBUTUP;
     1236        infoPtr->curSelDay=0;
     1237
     1238    nmhdr.hwndFrom = hwnd;
     1239    nmhdr.idFrom   = GetWindowLongA( hwnd, GWL_ID);
     1240    nmhdr.code     = NM_RELEASEDCAPTURE;
     1241        //TRACE ("Sent notification from %x to %x\n", hwnd, GetParent (hwnd));
     1242
     1243    SendMessageA (GetParent (hwnd), WM_NOTIFY,
     1244                                   (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr);
     1245
     1246    nmsc.nmhdr.hwndFrom = hwnd;
     1247    nmsc.nmhdr.idFrom   = GetWindowLongA( hwnd, GWL_ID);
     1248    nmsc.nmhdr.code     = MCN_SELECT;
     1249        MONTHCAL_CopyTime (&nmsc.stSelStart, &infoPtr->minSel);
     1250        MONTHCAL_CopyTime (&nmsc.stSelEnd, &infoPtr->maxSel);
     1251
     1252    SendMessageA (GetParent (hwnd), WM_NOTIFY,
     1253                                   (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc);
     1254
     1255    hdc=GetDC (hwnd);
     1256    MONTHCAL_Refresh (hwnd,hdc);
     1257    ReleaseDC (hwnd,hdc);
     1258
     1259        return 0;
     1260}
     1261
     1262static LRESULT
     1263MONTHCAL_Timer (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1264
     1265{
     1266    MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd);
     1267    HDC hdc;
     1268
     1269    //TRACE(" %d\n",wParam);
     1270    if (!infoPtr) return FALSE;
     1271
     1272    hdc=GetDC (hwnd);
     1273    switch (wParam) {
     1274        case MC_NEXTMONTHTIMER:
     1275                MONTHCAL_GoToNextMonth (hwnd, infoPtr);
     1276                break;
     1277        case MC_PREVMONTHTIMER:
     1278                MONTHCAL_GoToPrevMonth (hwnd, infoPtr);
     1279                break;
     1280    //default:
     1281        //ERR("got unknown timer\n");
     1282        }
     1283
     1284    MONTHCAL_Refresh (hwnd,hdc);
     1285    ReleaseDC (hwnd,hdc);
     1286    return 0;
     1287}
     1288
     1289
     1290
     1291static LRESULT
     1292MONTHCAL_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1293{
     1294    MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd);
     1295        MCHITTESTINFO ht;
     1296        HDC hdc;
     1297        int selday,hit;
     1298        RECT r;
     1299
     1300        if (!(infoPtr->status & MC_SEL_LBUTDOWN)) return 0;
     1301
     1302        ht.pt.x=LOWORD(lParam);
     1303        ht.pt.y=HIWORD(lParam);
     1304
     1305        hit=MONTHCAL_HitTest (hwnd, (LPARAM) &ht);
     1306
     1307        /* not on the calendar date numbers? bail out */
     1308        //TRACE ("hit:%x\n",hit);
     1309        if ((hit & MCHT_CALENDARDATE) !=MCHT_CALENDARDATE) return 0;
     1310
     1311        selday=ht.st.wDay;
     1312        infoPtr->curSelDay=selday;
     1313        MONTHCAL_CalcPosFromDay (infoPtr,selday,ht.st.wMonth,&r);
     1314
     1315        if ( GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT)  {
     1316                SYSTEMTIME selArray[2];
     1317                int i;
     1318
     1319        MONTHCAL_GetSelRange (hwnd,0,(LPARAM) &selArray);
     1320                i=0;
     1321                if (infoPtr->firstSelDay==selArray[0].wDay) i=1;
     1322                //TRACE ("oldRange:%d %d %d %d\n",infoPtr->firstSelDay,selArray[0].wDay,selArray[1].wDay,i);
     1323                if (infoPtr->firstSelDay==selArray[1].wDay) {
     1324                                /* 1st time we get here: selArray[0]=selArray[1])  */
     1325                                /* if we're still at the first selected date, return */
     1326                        if (infoPtr->firstSelDay==selday) goto done;
     1327
     1328                        if (selday<infoPtr->firstSelDay) i=0;
     1329                }
     1330
     1331                if (abs(infoPtr->firstSelDay - selday) >= infoPtr->maxSelCount) {
     1332                        if (selday>infoPtr->firstSelDay)
     1333                                selday=infoPtr->firstSelDay+infoPtr->maxSelCount;
     1334                        else
     1335                                selday=infoPtr->firstSelDay-infoPtr->maxSelCount;
     1336                }
     1337
     1338                if (selArray[i].wDay!=selday) {
     1339
     1340                //TRACE ("newRange:%d %d %d %d\n",infoPtr->firstSelDay,selArray[0].wDay,selArray[1].wDay,i);
     1341
     1342                        selArray[i].wDay=selday;
     1343
     1344
     1345                        if (selArray[0].wDay>selArray[1].wDay) {
     1346                                DWORD tempday;
     1347                                tempday=selArray[1].wDay;
     1348                                selArray[1].wDay=selArray[0].wDay;
     1349                                selArray[0].wDay=tempday;
     1350                        }
     1351
     1352                MONTHCAL_SetSelRange (hwnd,0,(LPARAM) &selArray);
     1353                }
     1354        }
     1355
     1356done:
     1357
     1358        hdc=GetDC (hwnd);
     1359        MONTHCAL_Refresh (hwnd, hdc);
     1360        ReleaseDC (hwnd, hdc);
     1361
     1362        return 0;
     1363}
     1364
     1365static LRESULT
     1366MONTHCAL_Paint (HWND hwnd, WPARAM wParam)
     1367{
     1368    HDC hdc;
     1369    PAINTSTRUCT ps;
     1370
     1371    hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam;
     1372    MONTHCAL_Refresh (hwnd, hdc);
     1373    if(!wParam)
     1374    EndPaint (hwnd, &ps);
     1375    return 0;
     1376}
     1377
     1378static LRESULT
     1379MONTHCAL_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1380{
     1381    HDC hdc;
     1382
     1383    //TRACE ("\n");
     1384
     1385    hdc = GetDC (hwnd);
     1386    MONTHCAL_Refresh (hwnd, hdc);
     1387    ReleaseDC (hwnd, hdc);
     1388    InvalidateRect (hwnd, NULL, TRUE);
     1389
     1390    return 0;
     1391}
     1392
     1393
     1394static LRESULT
     1395MONTHCAL_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam)
     1396{
     1397    HDC hdc;
     1398
     1399    //TRACE ("\n");
     1400
     1401    hdc = GetDC (hwnd);
     1402    MONTHCAL_Refresh (hwnd, hdc);
     1403    ReleaseDC (hwnd, hdc);
     1404
     1405    return 0;
     1406}
     1407
     1408
     1409/* FIXME: check whether dateMin/dateMax need to be adjusted. */
    291410
    301411
     
    331414{
    341415    MONTHCAL_INFO *infoPtr;
     1416        LOGFONTA        logFont;
    351417
    361418    /* allocate memory for info structure */
     
    381420    SetWindowLongA (hwnd, 0, (DWORD)infoPtr);
    391421
     1422        if (infoPtr == NULL) {
     1423        //ERR ( "could not allocate info memory!\n");
     1424        return 0;
     1425    }
     1426    if ((MONTHCAL_INFO*) GetWindowLongA( hwnd, 0) != infoPtr) {
     1427        //ERR ( "pointer assignment error!\n");
     1428        return 0;
     1429    }
     1430
     1431
     1432    infoPtr->hFont=GetStockObject(DEFAULT_GUI_FONT);
     1433                GetObjectA (infoPtr->hFont, sizeof (LOGFONTA), &logFont);
     1434        logFont.lfWeight=FW_BOLD;
     1435        infoPtr->hBoldFont = CreateFontIndirectA (&logFont);
    401436
    411437    /* initialize info structure */
    42 
    43 
     1438   /* FIXME: calculate systemtime ->> localtime (substract timezoneinfo) */
     1439
     1440        GetSystemTime (&infoPtr->todaysDate);
     1441        infoPtr->firstDay  = 0;
     1442        infoPtr->currentMonth = infoPtr->todaysDate.wMonth;
     1443        infoPtr->currentYear= infoPtr->todaysDate.wYear;
     1444        MONTHCAL_CopyTime (&infoPtr->todaysDate,&infoPtr->minDate);
     1445        MONTHCAL_CopyTime (&infoPtr->todaysDate,&infoPtr->maxDate);
     1446        infoPtr->maxSelCount=6;
     1447        infoPtr->monthRange=3;
     1448        infoPtr->monthdayState=COMCTL32_Alloc
     1449                           (infoPtr->monthRange*sizeof(MONTHDAYSTATE));
     1450        infoPtr->titlebk     = GetSysColor (COLOR_GRAYTEXT);
     1451        infoPtr->titletxt    = GetSysColor (COLOR_WINDOW);
     1452        infoPtr->monthbk     = GetSysColor (COLOR_WINDOW);
     1453        infoPtr->trailingtxt = GetSysColor (COLOR_GRAYTEXT);
     1454        infoPtr->bk                  = GetSysColor (COLOR_WINDOW);
     1455        infoPtr->txt         = GetSysColor (COLOR_WINDOWTEXT);
    441456
    451457    return 0;
     
    521464    MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr (hwnd);
    531465
    54 
    55 
    56 
    57 
    58 
    59     /* free ipaddress info data */
     1466    /* free month calendar info data */
    601467    COMCTL32_Free (infoPtr);
    611468
     
    651472
    661473
    67 
    68 LRESULT WINAPI
     1474static LRESULT WINAPI
    691475MONTHCAL_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    701476{
     1477
    711478    switch (uMsg)
    721479    {
    731480
    74 
    75         case WM_CREATE:
    76             return MONTHCAL_Create (hwnd, wParam, lParam);
    77 
    78         case WM_DESTROY:
    79             return MONTHCAL_Destroy (hwnd, wParam, lParam);
    80 
    81         default:
    82 //          if (uMsg >= WM_USER)
    83 //              ERR (monthcal, "unknown msg %04x wp=%08x lp=%08lx\n",
    84 //                   uMsg, wParam, lParam);
    85             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     1481        case MCM_GETCURSEL:
     1482        return MONTHCAL_GetCurSel (hwnd, wParam, lParam);
     1483
     1484        case MCM_SETCURSEL:
     1485        return MONTHCAL_SetCurSel (hwnd, wParam, lParam);
     1486
     1487        case MCM_GETMAXSELCOUNT:
     1488        return MONTHCAL_GetMaxSelCount (hwnd, wParam, lParam);
     1489
     1490        case MCM_SETMAXSELCOUNT:
     1491        return MONTHCAL_SetMaxSelCount (hwnd, wParam, lParam);
     1492
     1493        case MCM_GETSELRANGE:
     1494        return MONTHCAL_GetSelRange (hwnd, wParam, lParam);
     1495
     1496        case MCM_SETSELRANGE:
     1497        return MONTHCAL_SetSelRange (hwnd, wParam, lParam);
     1498
     1499        case MCM_GETMONTHRANGE:
     1500        return MONTHCAL_GetMonthRange (hwnd, wParam, lParam);
     1501
     1502        case MCM_SETDAYSTATE:
     1503        return MONTHCAL_SetDayState (hwnd, wParam, lParam);
     1504
     1505        case MCM_GETMINREQRECT:
     1506        return MONTHCAL_GetMinReqRect (hwnd, wParam, lParam);
     1507
     1508        case MCM_GETCOLOR:
     1509             return MONTHCAL_GetColor (hwnd, wParam, lParam);
     1510
     1511        case MCM_SETCOLOR:
     1512             return MONTHCAL_SetColor (hwnd, wParam, lParam);
     1513
     1514        case MCM_GETTODAY:
     1515             return MONTHCAL_GetToday (hwnd, wParam, lParam);
     1516
     1517        case MCM_SETTODAY:
     1518             return MONTHCAL_SetToday (hwnd, wParam, lParam);
     1519
     1520        case MCM_HITTEST:
     1521            return MONTHCAL_HitTest (hwnd,lParam);
     1522
     1523        case MCM_GETFIRSTDAYOFWEEK:
     1524        return MONTHCAL_GetFirstDayOfWeek (hwnd, wParam, lParam);
     1525
     1526        case MCM_SETFIRSTDAYOFWEEK:
     1527        return MONTHCAL_SetFirstDayOfWeek (hwnd, wParam, lParam);
     1528
     1529        case MCM_GETRANGE:
     1530             return MONTHCAL_GetRange (hwnd, wParam, lParam);
     1531
     1532        case MCM_SETRANGE:
     1533             return MONTHCAL_SetRange (hwnd, wParam, lParam);
     1534
     1535        case MCM_GETMONTHDELTA:
     1536             return MONTHCAL_GetMonthDelta (hwnd, wParam, lParam);
     1537
     1538        case MCM_SETMONTHDELTA:
     1539             return MONTHCAL_SetMonthDelta (hwnd, wParam, lParam);
     1540
     1541        case MCM_GETMAXTODAYWIDTH:
     1542             return MONTHCAL_GetMaxTodayWidth (hwnd);
     1543
     1544        case WM_GETDLGCODE:
     1545        return DLGC_WANTARROWS | DLGC_WANTCHARS;
     1546
     1547    case WM_KILLFOCUS:
     1548        return MONTHCAL_KillFocus (hwnd, wParam, lParam);
     1549
     1550    case WM_LBUTTONDOWN:
     1551        return MONTHCAL_LButtonDown (hwnd, wParam, lParam);
     1552
     1553    case WM_MOUSEMOVE:
     1554        return MONTHCAL_MouseMove (hwnd, wParam, lParam);
     1555
     1556    case WM_LBUTTONUP:
     1557        return MONTHCAL_LButtonUp (hwnd, wParam, lParam);
     1558
     1559    case WM_PAINT:
     1560        return MONTHCAL_Paint (hwnd, wParam);
     1561
     1562    case WM_SETFOCUS:
     1563        return MONTHCAL_SetFocus (hwnd, wParam, lParam);
     1564
     1565        case WM_CREATE:
     1566            return MONTHCAL_Create (hwnd, wParam, lParam);
     1567
     1568        case WM_TIMER:
     1569            return MONTHCAL_Timer (hwnd, wParam, lParam);
     1570
     1571        case WM_DESTROY:
     1572            return MONTHCAL_Destroy (hwnd, wParam, lParam);
     1573
     1574        default:
     1575            //if (uMsg >= WM_USER)
     1576            //    ERR ( "unknown msg %04x wp=%08x lp=%08lx\n",
     1577            //         uMsg, wParam, lParam);
     1578            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    861579    }
    871580    return 0;
     
    891582
    901583
    91 VOID
    92 MONTHCAL_Register (VOID)
     1584void
     1585MONTHCAL_Register (void)
    931586{
    941587    WNDCLASSA wndClass;
     
    1041597    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    1051598    wndClass.lpszClassName = MONTHCAL_CLASSA;
    106  
     1599
    1071600    RegisterClassA (&wndClass);
    1081601}
    1091602
    1101603
    111 VOID
    112 MONTHCAL_Unregister (VOID)
     1604void
     1605MONTHCAL_Unregister (void)
    1131606{
    1141607    if (GlobalFindAtomA (MONTHCAL_CLASSA))
    115         UnregisterClassA (MONTHCAL_CLASSA, (HINSTANCE)NULL);
    116 }
    117 
     1608        UnregisterClassA (MONTHCAL_CLASSA, (HINSTANCE)NULL);
     1609}
     1610
  • TabularUnified trunk/src/comctl32/nativefont.c

    r94 r496  
    1 /* $Id: nativefont.c,v 1.3 1999-06-10 16:22:01 achimha Exp $ */
     1/* $Id: nativefont.c,v 1.4 1999-08-14 16:13:12 cbratschi Exp $ */
    22/*
    33 * Native Font control
     
    6060
    6161
    62 LRESULT WINAPI
     62static LRESULT WINAPI
    6363NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    6464{
     
    6666    {
    6767
    68         case WM_CREATE:
    69             return NATIVEFONT_Create (hwnd, wParam, lParam);
     68        case WM_CREATE:
     69            return NATIVEFONT_Create (hwnd, wParam, lParam);
    7070
    71         case WM_DESTROY:
    72             return NATIVEFONT_Destroy (hwnd, wParam, lParam);
     71        case WM_DESTROY:
     72            return NATIVEFONT_Destroy (hwnd, wParam, lParam);
    7373
    74         default:
    75 //          ERR (nativefont, "unknown msg %04x wp=%08x lp=%08lx\n",
    76 //                   uMsg, wParam, lParam);
    77             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     74        default:
     75//          ERR (nativefont, "unknown msg %04x wp=%08x lp=%08lx\n",
     76//                   uMsg, wParam, lParam);
     77            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    7878    }
    7979    return 0;
     
    9696    wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
    9797    wndClass.lpszClassName = WC_NATIVEFONTCTLA;
    98  
     98
    9999    RegisterClassA (&wndClass);
    100100}
     
    105105{
    106106    if (GlobalFindAtomA (WC_NATIVEFONTCTLA))
    107         UnregisterClassA (WC_NATIVEFONTCTLA, (HINSTANCE)NULL);
     107        UnregisterClassA (WC_NATIVEFONTCTLA, (HINSTANCE)NULL);
    108108}
    109109
  • TabularUnified trunk/src/comctl32/pager.c

    r94 r496  
    1 /* $Id: pager.c,v 1.3 1999-06-10 16:22:01 achimha Exp $ */
     1/* $Id: pager.c,v 1.4 1999-08-14 16:13:12 cbratschi Exp $ */
    22/*
    33 * Pager control
     
    9393
    9494    if (infoPtr->hwndChild) {
    95         ZeroMemory (&nmpgcs, sizeof (NMPGCALCSIZE));
    96         nmpgcs.hdr.hwndFrom = hwnd;
    97         nmpgcs.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
    98         nmpgcs.hdr.code = PGN_CALCSIZE;
    99         nmpgcs.dwFlag = (dwStyle & PGS_HORZ) ? PGF_CALCWIDTH : PGF_CALCHEIGHT;
    100         SendMessageA (GetParent (hwnd), WM_NOTIFY,
    101                         (WPARAM)nmpgcs.hdr.idFrom, (LPARAM)&nmpgcs);
    102 
    103         infoPtr->nChildSize = (dwStyle & PGS_HORZ) ? nmpgcs.iWidth : nmpgcs.iHeight;
     95        ZeroMemory (&nmpgcs, sizeof (NMPGCALCSIZE));
     96        nmpgcs.hdr.hwndFrom = hwnd;
     97        nmpgcs.hdr.idFrom   = GetWindowLongA (hwnd, GWL_ID);
     98        nmpgcs.hdr.code = PGN_CALCSIZE;
     99        nmpgcs.dwFlag = (dwStyle & PGS_HORZ) ? PGF_CALCWIDTH : PGF_CALCHEIGHT;
     100        SendMessageA (GetParent (hwnd), WM_NOTIFY,
     101                        (WPARAM)nmpgcs.hdr.idFrom, (LPARAM)&nmpgcs);
     102
     103        infoPtr->nChildSize = (dwStyle & PGS_HORZ) ? nmpgcs.iWidth : nmpgcs.iHeight;
    104104
    105105
     
    168168    /* FIXME: redraw */
    169169    if (infoPtr->hwndChild) {
    170         SetParent (infoPtr->hwndChild, hwnd);
    171         SetWindowPos (infoPtr->hwndChild, HWND_TOP,
    172                         0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
     170        RECT rect;
     171
     172        GetClientRect(hwnd,&rect);
     173        SetParent (infoPtr->hwndChild, hwnd);
     174        SetWindowPos (infoPtr->hwndChild, HWND_TOP,
     175                        0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
     176
     177        MoveWindow (infoPtr->hwndChild, 0, 0, rect.right, rect.bottom, TRUE);
    173178    }
    174179
     
    188193    /* FIXME: redraw */
    189194    SetWindowPos (infoPtr->hwndChild, HWND_TOP,
    190                     0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
     195                    0, 0, 0, 0, SWP_SHOWWINDOW | SWP_NOSIZE);
    191196
    192197    return 0;
     
    268273    GetClientRect (hwnd, &rect);
    269274    if (infoPtr->hwndChild) {
    270         SetWindowPos (infoPtr->hwndChild, HWND_TOP, rect.left, rect.top,
    271                         rect.right - rect.left, rect.bottom - rect.top,
    272                         SWP_SHOWWINDOW);
    273 /*      MoveWindow32 (infoPtr->hwndChild, 1, 1, rect.right - 2, rect.bottom-2, TRUE); */
    274 /*      UpdateWindow32 (infoPtr->hwndChild); */
     275        SetWindowPos (infoPtr->hwndChild, HWND_TOP, rect.left, rect.top,
     276                        rect.right - rect.left, rect.bottom - rect.top,
     277                        SWP_SHOWWINDOW);
     278/*      MoveWindow (infoPtr->hwndChild, 1, 1, rect.right - 2, rect.bottom-2, TRUE); */
     279/*      UpdateWindow (infoPtr->hwndChild); */
    275280
    276281    }
    277 /*    FillRect32 ((HDC32)wParam, &rect, hBrush); */
    278 /*    DeleteObject32 (hBrush); */
     282/*    FillRect ((HDC)wParam, &rect, hBrush); */
     283/*    DeleteObject (hBrush); */
    279284    return TRUE;
    280285}
     
    282287
    283288
    284 LRESULT WINAPI
     289static LRESULT WINAPI
    285290PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    286291{
    287292    switch (uMsg)
    288293    {
    289         case PGM_FORWARDMOUSE:
    290             return PAGER_ForwardMouse (hwnd, wParam);
    291 
    292         case PGM_GETBKCOLOR:
    293             return PAGER_GetBkColor (hwnd, wParam, lParam);
    294 
    295         case PGM_GETBORDER:
    296             return PAGER_GetBorder (hwnd, wParam, lParam);
    297 
    298         case PGM_GETBUTTONSIZE:
    299             return PAGER_GetButtonSize (hwnd, wParam, lParam);
    300 
    301         case PGM_GETBUTTONSTATE:
    302             return PAGER_GetButtonState (hwnd, wParam, lParam);
    303 
    304 /*      case PGM_GETDROPTARGET: */
    305 
    306         case PGM_GETPOS:
    307             return PAGER_SetPos (hwnd, wParam, lParam);
    308 
    309         case PGM_RECALCSIZE:
    310             return PAGER_RecalcSize (hwnd, wParam, lParam);
    311 
    312         case PGM_SETBKCOLOR:
    313             return PAGER_SetBkColor (hwnd, wParam, lParam);
    314 
    315         case PGM_SETBORDER:
    316             return PAGER_SetBorder (hwnd, wParam, lParam);
    317 
    318         case PGM_SETBUTTONSIZE:
    319             return PAGER_SetButtonSize (hwnd, wParam, lParam);
    320 
    321         case PGM_SETCHILD:
    322             return PAGER_SetChild (hwnd, wParam, lParam);
    323 
    324         case PGM_SETPOS:
    325             return PAGER_SetPos (hwnd, wParam, lParam);
    326 
    327         case WM_CREATE:
    328             return PAGER_Create (hwnd, wParam, lParam);
    329 
    330         case WM_DESTROY:
    331             return PAGER_Destroy (hwnd, wParam, lParam);
    332 
    333         case WM_ERASEBKGND:
    334             return PAGER_EraseBackground (hwnd, wParam, lParam);
    335 
    336         case WM_MOUSEMOVE:
    337             return PAGER_MouseMove (hwnd, wParam, lParam);
    338 
    339         case WM_NOTIFY:
    340         case WM_COMMAND:
    341             return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
    342 
    343 /*      case WM_PAINT: */
    344 /*          return PAGER_Paint (hwnd, wParam); */
    345 
    346         case WM_SIZE:
    347             return PAGER_Size (hwnd, wParam, lParam);
    348 
    349         default:
    350 //          if (uMsg >= WM_USER)
    351 //              ERR (pager, "unknown msg %04x wp=%08x lp=%08lx\n",
    352 //                   uMsg, wParam, lParam);
    353             return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     294        case PGM_FORWARDMOUSE:
     295            return PAGER_ForwardMouse (hwnd, wParam);
     296
     297        case PGM_GETBKCOLOR:
     298            return PAGER_GetBkColor (hwnd, wParam, lParam);
     299
     300        case PGM_GETBORDER:
     301            return PAGER_GetBorder (hwnd, wParam, lParam);
     302
     303        case PGM_GETBUTTONSIZE:
     304            return PAGER_GetButtonSize (hwnd, wParam, lParam);
     305
     306        case PGM_GETBUTTONSTATE:
     307            return PAGER_GetButtonState (hwnd, wParam, lParam);
     308
     309/*      case PGM_GETDROPTARGET: */
     310
     311        case PGM_GETPOS:
     312            return PAGER_SetPos (hwnd, wParam, lParam);
     313
     314        case PGM_RECALCSIZE:
     315            return PAGER_RecalcSize (hwnd, wParam, lParam);
     316
     317        case PGM_SETBKCOLOR:
     318            return PAGER_SetBkColor (hwnd, wParam, lParam);
     319
     320        case PGM_SETBORDER:
     321            return PAGER_SetBorder (hwnd, wParam, lParam);
     322
     323        case PGM_SETBUTTONSIZE:
     324            return PAGER_SetButtonSize (hwnd, wParam, lParam);
     325
     326        case PGM_SETCHILD:
     327            return PAGER_SetChild (hwnd, wParam, lParam);
     328
     329        case PGM_SETPOS:
     330            return PAGER_SetPos (hwnd, wParam, lParam);
     331
     332        case WM_CREATE:
     333            return PAGER_Create (hwnd, wParam, lParam);
     334
     335        case WM_DESTROY:
     336            return PAGER_Destroy (hwnd, wParam, lParam);
     337
     338        case WM_ERASEBKGND:
     339            return PAGER_EraseBackground (hwnd, wParam, lParam);
     340
     341        case WM_MOUSEMOVE:
     342            return PAGER_MouseMove (hwnd, wParam, lParam);
     343
     344        case WM_NOTIFY:
     345        case WM_COMMAND:
     346            return SendMessageA (GetParent (hwnd), uMsg, wParam, lParam);
     347
     348/*      case WM_PAINT: */
     349/*          return PAGER_Paint (hwnd, wParam); */
     350
     351        case WM_SIZE:
     352            return PAGER_Size (hwnd, wParam, lParam);
     353
     354        default:
     355//          if (uMsg >= WM_USER)
     356//              ERR (pager, "unknown msg %04x wp=%08x lp=%08lx\n",
     357//                   uMsg, wParam, lParam);
     358            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    354359    }
    355360    return 0;
     
    372377    wndClass.hbrBackground = 0;
    373378    wndClass.lpszClassName = WC_PAGESCROLLERA;
    374  
     379
    375380    RegisterClassA (&wndClass);
    376381}
     
    381386{
    382387    if (GlobalFindAtomA (WC_PAGESCROLLERA))
    383         UnregisterClassA (WC_PAGESCROLLERA, (HINSTANCE)NULL);
    384 }
    385 
     388        UnregisterClassA (WC_PAGESCROLLERA, (HINSTANCE)NULL);
     389}
     390
  • TabularUnified trunk/src/comctl32/progress.c

    r236 r496  
    1 /* $Id: progress.c,v 1.7 1999-06-28 15:46:25 cbratschi Exp $ */
     1/* $Id: progress.c,v 1.8 1999-08-14 16:13:12 cbratschi Exp $ */
    22/*
    33 * Progress control
     
    493493 *           ProgressWindowProc
    494494 */
    495 LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
     495static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message,
    496496                                  WPARAM wParam, LPARAM lParam)
    497497{
  • TabularUnified trunk/src/comctl32/propsheet.c

    r295 r496  
    1 /* $Id: propsheet.c,v 1.6 1999-07-12 15:58:48 cbratschi Exp $ */
     1/* $Id: propsheet.c,v 1.7 1999-08-14 16:13:12 cbratschi Exp $ */
    22/*
    33 * Property Sheets
     
    627627    ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_SYSMENU;
    628628    ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_POPUP;
     629    ((MyDLGTEMPLATEEX*)pTemplate)->style &= ~WS_DISABLED;
    629630  }
    630631  else
     
    635636    pTemplate->style &= ~WS_SYSMENU;
    636637    pTemplate->style &= ~WS_POPUP;
     638    pTemplate->style &= ~WS_DISABLED;
     639
    637640  }
    638641
     
    668671
    669672  if (showPage)
     673  {
     674    NMHDR hdr;
     675
     676    hdr.hwndFrom = hwndParent;
     677    hdr.code = PSN_SETACTIVE;
     678
     679    /*
     680     * Send the notification before showing the page.
     681     */
     682    SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
     683
    670684    ShowWindow(hwndPage, SW_SHOW);
     685  }
    671686  else
    672687    ShowWindow(hwndPage, SW_HIDE);
     
    899914    return FALSE;
    900915
    901 //  if (hpage != NULL)
    902 //    FIXME(propsheet, "Implement HPROPSHEETPAGE!\n");
    903 //  else
    904     hwndPage = psInfo->proppage[index].hwndPage;
    905 
    906   /*
    907    * Notify the new page.
    908    */
    909   hdr.code = PSN_SETACTIVE;
    910 
    911   SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
     916  /*
     917   * hpage takes precedence over index.
     918   */
     919  if (hpage != NULL)
     920  {
     921    index = PROPSHEET_GetPageIndex(hpage, psInfo);
     922
     923    if (index == -1)
     924    {
     925      //TRACE("Could not find page to remove!\n");
     926      return FALSE;
     927    }
     928  }
     929
     930  hwndPage = psInfo->proppage[index].hwndPage;
     931
     932  /*
     933   * Notify the new page if it's already created.
     934   * If not it will get created and notified in PROPSHEET_ShowPage.
     935   */
     936  if (hwndPage)
     937  {
     938    int result;
     939    hdr.code = PSN_SETACTIVE;
     940
     941    result = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &hdr);
     942    /*
     943     * TODO: check return value.
     944     */
     945  }
    912946
    913947  /*
     
    13401374      if (pnmh->code == TCN_SELCHANGE)
    13411375      {
    1342         PropSheetInfo* psInfo = (PropSheetInfo*) GetPropA(hwnd,
    1343                                                           PropSheetInfoStr);
    13441376        int index = SendMessageA(pnmh->hwndFrom, TCM_GETCURSEL, 0, 0);
    1345         HWND hwndHelp  = GetDlgItem(hwnd, IDHELP);
    1346 
    1347         PROPSHEET_ShowPage(hwnd, index, psInfo);
    1348 
    1349         if (psInfo->proppage[index].hasHelp)
    1350           EnableWindow(hwndHelp, TRUE);
    1351         else
    1352           EnableWindow(hwndHelp, FALSE);
     1377        PROPSHEET_SetCurSel(hwnd, index, 0);
    13531378      }
    13541379
  • TabularUnified trunk/src/comctl32/rebar.c

    r295 r496  
    1 /* $Id: rebar.c,v 1.7 1999-07-12 15:58:48 cbratschi Exp $ */
     1/* $Id: rebar.c,v 1.8 1999-08-14 16:13:12 cbratschi Exp $ */
    22/*
    33 * Rebar control
     
    18611861
    18621862
    1863 LRESULT WINAPI
     1863static LRESULT WINAPI
    18641864REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    18651865{
  • TabularUnified trunk/src/comctl32/status.c

    r295 r496  
    1 /* $Id: status.c,v 1.9 1999-07-12 15:58:48 cbratschi Exp $ */
     1/* $Id: status.c,v 1.10 1999-08-14 16:13:12 cbratschi Exp $ */
    22/*
    33 * Interface code to StatusWindow widget/control
     
    11541154
    11551155
    1156 LRESULT WINAPI
     1156static LRESULT WINAPI
    11571157StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
    11581158{
  • TabularUnified trunk/src/comctl32/tab.c

    r295 r496  
    1 /* $Id: tab.c,v 1.9 1999-07-12 15:58:48 cbratschi Exp $ */
     1/* $Id: tab.c,v 1.10 1999-08-14 16:13:13 cbratschi Exp $ */
    22/*
    33 * Tab control
     
    800800         */
    801801        if (!(lStyle & TCS_OWNERDRAWFIXED))
     802        {
     803          DeleteObject(hbr);
    802804          hbr = CreateSolidBrush(GetSysColor(COLOR_3DHILIGHT));
     805        }
    803806
    804807        /*
     
    849852       * Background color.
    850853       */
     854      DeleteObject(hbr);
    851855      hbr = CreateSolidBrush(GetSysColor(COLOR_BTNFACE));
    852856
     
    963967    SetBkMode(hdc, oldBkMode);
    964968    SelectObject(hdc, holdPen);
     969    DeleteObject(hfocusPen);
     970    DeleteObject(hbr);
    965971  }
    966972}
     
    10981104  if (givenDC==0)
    10991105    ReleaseDC(hwnd, hdc);
     1106
     1107  DeleteObject(brush);
    11001108
    11011109  return 0;
     
    14201428   if (len>wineItem->cchTextMax)
    14211429     wineItem->pszText = COMCTL32_ReAlloc (wineItem->pszText, (len+1)*sizeof(WCHAR));
    1422    lstrcpynAtoW (wineItem->pszText, tabItem->pszText, len+1);
     1430   lstrcpyAtoW (wineItem->pszText, tabItem->pszText);
    14231431  }
    14241432
     
    14561464   if (len>wineItem->cchTextMax)
    14571465     wineItem->pszText = COMCTL32_ReAlloc (wineItem->pszText, (len+1)*sizeof(WCHAR));
    1458    lstrcpynW (wineItem->pszText, tabItem->pszText, len+1);
     1466   lstrcpyW (wineItem->pszText, tabItem->pszText);
    14591467  }
    14601468
     
    17841792}
    17851793
    1786 LRESULT WINAPI
     1794static LRESULT WINAPI
    17871795TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    17881796{
  • TabularUnified trunk/src/comctl32/toolbar.c

    r295 r496  
    1 /* $Id: toolbar.c,v 1.11 1999-07-12 15:58:49 cbratschi Exp $ */
     1/* $Id: toolbar.c,v 1.12 1999-08-14 16:13:13 cbratschi Exp $ */
    22/*
    33 * Toolbar control
     
    1414 *   - Fix TB_SETROWS.
    1515 *   - Tooltip support (almost complete).
    16  *   - Internal COMMCTL32 bitmaps.
    1716 *   - Fix TOOLBAR_SetButtonInfo32A.
    1817 *   - Drag & drop of buttons
     
    4544#define BOTTOM_BORDER      2
    4645
    47 #define TOOLBAR_GetInfoPtr(wndPtr) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
     46#define TOOLBAR_GetInfoPtr(hwnd) ((TOOLBAR_INFO *)GetWindowLongA(hwnd,0))
    4847
    4948
     
    130129              internals directly */
    131130
    132     HDC hdcImageList = CreateCompatibleDC (0);
    133     HDC hdcMask = CreateCompatibleDC (0);
    134131    HIMAGELIST himl = infoPtr->himlDef;
    135132    HBITMAP hbmMask;
     133    HDC hdcImageList;
     134    HDC hdcMask;
     135
     136    if (!himl)
     137        return;
     138
     139    /* create new dc's */
     140    hdcImageList = CreateCompatibleDC (0);
     141    hdcMask = CreateCompatibleDC (0);
    136142
    137143    /* create new bitmap */
     
    179185
    180186    rc = btnPtr->rect;
     187
     188    /* separator */
    181189    if (btnPtr->fsStyle & TBSTYLE_SEP)
    182190    {
    183       if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->idCommand == 0))
     191      if ((dwStyle & TBSTYLE_FLAT) && (btnPtr->iBitmap == 0))
    184192          TOOLBAR_DrawFlatSeparator (&rc, hdc);
    185193      return;
     
    15441552 * This function implements the toolbar customization dialog.
    15451553 */
    1546 BOOL WINAPI
     1554static BOOL WINAPI
    15471555TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    15481556{
     
    15851593    LPTBADDBITMAP lpAddBmp = (LPTBADDBITMAP)lParam;
    15861594    INT nIndex = 0,nButtons;
     1595    HBITMAP hbmLoad;
    15871596
    15881597    if (!lpAddBmp)
     
    16021611//        TRACE ("adding %d internal bitmaps!\n", nButtons);
    16031612
    1604         /* Windows resize all the buttons to the size of a newly added STandard Image*/
     1613        /* Windows resize all the buttons to the size of a newly added standard Image*/
    16051614        if (lpAddBmp->nID & 1)
    16061615        {
     
    16501659    else if (lpAddBmp->hInst == HINST_COMMCTRL)
    16511660    {
    1652         /* add internal bitmaps */
    1653 //        FIXME ("internal bitmaps not supported!\n");
    1654 
    1655         /* Hack to "add" some reserved images within the image list
    1656            to get the right image indices */
    1657         nIndex = ImageList_GetImageCount (infoPtr->himlDef);
    1658         ImageList_SetImageCount (infoPtr->himlDef, nIndex + nButtons);
     1661        /* Add system bitmaps */
     1662        switch (lpAddBmp->nID)
     1663      {
     1664            case IDB_STD_SMALL_COLOR:
     1665                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1666                                       MAKEINTRESOURCEA(IDB_STD_SMALL));
     1667                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1668                                              hbmLoad, CLR_DEFAULT);
     1669                DeleteObject (hbmLoad);
     1670                break;
     1671
     1672            case IDB_STD_LARGE_COLOR:
     1673                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1674                                       MAKEINTRESOURCEA(IDB_STD_LARGE));
     1675                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1676                                              hbmLoad, CLR_DEFAULT);
     1677                DeleteObject (hbmLoad);
     1678                break;
     1679
     1680            case IDB_VIEW_SMALL_COLOR:
     1681                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1682                                       MAKEINTRESOURCEA(IDB_VIEW_SMALL));
     1683                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1684                                              hbmLoad, CLR_DEFAULT);
     1685                DeleteObject (hbmLoad);
     1686                break;
     1687
     1688            case IDB_VIEW_LARGE_COLOR:
     1689                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1690                                       MAKEINTRESOURCEA(IDB_VIEW_LARGE));
     1691                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1692                                              hbmLoad, CLR_DEFAULT);
     1693                DeleteObject (hbmLoad);
     1694                break;
     1695
     1696            case IDB_HIST_SMALL_COLOR:
     1697                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1698                                       MAKEINTRESOURCEA(IDB_HIST_SMALL));
     1699                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1700                                              hbmLoad, CLR_DEFAULT);
     1701                DeleteObject (hbmLoad);
     1702                break;
     1703
     1704            case IDB_HIST_LARGE_COLOR:
     1705                hbmLoad = LoadBitmapA (COMCTL32_hModule,
     1706                                       MAKEINTRESOURCEA(IDB_HIST_LARGE));
     1707                nIndex = ImageList_AddMasked (infoPtr->himlDef,
     1708                                              hbmLoad, CLR_DEFAULT);
     1709                DeleteObject (hbmLoad);
     1710                break;
     1711
     1712            default:
     1713        nIndex = ImageList_GetImageCount (infoPtr->himlDef);
     1714                //ERR ("invalid imagelist!\n");
     1715                break;
     1716        }
    16591717    }
    16601718    else
    16611719    {
    1662         HBITMAP hBmp =
    1663             LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
    1664         nIndex = ImageList_AddMasked (infoPtr->himlDef, hBmp, CLR_DEFAULT);
    1665 
    1666         DeleteObject (hBmp);
     1720        hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID);
     1721        nIndex = ImageList_AddMasked (infoPtr->himlDef, hbmLoad, CLR_DEFAULT);
     1722        DeleteObject (hbmLoad);
    16671723    }
    16681724
     
    38253881
    38263882
    3827 LRESULT WINAPI
     3883static LRESULT WINAPI
    38283884ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    38293885{
  • TabularUnified trunk/src/comctl32/tooltips.c

    r295 r496  
    1 /* $Id: tooltips.c,v 1.12 1999-07-12 15:58:49 cbratschi Exp $ */
     1/* $Id: tooltips.c,v 1.13 1999-08-14 16:13:15 cbratschi Exp $ */
    22/*
    33 * Tool tip control
     
    21752175
    21762176
    2177 LRESULT CALLBACK
     2177static LRESULT CALLBACK
    21782178TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    21792179{
  • TabularUnified trunk/src/comctl32/trackbar.c

    r267 r496  
    1 /* $Id: trackbar.c,v 1.11 1999-07-04 21:06:00 cbratschi Exp $ */
     1/* $Id: trackbar.c,v 1.12 1999-08-14 16:13:15 cbratschi Exp $ */
    22/*
    33 * Trackbar control
     
    7474static BOOL TRACKBAR_SendNotify (HWND hwnd, UINT code);
    7575
    76 void TRACKBAR_RecalculateTics (HWND hwnd,TRACKBAR_INFO *infoPtr,BOOL restoreOld)
     76static void TRACKBAR_RecalculateTics (HWND hwnd,TRACKBAR_INFO *infoPtr,BOOL restoreOld)
    7777{
    7878    INT i,tic,nrTics;
     
    20322032
    20332033
    2034 LRESULT WINAPI
     2034static LRESULT WINAPI
    20352035TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    20362036{
  • TabularUnified trunk/src/comctl32/treeview.c

    r371 r496  
    1 /* $Id: treeview.c,v 1.9 1999-07-23 15:54:34 cbratschi Exp $ */
     1/* $Id: treeview.c,v 1.10 1999-08-14 16:13:16 cbratschi Exp $ */
    22/* Treeview control
    33 *
     
    4646#include "wingdi.h"
    4747#include "commctrl.h"
     48#include "comctl32.h"
    4849#include "treeview.h"
    4950
     
    460461
    461462static LRESULT
     463TREEVIEW_GetLineColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
     464{
     465  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     466
     467  //TRACE("\n");
     468  return (LRESULT) infoPtr->clrLine;
     469}
     470
     471static LRESULT
     472TREEVIEW_SetLineColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
     473{
     474  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     475  COLORREF prevColor=infoPtr->clrLine;
     476
     477  //TRACE("\n");
     478  infoPtr->clrLine=(COLORREF) lParam;
     479  return (LRESULT) prevColor;
     480}
     481
     482static LRESULT
    462483TREEVIEW_SetTextColor (HWND hwnd, WPARAM wParam, LPARAM lParam)
    463484{
     
    510531{
    511532  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
    512 
     533  DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    513534  INT   center,xpos,cx,cy, cditem, drawmode;
    514535  HFONT hOldFont;
     
    523544
    524545  cditem=0;
     546  //TRACE ("cdmode:%x\n",infoPtr->cdmode);
    525547  if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW) {
    526548                drawmode=CDDS_ITEMPREPAINT;
    527549
    528550                if (infoPtr->cdmode & CDRF_NOTIFYSUBITEMDRAW)
    529       drawmode|=CDDS_SUBITEM;
     551                  drawmode|=CDDS_SUBITEM;
    530552
    531553                cditem=TREEVIEW_SendCustomDrawItemNotify (hwnd, hdc, wineItem, drawmode);
     
    547569   * Display the tree hierarchy
    548570   */
    549   if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES)
     571  if ( dwStyle & TVS_HASLINES)
    550572  {
    551573    /*
     
    557579     * points[2] is attached to the parent or the up sibling
    558580     */
    559     if ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_LINESATROOT)
     581    if ( dwStyle & TVS_LINESATROOT)
    560582    {
    561583      TREEVIEW_ITEM *upNode    = NULL;
     
    598620
    599621      /*
    600        * Get a doted pen
     622       * Get a dotted pen
    601623       */
    602       hnewPen = CreatePen(PS_DOT, 0, GetSysColor(COLOR_WINDOWTEXT) );
     624      hnewPen = CreatePen(PS_DOT, 0, infoPtr->clrLine);
    603625      hOldPen = SelectObject( hdc, hnewPen );
    604626
     
    619641    xpos+=(5*wineItem->iLevel);
    620642
    621   if (( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASBUTTONS) &&
    622       ( GetWindowLongA( hwnd, GWL_STYLE) & TVS_HASLINES))
     643  if (( dwStyle & TVS_HASBUTTONS) && ( dwStyle & TVS_HASLINES))
    623644  {
    624645          if ( (wineItem->cChildren) ||
     
    876897  if (tvItem->mask & TVIF_INTEGRAL) {
    877898        wineItem->iIntegral=tvItem->iIntegral;
    878 //        FIXME (treeview," TVIF_INTEGRAL not supported yet\n");
    879899  }
    880900
     
    909929}
    910930
    911 
    912 
    913 
     931static LRESULT
     932TREEVIEW_GetItemState (HWND hwnd, WPARAM wParam, LPARAM lParam)
     933
     934{
     935    TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     936        TREEVIEW_ITEM *wineItem;
     937
     938        wineItem = TREEVIEW_ValidItem (infoPtr, (HTREEITEM)wParam);
     939        if (!wineItem) return 0;
     940
     941        return (wineItem->state & lParam);
     942}
    914943
    915944static void
     
    11441173   if (tvItem->mask & TVIF_INTEGRAL) {
    11451174        tvItem->iIntegral=wineItem->iIntegral;
    1146 //              FIXME (treeview," TVIF_INTEGRAL not supported yet\n");
    11471175   }
    11481176
     
    13821410
    13831411/***************************************************************************
     1412 * Treeview native sort routine: sort on item text.
     1413 */
     1414static INT WINAPI TREEVIEW_SortOnName (
     1415  LPVOID first,
     1416  LPVOID second,
     1417  LPARAM tvInfoPtr)
     1418{
     1419  HWND hwnd=(HWND) tvInfoPtr;
     1420  char *txt1, *txt2;
     1421  TREEVIEW_ITEM *item;
     1422
     1423
     1424  item=(TREEVIEW_ITEM *) first;
     1425  if (item->pszText==LPSTR_TEXTCALLBACKA)  {
     1426         TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT);
     1427        }
     1428  txt1=item->pszText;
     1429
     1430  item=(TREEVIEW_ITEM *) second;
     1431  if (item->pszText==LPSTR_TEXTCALLBACKA)  {
     1432         TREEVIEW_SendDispInfoNotify (hwnd, item, TVN_GETDISPINFO, TVIF_TEXT);
     1433        }
     1434  txt2=item->pszText;
     1435
     1436  return -strcmp (txt1,txt2);
     1437}
     1438
     1439/***************************************************************************
    13841440 * Setup the treeview structure with regards of the sort method
    13851441 * and sort the children of the TV item specified in lParam
     1442 * fRecurse: currently unused. Should be zero.
     1443 * parent: if pSort!=NULL, should equal pSort->hParent.
     1444 *         otherwise, item which child items are to be sorted.
     1445 * pSort:  sort method info. if NULL, sort on item text.
     1446 *         if non-NULL, sort on item's lParam content, and let the
     1447 *         application decide what that means. See also TVM_SORTCHILDRENCB.
    13861448 */
    1387 LRESULT WINAPI TREEVIEW_SortChildrenCB(
     1449
     1450static LRESULT WINAPI TREEVIEW_Sort (
    13881451  HWND   hwnd,
    1389   WPARAM wParam,
    1390   LPARAM lParam)
     1452  BOOL   fRecurse,
     1453  HTREEITEM parent,
     1454  LPTVSORTCB pSort
     1455  )
    13911456{
    13921457  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     
    13941459
    13951460  /* Obtain the TVSORTBC struct */
    1396   infoPtr->pCallBackSort = (LPTVSORTCB)lParam;
     1461  infoPtr->pCallBackSort = pSort;
     1462
     1463        /* undocumented feature: TVI_ROOT means `sort the whole tree' */
     1464
     1465  if (parent==TVI_ROOT)
     1466    parent=infoPtr->TopRootItem;
    13971467
    13981468  /* Check for a valid handle to the parent item */
    1399   if (!TREEVIEW_ValidItem(infoPtr, infoPtr->pCallBackSort->hParent))
     1469  if (!TREEVIEW_ValidItem(infoPtr, parent))
    14001470  {
    1401 //    ERR ("invalid item hParent=%d\n", (INT)infoPtr->pCallBackSort->hParent);
     1471    ERR ("invalid item hParent=%x\n", (INT)parent);
    14021472    return FALSE;
    14031473  }
    14041474
    14051475  /* Obtain the parent node to sort */
    1406   sortMe = &infoPtr->items[ (INT)infoPtr->pCallBackSort->hParent ];
     1476  sortMe = &infoPtr->items[ (INT)parent ];
    14071477
    14081478  /* Make sure there is something to sort */
     
    14341504
    14351505    /* let DPA perform the sort activity */
    1436     DPA_Sort(
    1437       sortList,                  /* what  */
    1438       TREEVIEW_CallBackCompare,  /* how   */
    1439       hwnd);                     /* owner */
     1506        if (pSort)
     1507        DPA_Sort(
     1508                sortList,                  /* what  */
     1509                TREEVIEW_CallBackCompare,  /* how   */
     1510                hwnd);                     /* owner */
     1511        else
     1512                DPA_Sort (
     1513                        sortList,                  /* what  */
     1514                TREEVIEW_SortOnName,       /* how   */
     1515                        hwnd);                     /* owner */
    14401516
    14411517    /*
     
    14761552  return FALSE;
    14771553}
     1554
     1555/***************************************************************************
     1556 * Setup the treeview structure with regards of the sort method
     1557 * and sort the children of the TV item specified in lParam
     1558 */
     1559static LRESULT WINAPI TREEVIEW_SortChildrenCB(
     1560  HWND   hwnd,
     1561  WPARAM wParam,
     1562  LPARAM lParam
     1563  )
     1564{
     1565 LPTVSORTCB pSort=(LPTVSORTCB) lParam;
     1566
     1567 return TREEVIEW_Sort (hwnd, wParam, pSort->hParent, pSort);
     1568}
     1569
     1570
     1571/***************************************************************************
     1572 * Sort the children of the TV item specified in lParam.
     1573 */
     1574static LRESULT WINAPI TREEVIEW_SortChildren (
     1575  HWND   hwnd,
     1576  WPARAM wParam,
     1577  LPARAM lParam)
     1578{
     1579 return TREEVIEW_Sort (hwnd, (BOOL) wParam, (HTREEITEM) lParam, NULL);
     1580}
     1581
    14781582
    14791583int ffs(int mask)
     
    17791883
    17801884
    1781 
     1885static LRESULT
     1886TREEVIEW_InsertItemW(HWND hwnd, WPARAM wParam, LPARAM lParam)
     1887{
     1888    TVINSERTSTRUCTW *tvisW;
     1889    TVINSERTSTRUCTA tvisA;
     1890    LRESULT lRes;
     1891
     1892    tvisW = (LPTVINSERTSTRUCTW)lParam;
     1893
     1894    tvisA.hParent = tvisW->hParent;
     1895    tvisA.hInsertAfter = tvisW->hInsertAfter;
     1896
     1897    tvisA.DUMMYUNIONNAME.item.mask           = tvisW->DUMMYUNIONNAME.item.mask;
     1898    tvisA.DUMMYUNIONNAME.item.hItem          = tvisW->DUMMYUNIONNAME.item.hItem;
     1899    tvisA.DUMMYUNIONNAME.item.state          = tvisW->DUMMYUNIONNAME.item.state;
     1900    tvisA.DUMMYUNIONNAME.item.stateMask      = tvisW->DUMMYUNIONNAME.item.stateMask;
     1901    tvisA.DUMMYUNIONNAME.item.cchTextMax     = tvisW->DUMMYUNIONNAME.item.cchTextMax;
     1902
     1903    if(tvisW->DUMMYUNIONNAME.item.pszText)
     1904    {
     1905        if (tvisW->DUMMYUNIONNAME.item.pszText!=LPSTR_TEXTCALLBACKW)
     1906        {
     1907            int len = lstrlenW (tvisW->DUMMYUNIONNAME.item.pszText)+1;
     1908            tvisA.DUMMYUNIONNAME.item.pszText = COMCTL32_Alloc (len);
     1909            lstrcpyWtoA (tvisA.DUMMYUNIONNAME.item.pszText,
     1910                         tvisW->DUMMYUNIONNAME.item.pszText );
     1911        }
     1912        else
     1913        {
     1914            tvisA.DUMMYUNIONNAME.item.pszText = LPSTR_TEXTCALLBACKA;
     1915            tvisA.DUMMYUNIONNAME.item.cchTextMax = 0;
     1916        }
     1917    }
     1918
     1919    tvisA.DUMMYUNIONNAME.item.iImage         = tvisW->DUMMYUNIONNAME.item.iImage;
     1920    tvisA.DUMMYUNIONNAME.item.iSelectedImage = tvisW->DUMMYUNIONNAME.item.iSelectedImage;
     1921    tvisA.DUMMYUNIONNAME.item.cChildren      = tvisW->DUMMYUNIONNAME.item.cChildren;
     1922    tvisA.DUMMYUNIONNAME.item.lParam         = tvisW->DUMMYUNIONNAME.item.lParam;
     1923
     1924    lRes = TREEVIEW_InsertItemA(hwnd,wParam,(LPARAM)&tvisA);
     1925
     1926    if (tvisA.DUMMYUNIONNAME.item.pszText!=LPSTR_TEXTCALLBACKA)
     1927    {
     1928        COMCTL32_Free(tvisA.DUMMYUNIONNAME.item.pszText);
     1929    }
     1930
     1931    return lRes;
     1932
     1933}
    17821934
    17831935
     
    18582010
    18592011
    1860 LRESULT CALLBACK
     2012static LRESULT CALLBACK
    18612013TREEVIEW_GetEditControl (HWND hwnd)
    18622014
     
    19792131TREEVIEW_StyleChanged (HWND hwnd, WPARAM wParam, LPARAM lParam)
    19802132{
    1981   LPSTYLESTRUCT lpss=(LPSTYLESTRUCT) lParam;
    1982 
    19832133//  TRACE (treeview,"(%x %lx)\n",wParam,lParam);
    19842134
    1985   if (wParam & (GWL_STYLE))
    1986          SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew);
    1987   if (wParam & (GWL_EXSTYLE))
    1988          SetWindowLongA( hwnd, GWL_STYLE, lpss->styleNew);
     2135  TREEVIEW_Refresh(hwnd);
    19892136
    19902137  return 0;
     
    20222169    infoPtr->clrBk = GetSysColor (COLOR_WINDOW);
    20232170    infoPtr->clrText = GetSysColor (COLOR_BTNTEXT);
     2171    infoPtr->clrLine = GetSysColor (COLOR_WINDOWTEXT);
    20242172    infoPtr->cy = 0;
    20252173    infoPtr->cx = 0;
     
    20392187    infoPtr->dropItem=0;
    20402188    infoPtr->pCallBackSort=NULL;
     2189    infoPtr->uScrollTime = 300; /* milliseconds */
    20412190
    20422191/*
     
    26962845
    26972846
    2698 LRESULT
     2847static LRESULT
    26992848TREEVIEW_LButtonDoubleClick (HWND hwnd, WPARAM wParam, LPARAM lParam)
    27002849{
     
    33583507}
    33593508
    3360 
    3361 LRESULT WINAPI
     3509static LRESULT
     3510TREEVIEW_GetScrollTime (HWND hwnd)
     3511{
     3512  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     3513  return infoPtr->uScrollTime;
     3514}
     3515
     3516static LRESULT
     3517TREEVIEW_SetScrollTime (HWND hwnd, UINT uScrollTime)
     3518{
     3519  TREEVIEW_INFO *infoPtr = TREEVIEW_GetInfoPtr(hwnd);
     3520  UINT uOldScrollTime = infoPtr->uScrollTime;
     3521  infoPtr->uScrollTime = min (uScrollTime, 100);
     3522  return uOldScrollTime;
     3523}
     3524
     3525static LRESULT WINAPI
    33623526TREEVIEW_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
    33633527{
     
    33673531
    33683532        case TVM_INSERTITEMW:
    3369 //                      FIXME (treeview, "Unimplemented msg TVM_INSERTITEM32W\n");
    3370                 return 0;
     3533          return TREEVIEW_InsertItemW(hwnd,wParam,lParam);
    33713534
    33723535        case TVM_DELETEITEM:
     
    34043567
    34053568        case TVM_GETITEMW:
    3406 //                      FIXME (treeview, "Unimplemented msg TVM_GETITEM32W\n");
     3569//                      FIXME (treeview, "Unimplemented msg TVM_GETITEMW\n");
    34073570                return 0;
    34083571
     
    34153578
    34163579        case TVM_EDITLABELA:
    3417 //                      FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32A \n");
     3580//                      FIXME (treeview, "Unimplemented msg TVM_EDITLABELA \n");
    34183581                return 0;
    34193582
    34203583        case TVM_EDITLABELW:
    3421 //                      FIXME (treeview, "Unimplemented msg TVM_EDITLABEL32W \n");
     3584//                      FIXME (treeview, "Unimplemented msg TVM_EDITLABELW \n");
    34223585                return 0;
    34233586
     
    34353598
    34363599        case TVM_SORTCHILDREN:
    3437 //                      FIXME (treeview, "Unimplemented msg TVM_SORTCHILDREN\n");
    3438                 return 0;
     3600                return TREEVIEW_SortChildrenCB(hwnd, wParam, lParam);
    34393601
    34403602        case TVM_ENSUREVISIBLE:
     
    34493611
    34503612        case TVM_GETISEARCHSTRINGA:
    3451 //                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32A\n");
     3613//                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRINGA\n");
    34523614                return 0;
    34533615
    34543616        case TVM_GETISEARCHSTRINGW:
    3455 //                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRING32W\n");
     3617//                      FIXME (treeview, "Unimplemented msg TVM_GETISEARCHSTRINGW\n");
    34563618                return 0;
    34573619
     
    34853647
    34863648        case TVM_SETSCROLLTIME:
    3487 //                      FIXME (treeview, "Unimplemented msg TVM_SETSCROLLTIME\n");
    3488                 return 0;
     3649                return TREEVIEW_SetScrollTime (hwnd, (UINT)wParam);
    34893650
    34903651        case TVM_GETSCROLLTIME:
    3491 //                      FIXME (treeview, "Unimplemented msg TVM_GETSCROLLTIME\n");
    3492                 return 0;
     3652                return TREEVIEW_GetScrollTime (hwnd);
     3653
     3654        case TVM_GETITEMSTATE:
     3655                return TREEVIEW_GetItemState (hwnd,wParam, lParam);
     3656
     3657        case TVM_GETLINECOLOR:
     3658                return TREEVIEW_GetLineColor (hwnd,wParam, lParam);
     3659
     3660        case TVM_SETLINECOLOR:
     3661                return TREEVIEW_SetLineColor (hwnd,wParam, lParam);
    34933662
    34943663        case TVM_SETINSERTMARKCOLOR:
     
    35043673                return 0;
    35053674
    3506                 case WM_COMMAND:
    3507                          return TREEVIEW_Command (hwnd, wParam, lParam);
    3508 
    3509                 case WM_CREATE:
    3510                         return TREEVIEW_Create (hwnd, wParam, lParam);
    3511 
    3512                 case WM_DESTROY:
    3513                         return TREEVIEW_Destroy (hwnd);
    3514 
    3515 /*              case WM_ENABLE: */
    3516 
    3517                 case WM_ERASEBKGND:
    3518                         return TREEVIEW_EraseBackground (hwnd, wParam, lParam);
    3519 
    3520                 case WM_GETDLGCODE:
     3675        case WM_COMMAND:
     3676                return TREEVIEW_Command (hwnd, wParam, lParam);
     3677
     3678        case WM_CREATE:
     3679                return TREEVIEW_Create (hwnd, wParam, lParam);
     3680
     3681        case WM_DESTROY:
     3682                return TREEVIEW_Destroy (hwnd);
     3683
     3684/*      case WM_ENABLE: */
     3685
     3686        case WM_ERASEBKGND:
     3687                return TREEVIEW_EraseBackground (hwnd, wParam, lParam);
     3688
     3689        case WM_GETDLGCODE:
    35213690                return DLGC_WANTARROWS | DLGC_WANTCHARS;
    35223691
    3523                 case WM_PAINT:
     3692        case WM_PAINT:
    35243693                return TREEVIEW_Paint (hwnd, wParam, lParam);
    35253694
    3526                 case WM_GETFONT:
     3695        case WM_GETFONT:
    35273696                return TREEVIEW_GetFont (hwnd, wParam, lParam);
    35283697
    3529                 case WM_SETFONT:
     3698        case WM_SETFONT:
    35303699                return TREEVIEW_SetFont (hwnd, wParam, lParam);
    35313700
    3532                 case WM_KEYDOWN:
    3533                         return TREEVIEW_KeyDown (hwnd, wParam, lParam);
    3534 
    3535 
    3536                 case WM_SETFOCUS:
    3537                         return TREEVIEW_SetFocus (hwnd, wParam, lParam);
    3538 
    3539                 case WM_KILLFOCUS:
    3540                         return TREEVIEW_KillFocus (hwnd, wParam, lParam);
    3541 
    3542 
    3543                 case WM_LBUTTONDOWN:
    3544                         return TREEVIEW_LButtonDown (hwnd, wParam, lParam);
    3545 
    3546                 case WM_LBUTTONUP:
    3547                         return TREEVIEW_LButtonUp (hwnd, wParam, lParam);
    3548 
    3549                 case WM_LBUTTONDBLCLK:
    3550                         return TREEVIEW_LButtonDoubleClick (hwnd, wParam, lParam);
    3551 
    3552                 case WM_RBUTTONDOWN:
    3553                         return TREEVIEW_RButtonDown (hwnd, wParam, lParam);
    3554 
    3555                 case WM_RBUTTONUP:
    3556                         return TREEVIEW_RButtonUp (hwnd, wParam, lParam);
    3557 
    3558                 case WM_MOUSEMOVE:
    3559                         return TREEVIEW_MouseMove (hwnd, wParam, lParam);
    3560 
    3561 
    3562 /*              case WM_SYSCOLORCHANGE: */
    3563                 case WM_STYLECHANGED:
    3564                         return TREEVIEW_StyleChanged (hwnd, wParam, lParam);
    3565 
    3566 /*              case WM_SETREDRAW: */
    3567 
    3568                 case WM_TIMER:
    3569                         return TREEVIEW_HandleTimer (hwnd, wParam, lParam);
    3570 
    3571                 case WM_SIZE:
    3572                         return TREEVIEW_Size (hwnd, wParam,lParam);
    3573 
    3574                 case WM_HSCROLL:
    3575                         return TREEVIEW_HScroll (hwnd, wParam, lParam);
    3576                 case WM_VSCROLL:
    3577                         return TREEVIEW_VScroll (hwnd, wParam, lParam);
    3578 
    3579                 case WM_DRAWITEM:
    3580 //                      printf ("drawItem\n");
    3581                         return DefWindowProcA (hwnd, uMsg, wParam, lParam);
    3582 
    3583                 default:
    3584 //                if (uMsg >= WM_USER)
    3585 //              FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n",
     3701        case WM_KEYDOWN:
     3702                return TREEVIEW_KeyDown (hwnd, wParam, lParam);
     3703
     3704        case WM_SETFOCUS:
     3705                return TREEVIEW_SetFocus (hwnd, wParam, lParam);
     3706
     3707        case WM_KILLFOCUS:
     3708                return TREEVIEW_KillFocus (hwnd, wParam, lParam);
     3709
     3710        case WM_LBUTTONDOWN:
     3711                return TREEVIEW_LButtonDown (hwnd, wParam, lParam);
     3712
     3713        case WM_LBUTTONUP:
     3714                return TREEVIEW_LButtonUp (hwnd, wParam, lParam);
     3715
     3716        case WM_LBUTTONDBLCLK:
     3717                return TREEVIEW_LButtonDoubleClick (hwnd, wParam, lParam);
     3718
     3719        case WM_RBUTTONDOWN:
     3720                return TREEVIEW_RButtonDown (hwnd, wParam, lParam);
     3721
     3722        case WM_RBUTTONUP:
     3723                return TREEVIEW_RButtonUp (hwnd, wParam, lParam);
     3724
     3725        case WM_MOUSEMOVE:
     3726                return TREEVIEW_MouseMove (hwnd, wParam, lParam);
     3727
     3728        case WM_STYLECHANGED:
     3729                return TREEVIEW_StyleChanged (hwnd, wParam, lParam);
     3730
     3731/*      case WM_SYSCOLORCHANGE: */
     3732/*      case WM_SETREDRAW: */
     3733
     3734        case WM_TIMER:
     3735                return TREEVIEW_HandleTimer (hwnd, wParam, lParam);
     3736
     3737        case WM_SIZE:
     3738                return TREEVIEW_Size (hwnd, wParam,lParam);
     3739
     3740        case WM_HSCROLL:
     3741                return TREEVIEW_HScroll (hwnd, wParam, lParam);
     3742
     3743        case WM_VSCROLL:
     3744                return TREEVIEW_VScroll (hwnd, wParam, lParam);
     3745
     3746        case WM_DRAWITEM:
     3747//              printf ("drawItem\n");
     3748                return DefWindowProcA (hwnd, uMsg, wParam, lParam);
     3749
     3750        default:
     3751//              if (uMsg >= WM_USER)
     3752//                FIXME (treeview, "Unknown msg %04x wp=%08x lp=%08lx\n",
    35863753//                   uMsg, wParam, lParam);
    35873754            return DefWindowProcA (hwnd, uMsg, wParam, lParam);
  • TabularUnified trunk/src/comctl32/updown.c

    r295 r496  
    1 /* $Id: updown.c,v 1.6 1999-07-12 15:58:51 cbratschi Exp $ */
     1/* $Id: updown.c,v 1.7 1999-08-14 16:13:16 cbratschi Exp $ */
    22/*
    33 * Updown control
     
    88 *
    99 * TODO:
    10  *   - subclass the buddy window (in UPDOWN_SetBuddyHandle) to process the
    11  *     arrow keys
    1210 *   - I am not sure about the default values for the Min, Max, Pos
    1311 *     (in the UPDOWN_INFO the fields: MinVal, MaxVal, CurVal)
     
    5654#define DEFAULT_ADDTOP    0  /* amount to extend above the buddy window */
    5755#define DEFAULT_ADDBOT    0  /* amount to extend below the buddy window */
     56#define DEFAULT_BUDDYBORDER  2  /* Width/height of the buddy border */
    5857
    5958
     
    6766#define TIMERID1         1
    6867#define TIMERID2         2
     68#define BUDDY_UPDOWN_HWND        "buddyUpDownHWND"
     69#define BUDDY_SUPERCLASS_WNDPROC "buddySupperClassWndProc"
    6970
    7071static int accelIndex = -1;
     
    7778#define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongA(hwnd,0))
    7879
     80static LRESULT CALLBACK
     81UPDOWN_Buddy_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
    7982
    8083/***********************************************************************
     
    119122
    120123/***********************************************************************
     124 * UPDOWN_HasBuddyBorder [Internal]
     125 *
     126 * When we have a buddy set and that we are aligned on our buddy, we
     127 * want to draw a sunken edge to make like we are part of that control.
     128 */
     129static BOOL UPDOWN_HasBuddyBorder(HWND hwnd)
     130{
     131  UPDOWN_INFO* infoPtr = UPDOWN_GetInfoPtr (hwnd);
     132  DWORD        dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     133
     134  return  ( ((dwStyle & (UDS_ALIGNLEFT | UDS_ALIGNRIGHT)) != 0) &&
     135            (SendMessageA(hwnd, UDM_GETBUDDY, 0, 0) != 0) &&
     136            (lstrcmpiA(infoPtr->szBuddyClass, "EDIT") == 0 ) );
     137}
     138
     139/***********************************************************************
    121140 *           UPDOWN_GetArrowRect
    122141 * wndPtr   - pointer to the up-down wnd
     
    128147static void UPDOWN_GetArrowRect (HWND hwnd, RECT *rect, BOOL incr)
    129148{
    130   int len; /* will hold the width or height */
     149  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     150  int   len; /* will hold the width or height */
    131151
    132152  GetClientRect (hwnd, rect);
    133153
    134   if (GetWindowLongA(hwnd, GWL_STYLE) & UDS_HORZ)
     154  /*
     155   * Make sure we calculate the rectangle to fit even if we draw the
     156   * border.
     157   */
     158  if (UPDOWN_HasBuddyBorder(hwnd))
    135159  {
    136     len = rect->right-rect->left; /* compute the width */
    137     if (incr) rect->left = len/2+1;
    138     else rect->right = len/2;
    139   } else
    140   {
    141     len = rect->bottom-rect->top; /* compute the height */
    142     if (incr) rect->bottom = len/2;
    143     else rect->top = len/2+1;
     160    if (dwStyle & UDS_ALIGNLEFT)
     161      rect->left+=DEFAULT_BUDDYBORDER;
     162    else
     163      rect->right-=DEFAULT_BUDDYBORDER;
     164
     165    InflateRect(rect, 0, -DEFAULT_BUDDYBORDER);
     166  }
     167
     168  /*
     169   * We're calculating the midpoint to figure-out where the
     170   * separation between the buttons will lay. We make sure that we
     171   * round the uneven numbers by adding 1.
     172   */
     173  if (dwStyle & UDS_HORZ) {
     174    len = rect->right - rect->left + 1; /* compute the width */
     175    if (incr)
     176      rect->left = rect->left + len/2;
     177    else
     178      rect->right =  rect->left + len/2;
     179  }
     180  else {
     181    len = rect->bottom - rect->top + 1; /* compute the height */
     182    if (incr)
     183      rect->bottom =  rect->top + len/2;
     184    else
     185      rect->top =  rect->top + len/2;
    144186  }
    145187}
     
    277319
    278320/***********************************************************************
     321 * UPDOWN_DrawBuddyBorder [Internal]
     322 *
     323 * When we have a buddy set and that we are aligned on our buddy, we
     324 * want to draw a sunken edge to make like we are part of that control.
     325 */
     326static void UPDOWN_DrawBuddyBorder (HWND hwnd, HDC hdc)
     327{
     328  DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     329  RECT  clientRect;
     330
     331  GetClientRect(hwnd, &clientRect);
     332
     333  if (dwStyle & UDS_ALIGNLEFT)
     334    DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_BOTTOM | BF_LEFT | BF_TOP);
     335  else
     336    DrawEdge(hdc, &clientRect, EDGE_SUNKEN, BF_BOTTOM | BF_RIGHT | BF_TOP);
     337}
     338
     339/***********************************************************************
    279340 * UPDOWN_Draw [Internal]
    280341 *
     
    287348  BOOL prssed;
    288349  RECT rect;
     350
     351  /*
     352   * Draw the common border between ourselves and our buddy.
     353   */
     354  if (UPDOWN_HasBuddyBorder(hwnd))
     355    UPDOWN_DrawBuddyBorder(hwnd, hdc);
    289356
    290357  /* Draw the incr button */
     
    332399 * Calls UPDOWN_Draw.
    333400 */
    334 static void UPDOWN_Paint (HWND hwnd)
     401static void UPDOWN_Paint (HWND hwnd, HDC passedDC)
    335402{
    336403    PAINTSTRUCT ps;
    337     HDC hdc;
    338 
    339     hdc = BeginPaint (hwnd, &ps);
     404    HDC         hdc = passedDC;
     405
     406    if (passedDC == 0)
     407      hdc = BeginPaint (hwnd, &ps);
     408
    340409    UPDOWN_Draw (hwnd, hdc);
    341     EndPaint (hwnd, &ps);
     410
     411    if (passedDC == 0)
     412      EndPaint (hwnd, &ps);
    342413}
    343414
    344415/***********************************************************************
    345416 *           UPDOWN_SetBuddyHandle
     417 * CB: UPDOWN_SetBuddy == message handler
    346418 * Tests if 'hwndBud' is a valid window handle. If not, returns FALSE.
    347419 * Else, sets it as a new Buddy.
     
    354426static BOOL UPDOWN_SetBuddyHandle (HWND hwnd, HWND hwndBud)
    355427{
    356   UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd);
    357   DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
    358   RECT budRect; /* new coord for the buddy */
    359   int x;          /* new x position and width for the up-down */
    360 
    361   *infoPtr->szBuddyClass = '\0';
    362 
    363   /* Is is a valid bud? */
     428  UPDOWN_INFO* infoPtr = UPDOWN_GetInfoPtr (hwnd);
     429  DWORD        dwStyle = GetWindowLongA (hwnd, GWL_STYLE);
     430  RECT         budRect;  /* new coord for the buddy */
     431  int          x,width;  /* new x position and width for the up-down */
     432       
     433  /* Is it a valid bud? */
    364434  if(!IsWindow(hwndBud))
    365435    return FALSE;
    366436
    367   /* Store buddy wundow handle */
     437  /* there is already a body assigned */
     438  if ( infoPtr->Buddy )
     439    RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
     440
     441  /* Store buddy window handle */
    368442  infoPtr->Buddy = hwndBud;
    369443
     444  /* keep upDown ctrl hwnd in a buddy property */
     445  SetPropA( hwndBud, BUDDY_UPDOWN_HWND, hwnd);
     446
    370447  /* Store buddy window clas name */
    371   GetClassNameA (hwndBud, infoPtr->szBuddyClass, 40);
     448  memset(infoPtr->szBuddyClass, 0, UPDOWN_BUDDYCLASSNAMELEN);
     449  GetClassNameA (hwndBud, infoPtr->szBuddyClass, UPDOWN_BUDDYCLASSNAMELEN-1);
    372450
    373451  if(dwStyle & UDS_ARROWKEYS){
    374 //    FIXME(updown, "we need to subclass the buddy to process the arrow keys.\n");
     452    /* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property
     453       when we reset the upDown ctrl buddy to another buddy because it is not
     454       good to break the window proc chain. */
     455
     456    /* keep buddy supperclass wndproc in prop instead of in ptr struct
     457       to prevent accessing freed memory */
     458    SetPropA(
     459      hwndBud,
     460      BUDDY_SUPERCLASS_WNDPROC,
     461      (LONG)GetWindowLongA(hwndBud, GWL_WNDPROC) );
     462
     463    /* Assign the buddy wndproc to local wndproc in order to override
     464       keyboard's up and down arrow */
     465    SetWindowLongA(
     466      hwndBud,
     467      GWL_WNDPROC,
     468      (LONG)UPDOWN_Buddy_SubclassProc);
    375469  }
    376470
     
    379473    return TRUE;
    380474
    381   infoPtr->Buddy = hwndBud;
    382 
    383475  /* Get the rect of the buddy relative to its parent */
    384476  GetWindowRect(infoPtr->Buddy, &budRect);
    385477  MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy),
    386                   (POINT *)(&budRect.left), 2);
     478                  (POINT *)(&budRect.left), 2);
    387479
    388480  /* now do the positioning */
     
    398490  /* first adjust the buddy to accomodate the up/down */
    399491  SetWindowPos(infoPtr->Buddy, 0, budRect.left, budRect.top,
    400                budRect.right  - budRect.left, budRect.bottom - budRect.top,
    401                SWP_NOACTIVATE|SWP_NOZORDER);
     492               budRect.right  - budRect.left, budRect.bottom - budRect.top,
     493               SWP_NOACTIVATE|SWP_NOZORDER);
    402494
    403495  /* now position the up/down */
    404496  /* Since the UDS_ALIGN* flags were used, */
    405497  /* we will pick the position and size of the window. */
    406 
    407   SetWindowPos (hwnd, 0, x, budRect.top-DEFAULT_ADDTOP,DEFAULT_WIDTH,
    408                  (budRect.bottom-budRect.top)+DEFAULT_ADDTOP+DEFAULT_ADDBOT,
    409                  SWP_NOACTIVATE|SWP_NOZORDER);
     498  width = DEFAULT_WIDTH;
     499
     500  /*
     501   * If the updown has a buddy border, it has to overlap with the buddy
     502   * to look as if it is integrated with the buddy control.
     503   * We nudge the control or change it size to overlap.
     504   */
     505  if (UPDOWN_HasBuddyBorder(hwnd))
     506  {
     507    if(dwStyle & UDS_ALIGNRIGHT)
     508      x-=DEFAULT_BUDDYBORDER;
     509    else
     510      width+=DEFAULT_BUDDYBORDER;
     511  }
     512
     513  SetWindowPos (hwnd, infoPtr->Buddy,
     514                x, budRect.top-DEFAULT_ADDTOP,
     515                width, (budRect.bottom-budRect.top)+DEFAULT_ADDTOP+DEFAULT_ADDBOT,
     516                SWP_NOACTIVATE);
    410517
    411518  return TRUE;
    412 }
     519}       
    413520
    414521/***********************************************************************
     
    640747  if(infoPtr->AccelVect) COMCTL32_Free(infoPtr->AccelVect);
    641748
     749  if ( IsWindow(infoPtr->Buddy) ) /* Cleanup */
     750        RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND);
     751
    642752  COMCTL32_Free (infoPtr);
    643753
     
    652762
    653763  if (dwStyle & WS_DISABLED) UPDOWN_CancelMode(hwnd);
    654   UPDOWN_Paint(hwnd);
     764
     765  UPDOWN_Refresh(hwnd);
    655766
    656767  return 0;
     
    811922  if (lParam) UNKNOWN_PARAM(UDM_SETBUDDY,wParam,lParam);
    812923  temp = infoPtr->Buddy;
    813   infoPtr->Buddy = wParam;
    814924  UPDOWN_SetBuddyHandle(hwnd,wParam);
    815925//      TRACE(updown, "UpDown Ctrl new buddy(%04x), hwnd=%04x\n",
     
    9011011 *           UpDownWndProc
    9021012 */
    903 LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam,
     1013static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam,
    9041014                                LPARAM lParam)
    9051015{
     
    9421052
    9431053    case WM_PAINT:
    944       UPDOWN_Paint(hwnd);
     1054      UPDOWN_Paint(hwnd,(HDC)wParam);
    9451055      break;
    9461056
     
    9911101}
    9921102
     1103/***********************************************************************
     1104 * UPDOWN_Buddy_SubclassProc used to handle messages sent to the buddy
     1105 *                           control.
     1106 */
     1107LRESULT CALLBACK
     1108UPDOWN_Buddy_SubclassProc (
     1109  HWND   hwnd,
     1110  UINT   uMsg,
     1111  WPARAM wParam,
     1112  LPARAM lParam)
     1113{
     1114  LONG superClassWndProc = GetPropA(hwnd, BUDDY_SUPERCLASS_WNDPROC);
     1115  //TRACE("hwnd=%04x, wndProc=%d, uMsg=%04x, wParam=%d, lParam=%d\n",
     1116  // hwnd, (INT)superClassWndProc, uMsg, wParam, (UINT)lParam);
     1117
     1118  switch (uMsg)
     1119  {
     1120    case WM_KEYDOWN:
     1121    {
     1122      if ( ((int)wParam == VK_UP ) || ((int)wParam == VK_DOWN ) )
     1123      {
     1124        HWND upDownHwnd      = GetPropA(hwnd, BUDDY_UPDOWN_HWND);
     1125        UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr(upDownHwnd);
     1126
     1127        if (!lstrcmpA (infoPtr->szBuddyClass, "ListBox"))
     1128        {
     1129          /* if the buddy is a list window, we must update curr index */
     1130          INT oldVal = SendMessageA(hwnd, LB_GETCURSEL, 0, 0);
     1131          SendMessageA(hwnd, LB_SETCURSEL, oldVal+1, 0);
     1132        }
     1133        else
     1134        {
     1135          UPDOWN_GetBuddyInt(upDownHwnd);
     1136          UPDOWN_DoAction(upDownHwnd, 1, wParam==VK_UP);
     1137        }
     1138
     1139        break;
     1140      }
     1141      /* else Fall Through */
     1142    }
     1143
     1144    default:
     1145      return CallWindowProcA( (WNDPROC)superClassWndProc, hwnd, uMsg, wParam, lParam);
     1146  }
     1147
     1148  return 0;
     1149}
    9931150
    9941151/***********************************************************************
Note: See TracChangeset for help on using the changeset viewer.