From 88f1bf6c5c4ddad3ab6a72ef887fbe2ca4194eae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Sun, 5 Dec 2004 23:09:27 +0000 Subject: [PATCH] Sync to Wine-20041201 Ulrich Czekalla - Prevent the animation thread from waiting on itself when it stops. Robert Shearman - Remove unnecessary WNDPROC casts. Alexandre Julliard - Avoid using the MAKEPOINTS macro, it's broken on big endian. - Use correct type instead of void* in item linked list. Dimitrie O. Paun - Minor cleanups. - Implement proper GWL_STYLE handling, proper reaction to style changes. - Merge {{Inc,Dec}rement,Reset{Up,Down}}Field into one method. Fix a bunch of bugs in the process. Implement DTM_[GS]ETMCFONT. Indentation fixes, cleanups. - Use typesafe signature where possible. - Use Unicode functions where possible. - Send notification messages in the format dictated by infoPtr->notifyFormat. - Audit the month calendar. - Rename STATUSWINDOWINFO to STATUS_INFO, for consistency with other controls. Fix some prototypes. Always pass infoPtr around. - Use only Unicode functions, it makes it easier to see we are fully Unicode compliant. Robert Shearman - Always remove WS_BORDER style from ComboBoxEx control. - Correct the date of the completeness audit. - Store the new style before redrawing and repositioning the control. - Set cache bitmap dimensions correctly when a 0x0 image list is used. - Optimize WM_STYLECHANGED handler to only redraw when a CCS_* style is changed, like native. - bNtfUnicode is a dup' of bUnicode so remove it and fix the few places where it was used. - Remove a load of useless NULL infoPtr checks. - Hardcode the default padding like native instead of using a wacky formula. - Replace some tabs with spaces and remove NMHDR casts. - Implement TBN_RESTORE notification. - Don't fill in any more information than native does for notifications. - Store hit code in a signed integer so that we can see whether it is less than zero. - Draw with ILD_TRANSPARENT instead of ILD_NORMAL to draw bitmaps from the native shell image list properly (reported by Thorsten Kani). - Rewrite TOOLBAR_NotifyFormat to avoid side-effects. James Hawkins - Fixed a few memory leaks. Zach Gorman - Add the DT_NOPREFIX flag when calling DrawText() for single-line listview controls. Dmitry Timoshkov - Pass infoPtr around in month calendar control. - Add support for WM_SETFONT and WM_GETFONT messages. - Dimensions of month calendar control should not depend on the client window size. - Convert NativeFont control to unicode, use hbrBackground as in native. - Do not retrieve infoPtr twice in ToolbarWindowProc entry. - do not move updown control and buddy if an alignment was not requested - in UDM_SETACCEL handler do not forget to update number of accelerators - update arrows info in WM_LBUTTONDOWN as well as in WM_MOUSEMOVE - use accelerators in WM_LBUTTONDOWN handler Uwe Bonnes - Monthcal_SetRange: Set proper value for min date. Thorsten Kani - Use address of tab_item.extra when building drawitemstruct. - Don't add extra OFFSET_X/Y to the calculation of rcBitmap.top/left, just use GetSystemMetrics. Huw Davies - The default font for the treeview should be the icon title font. svn path=/trunk/; revision=11952 --- reactos/lib/comctl32/animate.c | 29 +- reactos/lib/comctl32/comboex.c | 27 +- reactos/lib/comctl32/datetime.c | 1629 ++++++++++--------------- reactos/lib/comctl32/flatsb.c | 2 +- reactos/lib/comctl32/header.c | 2 +- reactos/lib/comctl32/hotkey.c | 101 +- reactos/lib/comctl32/imagelist.c | 1 + reactos/lib/comctl32/ipaddress.c | 20 +- reactos/lib/comctl32/listview.c | 157 +-- reactos/lib/comctl32/monthcal.c | 591 +++++---- reactos/lib/comctl32/nativefont.c | 58 +- reactos/lib/comctl32/progress.c | 6 +- reactos/lib/comctl32/rebar.c | 49 +- reactos/lib/comctl32/status.c | 95 +- reactos/lib/comctl32/syslink.c | 8 +- reactos/lib/comctl32/tab.c | 3 +- reactos/lib/comctl32/toolbar.c | 461 ++++--- reactos/lib/comctl32/tooltips.c | 46 +- reactos/lib/comctl32/trackbar.c | 24 +- reactos/lib/comctl32/treeview.c | 18 +- reactos/lib/comctl32/updown.c | 81 +- reactos/lib/comctl32/winehq2ros.patch | 103 +- reactos/w32api/include/commctrl.h | 20 +- 23 files changed, 1676 insertions(+), 1855 deletions(-) diff --git a/reactos/lib/comctl32/animate.c b/reactos/lib/comctl32/animate.c index 71f8b424358..374b3b1111c 100644 --- a/reactos/lib/comctl32/animate.c +++ b/reactos/lib/comctl32/animate.c @@ -73,6 +73,7 @@ typedef struct CRITICAL_SECTION cs; HANDLE hStopEvent; HANDLE hThread; + DWORD threadId; UINT uTimer; /* data for playing the file */ int nFromFrame; @@ -149,14 +150,20 @@ static LRESULT ANIMATE_DoStop(ANIMATE_INFO *infoPtr) HANDLE handle = infoPtr->hThread; TRACE("stopping animation thread\n"); - SetEvent( infoPtr->hStopEvent ); - LeaveCriticalSection(&infoPtr->cs); /* leave it a chance to run */ - WaitForSingleObject( handle, INFINITE ); - TRACE("animation thread stopped\n"); - EnterCriticalSection(&infoPtr->cs); - CloseHandle( infoPtr->hThread ); - CloseHandle( infoPtr->hStopEvent ); infoPtr->hThread = 0; + SetEvent( infoPtr->hStopEvent ); + + if (infoPtr->threadId != GetCurrentThreadId()) + { + LeaveCriticalSection(&infoPtr->cs); /* leave it a chance to run */ + WaitForSingleObject( handle, INFINITE ); + TRACE("animation thread stopped\n"); + EnterCriticalSection(&infoPtr->cs); + } + + CloseHandle( handle ); + CloseHandle( infoPtr->hStopEvent ); + infoPtr->hStopEvent = 0; } if (infoPtr->uTimer) { KillTimer(infoPtr->hwndSelf, infoPtr->uTimer); @@ -399,7 +406,7 @@ static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_) LeaveCriticalSection(&infoPtr->cs); /* time is in microseconds, we should convert it to milliseconds */ - if (WaitForSingleObject( event, (timeout+500)/1000) == WAIT_OBJECT_0) + if ((event == 0) || WaitForSingleObject( event, (timeout+500)/1000) == WAIT_OBJECT_0) break; } return TRUE; @@ -439,8 +446,6 @@ static LRESULT ANIMATE_Play(HWND hWnd, WPARAM wParam, LPARAM lParam) /* create a timer to display AVI */ infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL); } else { - DWORD threadID; - if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) { infoPtr->hbrushBG = (HBRUSH)SendMessageA(infoPtr->hwndNotify, @@ -449,7 +454,7 @@ static LRESULT ANIMATE_Play(HWND hWnd, WPARAM wParam, LPARAM lParam) TRACE("Using an animation thread\n"); infoPtr->hStopEvent = CreateEventW( NULL, TRUE, FALSE, NULL ); - infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr, 0, &threadID); + infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr, 0, &infoPtr->threadId); if(!infoPtr->hThread) { ERR("Could not create animation thread!\n"); @@ -950,7 +955,7 @@ void ANIMATE_Register(void) ZeroMemory(&wndClass, sizeof(WNDCLASSA)); wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; - wndClass.lpfnWndProc = (WNDPROC)ANIMATE_WindowProc; + wndClass.lpfnWndProc = ANIMATE_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(ANIMATE_INFO *); wndClass.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); diff --git a/reactos/lib/comctl32/comboex.c b/reactos/lib/comctl32/comboex.c index 174c110c700..94b5a82679f 100644 --- a/reactos/lib/comctl32/comboex.c +++ b/reactos/lib/comctl32/comboex.c @@ -45,9 +45,9 @@ WINE_DEFAULT_DEBUG_CHANNEL(comboex); /* Item structure */ -typedef struct +typedef struct _CBE_ITEMDATA { - VOID *next; + struct _CBE_ITEMDATA *next; UINT mask; LPWSTR pszText; LPWSTR pszTemp; @@ -126,10 +126,8 @@ typedef struct /* Things common to the entire DLL */ -static LRESULT WINAPI -COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -static LRESULT WINAPI -COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +static LRESULT WINAPI COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); +static LRESULT WINAPI COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr); typedef INT (WINAPI *cmp_func_t)(LPCWSTR, LPCWSTR); @@ -458,7 +456,7 @@ static CBE_ITEMDATA * COMBOEX_FindItem(COMBOEX_INFO *infoPtr, INT index) /* find the item in the list */ while (item && (i > index)) { - item = (CBE_ITEMDATA *)item->next; + item = item->next; i--; } if (!item || (i != index)) { @@ -579,7 +577,7 @@ static INT COMBOEX_InsertItemW (COMBOEX_INFO *infoPtr, COMBOBOXEXITEMW *cit) CBE_ITEMDATA *moving = infoPtr->items; while ((i > index) && moving) { - moving = (CBE_ITEMDATA *)moving->next; + moving = moving->next; i--; } if (!moving) { @@ -1252,7 +1250,7 @@ static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT *dis) /* find the prior item in the list */ while (item->next && (i > dis->itemID)) { - item = (CBE_ITEMDATA *)item->next; + item = item->next; i--; } if (!item->next || (i != dis->itemID)) { @@ -1260,7 +1258,7 @@ static BOOL COMBOEX_WM_DeleteItem (COMBOEX_INFO *infoPtr, DELETEITEMSTRUCT *dis) return FALSE; } olditem = item->next; - item->next = (CBE_ITEMDATA *)((CBE_ITEMDATA *)item->next)->next; + item->next = item->next->next; } infoPtr->nb_items--; @@ -1529,7 +1527,7 @@ static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr) item = infoPtr->items; while (item) { - next = (CBE_ITEMDATA *)item->next; + next = item->next; COMBOEX_FreeText (item); Free (item); item = next; @@ -1570,7 +1568,7 @@ static LRESULT COMBOEX_NCCreate (HWND hwnd) DWORD oldstyle, newstyle; oldstyle = (DWORD)GetWindowLongW (hwnd, GWL_STYLE); - newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL); + newstyle = oldstyle & ~(WS_VSCROLL | WS_HSCROLL | WS_BORDER); if (newstyle != oldstyle) { TRACE("req style %08lx, reseting style %08lx\n", oldstyle, newstyle); @@ -1912,7 +1910,8 @@ COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) rect.bottom = rect.top + SendMessageW(infoPtr->hwndSelf, CB_GETITEMHEIGHT, -1, 0); rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL); - POINTSTOPOINT(pt, MAKEPOINTS(lParam)); + pt.x = (short)LOWORD(lParam); + pt.y = (short)HIWORD(lParam); if (PtInRect(&rect, pt)) return CallWindowProcW (infoPtr->prevComboWndProc, hwnd, uMsg, wParam, lParam); @@ -2254,7 +2253,7 @@ void COMBOEX_Register (void) ZeroMemory (&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS; - wndClass.lpfnWndProc = (WNDPROC)COMBOEX_WindowProc; + wndClass.lpfnWndProc = COMBOEX_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(COMBOEX_INFO *); wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW); diff --git a/reactos/lib/comctl32/datetime.c b/reactos/lib/comctl32/datetime.c index 5bf8ddf2824..9a0826c384b 100644 --- a/reactos/lib/comctl32/datetime.c +++ b/reactos/lib/comctl32/datetime.c @@ -19,16 +19,31 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * NOTE + * + * This code was audited for completeness against the documented features + * of Comctl32.dll version 6.0 on Oct. 20, 2004, by Dimitrie O. Paun. + * + * Unless otherwise noted, we believe this code to be complete, as per + * the specification mentioned above. + * If you discover missing features, or bugs, please note them below. + * * TODO: - * - All messages. - * - All notifications. - * + * -- DTS_APPCANPARSE + * -- DTS_SHORTDATECENTURYFORMAT + * -- DTN_CLOSEUP + * -- DTN_FORMAT + * -- DTN_FORMATQUERY + * -- DTN_USERSTRING + * -- DTN_WMKEYDOWN + * -- FORMATCALLBACK */ #include #include #include #include +#include #include "windef.h" #include "winbase.h" @@ -38,32 +53,35 @@ #include "commctrl.h" #include "comctl32.h" #include "wine/debug.h" +#include "wine/unicode.h" WINE_DEFAULT_DEBUG_CHANNEL(datetime); typedef struct { - HWND hMonthCal; - HWND hwndNotify; - HWND hUpdown; - SYSTEMTIME date; - BOOL dateValid; - HWND hwndCheckbut; - RECT rcClient; /* rect around the edge of the window */ - RECT rcDraw; /* rect inside of the border */ - RECT checkbox; /* checkbox allowing the control to be enabled/disabled */ - RECT calbutton; /* button that toggles the dropdown of the monthcal control */ - BOOL bCalDepressed; /* TRUE = cal button is depressed */ - int select; - HFONT hFont; - int nrFieldsAllocated; - int nrFields; - int haveFocus; - int *fieldspec; - RECT *fieldRect; - int *buflen; - char textbuf[256]; - POINT monthcal_pos; + HWND hwndSelf; + HWND hMonthCal; + HWND hwndNotify; + HWND hUpdown; + DWORD dwStyle; + SYSTEMTIME date; + BOOL dateValid; + HWND hwndCheckbut; + RECT rcClient; /* rect around the edge of the window */ + RECT rcDraw; /* rect inside of the border */ + RECT checkbox; /* checkbox allowing the control to be enabled/disabled */ + RECT calbutton; /* button that toggles the dropdown of the monthcal control */ + BOOL bCalDepressed; /* TRUE = cal button is depressed */ + int select; + HFONT hFont; + int nrFieldsAllocated; + int nrFields; + int haveFocus; + int *fieldspec; + RECT *fieldRect; + int *buflen; + WCHAR textbuf[256]; + POINT monthcal_pos; } DATETIME_INFO, *LPDATETIME_INFO; /* in monthcal.c */ @@ -110,1174 +128,812 @@ extern int MONTHCAL_MonthLength(int month, int year); #define DTHT_MCPOPUP 0x300 /* & DTHT_DATEFIELD 0 when DATETIME_KeyDown */ #define DTHT_GOTFOCUS 0x400 /* tests for date-fields */ -#define DATETIME_GetInfoPtr(hwnd) ((DATETIME_INFO *)GetWindowLongPtrW (hwnd, 0)) - -static BOOL DATETIME_SendSimpleNotify (HWND hwnd, UINT code); -static BOOL DATETIME_SendDateTimeChangeNotify (HWND hwnd); +static BOOL DATETIME_SendSimpleNotify (DATETIME_INFO *infoPtr, UINT code); +static BOOL DATETIME_SendDateTimeChangeNotify (DATETIME_INFO *infoPtr); extern void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to); -static const char *allowedformatchars = {"dhHmMstyX'"}; +static const WCHAR allowedformatchars[] = {'d', 'h', 'H', 'm', 'M', 's', 't', 'y', 'X', '\'', 0}; static const int maxrepetition [] = {4,2,2,2,4,2,2,4,-1,-1}; -static LRESULT -DATETIME_GetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam ) +static DWORD +DATETIME_GetSystemTime (DATETIME_INFO *infoPtr, SYSTEMTIME *lprgSysTimeArray) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); - SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam; + if (!lprgSysTimeArray) return GDT_NONE; - TRACE("%04x %08lx\n",wParam,lParam); - if (!lParam) return GDT_NONE; - - if ((dwStyle & DTS_SHOWNONE) && - (SendMessageA (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0) == BST_UNCHECKED)) + if ((infoPtr->dwStyle & DTS_SHOWNONE) && + (SendMessageW (infoPtr->hwndCheckbut, BM_GETCHECK, 0, 0) == BST_UNCHECKED)) return GDT_NONE; - MONTHCAL_CopyTime (&infoPtr->date, lprgSysTimeArray); + MONTHCAL_CopyTime (&infoPtr->date, lprgSysTimeArray); - return GDT_VALID; + return GDT_VALID; } -static LRESULT -DATETIME_SetSystemTime (HWND hwnd, WPARAM wParam, LPARAM lParam ) +static BOOL +DATETIME_SetSystemTime (DATETIME_INFO *infoPtr, DWORD flag, SYSTEMTIME *lprgSysTimeArray) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *) lParam; + if (!lprgSysTimeArray) return 0; - TRACE("%p %04x %08lx\n",hwnd, wParam, lParam); - if (!lParam) return 0; + TRACE("%04d/%02d/%02d %02d:%02d:%02d\n", + lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay, + lprgSysTimeArray->wHour, lprgSysTimeArray->wMinute, lprgSysTimeArray->wSecond); - TRACE("%04d/%02d/%02d %02d:%02d:%02d\n", - lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay, - lprgSysTimeArray->wHour, lprgSysTimeArray->wMinute, lprgSysTimeArray->wSecond); + if (flag == GDT_VALID) { + infoPtr->dateValid = TRUE; + MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date); + SendMessageW (infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date)); + SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0); + } else if (flag == GDT_NONE) { + infoPtr->dateValid = FALSE; + SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0); + } - if (wParam==GDT_VALID) { - infoPtr->dateValid = TRUE; - MONTHCAL_CopyTime (lprgSysTimeArray, &infoPtr->date); - SendMessageA(infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date)); - SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0); - } else if (wParam==GDT_NONE) { - infoPtr->dateValid = FALSE; - SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_UNCHECKED, 0); - } - InvalidateRect(hwnd, NULL, TRUE); - return 1; + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); + return TRUE; } -static LRESULT -DATETIME_GetRange (HWND hwnd, LPARAM lParam ) -{ - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - LRESULT ret; - - TRACE("%08lx\n", lParam); - ret = SendMessageA (infoPtr->hMonthCal, MCM_GETRANGE, 0, lParam); - if (!ret) ret = 1; /* bug emulation... */ - return ret; -} - -static LRESULT -DATETIME_SetRange (HWND hwnd, WPARAM wParam, LPARAM lParam ) -{ - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - - TRACE("%04x %08lx\n",wParam,lParam); - - return SendMessageA (infoPtr->hMonthCal, MCM_SETRANGE, wParam, lParam); -} - -static LRESULT -DATETIME_GetMonthCalColor (HWND hwnd, WPARAM wParam) -{ - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - - TRACE("%04x\n",wParam); - return SendMessageA (infoPtr->hMonthCal, MCM_GETCOLOR, wParam, 0); -} - - -static LRESULT -DATETIME_SetMonthCalColor (HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - - TRACE("%04x %08lx\n",wParam,lParam); - return SendMessageA (infoPtr->hMonthCal, MCM_SETCOLOR, wParam, lParam); -} - - -/* FIXME: need to get way to force font into monthcal structure */ -static LRESULT -DATETIME_GetMonthCal (HWND hwnd) -{ - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - - TRACE("\n"); - return (LRESULT)infoPtr->hMonthCal; -} - - - -/* FIXME: need to get way to force font into monthcal structure */ - -static LRESULT -DATETIME_GetMonthCalFont (HWND hwnd) -{ - - TRACE("\n"); - return 0; -} - - -static LRESULT -DATETIME_SetMonthCalFont (HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - - TRACE("%04x %08lx\n",wParam,lParam); - return 0; -} - - -/* - Split up a formattxt in actions. - See ms documentation for the meaning of the letter codes/'specifiers'. - - Notes: - *'dddddd' is handled as 'dddd' plus 'dd'. - *unrecognized formats are strings (here given the type DT_STRING; - start of the string is encoded in lower bits of DT_STRING. - Therefore, 'string' ends finally up as 'tring'. - +/*** + * Split up a formattxt in actions. + * See ms documentation for the meaning of the letter codes/'specifiers'. + * + * Notes: + * *'dddddd' is handled as 'dddd' plus 'dd'. + * *unrecognized formats are strings (here given the type DT_STRING; + * start of the string is encoded in lower bits of DT_STRING. + * Therefore, 'string' ends finally up as 'tring'. + * */ - - static void -DATETIME_UseFormat (DATETIME_INFO *infoPtr, const char *formattxt) +DATETIME_UseFormat (DATETIME_INFO *infoPtr, LPCWSTR formattxt) { - unsigned int i; - int j,k,len; - int *nrFields=& infoPtr->nrFields; + unsigned int i; + int j, k, len; + int *nrFields = &infoPtr->nrFields; - TRACE ("%s\n",formattxt); + *nrFields = 0; + infoPtr->fieldspec[*nrFields] = 0; + len = strlenW(allowedformatchars); + k = 0; - - *nrFields=0; - infoPtr->fieldspec[*nrFields]=0; - len=strlen(allowedformatchars); - k=0; - - for (i=0; formattxt[i]; i++) { - TRACE ("\n%d %c:",i, formattxt[i]); - for (j=0; jfieldspec[*nrFields]); - if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) { - infoPtr->fieldspec[*nrFields]=(j<<4) +1; - break; - } - if (infoPtr->fieldspec[*nrFields]>>4!=j) { - (*nrFields)++; - infoPtr->fieldspec[*nrFields]=(j<<4) +1; - break; - } - if ((infoPtr->fieldspec[*nrFields] & 0x0f)==maxrepetition[j]) { - (*nrFields)++; - infoPtr->fieldspec[*nrFields]=(j<<4) +1; - break; - } - infoPtr->fieldspec[*nrFields]++; - break; - } /* if allowedformatchar */ - } /* for j */ - - - /* char is not a specifier: handle char like a string */ - if (j==len) { + for (i = 0; formattxt[i]; i++) { + TRACE ("\n%d %c:", i, formattxt[i]); + for (j = 0; j < len; j++) { + if (allowedformatchars[j]==formattxt[i]) { + TRACE ("%c[%d,%x]", allowedformatchars[j], *nrFields, infoPtr->fieldspec[*nrFields]); if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) { - infoPtr->fieldspec[*nrFields]=DT_STRING+k; - infoPtr->buflen[*nrFields]=0; - } else - if ((infoPtr->fieldspec[*nrFields] & DT_STRING)!=DT_STRING) { - (*nrFields)++; - infoPtr->fieldspec[*nrFields]=DT_STRING+k; - infoPtr->buflen[*nrFields]=0; + infoPtr->fieldspec[*nrFields] = (j<<4) + 1; + break; } - infoPtr->textbuf[k]=formattxt[i]; - k++; - infoPtr->buflen[*nrFields]++; + if (infoPtr->fieldspec[*nrFields] >> 4 != j) { + (*nrFields)++; + infoPtr->fieldspec[*nrFields] = (j<<4) + 1; + break; + } + if ((infoPtr->fieldspec[*nrFields] & 0x0f) == maxrepetition[j]) { + (*nrFields)++; + infoPtr->fieldspec[*nrFields] = (j<<4) + 1; + break; + } + infoPtr->fieldspec[*nrFields]++; + break; + } /* if allowedformatchar */ + } /* for j */ + + /* char is not a specifier: handle char like a string */ + if (j == len) { + if ((*nrFields==0) && (infoPtr->fieldspec[*nrFields]==0)) { + infoPtr->fieldspec[*nrFields] = DT_STRING + k; + infoPtr->buflen[*nrFields] = 0; + } else if ((infoPtr->fieldspec[*nrFields] & DT_STRING) != DT_STRING) { + (*nrFields)++; + infoPtr->fieldspec[*nrFields] = DT_STRING + k; + infoPtr->buflen[*nrFields] = 0; + } + infoPtr->textbuf[k] = formattxt[i]; + k++; + infoPtr->buflen[*nrFields]++; } /* if j=len */ - if (*nrFields==infoPtr->nrFieldsAllocated) { - FIXME ("out of memory; should reallocate. crash ahead.\n"); + if (*nrFields == infoPtr->nrFieldsAllocated) { + FIXME ("out of memory; should reallocate. crash ahead.\n"); } + } /* for i */ - } /* for i */ + TRACE("\n"); - TRACE("\n"); - - if (infoPtr->fieldspec[*nrFields]!=0) (*nrFields)++; + if (infoPtr->fieldspec[*nrFields] != 0) (*nrFields)++; } -static LRESULT -DATETIME_SetFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) +static BOOL +DATETIME_SetFormatW (DATETIME_INFO *infoPtr, LPCWSTR lpszFormat) { - DATETIME_INFO *infoPtr= DATETIME_GetInfoPtr (hwnd); - char format_buf[80]; - DWORD format_item; + if (!lpszFormat) { + WCHAR format_buf[80]; + DWORD format_item; - TRACE("%04x %08lx\n",wParam,lParam); - if (!lParam) { - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); - - if (dwStyle & DTS_LONGDATEFORMAT) - format_item=LOCALE_SLONGDATE; - else if (dwStyle & DTS_TIMEFORMAT) - format_item=LOCALE_STIMEFORMAT; + if (infoPtr->dwStyle & DTS_LONGDATEFORMAT) + format_item = LOCALE_SLONGDATE; + else if (infoPtr->dwStyle & DTS_TIMEFORMAT) + format_item = LOCALE_STIMEFORMAT; else /* DTS_SHORTDATEFORMAT */ - format_item=LOCALE_SSHORTDATE; - GetLocaleInfoA( GetSystemDefaultLCID(), format_item,format_buf,sizeof(format_buf)); - DATETIME_UseFormat (infoPtr, format_buf); - } - else - DATETIME_UseFormat (infoPtr, (char *) lParam); + format_item = LOCALE_SSHORTDATE; + GetLocaleInfoW( GetSystemDefaultLCID(), format_item, format_buf, sizeof(format_buf)/sizeof(format_buf[0])); + lpszFormat = format_buf; + } - return infoPtr->nrFields; + DATETIME_UseFormat (infoPtr, lpszFormat); + + return infoPtr->nrFields; } -static LRESULT -DATETIME_SetFormatW (HWND hwnd, WPARAM wParam, LPARAM lParam) - +static BOOL +DATETIME_SetFormatA (DATETIME_INFO *infoPtr, LPCSTR lpszFormat) { - TRACE("%04x %08lx\n",wParam,lParam); - if (lParam) { - LPSTR buf; - int retval; - int len = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, NULL, 0, NULL, NULL ); - - buf = (LPSTR) Alloc (len); - WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1, buf, len, NULL, NULL ); - retval=DATETIME_SetFormat (hwnd, 0, (LPARAM) buf); - Free (buf); + if (lpszFormat) { + BOOL retval; + INT len = MultiByteToWideChar(CP_ACP, 0, lpszFormat, -1, NULL, 0); + LPWSTR wstr = Alloc(len * sizeof(WCHAR)); + if (wstr) MultiByteToWideChar(CP_ACP, 0, lpszFormat, -1, wstr, len); + retval = DATETIME_SetFormatW (infoPtr, wstr); + Free (wstr); return retval; - } - else - return DATETIME_SetFormat (hwnd, 0, 0); + } + else + return DATETIME_SetFormatW (infoPtr, 0); } static void -DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, char *result, int resultSize) +DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, LPWSTR result, int resultSize) { - SYSTEMTIME date = infoPtr->date; - int spec; - char buffer[80]; + static const WCHAR fmt_dW[] = { '%', 'd', 0 }; + static const WCHAR fmt__2dW[] = { '%', '.', '2', 'd', 0 }; + static const WCHAR fmt__3sW[] = { '%', '.', '3', 's', 0 }; + SYSTEMTIME date = infoPtr->date; + int spec; + WCHAR buffer[80]; - *result=0; - TRACE ("%d,%d\n", infoPtr->nrFields, count); - if ((count>infoPtr->nrFields) || (count<0)) { + *result=0; + TRACE ("%d,%d\n", infoPtr->nrFields, count); + if (count>infoPtr->nrFields || count < 0) { WARN ("buffer overrun, have %d want %d\n", infoPtr->nrFields, count); return; - } + } - if (!infoPtr->fieldspec) return; + if (!infoPtr->fieldspec) return; - spec=infoPtr->fieldspec[count]; - if (spec & DT_STRING) { - int txtlen=infoPtr->buflen[count]; + spec = infoPtr->fieldspec[count]; + if (spec & DT_STRING) { + int txtlen = infoPtr->buflen[count]; if (txtlen > resultSize) txtlen = resultSize - 1; - memcpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen); - result[txtlen]=0; - TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result); + memcpy (result, infoPtr->textbuf + (spec &~ DT_STRING), txtlen * sizeof(WCHAR)); + result[txtlen] = 0; + TRACE ("arg%d=%x->[%s]\n", count, infoPtr->fieldspec[count], debugstr_w(result)); return; - } + } - switch (spec) { + switch (spec) { case DT_END_FORMAT: - *result=0; - break; + *result = 0; + break; case ONEDIGITDAY: - sprintf (result,"%d",date.wDay); - break; + wsprintfW (result, fmt_dW, date.wDay); + break; case TWODIGITDAY: - sprintf (result,"%.2d",date.wDay); - break; + wsprintfW (result, fmt__2dW, date.wDay); + break; case THREECHARDAY: - GetLocaleInfoA( LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7, - result,4); - /*sprintf (result,"%.3s",days[date.wDayOfWeek]);*/ - break; + GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SABBREVDAYNAME1+(date.wDayOfWeek+6)%7, result, 4); + /*wsprintfW (result,"%.3s",days[date.wDayOfWeek]);*/ + break; case FULLDAY: - GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SDAYNAME1+ (date.wDayOfWeek+6)%7, - result, resultSize); - break; + GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDAYNAME1+(date.wDayOfWeek+6)%7, result, resultSize); + break; case ONEDIGIT12HOUR: - if (date.wHour>12) - sprintf (result,"%d",date.wHour-12); - else - sprintf (result,"%d",date.wHour); - break; + wsprintfW (result, fmt_dW, date.wHour - (date.wHour > 12 ? 12 : 0)); + break; case TWODIGIT12HOUR: - if (date.wHour>12) - sprintf (result,"%.2d",date.wHour-12); - else - sprintf (result,"%.2d",date.wHour); - break; + wsprintfW (result, fmt__2dW, date.wHour - (date.wHour > 12 ? 12 : 0)); + break; case ONEDIGIT24HOUR: - sprintf (result,"%d",date.wHour); - break; + wsprintfW (result, fmt_dW, date.wHour); + break; case TWODIGIT24HOUR: - sprintf (result,"%.2d",date.wHour); - break; + wsprintfW (result, fmt__2dW, date.wHour); + break; case ONEDIGITSECOND: - sprintf (result,"%d",date.wSecond); - break; + wsprintfW (result, fmt_dW, date.wSecond); + break; case TWODIGITSECOND: - sprintf (result,"%.2d",date.wSecond); - break; + wsprintfW (result, fmt__2dW, date.wSecond); + break; case ONEDIGITMINUTE: - sprintf (result,"%d",date.wMinute); - break; + wsprintfW (result, fmt_dW, date.wMinute); + break; case TWODIGITMINUTE: - sprintf (result,"%.2d",date.wMinute); - break; + wsprintfW (result, fmt__2dW, date.wMinute); + break; case ONEDIGITMONTH: - sprintf (result,"%d",date.wMonth); - break; + wsprintfW (result, fmt_dW, date.wMonth); + break; case TWODIGITMONTH: - sprintf (result,"%.2d",date.wMonth); - break; + wsprintfW (result, fmt__2dW, date.wMonth); + break; case THREECHARMONTH: - GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1, - buffer,sizeof(buffer)); - sprintf (result,"%.3s",buffer); - break; + GetLocaleInfoW(GetSystemDefaultLCID(), LOCALE_SMONTHNAME1+date.wMonth -1, + buffer, sizeof(buffer)/sizeof(buffer[0])); + wsprintfW (result, fmt__3sW, buffer); + break; case FULLMONTH: - GetLocaleInfoA( GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1, - result, resultSize); - break; + GetLocaleInfoW(GetSystemDefaultLCID(),LOCALE_SMONTHNAME1+date.wMonth -1, + result, resultSize); + break; case ONELETTERAMPM: - if (date.wHour<12) - strcpy (result,"A"); - else - strcpy (result,"P"); - break; + result[0] = (date.wHour < 12 ? 'A' : 'P'); + result[1] = 0; + break; case TWOLETTERAMPM: - if (date.wHour<12) - strcpy (result,"AM"); - else - strcpy (result,"PM"); - break; + result[0] = (date.wHour < 12 ? 'A' : 'P'); + result[1] = 'M'; + result[2] = 0; + break; case FORMATCALLBACK: - FIXME ("Not implemented\n"); - strcpy (result,"xxx"); - break; + FIXME ("Not implemented\n"); + result[0] = 'x'; + result[1] = 0; + break; case ONEDIGITYEAR: - sprintf (result,"%d",date.wYear-10* (int) floor(date.wYear/10)); - break; + wsprintfW (result, fmt_dW, date.wYear-10* (int) floor(date.wYear/10)); + break; case TWODIGITYEAR: - sprintf (result,"%.2d",date.wYear-100* (int) floor(date.wYear/100)); - break; + wsprintfW (result, fmt__2dW, date.wYear-100* (int) floor(date.wYear/100)); + break; case INVALIDFULLYEAR: case FULLYEAR: - sprintf (result,"%d",date.wYear); - break; + wsprintfW (result, fmt_dW, date.wYear); + break; } - TRACE ("arg%d=%x->[%s]\n",count,infoPtr->fieldspec[count],result); + TRACE ("arg%d=%x->[%s]\n", count, infoPtr->fieldspec[count], debugstr_w(result)); } +static int wrap(int val, int delta, int minVal, int maxVal) +{ + val += delta; + if (delta == INT_MIN || val < minVal) return maxVal; + if (delta == INT_MAX || val > maxVal) return minVal; + return val; +} static void -DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number) +DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number, int delta) { - SYSTEMTIME *date = &infoPtr->date; - int spec; + SYSTEMTIME *date = &infoPtr->date; - TRACE ("%d\n",number); - if ((number>infoPtr->nrFields) || (number<0)) return; + TRACE ("%d\n", number); + if ((number > infoPtr->nrFields) || (number < 0)) return; - spec=infoPtr->fieldspec[number]; - if ((spec & DTHT_DATEFIELD)==0) return; + if ((infoPtr->fieldspec[number] & DTHT_DATEFIELD) == 0) return; - switch (spec) { - case ONEDIGITDAY: - case TWODIGITDAY: - case THREECHARDAY: - case FULLDAY: - date->wDay++; - if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear)) - date->wDay=1; - break; - case ONEDIGIT12HOUR: - case TWODIGIT12HOUR: - case ONEDIGIT24HOUR: - case TWODIGIT24HOUR: - date->wHour++; - if (date->wHour>23) date->wHour=0; - break; - case ONEDIGITSECOND: - case TWODIGITSECOND: - date->wSecond++; - if (date->wSecond>59) date->wSecond=0; - break; - case ONEDIGITMINUTE: - case TWODIGITMINUTE: - date->wMinute++; - if (date->wMinute>59) date->wMinute=0; - break; + switch (infoPtr->fieldspec[number]) { + case ONEDIGITYEAR: + case TWODIGITYEAR: + case FULLYEAR: + date->wYear = wrap(date->wYear, delta, 1752, 9999); + break; case ONEDIGITMONTH: case TWODIGITMONTH: case THREECHARMONTH: case FULLMONTH: - date->wMonth++; - if (date->wMonth>12) date->wMonth=1; - if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear)) - date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear); - break; - case ONELETTERAMPM: - case TWOLETTERAMPM: - date->wHour+=12; - if (date->wHour>23) date->wHour-=24; - break; - case FORMATCALLBACK: - FIXME ("Not implemented\n"); - break; - case ONEDIGITYEAR: - case TWODIGITYEAR: - case FULLYEAR: - date->wYear++; - break; - } - -} - - -static void -DATETIME_DecreaseField (DATETIME_INFO *infoPtr, int number) -{ - SYSTEMTIME *date = & infoPtr->date; - int spec; - - TRACE ("%d\n",number); - if ((number>infoPtr->nrFields) || (number<0)) return; - - spec = infoPtr->fieldspec[number]; - if ((spec & DTHT_DATEFIELD)==0) return; - - TRACE ("%x\n",spec); - - switch (spec) { + date->wMonth = wrap(date->wMonth, delta, 1, 12); + delta = 0; + /* fall through */ case ONEDIGITDAY: case TWODIGITDAY: case THREECHARDAY: case FULLDAY: - date->wDay--; - if (date->wDay<1) - date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear); - break; + date->wDay = wrap(date->wDay, delta, 1, MONTHCAL_MonthLength(date->wMonth, date->wYear)); + break; + case ONELETTERAMPM: + case TWOLETTERAMPM: + delta *= 12; + /* fall through */ case ONEDIGIT12HOUR: case TWODIGIT12HOUR: case ONEDIGIT24HOUR: case TWODIGIT24HOUR: - if (date->wHour) - date->wHour--; - else - date->wHour=23; - break; - case ONEDIGITSECOND: - case TWODIGITSECOND: - if (date->wHour) - date->wSecond--; - else - date->wHour=59; - break; + date->wHour = wrap(date->wHour, delta, 0, 23); + break; case ONEDIGITMINUTE: case TWODIGITMINUTE: - if (date->wMinute) - date->wMinute--; - else - date->wMinute=59; - break; - case ONEDIGITMONTH: - case TWODIGITMONTH: - case THREECHARMONTH: - case FULLMONTH: - if (date->wMonth>1) - date->wMonth--; - else - date->wMonth=12; - if (date->wDay>MONTHCAL_MonthLength(date->wMonth,date->wYear)) - date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear); - break; - case ONELETTERAMPM: - case TWOLETTERAMPM: - if (date->wHour<12) - date->wHour+=12; - else - date->wHour-=12; - break; + date->wMinute = wrap(date->wMinute, delta, 0, 59); + break; + case ONEDIGITSECOND: + case TWODIGITSECOND: + date->wSecond = wrap(date->wSecond, delta, 0, 59); + break; case FORMATCALLBACK: - FIXME ("Not implemented\n"); - break; - case ONEDIGITYEAR: - case TWODIGITYEAR: - case FULLYEAR: - date->wYear--; - break; - } + FIXME ("Not implemented\n"); + break; + } + /* FYI: On 1752/9/14 the calendar changed and England and the + * American colonies changed to the Gregorian calendar. This change + * involved having September 14th follow September 2nd. So no date + * algorithm works before that date. + */ + if (10000 * date->wYear + 100 * date->wMonth + date->wDay < 17520914) { + date->wYear = 1752; + date->wMonth = 9; + date->wDay = 14; + date->wSecond = 0; + date->wMinute = 0; + date->wHour = 0; + } } -static void -DATETIME_ResetFieldDown (DATETIME_INFO *infoPtr, int number) +static void +DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc) { - SYSTEMTIME *date = &infoPtr->date; - int spec; + int i,prevright; + RECT *field; + RECT *rcDraw = &infoPtr->rcDraw; + RECT *rcClient = &infoPtr->rcClient; + RECT *calbutton = &infoPtr->calbutton; + RECT *checkbox = &infoPtr->checkbox; + HBRUSH hbr; + SIZE size; + COLORREF oldBk, oldTextColor; - TRACE ("%d\n",number); - if ((number>infoPtr->nrFields) || (number<0)) return; + /* draw control edge */ + TRACE("\n"); + hbr = CreateSolidBrush(RGB(255, 255, 255)); + FillRect(hdc, rcClient, hbr); + DrawEdge(hdc, rcClient, EDGE_SUNKEN, BF_RECT); + DeleteObject(hbr); - spec = infoPtr->fieldspec[number]; - if ((spec & DTHT_DATEFIELD)==0) return; + if (infoPtr->dateValid) { + HFONT oldFont = SelectObject (hdc, infoPtr->hFont); + WCHAR txt[80]; + DATETIME_ReturnTxt (infoPtr, 0, txt, sizeof(txt)/sizeof(txt[0])); + GetTextExtentPoint32W (hdc, txt, strlenW(txt), &size); + rcDraw->bottom = size.cy + 2; - switch (spec) { - case ONEDIGITDAY: - case TWODIGITDAY: - case THREECHARDAY: - case FULLDAY: - date->wDay = 1; - break; - case ONEDIGIT12HOUR: - case TWODIGIT12HOUR: - case ONEDIGIT24HOUR: - case TWODIGIT24HOUR: - case ONELETTERAMPM: - case TWOLETTERAMPM: - date->wHour = 0; - break; - case ONEDIGITSECOND: - case TWODIGITSECOND: - date->wSecond = 0; - break; - case ONEDIGITMINUTE: - case TWODIGITMINUTE: - date->wMinute = 0; - break; - case ONEDIGITMONTH: - case TWODIGITMONTH: - case THREECHARMONTH: - case FULLMONTH: - date->wMonth = 1; - case FORMATCALLBACK: - FIXME ("Not implemented\n"); - break; - case ONEDIGITYEAR: - case TWODIGITYEAR: - /* FYI: On 1752/9/14 the calendar changed and England and the - * American colonies changed to the Gregorian calendar. This change - * involved having September 14th follow September 2nd. So no date - * algorithm works before that date. - */ - case FULLYEAR: - date->wSecond = 0; - date->wMinute = 0; - date->wHour = 0; - date->wDay = 14; /* overactive ms-programmers..*/ - date->wMonth = 9; - date->wYear = 1752; - break; - } + prevright = checkbox->right = ((infoPtr->dwStyle & DTS_SHOWNONE) ? 18 : 2); -} + for (i = 0; i < infoPtr->nrFields; i++) { + DATETIME_ReturnTxt (infoPtr, i, txt, sizeof(txt)/sizeof(txt[0])); + GetTextExtentPoint32W (hdc, txt, strlenW(txt), &size); + field = &infoPtr->fieldRect[i]; + field->left = prevright; + field->right = prevright+size.cx; + field->top = rcDraw->top; + field->bottom = rcDraw->bottom; + prevright = field->right; - -static void -DATETIME_ResetFieldUp (DATETIME_INFO *infoPtr, int number) -{ - SYSTEMTIME *date = & infoPtr->date; - int spec; - - TRACE("%d \n",number); - if ((number>infoPtr->nrFields) || (number<0)) return; - - spec=infoPtr->fieldspec[number]; - if ((spec & DTHT_DATEFIELD)==0) return; - - switch (spec) { - case ONEDIGITDAY: - case TWODIGITDAY: - case THREECHARDAY: - case FULLDAY: - date->wDay=MONTHCAL_MonthLength(date->wMonth,date->wYear); - break; - case ONEDIGIT12HOUR: - case TWODIGIT12HOUR: - case ONEDIGIT24HOUR: - case TWODIGIT24HOUR: - case ONELETTERAMPM: - case TWOLETTERAMPM: - date->wHour=23; - break; - case ONEDIGITSECOND: - case TWODIGITSECOND: - date->wSecond=59; - break; - case ONEDIGITMINUTE: - case TWODIGITMINUTE: - date->wMinute=59; - break; - case ONEDIGITMONTH: - case TWODIGITMONTH: - case THREECHARMONTH: - case FULLMONTH: - date->wMonth=12; - case FORMATCALLBACK: - FIXME ("Not implemented\n"); - break; - case ONEDIGITYEAR: - case TWODIGITYEAR: - case FULLYEAR: - date->wYear=9999; /* Y10K problem? naaah. */ - break; - } - -} - - -static void DATETIME_Refresh (HWND hwnd, HDC hdc) - -{ - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - int i,prevright; - RECT *field; - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); - RECT *rcDraw = &infoPtr->rcDraw; - RECT *rcClient = &infoPtr->rcClient; - RECT *calbutton = &infoPtr->calbutton; - RECT *checkbox = &infoPtr->checkbox; - HBRUSH hbr; - SIZE size; - COLORREF oldBk, oldTextColor; - - /* draw control edge */ - TRACE("\n"); - hbr = CreateSolidBrush(RGB(255, 255, 255)); - FillRect(hdc, rcClient, hbr); - DrawEdge(hdc, rcClient, EDGE_SUNKEN, BF_RECT); - DeleteObject(hbr); - - if (infoPtr->dateValid) { - char txt[80]; - HFONT oldFont; - oldFont = SelectObject (hdc, infoPtr->hFont); - - DATETIME_ReturnTxt (infoPtr, 0, txt, sizeof(txt)); - GetTextExtentPoint32A (hdc, txt, strlen (txt), &size); - rcDraw->bottom = size.cy+2; - - if (dwStyle & DTS_SHOWNONE) - checkbox->right = 18; - else - checkbox->right = 2; - prevright = checkbox->right; - - for (i=0; inrFields; i++) { - DATETIME_ReturnTxt (infoPtr, i, txt, sizeof(txt)); - GetTextExtentPoint32A (hdc, txt, strlen (txt), &size); - field = & infoPtr->fieldRect[i]; - field->left = prevright; - field->right = prevright+size.cx; - field->top = rcDraw->top; - field->bottom = rcDraw->bottom; - prevright = field->right; - - if ((infoPtr->haveFocus) && (i==infoPtr->select)) { - hbr = CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)); - FillRect(hdc, field, hbr); - oldBk = SetBkColor (hdc, GetSysColor(COLOR_ACTIVECAPTION)); - oldTextColor = SetTextColor (hdc, GetSysColor(COLOR_WINDOW)); - DeleteObject (hbr); - DrawTextA ( hdc, txt, strlen(txt), field, - DT_RIGHT | DT_VCENTER | DT_SINGLELINE ); - SetBkColor (hdc, oldBk); + if ((infoPtr->haveFocus) && (i == infoPtr->select)) { + hbr = CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)); + FillRect(hdc, field, hbr); + oldBk = SetBkColor (hdc, GetSysColor(COLOR_ACTIVECAPTION)); + oldTextColor = SetTextColor (hdc, GetSysColor(COLOR_WINDOW)); + DeleteObject (hbr); + DrawTextW (hdc, txt, strlenW(txt), field, DT_RIGHT | DT_VCENTER | DT_SINGLELINE); + SetBkColor (hdc, oldBk); SetTextColor (hdc, oldTextColor); - } - else - DrawTextA ( hdc, txt, strlen(txt), field, - DT_RIGHT | DT_VCENTER | DT_SINGLELINE ); + } else + DrawTextW ( hdc, txt, strlenW(txt), field, DT_RIGHT | DT_VCENTER | DT_SINGLELINE ); + } + SelectObject (hdc, oldFont); } - SelectObject (hdc, oldFont); - } - - if (!(dwStyle & DTS_UPDOWN)) { - DrawFrameControl(hdc, calbutton, DFC_SCROLL, - DFCS_SCROLLDOWN | (infoPtr->bCalDepressed ? DFCS_PUSHED : 0) | - (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); - } -} - - -static LRESULT -DATETIME_HitTest (HWND hwnd, DATETIME_INFO *infoPtr, POINT pt) -{ - int i, retval; - - TRACE ("%ld, %ld\n",pt.x,pt.y); - - retval = DTHT_NONE; - if (PtInRect (&infoPtr->calbutton, pt)) - {retval = DTHT_MCPOPUP; TRACE("Hit in calbutton(DTHT_MCPOPUP)\n"); goto done; } - if (PtInRect (&infoPtr->checkbox, pt)) - {retval = DTHT_CHECKBOX; TRACE("Hit in checkbox(DTHT_CHECKBOX)\n"); goto done; } - - for (i=0; inrFields; i++) { - if (PtInRect (&infoPtr->fieldRect[i], pt)) { - retval = i; - TRACE("Hit in date text in field %d\n", i); - break; + if (!(infoPtr->dwStyle & DTS_UPDOWN)) { + DrawFrameControl(hdc, calbutton, DFC_SCROLL, + DFCS_SCROLLDOWN | (infoPtr->bCalDepressed ? DFCS_PUSHED : 0) | + (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); } - } - -done: - return retval; } -static LRESULT -DATETIME_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) +static INT +DATETIME_HitTest (DATETIME_INFO *infoPtr, POINT pt) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); - int old, new; - POINT pt; + int i; - TRACE ("\n"); + TRACE ("%ld, %ld\n", pt.x, pt.y); - old = infoPtr->select; - pt.x = (INT)LOWORD(lParam); - pt.y = (INT)HIWORD(lParam); + if (PtInRect (&infoPtr->calbutton, pt)) return DTHT_MCPOPUP; + if (PtInRect (&infoPtr->checkbox, pt)) return DTHT_CHECKBOX; - new = DATETIME_HitTest (hwnd, infoPtr, pt); - - /* FIXME: might be conditions where we don't want to update infoPtr->select */ - infoPtr->select = new; - - if (infoPtr->select != old) { - infoPtr->haveFocus = DTHT_GOTFOCUS; - } - - if (infoPtr->select == DTHT_MCPOPUP) { - /* FIXME: button actually is only depressed during dropdown of the */ - /* calendar control and when the mouse is over the button window */ - infoPtr->bCalDepressed = TRUE; - - /* recalculate the position of the monthcal popup */ - if(dwStyle & DTS_RIGHTALIGN) - infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right - - infoPtr->calbutton.left) + 200); - else - infoPtr->monthcal_pos.x = 8; - - infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom; - ClientToScreen (hwnd, &(infoPtr->monthcal_pos)); - /* FIXME My Windoze has cx=about 200, but it probably depends on font size etc */ - SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x, - infoPtr->monthcal_pos.y, 200, 150, 0); - - if(IsWindowVisible(infoPtr->hMonthCal)) - ShowWindow(infoPtr->hMonthCal, SW_HIDE); - else { - SYSTEMTIME *lprgSysTimeArray = &infoPtr->date; - TRACE("update calendar %04d/%02d/%02d\n", - lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay); - SendMessageA(infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date)); - ShowWindow(infoPtr->hMonthCal, SW_SHOW); + for (i=0; i < infoPtr->nrFields; i++) { + if (PtInRect (&infoPtr->fieldRect[i], pt)) return i; } - TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p\n", - hwnd, infoPtr->hMonthCal, infoPtr->hwndNotify, GetDesktopWindow ()); - DATETIME_SendSimpleNotify (hwnd, DTN_DROPDOWN); - } - - InvalidateRect(hwnd, NULL, FALSE); - - return 0; + return DTHT_NONE; } static LRESULT -DATETIME_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) +DATETIME_LButtonDown (DATETIME_INFO *infoPtr, WORD wKey, INT x, INT y) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); + POINT pt; + int old, new; - TRACE("\n"); + pt.x = x; + pt.y = y; + old = infoPtr->select; + new = DATETIME_HitTest (infoPtr, pt); - if(infoPtr->bCalDepressed == TRUE) { - infoPtr->bCalDepressed = FALSE; - InvalidateRect(hwnd, &(infoPtr->calbutton), TRUE); - } + /* FIXME: might be conditions where we don't want to update infoPtr->select */ + infoPtr->select = new; - return 0; -} + if (infoPtr->select != old) + infoPtr->haveFocus = DTHT_GOTFOCUS; + if (infoPtr->select == DTHT_MCPOPUP) { + /* FIXME: button actually is only depressed during dropdown of the */ + /* calendar control and when the mouse is over the button window */ + infoPtr->bCalDepressed = TRUE; -static LRESULT -DATETIME_Paint (HWND hwnd, WPARAM wParam) -{ - HDC hdc; - PAINTSTRUCT ps; + /* recalculate the position of the monthcal popup */ + if(infoPtr->dwStyle & DTS_RIGHTALIGN) + infoPtr->monthcal_pos.x = infoPtr->rcClient.right - + ((infoPtr->calbutton.right - infoPtr->calbutton.left) + 200); + else + infoPtr->monthcal_pos.x = 8; + + infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom; + ClientToScreen (infoPtr->hwndSelf, &(infoPtr->monthcal_pos)); + /* FIXME My Windoze has cx=about 200, but it probably depends on font size etc */ + SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x, infoPtr->monthcal_pos.y, 200, 150, 0); + + if(IsWindowVisible(infoPtr->hMonthCal)) { + ShowWindow(infoPtr->hMonthCal, SW_HIDE); + } else { + SYSTEMTIME *lprgSysTimeArray = &infoPtr->date; + TRACE("update calendar %04d/%02d/%02d\n", + lprgSysTimeArray->wYear, lprgSysTimeArray->wMonth, lprgSysTimeArray->wDay); + SendMessageW(infoPtr->hMonthCal, MCM_SETCURSEL, 0, (LPARAM)(&infoPtr->date)); + ShowWindow(infoPtr->hMonthCal, SW_SHOW); + } + + TRACE ("dt:%p mc:%p mc parent:%p, desktop:%p\n", + infoPtr->hwndSelf, infoPtr->hMonthCal, infoPtr->hwndNotify, GetDesktopWindow ()); + DATETIME_SendSimpleNotify (infoPtr, DTN_DROPDOWN); + } + + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); - hdc = wParam==0 ? BeginPaint (hwnd, &ps) : (HDC)wParam; - DATETIME_Refresh (hwnd, hdc); - if(!wParam) - EndPaint (hwnd, &ps); return 0; } static LRESULT -DATETIME_Button_Command (HWND hwnd, WPARAM wParam, LPARAM lParam) +DATETIME_LButtonUp (DATETIME_INFO *infoPtr, WORD wKey) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd); + if(infoPtr->bCalDepressed == TRUE) { + infoPtr->bCalDepressed = FALSE; + InvalidateRect(infoPtr->hwndSelf, &(infoPtr->calbutton), TRUE); + } - switch(HIWORD(wParam)) { - case BN_CLICKED: - { - DWORD state = SendMessageA((HWND)lParam, BM_GETCHECK, 0, 0); - if(state == BST_CHECKED) - infoPtr->dateValid = TRUE; - else - infoPtr->dateValid = FALSE; - InvalidateRect(hwnd, NULL, TRUE); - return 0; + return 0; +} + + +static LRESULT +DATETIME_Paint (DATETIME_INFO *infoPtr, HDC hdc) +{ + if (!hdc) { + PAINTSTRUCT ps; + hdc = BeginPaint (infoPtr->hwndSelf, &ps); + DATETIME_Refresh (infoPtr, hdc); + EndPaint (infoPtr->hwndSelf, &ps); + } else { + DATETIME_Refresh (infoPtr, hdc); } - default: - return 0; + return 0; +} + + +static LRESULT +DATETIME_Button_Command (DATETIME_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +{ + if( HIWORD(wParam) == BN_CLICKED) { + DWORD state = SendMessageW((HWND)lParam, BM_GETCHECK, 0, 0); + infoPtr->dateValid = (state == BST_CHECKED); + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); } + return 0; } static LRESULT -DATETIME_Command (HWND hwnd, WPARAM wParam, LPARAM lParam) +DATETIME_Command (DATETIME_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd); - - TRACE("%08x %08lx\n", wParam, lParam); TRACE("hwndbutton = %p\n", infoPtr->hwndCheckbut); if(infoPtr->hwndCheckbut == (HWND)lParam) - return DATETIME_Button_Command(hwnd, wParam, lParam); + return DATETIME_Button_Command(infoPtr, wParam, lParam); return 0; } -static LRESULT -DATETIME_ParentNotify (HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - LPNMHDR lpnmh = (LPNMHDR) lParam; - TRACE ("%x,%lx\n",wParam, lParam); - TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom); - TRACE ("info: %p %p %p\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown); - return 0; +static LRESULT +DATETIME_Notify (DATETIME_INFO *infoPtr, int idCtrl, LPNMHDR lpnmh) +{ + TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom); + TRACE ("info: %p %p %p\n", infoPtr->hwndSelf, infoPtr->hMonthCal, infoPtr->hUpdown); + + if (lpnmh->code == MCN_SELECT) { + ShowWindow(infoPtr->hMonthCal, SW_HIDE); + infoPtr->dateValid = TRUE; + SendMessageW (infoPtr->hMonthCal, MCM_GETCURSEL, 0, (LPARAM)&infoPtr->date); + TRACE("got from calendar %04d/%02d/%02d\n", + infoPtr->date.wYear, infoPtr->date.wMonth, infoPtr->date.wDay); + SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0); + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); + DATETIME_SendDateTimeChangeNotify (infoPtr); + } + return 0; } static LRESULT -DATETIME_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam) - +DATETIME_KeyDown (DATETIME_INFO *infoPtr, DWORD vkCode, LPARAM flags) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - LPNMHDR lpnmh = (LPNMHDR) lParam; + int fieldNum = infoPtr->select & DTHT_DATEFIELD; + int wrap = 0; - TRACE ("%x,%lx\n",wParam, lParam); - TRACE ("Got notification %x from %p\n", lpnmh->code, lpnmh->hwndFrom); - TRACE ("info: %p %p %p\n",hwnd,infoPtr->hMonthCal,infoPtr->hUpdown); + if (!(infoPtr->haveFocus)) return 0; + if ((fieldNum==0) && (infoPtr->select)) return 0; - if (lpnmh->code==MCN_SELECT) { - ShowWindow(infoPtr->hMonthCal, SW_HIDE); - infoPtr->dateValid = TRUE; - SendMessageA (infoPtr->hMonthCal, MCM_GETCURSEL, 0, (LPARAM)&infoPtr->date); - TRACE("got from calendar %04d/%02d/%02d\n", - infoPtr->date.wYear, infoPtr->date.wMonth, infoPtr->date.wDay); - SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0); - InvalidateRect(hwnd, NULL, TRUE); - DATETIME_SendDateTimeChangeNotify (hwnd); - } - return 0; -} - - -static LRESULT -DATETIME_KeyDown (HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - int FieldNum,wrap=0; - - TRACE("%x %lx %x\n",wParam, lParam, infoPtr->select); - - FieldNum = infoPtr->select & DTHT_DATEFIELD; - - if (!(infoPtr->haveFocus)) return 0; - if ((FieldNum==0) && (infoPtr->select)) return 0; - - if (infoPtr->select & FORMATCALLMASK) { + if (infoPtr->select & FORMATCALLMASK) { FIXME ("Callbacks not implemented yet\n"); - } + } - switch (wParam) { + switch (vkCode) { case VK_ADD: case VK_UP: - DATETIME_IncreaseField (infoPtr,FieldNum); - DATETIME_SendDateTimeChangeNotify (hwnd); - break; + DATETIME_IncreaseField (infoPtr, fieldNum, 1); + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; case VK_SUBTRACT: case VK_DOWN: - DATETIME_DecreaseField (infoPtr,FieldNum); - DATETIME_SendDateTimeChangeNotify (hwnd); - break; + DATETIME_IncreaseField (infoPtr, fieldNum, -1); + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; case VK_HOME: - DATETIME_ResetFieldDown (infoPtr,FieldNum); - DATETIME_SendDateTimeChangeNotify (hwnd); - break; + DATETIME_IncreaseField (infoPtr, fieldNum, INT_MIN); + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; case VK_END: - DATETIME_ResetFieldUp(infoPtr,FieldNum); - DATETIME_SendDateTimeChangeNotify (hwnd); - break; + DATETIME_IncreaseField (infoPtr, fieldNum, INT_MAX); + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; case VK_LEFT: - do { - if (infoPtr->select==0) { - infoPtr->select = infoPtr->nrFields - 1; - wrap++; - } else - infoPtr->select--; + do { + if (infoPtr->select == 0) { + infoPtr->select = infoPtr->nrFields - 1; + wrap++; + } else { + infoPtr->select--; } - while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2)); - break; + } while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2)); + break; case VK_RIGHT: - do { - infoPtr->select++; - if (infoPtr->select==infoPtr->nrFields) { - infoPtr->select = 0; - wrap++; - } - } - while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2)); - break; - } + do { + infoPtr->select++; + if (infoPtr->select==infoPtr->nrFields) { + infoPtr->select = 0; + wrap++; + } + } while ((infoPtr->fieldspec[infoPtr->select] & DT_STRING) && (wrap<2)); + break; + } - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); - return 0; + return 0; } static LRESULT -DATETIME_KillFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) +DATETIME_KillFocus (DATETIME_INFO *infoPtr, HWND lostFocus) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - - TRACE ("\n"); - if (infoPtr->haveFocus) { - DATETIME_SendSimpleNotify (hwnd, NM_KILLFOCUS); + DATETIME_SendSimpleNotify (infoPtr, NM_KILLFOCUS); infoPtr->haveFocus = 0; } - InvalidateRect (hwnd, NULL, TRUE); + InvalidateRect (infoPtr->hwndSelf, NULL, TRUE); return 0; } static LRESULT -DATETIME_SetFocus (HWND hwnd, WPARAM wParam, LPARAM lParam) +DATETIME_SetFocus (DATETIME_INFO *infoPtr, HWND lostFocus) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - - TRACE ("\n"); - - if (infoPtr->haveFocus==0) { - DATETIME_SendSimpleNotify (hwnd, NM_SETFOCUS); + if (infoPtr->haveFocus == 0) { + DATETIME_SendSimpleNotify (infoPtr, NM_SETFOCUS); infoPtr->haveFocus = DTHT_GOTFOCUS; } - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return 0; } static BOOL -DATETIME_SendDateTimeChangeNotify (HWND hwnd) - +DATETIME_SendDateTimeChangeNotify (DATETIME_INFO *infoPtr) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); - NMDATETIMECHANGE dtdtc; + NMDATETIMECHANGE dtdtc; - TRACE ("\n"); - dtdtc.nmhdr.hwndFrom = hwnd; - dtdtc.nmhdr.idFrom = GetWindowLongPtrW(hwnd, GWLP_ID); - dtdtc.nmhdr.code = DTN_DATETIMECHANGE; + dtdtc.nmhdr.hwndFrom = infoPtr->hwndSelf; + dtdtc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID); + dtdtc.nmhdr.code = DTN_DATETIMECHANGE; - if ((GetWindowLongA (hwnd, GWL_STYLE) & DTS_SHOWNONE)) - dtdtc.dwFlags = GDT_NONE; - else - dtdtc.dwFlags = GDT_VALID; + dtdtc.dwFlags = (infoPtr->dwStyle & DTS_SHOWNONE) ? GDT_NONE : GDT_VALID; - MONTHCAL_CopyTime (&infoPtr->date, &dtdtc.st); - return (BOOL) SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, - (WPARAM)dtdtc.nmhdr.idFrom, (LPARAM)&dtdtc); + MONTHCAL_CopyTime (&infoPtr->date, &dtdtc.st); + return (BOOL) SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, + (WPARAM)dtdtc.nmhdr.idFrom, (LPARAM)&dtdtc); } static BOOL -DATETIME_SendSimpleNotify (HWND hwnd, UINT code) +DATETIME_SendSimpleNotify (DATETIME_INFO *infoPtr, UINT code) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); NMHDR nmhdr; - TRACE("%x\n",code); - nmhdr.hwndFrom = hwnd; - nmhdr.idFrom = GetWindowLongPtrW(hwnd, GWLP_ID); + TRACE("%x\n", code); + nmhdr.hwndFrom = infoPtr->hwndSelf; + nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID); nmhdr.code = code; - return (BOOL) SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, + return (BOOL) SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); } static LRESULT -DATETIME_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) +DATETIME_Size (DATETIME_INFO *infoPtr, WORD flags, INT width, INT height) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr(hwnd); - DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); + /* set size */ + infoPtr->rcClient.bottom = height; + infoPtr->rcClient.right = width; - /* set size */ - infoPtr->rcClient.bottom = HIWORD(lParam); - infoPtr->rcClient.right = LOWORD(lParam); + TRACE("Height=%ld, Width=%ld\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right); - TRACE("Height=%ld, Width=%ld\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right); + memcpy((&infoPtr->rcDraw), (&infoPtr->rcClient), sizeof(infoPtr->rcDraw)); - memcpy((&infoPtr->rcDraw), (&infoPtr->rcClient), sizeof(infoPtr->rcDraw)); + /* subract the size of the edge drawn by DrawEdge */ + InflateRect(&infoPtr->rcDraw, -2, -2); - /* subract the size of the edge drawn by DrawEdge */ - InflateRect(&infoPtr->rcDraw, -2, -2); + /* set the size of the button that drops the calendar down */ + /* FIXME: account for style that allows button on left side */ + infoPtr->calbutton.top = infoPtr->rcDraw.top; + infoPtr->calbutton.bottom= infoPtr->rcDraw.bottom; + infoPtr->calbutton.left = infoPtr->rcDraw.right-15; + infoPtr->calbutton.right = infoPtr->rcDraw.right; - /* set the size of the button that drops the calendar down */ - /* FIXME: account for style that allows button on left side */ - infoPtr->calbutton.top = infoPtr->rcDraw.top; - infoPtr->calbutton.bottom= infoPtr->rcDraw.bottom; - infoPtr->calbutton.left = infoPtr->rcDraw.right-15; - infoPtr->calbutton.right = infoPtr->rcDraw.right; + /* set enable/disable button size for show none style being enabled */ + /* FIXME: these dimensions are completely incorrect */ + infoPtr->checkbox.top = infoPtr->rcDraw.top; + infoPtr->checkbox.bottom = infoPtr->rcDraw.bottom; + infoPtr->checkbox.left = infoPtr->rcDraw.left; + infoPtr->checkbox.right = infoPtr->rcDraw.left + 10; - /* set enable/disable button size for show none style being enabled */ - /* FIXME: these dimensions are completely incorrect */ - infoPtr->checkbox.top = infoPtr->rcDraw.top; - infoPtr->checkbox.bottom = infoPtr->rcDraw.bottom; - infoPtr->checkbox.left = infoPtr->rcDraw.left; - infoPtr->checkbox.right = infoPtr->rcDraw.left + 10; + /* update the position of the monthcal control */ + if(infoPtr->dwStyle & DTS_RIGHTALIGN) + infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right - + infoPtr->calbutton.left) + 145); + else + infoPtr->monthcal_pos.x = 8; - /* update the position of the monthcal control */ - if(dwStyle & DTS_RIGHTALIGN) - infoPtr->monthcal_pos.x = infoPtr->rcClient.right - ((infoPtr->calbutton.right - - infoPtr->calbutton.left) + 145); - else - infoPtr->monthcal_pos.x = 8; + infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom; + ClientToScreen (infoPtr->hwndSelf, &(infoPtr->monthcal_pos)); + SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x, infoPtr->monthcal_pos.y, 145, 150, 0); - infoPtr->monthcal_pos.y = infoPtr->rcClient.bottom; - ClientToScreen (hwnd, &(infoPtr->monthcal_pos)); - SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x, - infoPtr->monthcal_pos.y, - 145, 150, 0); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); - InvalidateRect(hwnd, NULL, FALSE); - - return 0; -} - - -static LRESULT -DATETIME_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - DATETIME_INFO *infoPtr; - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); - - /* allocate memory for info structure */ - TRACE("%04x %08lx\n",wParam,lParam); - infoPtr = (DATETIME_INFO *)Alloc (sizeof(DATETIME_INFO)); - if (infoPtr == NULL) { - ERR("could not allocate info memory!\n"); return 0; - } +} - SetWindowLongPtrA (hwnd, 0, (DWORD_PTR)infoPtr); - if (dwStyle & DTS_SHOWNONE) { - infoPtr->hwndCheckbut=CreateWindowExA (0,"button", 0, - WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, - 2,2,13,13, - hwnd, - 0, (HINSTANCE)GetWindowLongPtrW (hwnd, GWLP_HINSTANCE), 0); - SendMessageA (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0); - } +static LRESULT +DATETIME_StyleChanged(DATETIME_INFO *infoPtr, WPARAM wStyleType, LPSTYLESTRUCT lpss) +{ + static const WCHAR buttonW[] = { 'b', 'u', 't', 't', 'o', 'n', 0 }; - if (dwStyle & DTS_UPDOWN) { - infoPtr->hUpdown=CreateUpDownControl ( - WS_CHILD | WS_BORDER | WS_VISIBLE, - 120,1,20,20, - hwnd,1,0,0, - UD_MAXVAL, UD_MINVAL, 0); - } + TRACE("(styletype=%x, styleOld=0x%08lx, styleNew=0x%08lx)\n", + wStyleType, lpss->styleOld, lpss->styleNew); - infoPtr->fieldspec = (int *) Alloc (32*sizeof(int)); - infoPtr->fieldRect = (RECT *) Alloc (32*sizeof(RECT)); - infoPtr->buflen = (int *) Alloc (32*sizeof(int)); - infoPtr->nrFieldsAllocated = 32; - infoPtr->hwndNotify = ((LPCREATESTRUCTA)lParam)->hwndParent; + if (wStyleType != GWL_STYLE) return 0; + + infoPtr->dwStyle = lpss->styleNew; - DATETIME_SetFormat (hwnd, 0, 0); + if ( !(lpss->styleOld & DTS_SHOWNONE) && (lpss->styleNew & DTS_SHOWNONE) ) { + infoPtr->hwndCheckbut = CreateWindowExW (0, buttonW, 0, WS_CHILD | WS_VISIBLE | BS_AUTOCHECKBOX, + 2, 2, 13, 13, infoPtr->hwndSelf, 0, + (HINSTANCE)GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_HINSTANCE), 0); + SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, 1, 0); + } + if ( (lpss->styleOld & DTS_SHOWNONE) && !(lpss->styleNew & DTS_SHOWNONE) ) { + DestroyWindow(infoPtr->hwndCheckbut); + infoPtr->hwndCheckbut = 0; + } + if ( !(lpss->styleOld & DTS_UPDOWN) && (lpss->styleNew & DTS_UPDOWN) ) { + infoPtr->hUpdown = CreateUpDownControl (WS_CHILD | WS_BORDER | WS_VISIBLE, 120, 1, 20, 20, + infoPtr->hwndSelf, 1, 0, 0, UD_MAXVAL, UD_MINVAL, 0); + } + if ( (lpss->styleOld & DTS_UPDOWN) && !(lpss->styleNew & DTS_UPDOWN) ) { + DestroyWindow(infoPtr->hUpdown); + infoPtr->hUpdown = 0; + } - /* create the monthcal control */ - infoPtr->hMonthCal = CreateWindowExA (0,"SysMonthCal32", 0, - WS_BORDER | WS_POPUP | WS_CLIPSIBLINGS, - 0, 0, 0, 0, - hwnd, - 0, 0, 0); - - /* initialize info structure */ - GetSystemTime (&infoPtr->date); - infoPtr->dateValid = TRUE; - infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT); - return 0; + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); + return 0; } static LRESULT -DATETIME_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) +DATETIME_Create (HWND hwnd, LPCREATESTRUCTW lpcs) { - DATETIME_INFO *infoPtr = DATETIME_GetInfoPtr (hwnd); + static const WCHAR SysMonthCal32W[] = { 'S', 'y', 's', 'M', 'o', 'n', 't', 'h', 'C', 'a', 'l', '3', '2', 0 }; + DATETIME_INFO *infoPtr = (DATETIME_INFO *)Alloc (sizeof(DATETIME_INFO)); + STYLESTRUCT ss = { 0, lpcs->style }; - TRACE("\n"); - if (infoPtr->hMonthCal) { - /* FIXME I don't completely understand why doesn't it - * happen automatically, WS_POPUP maybe? */ + if (!infoPtr) return -1; + + infoPtr->hwndSelf = hwnd; + infoPtr->dwStyle = lpcs->style; + + infoPtr->nrFieldsAllocated = 32; + infoPtr->fieldspec = (int *) Alloc (infoPtr->nrFieldsAllocated * sizeof(int)); + infoPtr->fieldRect = (RECT *) Alloc (infoPtr->nrFieldsAllocated * sizeof(RECT)); + infoPtr->buflen = (int *) Alloc (infoPtr->nrFieldsAllocated * sizeof(int)); + infoPtr->hwndNotify = lpcs->hwndParent; + + DATETIME_StyleChanged(infoPtr, GWL_STYLE, &ss); + DATETIME_SetFormatW (infoPtr, 0); + + /* create the monthcal control */ + infoPtr->hMonthCal = CreateWindowExW (0, SysMonthCal32W, 0, WS_BORDER | WS_POPUP | WS_CLIPSIBLINGS, + 0, 0, 0, 0, infoPtr->hwndSelf, 0, 0, 0); + + /* initialize info structure */ + GetSystemTime (&infoPtr->date); + infoPtr->dateValid = TRUE; + infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT); + + SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); + + return 0; +} + + + +static LRESULT +DATETIME_Destroy (DATETIME_INFO *infoPtr) +{ + if (infoPtr->hwndCheckbut) + DestroyWindow(infoPtr->hwndCheckbut); + if (infoPtr->hUpdown) + DestroyWindow(infoPtr->hUpdown); + if (infoPtr->hMonthCal) DestroyWindow(infoPtr->hMonthCal); - infoPtr->hMonthCal = NULL; - } + SetWindowLongPtrW( infoPtr->hwndSelf, 0, 0 ); /* clear infoPtr */ Free (infoPtr); - SetWindowLongPtrA( hwnd, 0, 0 ); /* clear infoPtr */ return 0; } @@ -1285,116 +941,119 @@ DATETIME_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - if (!DATETIME_GetInfoPtr(hwnd) && (uMsg != WM_CREATE)) - return DefWindowProcA( hwnd, uMsg, wParam, lParam ); + DATETIME_INFO *infoPtr = ((DATETIME_INFO *)GetWindowLongPtrW (hwnd, 0)); + LRESULT ret; - switch (uMsg) - { + TRACE ("%x, %x, %lx\n", uMsg, wParam, lParam); + + if (!infoPtr && (uMsg != WM_CREATE)) + return DefWindowProcW( hwnd, uMsg, wParam, lParam ); + + switch (uMsg) { case DTM_GETSYSTEMTIME: - return DATETIME_GetSystemTime (hwnd, wParam, lParam); + return DATETIME_GetSystemTime (infoPtr, (SYSTEMTIME *) lParam); case DTM_SETSYSTEMTIME: - return DATETIME_SetSystemTime (hwnd, wParam, lParam); + return DATETIME_SetSystemTime (infoPtr, wParam, (SYSTEMTIME *) lParam); case DTM_GETRANGE: - return DATETIME_GetRange(hwnd, lParam); + ret = SendMessageW (infoPtr->hMonthCal, MCM_GETRANGE, wParam, lParam); + return ret ? ret : 1; /* bug emulation */ case DTM_SETRANGE: - return DATETIME_SetRange(hwnd, wParam, lParam); + return SendMessageW (infoPtr->hMonthCal, MCM_SETRANGE, wParam, lParam); case DTM_SETFORMATA: - return DATETIME_SetFormat (hwnd, wParam, lParam); + return DATETIME_SetFormatA (infoPtr, (LPCSTR)lParam); case DTM_SETFORMATW: - return DATETIME_SetFormatW (hwnd, wParam, lParam); - - case DTM_SETMCCOLOR: - return DATETIME_SetMonthCalColor (hwnd, wParam, lParam); - - case DTM_GETMCCOLOR: - return DATETIME_GetMonthCalColor (hwnd, wParam); + return DATETIME_SetFormatW (infoPtr, (LPCWSTR)lParam); case DTM_GETMONTHCAL: - return DATETIME_GetMonthCal (hwnd); + return (LRESULT)infoPtr->hMonthCal; + + case DTM_SETMCCOLOR: + return SendMessageW (infoPtr->hMonthCal, MCM_SETCOLOR, wParam, lParam); + + case DTM_GETMCCOLOR: + return SendMessageW (infoPtr->hMonthCal, MCM_GETCOLOR, wParam, 0); case DTM_SETMCFONT: - return DATETIME_SetMonthCalFont (hwnd, wParam, lParam); + return SendMessageW (infoPtr->hMonthCal, WM_SETFONT, wParam, lParam); case DTM_GETMCFONT: - return DATETIME_GetMonthCalFont (hwnd); - - case WM_PARENTNOTIFY: - return DATETIME_ParentNotify (hwnd, wParam, lParam); + return SendMessageW (infoPtr->hMonthCal, WM_GETFONT, wParam, lParam); case WM_NOTIFY: - return DATETIME_Notify (hwnd, wParam, lParam); + return DATETIME_Notify (infoPtr, (int)wParam, (LPNMHDR)lParam); case WM_GETDLGCODE: return DLGC_WANTARROWS | DLGC_WANTCHARS; case WM_PAINT: - return DATETIME_Paint (hwnd, wParam); + return DATETIME_Paint (infoPtr, (HDC)wParam); case WM_KEYDOWN: - return DATETIME_KeyDown (hwnd, wParam, lParam); + return DATETIME_KeyDown (infoPtr, wParam, lParam); case WM_KILLFOCUS: - return DATETIME_KillFocus (hwnd, wParam, lParam); + return DATETIME_KillFocus (infoPtr, (HWND)wParam); case WM_SETFOCUS: - return DATETIME_SetFocus (hwnd, wParam, lParam); + return DATETIME_SetFocus (infoPtr, (HWND)wParam); case WM_SIZE: - return DATETIME_Size (hwnd, wParam, lParam); + return DATETIME_Size (infoPtr, wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_LBUTTONDOWN: - return DATETIME_LButtonDown (hwnd, wParam, lParam); + return DATETIME_LButtonDown (infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_LBUTTONUP: - return DATETIME_LButtonUp (hwnd, wParam, lParam); + return DATETIME_LButtonUp (infoPtr, (WORD)wParam); case WM_CREATE: - return DATETIME_Create (hwnd, wParam, lParam); + return DATETIME_Create (hwnd, (LPCREATESTRUCTW)lParam); case WM_DESTROY: - return DATETIME_Destroy (hwnd, wParam, lParam); + return DATETIME_Destroy (infoPtr); case WM_COMMAND: - return DATETIME_Command (hwnd, wParam, lParam); + return DATETIME_Command (infoPtr, wParam, lParam); + + case WM_STYLECHANGED: + return DATETIME_StyleChanged(infoPtr, wParam, (LPSTYLESTRUCT)lParam); default: if ((uMsg >= WM_USER) && (uMsg < WM_APP)) ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); - return DefWindowProcA (hwnd, uMsg, wParam, lParam); + return DefWindowProcW (hwnd, uMsg, wParam, lParam); } return 0; } -VOID +void DATETIME_Register (void) { - WNDCLASSA wndClass; + WNDCLASSW wndClass; - TRACE("\n"); - ZeroMemory (&wndClass, sizeof(WNDCLASSA)); + ZeroMemory (&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS; - wndClass.lpfnWndProc = (WNDPROC)DATETIME_WindowProc; + wndClass.lpfnWndProc = DATETIME_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(DATETIME_INFO *); - wndClass.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW); + wndClass.hCursor = LoadCursorW (0, (LPCWSTR)IDC_ARROW); wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wndClass.lpszClassName = DATETIMEPICK_CLASSA; + wndClass.lpszClassName = DATETIMEPICK_CLASSW; - RegisterClassA (&wndClass); + RegisterClassW (&wndClass); } -VOID +void DATETIME_Unregister (void) { - TRACE("\n"); - UnregisterClassA (DATETIMEPICK_CLASSA, NULL); + UnregisterClassW (DATETIMEPICK_CLASSW, NULL); } diff --git a/reactos/lib/comctl32/flatsb.c b/reactos/lib/comctl32/flatsb.c index a7a1f0063f2..cd15e3e1e5a 100644 --- a/reactos/lib/comctl32/flatsb.c +++ b/reactos/lib/comctl32/flatsb.c @@ -274,7 +274,7 @@ FLATSB_Register (void) ZeroMemory (&wndClass, sizeof(WNDCLASSA)); wndClass.style = CS_GLOBALCLASS; - wndClass.lpfnWndProc = (WNDPROC)FlatSB_WindowProc; + wndClass.lpfnWndProc = FlatSB_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(FLATSB_INFO *); wndClass.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW); diff --git a/reactos/lib/comctl32/header.c b/reactos/lib/comctl32/header.c index cb4ec0b9757..743725c7609 100644 --- a/reactos/lib/comctl32/header.c +++ b/reactos/lib/comctl32/header.c @@ -1842,7 +1842,7 @@ HEADER_Register (void) ZeroMemory (&wndClass, sizeof(WNDCLASSA)); wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; - wndClass.lpfnWndProc = (WNDPROC)HEADER_WindowProc; + wndClass.lpfnWndProc = HEADER_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(HEADER_INFO *); wndClass.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW); diff --git a/reactos/lib/comctl32/hotkey.c b/reactos/lib/comctl32/hotkey.c index 6be4747c797..aeb39c4d614 100644 --- a/reactos/lib/comctl32/hotkey.c +++ b/reactos/lib/comctl32/hotkey.c @@ -57,10 +57,8 @@ typedef struct tagHOTKEY_INFO WCHAR strNone[15]; /* hope its long enough ... */ } HOTKEY_INFO; -#define HOTKEY_GetInfoPtr(hwnd) ((HOTKEY_INFO *)GetWindowLongPtrA (hwnd, 0)) - static const WCHAR HOTKEY_plussep[] = { ' ', '+', ' ' }; -static LRESULT HOTKEY_SetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam); +static LRESULT HOTKEY_SetFont (HOTKEY_INFO *infoPtr, HFONT hFont, BOOL redraw); #define IsOnlySet(flags) (infoPtr->CurrMod == (flags)) @@ -94,7 +92,7 @@ HOTKEY_IsCombInv(HOTKEY_INFO *infoPtr) #undef IsOnlySet static void -HOTKEY_DrawHotKey(HOTKEY_INFO *infoPtr, LPCWSTR KeyName, WORD NameLen, HDC hdc) +HOTKEY_DrawHotKey(HOTKEY_INFO *infoPtr, HDC hdc, LPCWSTR KeyName, WORD NameLen) { SIZE TextSize; INT nXStart, nYStart; @@ -142,7 +140,7 @@ HOTKEY_Refresh(HOTKEY_INFO *infoPtr, HDC hdc) TRACE("(infoPtr=%p hdc=%p)\n", infoPtr, hdc); if(!infoPtr->CurrMod && !infoPtr->HotKey) { - HOTKEY_DrawHotKey (infoPtr, infoPtr->strNone, 4, hdc); + HOTKEY_DrawHotKey (infoPtr, hdc, infoPtr->strNone, 4); return; } @@ -182,7 +180,7 @@ HOTKEY_Refresh(HOTKEY_INFO *infoPtr, HDC hdc) else KeyName[NameLen] = 0; - HOTKEY_DrawHotKey (infoPtr, KeyName, NameLen, hdc); + HOTKEY_DrawHotKey (infoPtr, hdc, KeyName, NameLen); } static void @@ -207,39 +205,39 @@ HOTKEY_GetHotKey(HOTKEY_INFO *infoPtr) } static void -HOTKEY_SetHotKey(HOTKEY_INFO *infoPtr, WPARAM wParam) +HOTKEY_SetHotKey(HOTKEY_INFO *infoPtr, WORD hotKey) { - infoPtr->HotKey = (WORD)wParam; + infoPtr->HotKey = hotKey; infoPtr->ScanCode = MAKELPARAM(0, MapVirtualKeyW(LOBYTE(infoPtr->HotKey), 0)); - TRACE("(infoPtr=%p wParam=%x) Modifiers: 0x%x, Virtual Key: %d\n", infoPtr, - wParam, HIBYTE(infoPtr->HotKey), LOBYTE(infoPtr->HotKey)); + TRACE("(infoPtr=%p hotKey=%x) Modifiers: 0x%x, Virtual Key: %d\n", infoPtr, + hotKey, HIBYTE(infoPtr->HotKey), LOBYTE(infoPtr->HotKey)); InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); } static void -HOTKEY_SetRules(HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_SetRules(HOTKEY_INFO *infoPtr, WORD invComb, WORD invMod) { - infoPtr->InvComb = (WORD)wParam; - infoPtr->InvMod = (WORD)lParam; + infoPtr->InvComb = invComb; + infoPtr->InvMod = invMod; TRACE("(infoPtr=%p) Invalid Modifers: 0x%x, If Invalid: 0x%x\n", infoPtr, infoPtr->InvComb, infoPtr->InvMod); } static LRESULT -HOTKEY_Create (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_Create (HOTKEY_INFO *infoPtr, LPCREATESTRUCTW lpcs) { - infoPtr->hwndNotify = ((LPCREATESTRUCTA)lParam)->hwndParent; + infoPtr->hwndNotify = lpcs->hwndParent; - HOTKEY_SetFont(infoPtr, (WPARAM)GetStockObject(SYSTEM_FONT), 0); + HOTKEY_SetFont(infoPtr, GetStockObject(SYSTEM_FONT), 0); return 0; } static LRESULT -HOTKEY_Destroy (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_Destroy (HOTKEY_INFO *infoPtr) { HWND hwnd = infoPtr->hwndSelf; /* free hotkey info data */ @@ -250,7 +248,7 @@ HOTKEY_Destroy (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) static LRESULT -HOTKEY_EraseBackground (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_EraseBackground (HOTKEY_INFO *infoPtr, HDC hdc) { HBRUSH hBrush, hSolidBrush = NULL; RECT rc; @@ -260,14 +258,14 @@ HOTKEY_EraseBackground (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) else { hBrush = (HBRUSH)SendMessageW(infoPtr->hwndNotify, WM_CTLCOLOREDIT, - wParam, (LPARAM)infoPtr->hwndSelf); + (WPARAM)hdc, (LPARAM)infoPtr->hwndSelf); if (!hBrush) hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrWindow); } GetClientRect (infoPtr->hwndSelf, &rc); - FillRect ((HDC)wParam, &rc, hBrush); + FillRect (hdc, &rc, hBrush); if (hSolidBrush) DeleteObject(hSolidBrush); @@ -277,13 +275,13 @@ HOTKEY_EraseBackground (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) inline static LRESULT -HOTKEY_GetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_GetFont (HOTKEY_INFO *infoPtr) { return (LRESULT)infoPtr->hFont; } static LRESULT -HOTKEY_KeyDown (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_KeyDown (HOTKEY_INFO *infoPtr, DWORD key, DWORD flags) { WORD wOldHotKey; BYTE bOldMod; @@ -291,7 +289,7 @@ HOTKEY_KeyDown (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED) return 0; - TRACE("() Key: %d\n", wParam); + TRACE("() Key: %ld\n", key); wOldHotKey = infoPtr->HotKey; bOldMod = infoPtr->CurrMod; @@ -299,7 +297,7 @@ HOTKEY_KeyDown (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) /* If any key is Pressed, we have to reset the hotkey in the control */ infoPtr->HotKey = 0; - switch (wParam) + switch (key) { case VK_RETURN: case VK_TAB: @@ -308,8 +306,7 @@ HOTKEY_KeyDown (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) case VK_ESCAPE: case VK_BACK: InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); - return DefWindowProcW (infoPtr->hwndSelf, WM_KEYDOWN, wParam, - lParam); + return DefWindowProcW (infoPtr->hwndSelf, WM_KEYDOWN, key, flags); case VK_SHIFT: infoPtr->CurrMod |= HOTKEYF_SHIFT; @@ -323,10 +320,10 @@ HOTKEY_KeyDown (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) default: if(HOTKEY_IsCombInv(infoPtr)) - infoPtr->HotKey = MAKEWORD(wParam, infoPtr->InvMod); + infoPtr->HotKey = MAKEWORD(key, infoPtr->InvMod); else - infoPtr->HotKey = MAKEWORD(wParam, infoPtr->CurrMod); - infoPtr->ScanCode = lParam; + infoPtr->HotKey = MAKEWORD(key, infoPtr->CurrMod); + infoPtr->ScanCode = flags; break; } @@ -345,18 +342,18 @@ HOTKEY_KeyDown (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) static LRESULT -HOTKEY_KeyUp (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_KeyUp (HOTKEY_INFO *infoPtr, DWORD key, DWORD flags) { BYTE bOldMod; if (GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED) return 0; - TRACE("() Key: %d\n", wParam); + TRACE("() Key: %ld\n", key); bOldMod = infoPtr->CurrMod; - switch (wParam) + switch (key) { case VK_SHIFT: infoPtr->CurrMod &= ~HOTKEYF_SHIFT; @@ -386,7 +383,7 @@ HOTKEY_KeyUp (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) static LRESULT -HOTKEY_KillFocus (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_KillFocus (HOTKEY_INFO *infoPtr, HWND receiveFocus) { infoPtr->bFocus = FALSE; DestroyCaret (); @@ -396,7 +393,7 @@ HOTKEY_KillFocus (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) static LRESULT -HOTKEY_LButtonDown (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_LButtonDown (HOTKEY_INFO *infoPtr) { if (!(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & WS_DISABLED)) SetFocus (infoPtr->hwndSelf); @@ -406,7 +403,7 @@ HOTKEY_LButtonDown (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) inline static LRESULT -HOTKEY_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) +HOTKEY_NCCreate (HWND hwnd, LPCREATESTRUCTW lpcs) { HOTKEY_INFO *infoPtr; DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE); @@ -423,11 +420,11 @@ HOTKEY_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->hwndSelf = hwnd; LoadStringW(COMCTL32_hModule, HKY_NONE, infoPtr->strNone, 15); - return DefWindowProcW (infoPtr->hwndSelf, WM_NCCREATE, wParam, lParam); + return DefWindowProcW (infoPtr->hwndSelf, WM_NCCREATE, 0, (LPARAM)lpcs); } static LRESULT -HOTKEY_SetFocus (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_SetFocus (HOTKEY_INFO *infoPtr, HWND lostFocus) { infoPtr->bFocus = TRUE; @@ -440,13 +437,13 @@ HOTKEY_SetFocus (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) static LRESULT -HOTKEY_SetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +HOTKEY_SetFont (HOTKEY_INFO *infoPtr, HFONT hFont, BOOL redraw) { TEXTMETRICW tm; HDC hdc; HFONT hOldFont = 0; - infoPtr->hFont = (HFONT)wParam; + infoPtr->hFont = hFont; hdc = GetDC (infoPtr->hwndSelf); if (infoPtr->hFont) @@ -459,7 +456,7 @@ HOTKEY_SetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) SelectObject (hdc, hOldFont); ReleaseDC (infoPtr->hwndSelf, hdc); - if (LOWORD(lParam)) + if (redraw) InvalidateRect (infoPtr->hwndSelf, NULL, TRUE); return 0; @@ -468,7 +465,7 @@ HOTKEY_SetFont (HOTKEY_INFO *infoPtr, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - HOTKEY_INFO *infoPtr = HOTKEY_GetInfoPtr (hwnd); + HOTKEY_INFO *infoPtr = (HOTKEY_INFO *)GetWindowLongPtrW (hwnd, 0); TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam); if (!infoPtr && (uMsg != WM_NCCREATE)) return DefWindowProcW (hwnd, uMsg, wParam, lParam); @@ -477,10 +474,10 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case HKM_GETHOTKEY: return HOTKEY_GetHotKey (infoPtr); case HKM_SETHOTKEY: - HOTKEY_SetHotKey (infoPtr, wParam); + HOTKEY_SetHotKey (infoPtr, (WORD)wParam); break; case HKM_SETRULES: - HOTKEY_SetRules (infoPtr, wParam, lParam); + HOTKEY_SetRules (infoPtr, (WORD)wParam, (WORD)lParam); break; case WM_CHAR: @@ -488,19 +485,19 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return HOTKEY_KeyDown (infoPtr, MapVirtualKeyW(LOBYTE(HIWORD(lParam)), 1), lParam); case WM_CREATE: - return HOTKEY_Create (infoPtr, wParam, lParam); + return HOTKEY_Create (infoPtr, (LPCREATESTRUCTW)lParam); case WM_DESTROY: - return HOTKEY_Destroy (infoPtr, wParam, lParam); + return HOTKEY_Destroy (infoPtr); case WM_ERASEBKGND: - return HOTKEY_EraseBackground (infoPtr, wParam, lParam); + return HOTKEY_EraseBackground (infoPtr, (HDC)wParam); case WM_GETDLGCODE: return DLGC_WANTCHARS | DLGC_WANTARROWS; case WM_GETFONT: - return HOTKEY_GetFont (infoPtr, wParam, lParam); + return HOTKEY_GetFont (infoPtr); case WM_KEYDOWN: case WM_SYSKEYDOWN: @@ -511,23 +508,23 @@ HOTKEY_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return HOTKEY_KeyUp (infoPtr, wParam, lParam); case WM_KILLFOCUS: - return HOTKEY_KillFocus (infoPtr, wParam, lParam); + return HOTKEY_KillFocus (infoPtr, (HWND)wParam); case WM_LBUTTONDOWN: - return HOTKEY_LButtonDown (infoPtr, wParam, lParam); + return HOTKEY_LButtonDown (infoPtr); case WM_NCCREATE: - return HOTKEY_NCCreate (hwnd, wParam, lParam); + return HOTKEY_NCCreate (hwnd, (LPCREATESTRUCTW)lParam); case WM_PAINT: HOTKEY_Paint(infoPtr, (HDC)wParam); return 0; case WM_SETFOCUS: - return HOTKEY_SetFocus (infoPtr, wParam, lParam); + return HOTKEY_SetFocus (infoPtr, (HWND)wParam); case WM_SETFONT: - return HOTKEY_SetFont (infoPtr, wParam, lParam); + return HOTKEY_SetFont (infoPtr, (HFONT)wParam, LOWORD(lParam)); default: if ((uMsg >= WM_USER) && (uMsg < WM_APP)) diff --git a/reactos/lib/comctl32/imagelist.c b/reactos/lib/comctl32/imagelist.c index 6eb2a99ab9b..b586c7a574c 100644 --- a/reactos/lib/comctl32/imagelist.c +++ b/reactos/lib/comctl32/imagelist.c @@ -2731,6 +2731,7 @@ _write_bitmap(HBITMAP hBitmap, LPSTREAM pstm, int cx, int cy) failed: ReleaseDC(0, xdc); LocalFree((HLOCAL)lpBitsOrg); + LocalFree((HLOCAL)data); return result; } diff --git a/reactos/lib/comctl32/ipaddress.c b/reactos/lib/comctl32/ipaddress.c index 7f754e56990..3a2abf6ac3d 100644 --- a/reactos/lib/comctl32/ipaddress.c +++ b/reactos/lib/comctl32/ipaddress.c @@ -65,15 +65,14 @@ typedef struct IPPART_INFO Part[4]; } IPADDRESS_INFO; +static const WCHAR IP_SUBCLASS_PROP[] = + { 'C', 'C', 'I', 'P', '3', '2', 'S', 'u', 'b', 'c', 'l', 'a', 's', 's', 'I', 'n', 'f', 'o', 0 }; + #define POS_DEFAULT 0 #define POS_LEFT 1 #define POS_RIGHT 2 #define POS_SELALL 3 -#define IP_SUBCLASS_PROP "CCIP32SubclassInfo" -#define IPADDRESS_GetInfoPtr(hwnd) ((IPADDRESS_INFO *)GetWindowLongPtrW (hwnd, 0)) - - static LRESULT CALLBACK IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam); @@ -125,6 +124,7 @@ static int IPADDRESS_GetPartIndex(IPADDRESS_INFO *infoPtr, HWND hwnd) static LRESULT IPADDRESS_Draw (IPADDRESS_INFO *infoPtr, HDC hdc) { + static const WCHAR dotW[] = { '.', 0 }; RECT rect, rcPart; POINT pt; int i; @@ -143,7 +143,7 @@ static LRESULT IPADDRESS_Draw (IPADDRESS_INFO *infoPtr, HDC hdc) pt.x = rcPart.left; ScreenToClient(infoPtr->Self, &pt); rect.right = pt.x; - DrawTextA(hdc, ".", 1, &rect, DT_SINGLELINE | DT_CENTER | DT_BOTTOM); + DrawTextW(hdc, dotW, 1, &rect, DT_SINGLELINE | DT_CENTER | DT_BOTTOM); } return 0; @@ -152,10 +152,10 @@ static LRESULT IPADDRESS_Draw (IPADDRESS_INFO *infoPtr, HDC hdc) static LRESULT IPADDRESS_Create (HWND hwnd, LPCREATESTRUCTA lpCreate) { + static const WCHAR EDIT[] = { 'E', 'd', 'i', 't', 0 }; IPADDRESS_INFO *infoPtr; RECT rcClient, edit; int i, fieldsize; - static const WCHAR EDIT[] = { 'E', 'd', 'i', 't', 0 }; TRACE("\n"); @@ -188,7 +188,7 @@ static LRESULT IPADDRESS_Create (HWND hwnd, LPCREATESTRUCTA lpCreate) edit.left, edit.top, edit.right - edit.left, edit.bottom - edit.top, hwnd, (HMENU) 1, (HINSTANCE)GetWindowLongPtrW(hwnd, GWLP_HINSTANCE), NULL); - SetPropA(part->EditHwnd, IP_SUBCLASS_PROP, hwnd); + SetPropW(part->EditHwnd, IP_SUBCLASS_PROP, hwnd); part->OrigProc = (WNDPROC) SetWindowLongPtrW (part->EditHwnd, GWLP_WNDPROC, (DWORD_PTR)IPADDRESS_SubclassProc); @@ -419,8 +419,8 @@ static BOOL IPADDRESS_GotoNextField (IPADDRESS_INFO *infoPtr, int cur, int sel) LRESULT CALLBACK IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - HWND Self = (HWND)GetPropA (hwnd, IP_SUBCLASS_PROP); - IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (Self); + HWND Self = (HWND)GetPropW (hwnd, IP_SUBCLASS_PROP); + IPADDRESS_INFO *infoPtr = (IPADDRESS_INFO *)GetWindowLongPtrW (Self, 0); CHAR c = (CHAR)wParam; INT index, len = 0, startsel, endsel; IPPART_INFO *part; @@ -502,7 +502,7 @@ IPADDRESS_SubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI IPADDRESS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - IPADDRESS_INFO *infoPtr = IPADDRESS_GetInfoPtr (hwnd); + IPADDRESS_INFO *infoPtr = (IPADDRESS_INFO *)GetWindowLongPtrW (hwnd, 0); TRACE("(hwnd=%p msg=0x%x wparam=0x%x lparam=0x%lx)\n", hwnd, uMsg, wParam, lParam); diff --git a/reactos/lib/comctl32/listview.c b/reactos/lib/comctl32/listview.c index 69f8dea59cc..64532dd8577 100644 --- a/reactos/lib/comctl32/listview.c +++ b/reactos/lib/comctl32/listview.c @@ -348,7 +348,7 @@ typedef struct tagLISTVIEW_INFO /* Standard DrawText flags */ #define LV_ML_DT_FLAGS (DT_TOP | DT_NOPREFIX | DT_EDITCONTROL | DT_CENTER | DT_WORDBREAK | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS) #define LV_FL_DT_FLAGS (DT_TOP | DT_NOPREFIX | DT_EDITCONTROL | DT_CENTER | DT_WORDBREAK | DT_NOCLIP) -#define LV_SL_DT_FLAGS (DT_VCENTER | DT_EDITCONTROL | DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS) +#define LV_SL_DT_FLAGS (DT_VCENTER | DT_NOPREFIX | DT_EDITCONTROL | DT_SINGLELINE | DT_WORD_ELLIPSIS | DT_END_ELLIPSIS) /* The time in milliseconds to reset the search in the list */ #define KEY_DELAY 450 @@ -819,10 +819,8 @@ static int get_ansi_notification(INT unicodeNotificationCode) } /* - With testing on Windows 2000 it looks like the notify format - has nothing to do with this message. It ALWAYS seems to be - in ansi format. - + Send notification. depends on dispinfoW having same + structure as dispinfoA. infoPtr : listview struct notificationCode : *Unicode* notification code pdi : dispinfo structure (can be unicode or ansi) @@ -831,32 +829,40 @@ static int get_ansi_notification(INT unicodeNotificationCode) static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNMLVDISPINFOW pdi, BOOL isW) { BOOL bResult = FALSE; - BOOL convertToAnsi = FALSE; - INT cchTempBufMax = 0, savCchTextMax = 0; + BOOL convertToAnsi = FALSE, convertToUnicode = FALSE; + INT cchTempBufMax = 0, savCchTextMax = 0, realNotifCode; LPWSTR pszTempBuf = NULL, savPszText = NULL; if ((pdi->item.mask & LVIF_TEXT) && is_textT(pdi->item.pszText, isW)) - convertToAnsi = isW; + { + convertToAnsi = (isW && infoPtr->notifyFormat == NFR_ANSI); + convertToUnicode = (!isW && infoPtr->notifyFormat == NFR_UNICODE); + } - if (convertToAnsi) + if (convertToAnsi || convertToUnicode) { if (notificationCode != LVN_GETDISPINFOW) - { - cchTempBufMax = WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, - -1, NULL, 0, NULL, NULL); - } - else - { - cchTempBufMax = pdi->item.cchTextMax; - *pdi->item.pszText = 0; /* make sure we don't process garbage */ + { + cchTempBufMax = convertToUnicode ? + MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, NULL, 0): + WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, NULL, 0, NULL, NULL); } + else + { + cchTempBufMax = pdi->item.cchTextMax; + *pdi->item.pszText = 0; /* make sure we don't process garbage */ + } - pszTempBuf = HeapAlloc(GetProcessHeap(), 0, sizeof(CHAR) * - cchTempBufMax); + pszTempBuf = HeapAlloc(GetProcessHeap(), 0, + (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax); if (!pszTempBuf) return FALSE; - WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) - pszTempBuf, cchTempBufMax, NULL, NULL); + if (convertToUnicode) + MultiByteToWideChar(CP_ACP, 0, (LPCSTR)pdi->item.pszText, -1, + pszTempBuf, cchTempBufMax); + else + WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) pszTempBuf, + cchTempBufMax, NULL, NULL); savCchTextMax = pdi->item.cchTextMax; savPszText = pdi->item.pszText; @@ -864,16 +870,21 @@ static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNML pdi->item.cchTextMax = cchTempBufMax; } - TRACE(" pdi->item=%s\n", debuglvitem_t(&pdi->item, infoPtr->notifyFormat != - NFR_ANSI)); + if (infoPtr->notifyFormat == NFR_ANSI) + realNotifCode = get_ansi_notification(notificationCode); + else + realNotifCode = notificationCode; + TRACE(" pdi->item=%s\n", debuglvitem_t(&pdi->item, infoPtr->notifyFormat != NFR_ANSI)); + bResult = notify_hdr(infoPtr, realNotifCode, &pdi->hdr); - bResult = notify_hdr(infoPtr, get_ansi_notification(notificationCode), - (LPNMHDR)pdi); - - if (convertToAnsi) + if (convertToUnicode || convertToAnsi) { - MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1, - savPszText, savCchTextMax); + if (convertToUnicode) /* note : pointer can be changed by app ! */ + WideCharToMultiByte(CP_ACP, 0, pdi->item.pszText, -1, (LPSTR) savPszText, + savCchTextMax, NULL, NULL); + else + MultiByteToWideChar(CP_ACP, 0, (LPSTR) pdi->item.pszText, -1, + savPszText, savCchTextMax); pdi->item.pszText = savPszText; /* restores our buffer */ pdi->item.cchTextMax = savCchTextMax; HeapFree(GetProcessHeap(), 0, pszTempBuf); @@ -3131,7 +3142,7 @@ static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *infoPtr, INT nItem) * PARAMETER(S): * [I] infoPtr : valid pointer to the listview structure * [I] fwKeys : key indicator - * [I] pts : mouse position + * [I] x,y : mouse position * * RETURN: * 0 if the message was processed, non-zero if there was an error @@ -3141,7 +3152,7 @@ static BOOL LISTVIEW_KeySelection(LISTVIEW_INFO *infoPtr, INT nItem) * over the item for a certain period of time. * */ -static LRESULT LISTVIEW_MouseHover(LISTVIEW_INFO *infoPtr, WORD fwKyes, POINTS pts) +static LRESULT LISTVIEW_MouseHover(LISTVIEW_INFO *infoPtr, WORD fwKyes, INT x, INT y) { if(infoPtr->dwLvExStyle & LVS_EX_TRACKSELECT) /* FIXME: select the item!!! */ @@ -3157,12 +3168,12 @@ static LRESULT LISTVIEW_MouseHover(LISTVIEW_INFO *infoPtr, WORD fwKyes, POINTS p * PARAMETER(S): * [I] infoPtr : valid pointer to the listview structure * [I] fwKeys : key indicator - * [I] pts : mouse position + * [I] x,y : mouse position * * RETURN: * 0 if the message is processed, non-zero if there was an error */ -static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, POINTS pts) +static LRESULT LISTVIEW_MouseMove(LISTVIEW_INFO *infoPtr, WORD fwKeys, INT x, INT y) { TRACKMOUSEEVENT trackinfo; @@ -7951,22 +7962,22 @@ static LRESULT LISTVIEW_TrackMouse(LISTVIEW_INFO *infoPtr, POINT pt) * PARAMETER(S): * [I] infoPtr : valid pointer to the listview structure * [I] wKey : key flag - * [I] pts : mouse coordinate + * [I] x,y : mouse coordinate * * RETURN: * Zero */ -static LRESULT LISTVIEW_LButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts) +static LRESULT LISTVIEW_LButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y) { LVHITTESTINFO htInfo; - TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, pts.x, pts.y); + TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, x, y); /* send NM_RELEASEDCAPTURE notification */ notify(infoPtr, NM_RELEASEDCAPTURE); - htInfo.pt.x = pts.x; - htInfo.pt.y = pts.y; + htInfo.pt.x = x; + htInfo.pt.y = y; /* send NM_DBLCLK notification */ LISTVIEW_HitTest(infoPtr, &htInfo, TRUE, FALSE); @@ -7985,19 +7996,19 @@ static LRESULT LISTVIEW_LButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS * PARAMETER(S): * [I] infoPtr : valid pointer to the listview structure * [I] wKey : key flag - * [I] pts : mouse coordinate + * [I] x,y : mouse coordinate * * RETURN: * Zero */ -static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts) +static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y) { LVHITTESTINFO lvHitTestInfo; static BOOL bGroupSelect = TRUE; - POINT pt = { pts.x, pts.y }; + POINT pt = { x, y }; INT nItem; - TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, pts.x, pts.y); + TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, x, y); /* send NM_RELEASEDCAPTURE notification */ notify(infoPtr, NM_RELEASEDCAPTURE); @@ -8007,8 +8018,8 @@ static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pt /* set left button down flag */ infoPtr->bLButtonDown = TRUE; - lvHitTestInfo.pt.x = pts.x; - lvHitTestInfo.pt.y = pts.y; + lvHitTestInfo.pt.x = x; + lvHitTestInfo.pt.y = y; nItem = LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE); TRACE("at %s, nItem=%d\n", debugpoint(&pt), nItem); @@ -8112,21 +8123,21 @@ static LRESULT LISTVIEW_LButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pt * PARAMETER(S): * [I] infoPtr : valid pointer to the listview structure * [I] wKey : key flag - * [I] pts : mouse coordinate + * [I] x,y : mouse coordinate * * RETURN: * Zero */ -static LRESULT LISTVIEW_LButtonUp(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts) +static LRESULT LISTVIEW_LButtonUp(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y) { LVHITTESTINFO lvHitTestInfo; - TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, pts.x, pts.y); + TRACE("(key=%hu, X=%hu, Y=%hu)\n", wKey, x, y); if (!infoPtr->bLButtonDown) return 0; - lvHitTestInfo.pt.x = pts.x; - lvHitTestInfo.pt.y = pts.y; + lvHitTestInfo.pt.x = x; + lvHitTestInfo.pt.y = y; /* send NM_CLICK notification */ LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, FALSE); @@ -8344,23 +8355,23 @@ static LRESULT LISTVIEW_Paint(LISTVIEW_INFO *infoPtr, HDC hdc) * PARAMETER(S): * [I] infoPtr : valid pointer to the listview structure * [I] wKey : key flag - * [I] pts : mouse coordinate + * [I] x,y : mouse coordinate * * RETURN: * Zero */ -static LRESULT LISTVIEW_RButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts) +static LRESULT LISTVIEW_RButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y) { LVHITTESTINFO lvHitTestInfo; - TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, pts.x, pts.y); + TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, x, y); /* send NM_RELEASEDCAPTURE notification */ notify(infoPtr, NM_RELEASEDCAPTURE); /* send NM_RDBLCLK notification */ - lvHitTestInfo.pt.x = pts.x; - lvHitTestInfo.pt.y = pts.y; + lvHitTestInfo.pt.x = x; + lvHitTestInfo.pt.y = y; LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, FALSE); notify_click(infoPtr, NM_RDBLCLK, &lvHitTestInfo); @@ -8374,17 +8385,17 @@ static LRESULT LISTVIEW_RButtonDblClk(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS * PARAMETER(S): * [I] infoPtr : valid pointer to the listview structure * [I] wKey : key flag - * [I] pts : mouse coordinate + * [I] x,y : mouse coordinate * * RETURN: * Zero */ -static LRESULT LISTVIEW_RButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts) +static LRESULT LISTVIEW_RButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y) { LVHITTESTINFO lvHitTestInfo; INT nItem; - TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, pts.x, pts.y); + TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, x, y); /* send NM_RELEASEDCAPTURE notification */ notify(infoPtr, NM_RELEASEDCAPTURE); @@ -8396,8 +8407,8 @@ static LRESULT LISTVIEW_RButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pt infoPtr->bRButtonDown = TRUE; /* determine the index of the selected item */ - lvHitTestInfo.pt.x = pts.x; - lvHitTestInfo.pt.y = pts.y; + lvHitTestInfo.pt.x = x; + lvHitTestInfo.pt.y = y; nItem = LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, TRUE); if ((nItem >= 0) && (nItem < infoPtr->nItemCount)) @@ -8422,17 +8433,17 @@ static LRESULT LISTVIEW_RButtonDown(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pt * PARAMETER(S): * [I] infoPtr : valid pointer to the listview structure * [I] wKey : key flag - * [I] pts : mouse coordinate + * [I] x,y : mouse coordinate * * RETURN: * Zero */ -static LRESULT LISTVIEW_RButtonUp(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts) +static LRESULT LISTVIEW_RButtonUp(LISTVIEW_INFO *infoPtr, WORD wKey, INT x, INT y) { LVHITTESTINFO lvHitTestInfo; POINT pt; - TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, pts.x, pts.y); + TRACE("(key=%hu,X=%hu,Y=%hu)\n", wKey, x, y); if (!infoPtr->bRButtonDown) return 0; @@ -8440,8 +8451,8 @@ static LRESULT LISTVIEW_RButtonUp(LISTVIEW_INFO *infoPtr, WORD wKey, POINTS pts) infoPtr->bRButtonDown = FALSE; /* Send NM_RClICK notification */ - lvHitTestInfo.pt.x = pts.x; - lvHitTestInfo.pt.y = pts.y; + lvHitTestInfo.pt.x = x; + lvHitTestInfo.pt.y = y; LISTVIEW_HitTest(infoPtr, &lvHitTestInfo, TRUE, FALSE); notify_click(infoPtr, NM_RCLICK, &lvHitTestInfo); @@ -9159,19 +9170,19 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return LISTVIEW_KillFocus(infoPtr); case WM_LBUTTONDBLCLK: - return LISTVIEW_LButtonDblClk(infoPtr, (WORD)wParam, MAKEPOINTS(lParam)); + return LISTVIEW_LButtonDblClk(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_LBUTTONDOWN: - return LISTVIEW_LButtonDown(infoPtr, (WORD)wParam, MAKEPOINTS(lParam)); + return LISTVIEW_LButtonDown(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_LBUTTONUP: - return LISTVIEW_LButtonUp(infoPtr, (WORD)wParam, MAKEPOINTS(lParam)); + return LISTVIEW_LButtonUp(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_MOUSEMOVE: - return LISTVIEW_MouseMove (infoPtr, (WORD)wParam, MAKEPOINTS(lParam)); + return LISTVIEW_MouseMove (infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_MOUSEHOVER: - return LISTVIEW_MouseHover(infoPtr, (WORD)wParam, MAKEPOINTS(lParam)); + return LISTVIEW_MouseHover(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_NCDESTROY: return LISTVIEW_NCDestroy(infoPtr); @@ -9188,13 +9199,13 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return LISTVIEW_Paint(infoPtr, (HDC)wParam); case WM_RBUTTONDBLCLK: - return LISTVIEW_RButtonDblClk(infoPtr, (WORD)wParam, MAKEPOINTS(lParam)); + return LISTVIEW_RButtonDblClk(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_RBUTTONDOWN: - return LISTVIEW_RButtonDown(infoPtr, (WORD)wParam, MAKEPOINTS(lParam)); + return LISTVIEW_RButtonDown(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_RBUTTONUP: - return LISTVIEW_RButtonUp(infoPtr, (WORD)wParam, MAKEPOINTS(lParam)); + return LISTVIEW_RButtonUp(infoPtr, (WORD)wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_SETCURSOR: if(LISTVIEW_SetCursor(infoPtr, (HWND)wParam, LOWORD(lParam), HIWORD(lParam))) @@ -9270,7 +9281,7 @@ void LISTVIEW_Register(void) ZeroMemory(&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; - wndClass.lpfnWndProc = (WNDPROC)LISTVIEW_WindowProc; + wndClass.lpfnWndProc = LISTVIEW_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(LISTVIEW_INFO *); wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW); diff --git a/reactos/lib/comctl32/monthcal.c b/reactos/lib/comctl32/monthcal.c index 0a56ac4bc2c..f1130aedb3b 100644 --- a/reactos/lib/comctl32/monthcal.c +++ b/reactos/lib/comctl32/monthcal.c @@ -21,13 +21,26 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * NOTE + * + * This code was audited for completeness against the documented features + * of Comctl32.dll version 6.0 on Oct. 20, 2004, by Dimitrie O. Paun. + * + * Unless otherwise noted, we believe this code to be complete, as per + * the specification mentioned above. + * If you discover missing features, or bugs, please note them below. + * * TODO: - * - Notifications. - * - * - * FIXME: handle resources better (doesn't work now); also take care - of internationalization. - * FIXME: keyboard handling. + * -- MCM_[GS]ETUNICODEFORMAT + * -- MONTHCAL_GetMonthRange + * -- Unicodification + * -- handle resources better (doesn't work now); + * -- take care of internationalization. + * -- keyboard handling. + * -- GetRange: At the moment, we copy ranges anyway, regardless of + * infoPtr->rangeValid; a invalid range is simply filled + * with zeros in SetRange. Is this the right behavior? + * -- search for FIXME */ #include @@ -59,6 +72,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(monthcal); typedef struct { + HWND hwndSelf; COLORREF bk; COLORREF txt; COLORREF titlebk; @@ -71,8 +85,6 @@ typedef struct int textWidth; int height_increment; int width_increment; - int left_offset; - int top_offset; int firstDayplace; /* place of the first day of the current month */ int delta; /* scroll rate; # of months that the */ /* control moves when user clicks a scroll button */ @@ -93,8 +105,6 @@ typedef struct SYSTEMTIME minDate; SYSTEMTIME maxDate; - RECT rcClient; /* rect for whole client area */ - RECT rcDraw; /* rect for drawable portion of client area */ RECT title; /* rect for the header above the calendar */ RECT titlebtnnext; /* the `next month' button in the header */ RECT titlebtnprev; /* the `prev month' button in the header */ @@ -195,12 +205,15 @@ static int MONTHCAL_CalcDayFromPos(MONTHCAL_INFO *infoPtr, int x, int y, int *daypos,int *weekpos) { int retval, firstDay; + RECT rcClient; + + GetClientRect(infoPtr->hwndSelf, &rcClient); /* if the point is outside the x bounds of the window put it at the boundry */ - if(x > infoPtr->rcClient.right) { - x = infoPtr->rcClient.right ; - } + if (x > rcClient.right) + x = rcClient.right; + *daypos = (x - infoPtr->days.left ) / infoPtr->width_increment; *weekpos = (y - infoPtr->days.top ) / infoPtr->height_increment; @@ -266,8 +279,7 @@ static inline void MONTHCAL_CalcPosFromDay(MONTHCAL_INFO *infoPtr, /* day is the day in the month(1 == 1st of the month) */ /* month is the month value(1 == january, 12 == december) */ -static void MONTHCAL_CircleDay(HDC hdc, MONTHCAL_INFO *infoPtr, int day, -int month) +static void MONTHCAL_CircleDay(MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month) { HPEN hRedPen = CreatePen(PS_SOLID, 2, RGB(255, 0, 0)); HPEN hOldPen2 = SelectObject(hdc, hRedPen); @@ -318,7 +330,7 @@ int month) } -static void MONTHCAL_DrawDay(HDC hdc, MONTHCAL_INFO *infoPtr, int day, int month, +static void MONTHCAL_DrawDay(MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month, int x, int y, int bold) { char buf[10]; @@ -391,12 +403,8 @@ static void MONTHCAL_DrawDay(HDC hdc, MONTHCAL_INFO *infoPtr, int day, int month } -/* CHECKME: For `todays date', do we need to check the locale?*/ -static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) +static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, PAINTSTRUCT* ps) { - MONTHCAL_INFO *infoPtr=MONTHCAL_GetInfoPtr(hwnd); - RECT *rcClient=&infoPtr->rcClient; - RECT *rcDraw=&infoPtr->rcDraw; RECT *title=&infoPtr->title; RECT *prev=&infoPtr->titlebtnprev; RECT *next=&infoPtr->titlebtnnext; @@ -410,12 +418,11 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) SIZE size; HBRUSH hbr; HFONT currentFont; - /* LOGFONTA logFont; */ char buf[20]; char buf1[20]; char buf2[32]; COLORREF oldTextColor, oldBkColor; - DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); + DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); RECT rcTemp; RECT rcDay; /* used in MONTHCAL_CalcDayRect() */ SYSTEMTIME localtime; @@ -423,10 +430,9 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) oldTextColor = SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); - /* fill background */ hbr = CreateSolidBrush (infoPtr->bk); - FillRect(hdc, rcClient, hbr); + FillRect(hdc, &ps->rcPaint, hbr); DeleteObject(hbr); /* draw header */ @@ -507,8 +513,7 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) /* draw line under day abbreviatons */ MoveToEx(hdc, infoPtr->days.left + 3, title->bottom + textHeight + 1, NULL); - - LineTo(hdc, rcDraw->right - 3, title->bottom + textHeight + 1); + LineTo(hdc, infoPtr->days.right - 3, title->bottom + textHeight + 1); prevMonth = infoPtr->currentMonth - 1; if(prevMonth == 0) /* if currentMonth is january(1) prevMonth is */ @@ -555,7 +560,7 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, 0); if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) { - MONTHCAL_DrawDay(hdc, infoPtr, day, prevMonth, i, 0, + MONTHCAL_DrawDay(infoPtr, hdc, day, prevMonth, i, 0, infoPtr->monthdayState[m] & mask); } @@ -579,14 +584,14 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) { - MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, 0, + MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->currentMonth, i, 0, infoPtr->monthdayState[m] & mask); if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) && (day==infoPtr->todaysDate.wDay) && (infoPtr->currentYear == infoPtr->todaysDate.wYear)) { if(!(dwStyle & MCS_NOTODAYCIRCLE)) - MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth); + MONTHCAL_CircleDay(infoPtr, hdc, day, infoPtr->currentMonth); } } @@ -601,14 +606,14 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j); if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) { - MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth, i, j, + MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->currentMonth, i, j, infoPtr->monthdayState[m] & mask); if((infoPtr->currentMonth==infoPtr->todaysDate.wMonth) && (day==infoPtr->todaysDate.wDay) && (infoPtr->currentYear == infoPtr->todaysDate.wYear)) if(!(dwStyle & MCS_NOTODAYCIRCLE)) - MONTHCAL_CircleDay(hdc, infoPtr, day, infoPtr->currentMonth); + MONTHCAL_CircleDay(infoPtr, hdc, day, infoPtr->currentMonth); } mask<<=1; day++; @@ -630,7 +635,7 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) MONTHCAL_CalcDayRect(infoPtr, &rcDay, i, j); if(IntersectRect(&rcTemp, &(ps->rcPaint), &rcDay)) { - MONTHCAL_DrawDay(hdc, infoPtr, day, infoPtr->currentMonth + 1, i, j, + MONTHCAL_DrawDay(infoPtr, hdc, day, infoPtr->currentMonth + 1, i, j, infoPtr->monthdayState[m] & mask); } @@ -652,7 +657,7 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) int offset = 0; if(!(dwStyle & MCS_NOTODAYCIRCLE)) { /*day is the number of days from nextmonth we put on the calendar */ - MONTHCAL_CircleDay(hdc, infoPtr, + MONTHCAL_CircleDay(infoPtr, hdc, day+MONTHCAL_MonthLength(infoPtr->currentMonth,infoPtr->currentYear), infoPtr->currentMonth); offset+=textWidth; @@ -765,30 +770,32 @@ static void MONTHCAL_Refresh(HWND hwnd, HDC hdc, PAINTSTRUCT* ps) static LRESULT -MONTHCAL_GetMinReqRect(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_GetMinReqRect(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); LPRECT lpRect = (LPRECT) lParam; - TRACE("%x %lx\n", wParam, lParam); + + TRACE("rect %p\n", lpRect); /* validate parameters */ if((infoPtr==NULL) ||(lpRect == NULL) ) return FALSE; - lpRect->left = infoPtr->rcClient.left; - lpRect->right = infoPtr->rcClient.right; - lpRect->top = infoPtr->rcClient.top; - lpRect->bottom = infoPtr->rcClient.bottom; + lpRect->left = infoPtr->title.left; + lpRect->top = infoPtr->title.top; + lpRect->right = infoPtr->title.right; + lpRect->bottom = infoPtr->todayrect.bottom; + AdjustWindowRect(lpRect, GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE), FALSE); + + TRACE("%s\n", wine_dbgstr_rect(lpRect)); + return TRUE; } static LRESULT -MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_GetColor(MONTHCAL_INFO *infoPtr, WPARAM wParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); - - TRACE("%x %lx\n", wParam, lParam); + TRACE("\n"); switch((int)wParam) { case MCSC_BACKGROUND: @@ -810,12 +817,11 @@ MONTHCAL_GetColor(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_SetColor(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); int prev = -1; - TRACE("%x %lx\n", wParam, lParam); + TRACE("%d: color %08lx\n", wParam, lParam); switch((int)wParam) { case MCSC_BACKGROUND: @@ -844,17 +850,15 @@ MONTHCAL_SetColor(HWND hwnd, WPARAM wParam, LPARAM lParam) break; } - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return prev; } static LRESULT -MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_GetMonthDelta(MONTHCAL_INFO *infoPtr) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); - - TRACE("%x %lx\n", wParam, lParam); + TRACE("\n"); if(infoPtr->delta) return infoPtr->delta; @@ -864,12 +868,11 @@ MONTHCAL_GetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_SetMonthDelta(MONTHCAL_INFO *infoPtr, WPARAM wParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); int prev = infoPtr->delta; - TRACE("%x %lx\n", wParam, lParam); + TRACE("delta %d\n", wParam); infoPtr->delta = (int)wParam; return prev; @@ -877,10 +880,8 @@ MONTHCAL_SetMonthDelta(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_GetFirstDayOfWeek(MONTHCAL_INFO *infoPtr) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); - return infoPtr->firstDay; } @@ -890,14 +891,13 @@ MONTHCAL_GetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam) /* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */ /* FIXME: we need more error checking here */ static LRESULT -MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_SetFirstDayOfWeek(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); int prev = infoPtr->firstDay; char buf[40]; int day; - TRACE("%x %lx\n", wParam, lParam); + TRACE("day %ld\n", lParam); if((lParam >= 0) && (lParam < 7)) { infoPtr->firstDay = (int)lParam; @@ -916,24 +916,18 @@ MONTHCAL_SetFirstDayOfWeek(HWND hwnd, WPARAM wParam, LPARAM lParam) } -/* FIXME: fill this in */ static LRESULT -MONTHCAL_GetMonthRange(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_GetMonthRange(MONTHCAL_INFO *infoPtr) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); - - TRACE("%x %lx\n", wParam, lParam); - FIXME("stub\n"); + TRACE("\n"); return infoPtr->monthRange; } static LRESULT -MONTHCAL_GetMaxTodayWidth(HWND hwnd) +MONTHCAL_GetMaxTodayWidth(MONTHCAL_INFO *infoPtr) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); - return(infoPtr->todayrect.right - infoPtr->todayrect.left); } @@ -945,9 +939,8 @@ MONTHCAL_GetMaxTodayWidth(HWND hwnd) */ static LRESULT -MONTHCAL_SetRange(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_SetRange(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); SYSTEMTIME *lprgSysTimeArray=(SYSTEMTIME *)lParam; int prev; @@ -964,11 +957,11 @@ MONTHCAL_SetRange(HWND hwnd, WPARAM wParam, LPARAM lParam) } if(wParam & GDTR_MIN) { if(MONTHCAL_ValidateTime(lprgSysTimeArray[0])) { - MONTHCAL_CopyTime(&lprgSysTimeArray[0], &infoPtr->maxDate); + MONTHCAL_CopyTime(&lprgSysTimeArray[0], &infoPtr->minDate); infoPtr->rangeValid|=GDTR_MIN; } else { GetSystemTime(&infoPtr->todaysDate); - MONTHCAL_CopyTime(&infoPtr->todaysDate, &infoPtr->maxDate); + MONTHCAL_CopyTime(&infoPtr->todaysDate, &infoPtr->minDate); } } @@ -984,11 +977,6 @@ MONTHCAL_SetRange(HWND hwnd, WPARAM wParam, LPARAM lParam) } -/* CHECKME: At the moment, we copy ranges anyway,regardless of - * infoPtr->rangeValid; a invalid range is simply filled with zeros in - * SetRange. Is this the right behavior? -*/ - static LRESULT MONTHCAL_GetRange(HWND hwnd, WPARAM wParam, LPARAM lParam) { @@ -1007,10 +995,9 @@ MONTHCAL_GetRange(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -MONTHCAL_SetDayState(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_SetDayState(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); int i, iMonths = (int)wParam; MONTHDAYSTATE *dayStates = (LPMONTHDAYSTATE)lParam; @@ -1023,14 +1010,13 @@ MONTHCAL_SetDayState(HWND hwnd, WPARAM wParam, LPARAM lParam) } static LRESULT -MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_GetCurSel(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); SYSTEMTIME *lpSel = (SYSTEMTIME *) lParam; - TRACE("%x %lx\n", wParam, lParam); + TRACE("%lx\n", lParam); if((infoPtr==NULL) ||(lpSel==NULL)) return FALSE; - if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT) return FALSE; + if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) return FALSE; MONTHCAL_CopyTime(&infoPtr->minSel, lpSel); TRACE("%d/%d/%d\n", lpSel->wYear, lpSel->wMonth, lpSel->wDay); @@ -1040,14 +1026,13 @@ MONTHCAL_GetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam) /* FIXME: if the specified date is not visible, make it visible */ /* FIXME: redraw? */ static LRESULT -MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_SetCurSel(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); SYSTEMTIME *lpSel = (SYSTEMTIME *)lParam; - TRACE("%x %lx\n", wParam, lParam); + TRACE("%lx\n", lParam); if((infoPtr==NULL) ||(lpSel==NULL)) return FALSE; - if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT) return FALSE; + if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) return FALSE; infoPtr->currentMonth=lpSel->wMonth; infoPtr->currentYear=lpSel->wYear; @@ -1055,29 +1040,25 @@ MONTHCAL_SetCurSel(HWND hwnd, WPARAM wParam, LPARAM lParam) MONTHCAL_CopyTime(lpSel, &infoPtr->minSel); MONTHCAL_CopyTime(lpSel, &infoPtr->maxSel); - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return TRUE; } static LRESULT -MONTHCAL_GetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_GetMaxSelCount(MONTHCAL_INFO *infoPtr) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); - - TRACE("%x %lx\n", wParam, lParam); return infoPtr->maxSelCount; } static LRESULT -MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_SetMaxSelCount(MONTHCAL_INFO *infoPtr, WPARAM wParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); + TRACE("%x\n", wParam); - TRACE("%x %lx\n", wParam, lParam); - if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT) { + if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) { infoPtr->maxSelCount = wParam; } @@ -1086,18 +1067,17 @@ MONTHCAL_SetMaxSelCount(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_GetSelRange(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); SYSTEMTIME *lprgSysTimeArray = (SYSTEMTIME *) lParam; - TRACE("%x %lx\n", wParam, lParam); + TRACE("%lx\n", lParam); /* validate parameters */ if((infoPtr==NULL) ||(lprgSysTimeArray==NULL)) return FALSE; - if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT) + if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) { MONTHCAL_CopyTime(&infoPtr->maxSel, &lprgSysTimeArray[1]); MONTHCAL_CopyTime(&infoPtr->minSel, &lprgSysTimeArray[0]); @@ -1110,18 +1090,17 @@ MONTHCAL_GetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_SetSelRange(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); SYSTEMTIME *lprgSysTimeArray = (SYSTEMTIME *) lParam; - TRACE("%x %lx\n", wParam, lParam); + TRACE("%lx\n", lParam); /* validate parameters */ if((infoPtr==NULL) ||(lprgSysTimeArray==NULL)) return FALSE; - if(GetWindowLongA( hwnd, GWL_STYLE) & MCS_MULTISELECT) + if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) { MONTHCAL_CopyTime(&lprgSysTimeArray[1], &infoPtr->maxSel); MONTHCAL_CopyTime(&lprgSysTimeArray[0], &infoPtr->minSel); @@ -1134,12 +1113,11 @@ MONTHCAL_SetSelRange(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_GetToday(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); SYSTEMTIME *lpToday = (SYSTEMTIME *) lParam; - TRACE("%x %lx\n", wParam, lParam); + TRACE("%lx\n", lParam); /* validate parameters */ @@ -1150,26 +1128,24 @@ MONTHCAL_GetToday(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -MONTHCAL_SetToday(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_SetToday(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); SYSTEMTIME *lpToday = (SYSTEMTIME *) lParam; - TRACE("%x %lx\n", wParam, lParam); + TRACE("%lx\n", lParam); /* validate parameters */ if((infoPtr==NULL) ||(lpToday==NULL)) return FALSE; MONTHCAL_CopyTime(lpToday, &infoPtr->todaysDate); - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return TRUE; } static LRESULT -MONTHCAL_HitTest(HWND hwnd, LPARAM lParam) +MONTHCAL_HitTest(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); PMCHITTESTINFO lpht = (PMCHITTESTINFO)lParam; UINT x,y; DWORD retval; @@ -1285,9 +1261,9 @@ MONTHCAL_HitTest(HWND hwnd, LPARAM lParam) } -static void MONTHCAL_GoToNextMonth(HWND hwnd, MONTHCAL_INFO *infoPtr) +static void MONTHCAL_GoToNextMonth(MONTHCAL_INFO *infoPtr) { - DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); + DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); TRACE("MONTHCAL_GoToNextMonth\n"); @@ -1301,8 +1277,8 @@ static void MONTHCAL_GoToNextMonth(HWND hwnd, MONTHCAL_INFO *infoPtr) NMDAYSTATE nmds; int i; - nmds.nmhdr.hwndFrom = hwnd; - nmds.nmhdr.idFrom = GetWindowLongPtrW(hwnd, GWLP_ID); + nmds.nmhdr.hwndFrom = infoPtr->hwndSelf; + nmds.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID); nmds.nmhdr.code = MCN_GETDAYSTATE; nmds.cDayState = infoPtr->monthRange; nmds.prgDayState = Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE)); @@ -1315,11 +1291,11 @@ static void MONTHCAL_GoToNextMonth(HWND hwnd, MONTHCAL_INFO *infoPtr) } -static void MONTHCAL_GoToPrevMonth(HWND hwnd, MONTHCAL_INFO *infoPtr) +static void MONTHCAL_GoToPrevMonth(MONTHCAL_INFO *infoPtr) { - DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); + DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); - TRACE("MONTHCAL_GoToPrevMonth\n"); + TRACE("\n"); infoPtr->currentMonth--; if(infoPtr->currentMonth < 1) { @@ -1331,8 +1307,8 @@ static void MONTHCAL_GoToPrevMonth(HWND hwnd, MONTHCAL_INFO *infoPtr) NMDAYSTATE nmds; int i; - nmds.nmhdr.hwndFrom = hwnd; - nmds.nmhdr.idFrom = GetWindowLongPtrW(hwnd, GWLP_ID); + nmds.nmhdr.hwndFrom = infoPtr->hwndSelf; + nmds.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID); nmds.nmhdr.code = MCN_GETDAYSTATE; nmds.cDayState = infoPtr->monthRange; nmds.prgDayState = Alloc @@ -1346,9 +1322,8 @@ static void MONTHCAL_GoToPrevMonth(HWND hwnd, MONTHCAL_INFO *infoPtr) } static LRESULT -MONTHCAL_RButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_RButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); HMENU hMenu; POINT menupoint; char buf[32]; @@ -1362,21 +1337,20 @@ MONTHCAL_RButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) AppendMenuA(hMenu, MF_STRING|MF_ENABLED,1, buf); menupoint.x=(INT)LOWORD(lParam); menupoint.y=(INT)HIWORD(lParam); - ClientToScreen(hwnd, &menupoint); + ClientToScreen(infoPtr->hwndSelf, &menupoint); if( TrackPopupMenu(hMenu,TPM_RIGHTBUTTON| TPM_NONOTIFY|TPM_RETURNCMD, - menupoint.x,menupoint.y,0,hwnd,NULL)) + menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL)) { infoPtr->currentMonth=infoPtr->todaysDate.wMonth; infoPtr->currentYear=infoPtr->todaysDate.wYear; - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); } return 0; } static LRESULT -MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); MCHITTESTINFO ht; DWORD hit; HMENU hMenu; @@ -1384,7 +1358,8 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) char buf[32]; int i; POINT menupoint; - TRACE("%x %lx\n", wParam, lParam); + + TRACE("%lx\n", lParam); if (infoPtr->hWndYearUpDown) { @@ -1401,28 +1376,28 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) } else infoPtr->hWndYearEdit=0; - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); } ht.pt.x = (INT)LOWORD(lParam); ht.pt.y = (INT)HIWORD(lParam); - hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht); + hit = MONTHCAL_HitTest(infoPtr, (LPARAM)&ht); /* FIXME: these flags should be checked by */ /*((hit & MCHT_XXX) == MCHT_XXX) b/c some of the flags are */ /* multi-bit */ if(hit ==MCHT_TITLEBTNNEXT) { - MONTHCAL_GoToNextMonth(hwnd, infoPtr); + MONTHCAL_GoToNextMonth(infoPtr); infoPtr->status = MC_NEXTPRESSED; - SetTimer(hwnd, MC_NEXTMONTHTIMER, MC_NEXTMONTHDELAY, 0); - InvalidateRect(hwnd, NULL, FALSE); + SetTimer(infoPtr->hwndSelf, MC_NEXTMONTHTIMER, MC_NEXTMONTHDELAY, 0); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return TRUE; } if(hit == MCHT_TITLEBTNPREV){ - MONTHCAL_GoToPrevMonth(hwnd, infoPtr); + MONTHCAL_GoToPrevMonth(infoPtr); infoPtr->status = MC_PREVPRESSED; - SetTimer(hwnd, MC_PREVMONTHTIMER, MC_NEXTMONTHDELAY, 0); - InvalidateRect(hwnd, NULL, FALSE); + SetTimer(infoPtr->hwndSelf, MC_PREVMONTHTIMER, MC_NEXTMONTHDELAY, 0); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return TRUE; } @@ -1437,13 +1412,13 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) } menupoint.x=infoPtr->titlemonth.right; menupoint.y=infoPtr->titlemonth.bottom; - ClientToScreen(hwnd, &menupoint); + ClientToScreen(infoPtr->hwndSelf, &menupoint); i= TrackPopupMenu(hMenu,TPM_LEFTALIGN | TPM_NONOTIFY | TPM_RIGHTBUTTON | TPM_RETURNCMD, - menupoint.x,menupoint.y,0,hwnd,NULL); + menupoint.x, menupoint.y, 0, infoPtr->hwndSelf, NULL); if ((i>0) && (i<13)) { infoPtr->currentMonth=i; - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); } } if(hit == MCHT_TITLEYEAR) { @@ -1454,7 +1429,7 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top, infoPtr->titleyear.right-infoPtr->titleyear.left, infoPtr->textHeight, - hwnd, + infoPtr->hwndSelf, NULL, NULL, NULL); @@ -1465,7 +1440,7 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top, 20, infoPtr->textHeight, - hwnd, + infoPtr->hwndSelf, NULL, NULL, NULL); @@ -1478,7 +1453,7 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) if(hit == MCHT_TODAYLINK) { infoPtr->currentMonth=infoPtr->todaysDate.wMonth; infoPtr->currentYear=infoPtr->todaysDate.wYear; - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return TRUE; } if(hit == MCHT_CALENDARDATE) { @@ -1487,11 +1462,11 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) MONTHCAL_CopyTime(&ht.st, &selArray[0]); MONTHCAL_CopyTime(&ht.st, &selArray[1]); - MONTHCAL_SetSelRange(hwnd,0,(LPARAM) &selArray); - MONTHCAL_SetCurSel(hwnd,0,(LPARAM) &selArray); + MONTHCAL_SetSelRange(infoPtr, (LPARAM)&selArray); + MONTHCAL_SetCurSel(infoPtr, (LPARAM)&selArray); TRACE("MCHT_CALENDARDATE\n"); - nmsc.nmhdr.hwndFrom = hwnd; - nmsc.nmhdr.idFrom = GetWindowLongPtrW(hwnd, GWLP_ID); + nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf; + nmsc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID); nmsc.nmhdr.code = MCN_SELCHANGE; MONTHCAL_CopyTime(&infoPtr->minSel,&nmsc.stSelStart); MONTHCAL_CopyTime(&infoPtr->maxSel,&nmsc.stSelEnd); @@ -1503,10 +1478,10 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) /* redraw both old and new days if the selected day changed */ if(infoPtr->curSelDay != ht.st.wDay) { MONTHCAL_CalcPosFromDay(infoPtr, ht.st.wDay, ht.st.wMonth, &rcDay); - InvalidateRect(hwnd, &rcDay, TRUE); + InvalidateRect(infoPtr->hwndSelf, &rcDay, TRUE); MONTHCAL_CalcPosFromDay(infoPtr, infoPtr->curSelDay, infoPtr->currentMonth, &rcDay); - InvalidateRect(hwnd, &rcDay, TRUE); + InvalidateRect(infoPtr->hwndSelf, &rcDay, TRUE); } infoPtr->firstSelDay = ht.st.wDay; @@ -1520,9 +1495,8 @@ MONTHCAL_LButtonDown(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -MONTHCAL_LButtonUp(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_LButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); NMSELCHANGE nmsc; NMHDR nmhdr; BOOL redraw = FALSE; @@ -1532,46 +1506,46 @@ MONTHCAL_LButtonUp(HWND hwnd, WPARAM wParam, LPARAM lParam) TRACE("\n"); if(infoPtr->status & MC_NEXTPRESSED) { - KillTimer(hwnd, MC_NEXTMONTHTIMER); + KillTimer(infoPtr->hwndSelf, MC_NEXTMONTHTIMER); infoPtr->status &= ~MC_NEXTPRESSED; redraw = TRUE; } if(infoPtr->status & MC_PREVPRESSED) { - KillTimer(hwnd, MC_PREVMONTHTIMER); + KillTimer(infoPtr->hwndSelf, MC_PREVMONTHTIMER); infoPtr->status &= ~MC_PREVPRESSED; redraw = TRUE; } ht.pt.x = (INT)LOWORD(lParam); ht.pt.y = (INT)HIWORD(lParam); - hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht); + hit = MONTHCAL_HitTest(infoPtr, (LPARAM)&ht); infoPtr->status = MC_SEL_LBUTUP; if(hit ==MCHT_CALENDARDATENEXT) { - MONTHCAL_GoToNextMonth(hwnd, infoPtr); - InvalidateRect(hwnd, NULL, FALSE); + MONTHCAL_GoToNextMonth(infoPtr); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return TRUE; } if(hit == MCHT_CALENDARDATEPREV){ - MONTHCAL_GoToPrevMonth(hwnd, infoPtr); - InvalidateRect(hwnd, NULL, FALSE); + MONTHCAL_GoToPrevMonth(infoPtr); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return TRUE; } - nmhdr.hwndFrom = hwnd; - nmhdr.idFrom = GetWindowLongPtrW( hwnd, GWLP_ID); + nmhdr.hwndFrom = infoPtr->hwndSelf; + nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID); nmhdr.code = NM_RELEASEDCAPTURE; - TRACE("Sent notification from %p to %p\n", hwnd, infoPtr->hwndNotify); + TRACE("Sent notification from %p to %p\n", infoPtr->hwndSelf, infoPtr->hwndNotify); SendMessageA(infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); /* redraw if necessary */ if(redraw) - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); /* only send MCN_SELECT if currently displayed month's day was selected */ if(hit == MCHT_CALENDARDATE) { - nmsc.nmhdr.hwndFrom = hwnd; - nmsc.nmhdr.idFrom = GetWindowLongPtrW(hwnd, GWLP_ID); + nmsc.nmhdr.hwndFrom = infoPtr->hwndSelf; + nmsc.nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID); nmsc.nmhdr.code = MCN_SELECT; MONTHCAL_CopyTime(&infoPtr->minSel, &nmsc.stSelStart); MONTHCAL_CopyTime(&infoPtr->maxSel, &nmsc.stSelEnd); @@ -1585,39 +1559,37 @@ MONTHCAL_LButtonUp(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT -MONTHCAL_Timer(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_Timer(MONTHCAL_INFO *infoPtr, WPARAM wParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); BOOL redraw = FALSE; - TRACE(" %d\n", wParam); - if(!infoPtr) return 0; + TRACE("%d\n", wParam); switch(wParam) { case MC_NEXTMONTHTIMER: redraw = TRUE; - MONTHCAL_GoToNextMonth(hwnd, infoPtr); + MONTHCAL_GoToNextMonth(infoPtr); break; case MC_PREVMONTHTIMER: redraw = TRUE; - MONTHCAL_GoToPrevMonth(hwnd, infoPtr); + MONTHCAL_GoToPrevMonth(infoPtr); break; default: ERR("got unknown timer\n"); + break; } /* redraw only if necessary */ if(redraw) - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return 0; } static LRESULT -MONTHCAL_MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_MouseMove(MONTHCAL_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); MCHITTESTINFO ht; int oldselday, selday, hit; RECT r; @@ -1627,7 +1599,7 @@ MONTHCAL_MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam) ht.pt.x = LOWORD(lParam); ht.pt.y = HIWORD(lParam); - hit = MONTHCAL_HitTest(hwnd, (LPARAM)&ht); + hit = MONTHCAL_HitTest(infoPtr, (LPARAM)&ht); /* not on the calendar date numbers? bail out */ TRACE("hit:%x\n",hit); @@ -1638,11 +1610,11 @@ MONTHCAL_MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->curSelDay = selday; MONTHCAL_CalcPosFromDay(infoPtr, selday, ht.st. wMonth, &r); - if(GetWindowLongA(hwnd, GWL_STYLE) & MCS_MULTISELECT) { + if(GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE) & MCS_MULTISELECT) { SYSTEMTIME selArray[2]; int i; - MONTHCAL_GetSelRange(hwnd, 0, (LPARAM)&selArray); + MONTHCAL_GetSelRange(infoPtr, (LPARAM)&selArray); i = 0; if(infoPtr->firstSelDay==selArray[0].wDay) i=1; TRACE("oldRange:%d %d %d %d\n", infoPtr->firstSelDay, selArray[0].wDay, selArray[1].wDay, i); @@ -1672,7 +1644,7 @@ MONTHCAL_MouseMove(HWND hwnd, WPARAM wParam, LPARAM lParam) selArray[0].wDay = tempday; } - MONTHCAL_SetSelRange(hwnd, 0, (LPARAM)&selArray); + MONTHCAL_SetSelRange(infoPtr, (LPARAM)&selArray); } } @@ -1682,57 +1654,57 @@ done: /* FIXME: this should specify a rectangle containing only the days that changed */ /* using InvalidateRect */ if(oldselday != infoPtr->curSelDay) - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return 0; } static LRESULT -MONTHCAL_Paint(HWND hwnd, WPARAM wParam) +MONTHCAL_Paint(MONTHCAL_INFO *infoPtr, WPARAM wParam) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); HDC hdc; PAINTSTRUCT ps; - /* fill ps.rcPaint with a default rect */ - memcpy(&(ps.rcPaint), &(infoPtr->rcClient), sizeof(infoPtr->rcClient)); + if (wParam) + { + GetClientRect(infoPtr->hwndSelf, &ps.rcPaint); + hdc = (HDC)wParam; + } + else + hdc = BeginPaint(infoPtr->hwndSelf, &ps); - hdc = (wParam==0 ? BeginPaint(hwnd, &ps) : (HDC)wParam); - MONTHCAL_Refresh(hwnd, hdc, &ps); - if(!wParam) EndPaint(hwnd, &ps); + MONTHCAL_Refresh(infoPtr, hdc, &ps); + if (!wParam) EndPaint(infoPtr->hwndSelf, &ps); return 0; } static LRESULT -MONTHCAL_KillFocus(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_KillFocus(MONTHCAL_INFO *infoPtr) { TRACE("\n"); - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); return 0; } static LRESULT -MONTHCAL_SetFocus(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_SetFocus(MONTHCAL_INFO *infoPtr) { TRACE("\n"); - InvalidateRect(hwnd, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return 0; } /* sets the size information */ -static void MONTHCAL_UpdateSize(HWND hwnd) +static void MONTHCAL_UpdateSize(MONTHCAL_INFO *infoPtr) { - HDC hdc = GetDC(hwnd); - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); - RECT *rcClient=&infoPtr->rcClient; - RECT *rcDraw=&infoPtr->rcDraw; + HDC hdc = GetDC(infoPtr->hwndSelf); RECT *title=&infoPtr->title; RECT *prev=&infoPtr->titlebtnprev; RECT *next=&infoPtr->titlebtnnext; @@ -1744,74 +1716,43 @@ static void MONTHCAL_UpdateSize(HWND hwnd) RECT *todayrect=&infoPtr->todayrect; SIZE size; TEXTMETRICA tm; - DWORD dwStyle = GetWindowLongA(hwnd, GWL_STYLE); + DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); HFONT currentFont; - double xdiv; + int xdiv, left_offset; + RECT rcClient; + + GetClientRect(infoPtr->hwndSelf, &rcClient); currentFont = SelectObject(hdc, infoPtr->hFont); - /* FIXME: need a way to determine current font, without setting it */ - /* - if(infoPtr->hFont!=currentFont) { - SelectObject(hdc, currentFont); - infoPtr->hFont=currentFont; - GetObjectA(currentFont, sizeof(LOGFONTA), &logFont); - logFont.lfWeight=FW_BOLD; - infoPtr->hBoldFont = CreateFontIndirectA(&logFont); - } - */ - /* get the height and width of each day's text */ GetTextMetricsA(hdc, &tm); - infoPtr->textHeight = tm.tmHeight + tm.tmExternalLeading; + infoPtr->textHeight = tm.tmHeight + tm.tmExternalLeading + tm.tmInternalLeading; GetTextExtentPoint32A(hdc, "Sun", 3, &size); infoPtr->textWidth = size.cx + 2; - /* retrieve the controls client rectangle info infoPtr->rcClient */ - GetClientRect(hwnd, rcClient); - - /* rcDraw is the rectangle the control is drawn in */ - rcDraw->left = rcClient->left; - rcDraw->right = rcClient->right; - rcDraw->top = rcClient->top; - rcDraw->bottom = rcClient->bottom; - /* recalculate the height and width increments and offsets */ - /* FIXME: We use up all available width. This will inhibit having multiple - calendars in a row, like win doesn - */ - if(dwStyle & MCS_WEEKNUMBERS) - xdiv=8.0; - else - xdiv=7.0; - infoPtr->width_increment = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) / xdiv; - infoPtr->height_increment = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) / 10.0; - infoPtr->left_offset = (infoPtr->rcDraw.right - infoPtr->rcDraw.left) - (infoPtr->width_increment * xdiv); - infoPtr->top_offset = (infoPtr->rcDraw.bottom - infoPtr->rcDraw.top) - (infoPtr->height_increment * 10.0); + GetTextExtentPoint32A(hdc, "00", 2, &size); - rcDraw->bottom = rcDraw->top + 10 * infoPtr->height_increment; - /* this is correct, the control does NOT expand vertically */ - /* like it does horizontally */ - /* make sure we don't move the controls bottom out of the client */ - /* area */ - /* title line has about 3 text heights, abrev days line, 6 weeksline and today circle line*/ - /*if((rcDraw->top + 9 * infoPtr->textHeight + 5) < rcDraw->bottom) { - rcDraw->bottom = rcDraw->top + 9 * infoPtr->textHeight + 5; - }*/ + xdiv = (dwStyle & MCS_WEEKNUMBERS) ? 8 : 7; + + infoPtr->width_increment = size.cx * 2; + infoPtr->height_increment = infoPtr->textHeight; + left_offset = (rcClient.right - rcClient.left) - (infoPtr->width_increment * xdiv); /* calculate title area */ - title->top = rcClient->top; - title->bottom = title->top + 2 * infoPtr->height_increment; - title->left = rcClient->left; - title->right = rcClient->right; + title->top = rcClient.top; + title->bottom = title->top + 3 * infoPtr->height_increment / 2; + title->left = left_offset; + title->right = rcClient.right; /* set the dimensions of the next and previous buttons and center */ /* the month text vertically */ - prev->top = next->top = title->top + 6; - prev->bottom = next->bottom = title->bottom - 6; - prev->left = title->left + 6; + prev->top = next->top = title->top + 4; + prev->bottom = next->bottom = title->bottom - 4; + prev->left = title->left + 4; prev->right = prev->left + (title->bottom - title->top) ; - next->right = title->right - 6; + next->right = title->right - 4; next->left = next->right - (title->bottom - title->top); /* titlemonth->left and right change based upon the current month */ @@ -1822,7 +1763,7 @@ static void MONTHCAL_UpdateSize(HWND hwnd) /* setup the dimensions of the rectangle we draw the names of the */ /* days of the week in */ - weeknumrect->left =infoPtr->left_offset; + weeknumrect->left = left_offset; if(dwStyle & MCS_WEEKNUMBERS) weeknumrect->right=prev->right; else @@ -1833,47 +1774,69 @@ static void MONTHCAL_UpdateSize(HWND hwnd) wdays->bottom = wdays->top + infoPtr->height_increment; days->top = weeknumrect->top = wdays->bottom ; - days->bottom = weeknumrect->bottom = days->top + 6 * infoPtr->height_increment; + days->bottom = weeknumrect->bottom = days->top + 6 * infoPtr->height_increment; - todayrect->left = rcClient->left; - todayrect->right = rcClient->right; + todayrect->left = rcClient.left; + todayrect->right = rcClient.right; todayrect->top = days->bottom; todayrect->bottom = days->bottom + infoPtr->height_increment; - /* uncomment for excessive debugging - TRACE("dx=%d dy=%d rcC[%d %d %d %d] t[%d %d %d %d] wd[%d %d %d %d] w[%d %d %d %d] t[%d %d %d %d]\n", + TRACE("dx=%d dy=%d client[%s] title[%s] wdays[%s] days[%s] today[%s]\n", infoPtr->width_increment,infoPtr->height_increment, - rcClient->left, rcClient->right, rcClient->top, rcClient->bottom, - title->left, title->right, title->top, title->bottom, - wdays->left, wdays->right, wdays->top, wdays->bottom, - days->left, days->right, days->top, days->bottom, - todayrect->left,todayrect->right,todayrect->top,todayrect->bottom); - */ + wine_dbgstr_rect(&rcClient), + wine_dbgstr_rect(title), + wine_dbgstr_rect(wdays), + wine_dbgstr_rect(days), + wine_dbgstr_rect(todayrect)); /* restore the originally selected font */ SelectObject(hdc, currentFont); - ReleaseDC(hwnd, hdc); + ReleaseDC(infoPtr->hwndSelf, hdc); } -static LRESULT MONTHCAL_Size(HWND hwnd, int Width, int Height) +static LRESULT MONTHCAL_Size(MONTHCAL_INFO *infoPtr, int Width, int Height) { - TRACE("(hwnd=%p, width=%d, height=%d)\n", hwnd, Width, Height); + TRACE("(width=%d, height=%d)\n", Width, Height); - MONTHCAL_UpdateSize(hwnd); + MONTHCAL_UpdateSize(infoPtr); /* invalidate client area and erase background */ - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); return 0; } +static LRESULT MONTHCAL_GetFont(MONTHCAL_INFO *infoPtr) +{ + return (LRESULT)infoPtr->hFont; +} + +static LRESULT MONTHCAL_SetFont(MONTHCAL_INFO *infoPtr, HFONT hFont, BOOL redraw) +{ + HFONT hOldFont; + LOGFONTW lf; + + if (!hFont) return 0; + + hOldFont = infoPtr->hFont; + infoPtr->hFont = hFont; + + GetObjectW(infoPtr->hFont, sizeof(lf), &lf); + lf.lfWeight = FW_BOLD; + infoPtr->hBoldFont = CreateFontIndirectW(&lf); + + if (redraw) + InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); + + return (LRESULT)hOldFont; +} + /* FIXME: check whether dateMin/dateMax need to be adjusted. */ static LRESULT MONTHCAL_Create(HWND hwnd, WPARAM wParam, LPARAM lParam) { MONTHCAL_INFO *infoPtr; - LOGFONTA logFont; /* allocate memory for info structure */ infoPtr =(MONTHCAL_INFO*)Alloc(sizeof(MONTHCAL_INFO)); @@ -1883,23 +1846,17 @@ MONTHCAL_Create(HWND hwnd, WPARAM wParam, LPARAM lParam) ERR( "could not allocate info memory!\n"); return 0; } - if((MONTHCAL_INFO*)GetWindowLongPtrW(hwnd, 0) != infoPtr) { - ERR( "pointer assignment error!\n"); - return 0; - } + infoPtr->hwndSelf = hwnd; infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent; - infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT); - GetObjectA(infoPtr->hFont, sizeof(LOGFONTA), &logFont); - logFont.lfWeight = FW_BOLD; - infoPtr->hBoldFont = CreateFontIndirectA(&logFont); + MONTHCAL_SetFont(infoPtr, GetStockObject(DEFAULT_GUI_FONT), FALSE); /* initialize info structure */ /* FIXME: calculate systemtime ->> localtime(substract timezoneinfo) */ GetSystemTime(&infoPtr->todaysDate); - MONTHCAL_SetFirstDayOfWeek(hwnd,0,(LPARAM)-1); + MONTHCAL_SetFirstDayOfWeek(infoPtr, (LPARAM)-1); infoPtr->currentMonth = infoPtr->todaysDate.wMonth; infoPtr->currentYear = infoPtr->todaysDate.wYear; MONTHCAL_CopyTime(&infoPtr->todaysDate, &infoPtr->minDate); @@ -1919,22 +1876,20 @@ MONTHCAL_Create(HWND hwnd, WPARAM wParam, LPARAM lParam) /* call MONTHCAL_UpdateSize to set all of the dimensions */ /* of the control */ - MONTHCAL_UpdateSize(hwnd); + MONTHCAL_UpdateSize(infoPtr); return 0; } static LRESULT -MONTHCAL_Destroy(HWND hwnd, WPARAM wParam, LPARAM lParam) +MONTHCAL_Destroy(MONTHCAL_INFO *infoPtr) { - MONTHCAL_INFO *infoPtr = MONTHCAL_GetInfoPtr(hwnd); - /* free month calendar info data */ if(infoPtr->monthdayState) Free(infoPtr->monthdayState); + SetWindowLongPtrW(infoPtr->hwndSelf, 0, 0); Free(infoPtr); - SetWindowLongPtrW(hwnd, 0, 0); return 0; } @@ -1942,109 +1897,119 @@ MONTHCAL_Destroy(HWND hwnd, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + MONTHCAL_INFO *infoPtr; + TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam); - if (!MONTHCAL_GetInfoPtr(hwnd) && (uMsg != WM_CREATE)) + + infoPtr = MONTHCAL_GetInfoPtr(hwnd); + if (!infoPtr && (uMsg != WM_CREATE)) return DefWindowProcA(hwnd, uMsg, wParam, lParam); switch(uMsg) { case MCM_GETCURSEL: - return MONTHCAL_GetCurSel(hwnd, wParam, lParam); + return MONTHCAL_GetCurSel(infoPtr, lParam); case MCM_SETCURSEL: - return MONTHCAL_SetCurSel(hwnd, wParam, lParam); + return MONTHCAL_SetCurSel(infoPtr, lParam); case MCM_GETMAXSELCOUNT: - return MONTHCAL_GetMaxSelCount(hwnd, wParam, lParam); + return MONTHCAL_GetMaxSelCount(infoPtr); case MCM_SETMAXSELCOUNT: - return MONTHCAL_SetMaxSelCount(hwnd, wParam, lParam); + return MONTHCAL_SetMaxSelCount(infoPtr, wParam); case MCM_GETSELRANGE: - return MONTHCAL_GetSelRange(hwnd, wParam, lParam); + return MONTHCAL_GetSelRange(infoPtr, lParam); case MCM_SETSELRANGE: - return MONTHCAL_SetSelRange(hwnd, wParam, lParam); + return MONTHCAL_SetSelRange(infoPtr, lParam); case MCM_GETMONTHRANGE: - return MONTHCAL_GetMonthRange(hwnd, wParam, lParam); + return MONTHCAL_GetMonthRange(infoPtr); case MCM_SETDAYSTATE: - return MONTHCAL_SetDayState(hwnd, wParam, lParam); + return MONTHCAL_SetDayState(infoPtr, wParam, lParam); case MCM_GETMINREQRECT: - return MONTHCAL_GetMinReqRect(hwnd, wParam, lParam); + return MONTHCAL_GetMinReqRect(infoPtr, lParam); case MCM_GETCOLOR: - return MONTHCAL_GetColor(hwnd, wParam, lParam); + return MONTHCAL_GetColor(infoPtr, wParam); case MCM_SETCOLOR: - return MONTHCAL_SetColor(hwnd, wParam, lParam); + return MONTHCAL_SetColor(infoPtr, wParam, lParam); case MCM_GETTODAY: - return MONTHCAL_GetToday(hwnd, wParam, lParam); + return MONTHCAL_GetToday(infoPtr, lParam); case MCM_SETTODAY: - return MONTHCAL_SetToday(hwnd, wParam, lParam); + return MONTHCAL_SetToday(infoPtr, lParam); case MCM_HITTEST: - return MONTHCAL_HitTest(hwnd,lParam); + return MONTHCAL_HitTest(infoPtr, lParam); case MCM_GETFIRSTDAYOFWEEK: - return MONTHCAL_GetFirstDayOfWeek(hwnd, wParam, lParam); + return MONTHCAL_GetFirstDayOfWeek(infoPtr); case MCM_SETFIRSTDAYOFWEEK: - return MONTHCAL_SetFirstDayOfWeek(hwnd, wParam, lParam); + return MONTHCAL_SetFirstDayOfWeek(infoPtr, lParam); case MCM_GETRANGE: return MONTHCAL_GetRange(hwnd, wParam, lParam); case MCM_SETRANGE: - return MONTHCAL_SetRange(hwnd, wParam, lParam); + return MONTHCAL_SetRange(infoPtr, wParam, lParam); case MCM_GETMONTHDELTA: - return MONTHCAL_GetMonthDelta(hwnd, wParam, lParam); + return MONTHCAL_GetMonthDelta(infoPtr); case MCM_SETMONTHDELTA: - return MONTHCAL_SetMonthDelta(hwnd, wParam, lParam); + return MONTHCAL_SetMonthDelta(infoPtr, wParam); case MCM_GETMAXTODAYWIDTH: - return MONTHCAL_GetMaxTodayWidth(hwnd); + return MONTHCAL_GetMaxTodayWidth(infoPtr); case WM_GETDLGCODE: return DLGC_WANTARROWS | DLGC_WANTCHARS; case WM_KILLFOCUS: - return MONTHCAL_KillFocus(hwnd, wParam, lParam); + return MONTHCAL_KillFocus(infoPtr); case WM_RBUTTONDOWN: - return MONTHCAL_RButtonDown(hwnd, wParam, lParam); + return MONTHCAL_RButtonDown(infoPtr, lParam); case WM_LBUTTONDOWN: - return MONTHCAL_LButtonDown(hwnd, wParam, lParam); + return MONTHCAL_LButtonDown(infoPtr, lParam); case WM_MOUSEMOVE: - return MONTHCAL_MouseMove(hwnd, wParam, lParam); + return MONTHCAL_MouseMove(infoPtr, wParam, lParam); case WM_LBUTTONUP: - return MONTHCAL_LButtonUp(hwnd, wParam, lParam); + return MONTHCAL_LButtonUp(infoPtr, lParam); case WM_PAINT: - return MONTHCAL_Paint(hwnd, wParam); + return MONTHCAL_Paint(infoPtr, wParam); case WM_SETFOCUS: - return MONTHCAL_SetFocus(hwnd, wParam, lParam); + return MONTHCAL_SetFocus(infoPtr); case WM_SIZE: - return MONTHCAL_Size(hwnd, (short)LOWORD(lParam), (short)HIWORD(lParam)); + return MONTHCAL_Size(infoPtr, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_CREATE: return MONTHCAL_Create(hwnd, wParam, lParam); + case WM_SETFONT: + return MONTHCAL_SetFont(infoPtr, (HFONT)wParam, (BOOL)lParam); + + case WM_GETFONT: + return MONTHCAL_GetFont(infoPtr); + case WM_TIMER: - return MONTHCAL_Timer(hwnd, wParam, lParam); + return MONTHCAL_Timer(infoPtr, wParam); case WM_DESTROY: - return MONTHCAL_Destroy(hwnd, wParam, lParam); + return MONTHCAL_Destroy(infoPtr); default: if ((uMsg >= WM_USER) && (uMsg < WM_APP)) @@ -2062,7 +2027,7 @@ MONTHCAL_Register(void) ZeroMemory(&wndClass, sizeof(WNDCLASSA)); wndClass.style = CS_GLOBALCLASS; - wndClass.lpfnWndProc = (WNDPROC)MONTHCAL_WindowProc; + wndClass.lpfnWndProc = MONTHCAL_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(MONTHCAL_INFO *); wndClass.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); diff --git a/reactos/lib/comctl32/nativefont.c b/reactos/lib/comctl32/nativefont.c index c5bee8b4fd9..86d1e79fa96 100644 --- a/reactos/lib/comctl32/nativefont.c +++ b/reactos/lib/comctl32/nativefont.c @@ -28,12 +28,11 @@ */ #include -#include + #include "windef.h" #include "winbase.h" #include "wingdi.h" #include "winuser.h" -#include "winnls.h" #include "commctrl.h" #include "comctl32.h" #include "wine/debug.h" @@ -42,12 +41,11 @@ WINE_DEFAULT_DEBUG_CHANNEL(nativefont); typedef struct { - DWORD dwDummy; /* just to keep the compiler happy ;-) */ + HWND hwndSelf; /* my own handle */ } NATIVEFONT_INFO; #define NATIVEFONT_GetInfoPtr(hwnd) ((NATIVEFONT_INFO *)GetWindowLongPtrW (hwnd, 0)) - static LRESULT NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) { @@ -57,45 +55,40 @@ NATIVEFONT_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr = (NATIVEFONT_INFO *)Alloc (sizeof(NATIVEFONT_INFO)); SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); - /* initialize info structure */ - + infoPtr->hwndSelf = hwnd; return 0; } - static LRESULT -NATIVEFONT_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) +NATIVEFONT_Destroy (NATIVEFONT_INFO *infoPtr) { - NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr (hwnd); - - - - - /* free comboex info data */ + /* free control info data */ + SetWindowLongPtrW( infoPtr->hwndSelf, 0, 0 ); Free (infoPtr); - SetWindowLongPtrW( hwnd, 0, 0 ); return 0; } - - static LRESULT WINAPI NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - if (!NATIVEFONT_GetInfoPtr(hwnd) && (uMsg != WM_CREATE)) - return DefWindowProcA( hwnd, uMsg, wParam, lParam ); + NATIVEFONT_INFO *infoPtr = NATIVEFONT_GetInfoPtr(hwnd); + + TRACE("hwnd=%p msg=%04x wparam=%08x lparam=%08lx\n", + hwnd, uMsg, wParam, lParam); + + if (!infoPtr && (uMsg != WM_CREATE)) + return DefWindowProcW( hwnd, uMsg, wParam, lParam ); switch (uMsg) { - case WM_CREATE: return NATIVEFONT_Create (hwnd, wParam, lParam); case WM_DESTROY: - return NATIVEFONT_Destroy (hwnd, wParam, lParam); + return NATIVEFONT_Destroy (infoPtr); case WM_MOVE: case WM_SIZE: @@ -105,12 +98,13 @@ NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_SETFONT: case WM_GETDLGCODE: /* FIXME("message %04x seen but stubbed\n", uMsg); */ - return DefWindowProcA (hwnd, uMsg, wParam, lParam); + return DefWindowProcW (hwnd, uMsg, wParam, lParam); default: - ERR("unknown msg %04x wp=%08x lp=%08lx\n", + if ((uMsg >= WM_USER) && (uMsg < WM_APP)) + ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); - return DefWindowProcA (hwnd, uMsg, wParam, lParam); + return DefWindowProcW (hwnd, uMsg, wParam, lParam); } return 0; } @@ -119,23 +113,23 @@ NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) VOID NATIVEFONT_Register (void) { - WNDCLASSA wndClass; + WNDCLASSW wndClass; - ZeroMemory (&wndClass, sizeof(WNDCLASSA)); + ZeroMemory (&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS; - wndClass.lpfnWndProc = (WNDPROC)NATIVEFONT_WindowProc; + wndClass.lpfnWndProc = NATIVEFONT_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(NATIVEFONT_INFO *); - wndClass.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW); - wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wndClass.lpszClassName = WC_NATIVEFONTCTLA; + wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW); + wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); + wndClass.lpszClassName = WC_NATIVEFONTCTLW; - RegisterClassA (&wndClass); + RegisterClassW (&wndClass); } VOID NATIVEFONT_Unregister (void) { - UnregisterClassA (WC_NATIVEFONTCTLA, NULL); + UnregisterClassW (WC_NATIVEFONTCTLW, NULL); } diff --git a/reactos/lib/comctl32/progress.c b/reactos/lib/comctl32/progress.c index bd19b48dcc3..72cc2516a4f 100644 --- a/reactos/lib/comctl32/progress.c +++ b/reactos/lib/comctl32/progress.c @@ -493,7 +493,7 @@ static DWORD PROGRESS_SetRange (PROGRESS_INFO *infoPtr, int low, int high) * ProgressWindowProc */ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, - WPARAM wParam, LPARAM lParam) + WPARAM wParam, LPARAM lParam) { PROGRESS_INFO *infoPtr; @@ -654,7 +654,7 @@ static LRESULT WINAPI ProgressWindowProc(HWND hwnd, UINT message, * * Registers the progress bar window class. */ -VOID PROGRESS_Register (void) +void PROGRESS_Register (void) { WNDCLASSW wndClass; @@ -675,7 +675,7 @@ VOID PROGRESS_Register (void) * * Unregisters the progress bar window class. */ -VOID PROGRESS_Unregister (void) +void PROGRESS_Unregister (void) { UnregisterClassW (PROGRESS_CLASSW, NULL); } diff --git a/reactos/lib/comctl32/rebar.c b/reactos/lib/comctl32/rebar.c index dd440177f11..069734ea6f7 100644 --- a/reactos/lib/comctl32/rebar.c +++ b/reactos/lib/comctl32/rebar.c @@ -19,7 +19,7 @@ * * * This code was audited for completeness against the documented features - * of Comctl32.dll version 6.0 on Mar. 14, 2004, by Robert Shearman. + * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman. * * Unless otherwise noted, we believe this code to be complete, as per * the specification mentioned above. @@ -194,8 +194,8 @@ typedef struct HCURSOR hcurVert; /* handle to the NS cursor */ HCURSOR hcurDrag; /* handle to the drag cursor */ INT iVersion; /* version number */ - POINTS dragStart; /* x,y of button down */ - POINTS dragNow; /* x,y of this MouseMove */ + POINT dragStart; /* x,y of button down */ + POINT dragNow; /* x,y of this MouseMove */ INT iOldBand; /* last band that had the mouse cursor over it */ INT ihitoffset; /* offset of hotspot from gripper.left */ POINT origin; /* left/upper corner of client */ @@ -394,7 +394,7 @@ REBAR_DumpBand (REBAR_INFO *iP) TRACE("hwnd=%p: color=%08lx/%08lx, bands=%u, rows=%u, cSize=%ld,%ld\n", iP->hwndSelf, iP->clrText, iP->clrBk, iP->uNumBands, iP->uNumRows, iP->calcSize.cx, iP->calcSize.cy); - TRACE("hwnd=%p: flags=%08x, dragStart=%d,%d, dragNow=%d,%d, iGrabbedBand=%d\n", + TRACE("hwnd=%p: flags=%08x, dragStart=%ld,%ld, dragNow=%ld,%ld, iGrabbedBand=%d\n", iP->hwndSelf, iP->fStatus, iP->dragStart.x, iP->dragStart.y, iP->dragNow.x, iP->dragNow.y, iP->iGrabbedBand); @@ -2418,7 +2418,7 @@ REBAR_Shrink (REBAR_INFO *infoPtr, REBAR_BAND *band, INT movement, INT i) static void -REBAR_HandleLRDrag (REBAR_INFO *infoPtr, POINTS *ptsmove) +REBAR_HandleLRDrag (REBAR_INFO *infoPtr, const POINT *ptsmove) /* Function: This will implement the functionality of a */ /* Gripper drag within a row. It will not implement "out- */ /* of-row" drags. (They are detected and handled in */ @@ -2491,7 +2491,7 @@ REBAR_HandleLRDrag (REBAR_INFO *infoPtr, POINTS *ptsmove) infoPtr->ihitoffset); infoPtr->dragNow = *ptsmove; - TRACE("before: movement=%d (%d,%d), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n", + TRACE("before: movement=%d (%ld,%ld), imindBand=%d, ihitBand=%d, imaxdBand=%d, LSum=%d, RSum=%d\n", movement, ptsmove->x, ptsmove->y, imindBand, ihitBand, imaxdBand, LHeaderSum, RHeaderSum); REBAR_DumpBand (infoPtr); @@ -3874,7 +3874,8 @@ REBAR_LButtonDown (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) infoPtr->iGrabbedBand = iHitBand; /* save off the LOWORD and HIWORD of lParam as initial x,y */ - infoPtr->dragStart = MAKEPOINTS(lParam); + infoPtr->dragStart.x = (short)LOWORD(lParam); + infoPtr->dragStart.y = (short)HIWORD(lParam); infoPtr->dragNow = infoPtr->dragStart; if (infoPtr->dwStyle & CCS_VERT) infoPtr->ihitoffset = infoPtr->dragStart.y - (lpBand->rcBand.top+REBAR_PRE_GRIPPER); @@ -3935,9 +3936,10 @@ static LRESULT REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { REBAR_BAND *lpChevronBand; - POINTS ptsmove; + POINT ptMove; - ptsmove = MAKEPOINTS(lParam); + ptMove.x = (short)LOWORD(lParam); + ptMove.y = (short)HIWORD(lParam); /* if we are currently dragging a band */ if (infoPtr->iGrabbedBand >= 0) @@ -3951,40 +3953,37 @@ REBAR_MouseMove (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) band2 = &infoPtr->bands[infoPtr->iGrabbedBand]; /* if mouse did not move much, exit */ - if ((abs(ptsmove.x - infoPtr->dragNow.x) <= mindragx) && - (abs(ptsmove.y - infoPtr->dragNow.y) <= mindragy)) return 0; + if ((abs(ptMove.x - infoPtr->dragNow.x) <= mindragx) && + (abs(ptMove.y - infoPtr->dragNow.y) <= mindragy)) return 0; /* Test for valid drag case - must not be first band in row */ if (infoPtr->dwStyle & CCS_VERT) { - if ((ptsmove.x < band2->rcBand.left) || - (ptsmove.x > band2->rcBand.right) || + if ((ptMove.x < band2->rcBand.left) || + (ptMove.x > band2->rcBand.right) || ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) { FIXME("Cannot drag to other rows yet!!\n"); } else { - REBAR_HandleLRDrag (infoPtr, &ptsmove); + REBAR_HandleLRDrag (infoPtr, &ptMove); } } else { - if ((ptsmove.y < band2->rcBand.top) || - (ptsmove.y > band2->rcBand.bottom) || + if ((ptMove.y < band2->rcBand.top) || + (ptMove.y > band2->rcBand.bottom) || ((infoPtr->iGrabbedBand > 0) && (band1->iRow != band2->iRow))) { FIXME("Cannot drag to other rows yet!!\n"); } else { - REBAR_HandleLRDrag (infoPtr, &ptsmove); + REBAR_HandleLRDrag (infoPtr, &ptMove); } } } else { - POINT ptMove; INT iHitBand; UINT htFlags; TRACKMOUSEEVENT trackinfo; - ptMove.x = (INT)ptsmove.x; - ptMove.y = (INT)ptsmove.y; REBAR_InternalHitTest(infoPtr, &ptMove, &htFlags, &iHitBand); if (infoPtr->iOldBand >= 0 && infoPtr->iOldBand == infoPtr->ichevronhotBand) @@ -4152,8 +4151,7 @@ static LRESULT REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { NMMOUSE nmmouse; - POINTS shortpt; - POINT clpt, pt; + POINT clpt; INT i; UINT scrap; LRESULT ret = HTCLIENT; @@ -4166,9 +4164,8 @@ REBAR_NCHitTest (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) * 3. native always seems to return HTCLIENT if notify return is 0. */ - shortpt = MAKEPOINTS (lParam); - POINTSTOPOINT(pt, shortpt); - clpt = pt; + clpt.x = (short)LOWORD(lParam); + clpt.y = (short)HIWORD(lParam); ScreenToClient (infoPtr->hwndSelf, &clpt); REBAR_InternalHitTest (infoPtr, &clpt, &scrap, (INT *)&nmmouse.dwItemSpec); @@ -4710,7 +4707,7 @@ REBAR_Register (void) ZeroMemory (&wndClass, sizeof(WNDCLASSA)); wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; - wndClass.lpfnWndProc = (WNDPROC)REBAR_WindowProc; + wndClass.lpfnWndProc = REBAR_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(REBAR_INFO *); wndClass.hCursor = 0; diff --git a/reactos/lib/comctl32/status.c b/reactos/lib/comctl32/status.c index b083d02860d..ad099c9beef 100644 --- a/reactos/lib/comctl32/status.c +++ b/reactos/lib/comctl32/status.c @@ -79,7 +79,7 @@ typedef struct BOOL NtfUnicode; /* notify format */ STATUSWINDOWPART part0; /* simple window */ STATUSWINDOWPART* parts; -} STATUSWINDOWINFO; +} STATUS_INFO; /* * Run tests using Waite Group Windows95 API Bible Vol. 1&2 @@ -91,11 +91,9 @@ typedef struct #define VERT_BORDER 2 #define HORZ_GAP 2 -#define STATUSBAR_GetInfoPtr(hwnd) ((STATUSWINDOWINFO *)GetWindowLongPtrW (hwnd, 0)) - /* prototype */ static void -STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr); +STATUSBAR_SetPartBounds (STATUS_INFO *infoPtr); static inline LPCSTR debugstr_t(LPCWSTR text, BOOL isW) { @@ -148,7 +146,7 @@ STATUSBAR_DrawSizeGrip (HDC hdc, LPRECT lpRect) static void -STATUSBAR_DrawPart (HDC hdc, const STATUSWINDOWPART *part, const STATUSWINDOWINFO *infoPtr, int itemID) +STATUSBAR_DrawPart (STATUS_INFO *infoPtr, HDC hdc, STATUSWINDOWPART *part, int itemID) { RECT r = part->bound; UINT border = BDR_SUNKENOUTER; @@ -189,7 +187,7 @@ STATUSBAR_DrawPart (HDC hdc, const STATUSWINDOWPART *part, const STATUSWINDOWINF static void -STATUSBAR_RefreshPart (const STATUSWINDOWINFO *infoPtr, const STATUSWINDOWPART *part, HDC hdc, int itemID) +STATUSBAR_RefreshPart (STATUS_INFO *infoPtr, HDC hdc, STATUSWINDOWPART *part, int itemID) { HBRUSH hbrBk; HFONT hOldFont; @@ -208,7 +206,7 @@ STATUSBAR_RefreshPart (const STATUSWINDOWINFO *infoPtr, const STATUSWINDOWPART * hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont); - STATUSBAR_DrawPart (hdc, part, infoPtr, itemID); + STATUSBAR_DrawPart (infoPtr, hdc, part, itemID); SelectObject (hdc, hOldFont); @@ -226,7 +224,7 @@ STATUSBAR_RefreshPart (const STATUSWINDOWINFO *infoPtr, const STATUSWINDOWPART * static LRESULT -STATUSBAR_Refresh (STATUSWINDOWINFO *infoPtr, HDC hdc) +STATUSBAR_Refresh (STATUS_INFO *infoPtr, HDC hdc) { int i; RECT rect; @@ -250,10 +248,10 @@ STATUSBAR_Refresh (STATUSWINDOWINFO *infoPtr, HDC hdc) hOldFont = SelectObject (hdc, infoPtr->hFont ? infoPtr->hFont : infoPtr->hDefaultFont); if (infoPtr->simple) { - STATUSBAR_RefreshPart (infoPtr, &infoPtr->part0, hdc, 0); + STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->part0, 0); } else { for (i = 0; i < infoPtr->numParts; i++) { - STATUSBAR_RefreshPart (infoPtr, &infoPtr->parts[i], hdc, i); + STATUSBAR_RefreshPart (infoPtr, hdc, &infoPtr->parts[i], i); } } @@ -270,7 +268,7 @@ STATUSBAR_Refresh (STATUSWINDOWINFO *infoPtr, HDC hdc) static void -STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr) +STATUSBAR_SetPartBounds (STATUS_INFO *infoPtr) { STATUSWINDOWPART *part; RECT rect, *r; @@ -315,7 +313,7 @@ STATUSBAR_SetPartBounds (STATUSWINDOWINFO *infoPtr) static LRESULT -STATUSBAR_Relay2Tip (STATUSWINDOWINFO *infoPtr, UINT uMsg, +STATUSBAR_Relay2Tip (STATUS_INFO *infoPtr, UINT uMsg, WPARAM wParam, LPARAM lParam) { MSG msg; @@ -345,7 +343,7 @@ STATUSBAR_GetBorders (INT out[]) static HICON -STATUSBAR_GetIcon (STATUSWINDOWINFO *infoPtr, INT nPart) +STATUSBAR_GetIcon (STATUS_INFO *infoPtr, INT nPart) { TRACE("%d\n", nPart); /* MSDN says: "simple parts are indexed with -1" */ @@ -360,7 +358,7 @@ STATUSBAR_GetIcon (STATUSWINDOWINFO *infoPtr, INT nPart) static INT -STATUSBAR_GetParts (STATUSWINDOWINFO *infoPtr, INT num_parts, INT parts[]) +STATUSBAR_GetParts (STATUS_INFO *infoPtr, INT num_parts, INT parts[]) { INT i; @@ -375,7 +373,7 @@ STATUSBAR_GetParts (STATUSWINDOWINFO *infoPtr, INT num_parts, INT parts[]) static BOOL -STATUSBAR_GetRect (STATUSWINDOWINFO *infoPtr, INT nPart, LPRECT rect) +STATUSBAR_GetRect (STATUS_INFO *infoPtr, INT nPart, LPRECT rect) { TRACE("part %d\n", nPart); if (infoPtr->simple) @@ -387,7 +385,7 @@ STATUSBAR_GetRect (STATUSWINDOWINFO *infoPtr, INT nPart, LPRECT rect) static LRESULT -STATUSBAR_GetTextA (STATUSWINDOWINFO *infoPtr, INT nPart, LPSTR buf) +STATUSBAR_GetTextA (STATUS_INFO *infoPtr, INT nPart, LPSTR buf) { STATUSWINDOWPART *part; LRESULT result; @@ -416,7 +414,7 @@ STATUSBAR_GetTextA (STATUSWINDOWINFO *infoPtr, INT nPart, LPSTR buf) static LRESULT -STATUSBAR_GetTextW (STATUSWINDOWINFO *infoPtr, INT nPart, LPWSTR buf) +STATUSBAR_GetTextW (STATUS_INFO *infoPtr, INT nPart, LPWSTR buf) { STATUSWINDOWPART *part; LRESULT result; @@ -442,7 +440,7 @@ STATUSBAR_GetTextW (STATUSWINDOWINFO *infoPtr, INT nPart, LPWSTR buf) static LRESULT -STATUSBAR_GetTextLength (STATUSWINDOWINFO *infoPtr, INT nPart) +STATUSBAR_GetTextLength (STATUS_INFO *infoPtr, INT nPart) { STATUSWINDOWPART *part; DWORD result; @@ -467,7 +465,7 @@ STATUSBAR_GetTextLength (STATUSWINDOWINFO *infoPtr, INT nPart) } static LRESULT -STATUSBAR_GetTipTextA (STATUSWINDOWINFO *infoPtr, INT id, LPSTR tip, INT size) +STATUSBAR_GetTipTextA (STATUS_INFO *infoPtr, INT id, LPSTR tip, INT size) { TRACE("\n"); if (tip) { @@ -489,7 +487,7 @@ STATUSBAR_GetTipTextA (STATUSWINDOWINFO *infoPtr, INT id, LPSTR tip, INT size) static LRESULT -STATUSBAR_GetTipTextW (STATUSWINDOWINFO *infoPtr, INT id, LPWSTR tip, INT size) +STATUSBAR_GetTipTextW (STATUS_INFO *infoPtr, INT id, LPWSTR tip, INT size) { TRACE("\n"); if (tip) { @@ -512,7 +510,7 @@ STATUSBAR_GetTipTextW (STATUSWINDOWINFO *infoPtr, INT id, LPWSTR tip, INT size) static COLORREF -STATUSBAR_SetBkColor (STATUSWINDOWINFO *infoPtr, COLORREF color) +STATUSBAR_SetBkColor (STATUS_INFO *infoPtr, COLORREF color) { COLORREF oldBkColor; @@ -526,7 +524,7 @@ STATUSBAR_SetBkColor (STATUSWINDOWINFO *infoPtr, COLORREF color) static BOOL -STATUSBAR_SetIcon (STATUSWINDOWINFO *infoPtr, INT nPart, HICON hIcon) +STATUSBAR_SetIcon (STATUS_INFO *infoPtr, INT nPart, HICON hIcon) { if ((nPart < -1) || (nPart >= infoPtr->numParts)) return FALSE; @@ -553,7 +551,7 @@ STATUSBAR_SetIcon (STATUSWINDOWINFO *infoPtr, INT nPart, HICON hIcon) static BOOL -STATUSBAR_SetMinHeight (STATUSWINDOWINFO *infoPtr, INT height) +STATUSBAR_SetMinHeight (STATUS_INFO *infoPtr, INT height) { TRACE("(height=%d)\n", height); @@ -577,7 +575,7 @@ STATUSBAR_SetMinHeight (STATUSWINDOWINFO *infoPtr, INT height) static BOOL -STATUSBAR_SetParts (STATUSWINDOWINFO *infoPtr, INT count, LPINT parts) +STATUSBAR_SetParts (STATUS_INFO *infoPtr, INT count, LPINT parts) { STATUSWINDOWPART *tmp; int i, oldNumParts; @@ -647,7 +645,7 @@ STATUSBAR_SetParts (STATUSWINDOWINFO *infoPtr, INT count, LPINT parts) static BOOL -STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style, +STATUSBAR_SetTextT (STATUS_INFO *infoPtr, INT nPart, WORD style, LPCWSTR text, BOOL isW) { STATUSWINDOWPART *part=NULL; @@ -715,7 +713,7 @@ STATUSBAR_SetTextT (STATUSWINDOWINFO *infoPtr, INT nPart, WORD style, static LRESULT -STATUSBAR_SetTipTextA (STATUSWINDOWINFO *infoPtr, INT id, LPSTR text) +STATUSBAR_SetTipTextA (STATUS_INFO *infoPtr, INT id, LPSTR text) { TRACE("part %d: \"%s\"\n", id, text); if (infoPtr->hwndToolTip) { @@ -734,7 +732,7 @@ STATUSBAR_SetTipTextA (STATUSWINDOWINFO *infoPtr, INT id, LPSTR text) static LRESULT -STATUSBAR_SetTipTextW (STATUSWINDOWINFO *infoPtr, INT id, LPWSTR text) +STATUSBAR_SetTipTextW (STATUS_INFO *infoPtr, INT id, LPWSTR text) { TRACE("part %d: \"%s\"\n", id, debugstr_w(text)); if (infoPtr->hwndToolTip) { @@ -753,7 +751,7 @@ STATUSBAR_SetTipTextW (STATUSWINDOWINFO *infoPtr, INT id, LPWSTR text) inline static LRESULT -STATUSBAR_SetUnicodeFormat (STATUSWINDOWINFO *infoPtr, BOOL bUnicode) +STATUSBAR_SetUnicodeFormat (STATUS_INFO *infoPtr, BOOL bUnicode) { BOOL bOld = infoPtr->bUnicode; @@ -765,7 +763,7 @@ STATUSBAR_SetUnicodeFormat (STATUSWINDOWINFO *infoPtr, BOOL bUnicode) static BOOL -STATUSBAR_Simple (STATUSWINDOWINFO *infoPtr, BOOL simple) +STATUSBAR_Simple (STATUS_INFO *infoPtr, BOOL simple) { NMHDR nmhdr; @@ -786,7 +784,7 @@ STATUSBAR_Simple (STATUSWINDOWINFO *infoPtr, BOOL simple) static LRESULT -STATUSBAR_WMDestroy (STATUSWINDOWINFO *infoPtr) +STATUSBAR_WMDestroy (STATUS_INFO *infoPtr) { int i; @@ -816,7 +814,7 @@ STATUSBAR_WMDestroy (STATUSWINDOWINFO *infoPtr) static LRESULT STATUSBAR_WMCreate (HWND hwnd, LPCREATESTRUCTA lpCreate) { - STATUSWINDOWINFO *infoPtr; + STATUS_INFO *infoPtr; NONCLIENTMETRICSW nclm; DWORD dwStyle; RECT rect; @@ -824,7 +822,7 @@ STATUSBAR_WMCreate (HWND hwnd, LPCREATESTRUCTA lpCreate) HDC hdc; TRACE("\n"); - infoPtr = (STATUSWINDOWINFO*)Alloc (sizeof(STATUSWINDOWINFO)); + infoPtr = (STATUS_INFO*)Alloc (sizeof(STATUS_INFO)); if (!infoPtr) goto create_fail; SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); @@ -944,7 +942,7 @@ create_fail: /* in contrast to SB_GETTEXT*, WM_GETTEXT handles the text * of the first part only (usual behaviour) */ static INT -STATUSBAR_WMGetText (STATUSWINDOWINFO *infoPtr, INT size, LPWSTR buf) +STATUSBAR_WMGetText (STATUS_INFO *infoPtr, INT size, LPWSTR buf) { INT len; @@ -970,7 +968,7 @@ STATUSBAR_WMGetText (STATUSWINDOWINFO *infoPtr, INT size, LPWSTR buf) static BOOL -STATUSBAR_WMNCHitTest (STATUSWINDOWINFO *infoPtr, INT x, INT y) +STATUSBAR_WMNCHitTest (STATUS_INFO *infoPtr, INT x, INT y) { if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & SBARS_SIZEGRIP) { RECT rect; @@ -994,7 +992,7 @@ STATUSBAR_WMNCHitTest (STATUSWINDOWINFO *infoPtr, INT x, INT y) static LRESULT -STATUSBAR_WMPaint (STATUSWINDOWINFO *infoPtr, HDC hdc) +STATUSBAR_WMPaint (STATUS_INFO *infoPtr, HDC hdc) { PAINTSTRUCT ps; @@ -1009,7 +1007,7 @@ STATUSBAR_WMPaint (STATUSWINDOWINFO *infoPtr, HDC hdc) static LRESULT -STATUSBAR_WMSetFont (STATUSWINDOWINFO *infoPtr, HFONT font, BOOL redraw) +STATUSBAR_WMSetFont (STATUS_INFO *infoPtr, HFONT font, BOOL redraw) { infoPtr->hFont = font; TRACE("%p\n", infoPtr->hFont); @@ -1021,7 +1019,7 @@ STATUSBAR_WMSetFont (STATUSWINDOWINFO *infoPtr, HFONT font, BOOL redraw) static BOOL -STATUSBAR_WMSetText (STATUSWINDOWINFO *infoPtr, LPCSTR text) +STATUSBAR_WMSetText (STATUS_INFO *infoPtr, LPCSTR text) { STATUSWINDOWPART *part; int len; @@ -1058,7 +1056,7 @@ STATUSBAR_WMSetText (STATUSWINDOWINFO *infoPtr, LPCSTR text) static BOOL -STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, WORD flags) +STATUSBAR_WMSize (STATUS_INFO *infoPtr, WORD flags) { INT width, x, y; RECT parent_rect; @@ -1088,7 +1086,7 @@ STATUSBAR_WMSize (STATUSWINDOWINFO *infoPtr, WORD flags) static LRESULT -STATUSBAR_NotifyFormat (STATUSWINDOWINFO *infoPtr, HWND from, INT cmd) +STATUSBAR_NotifyFormat (STATUS_INFO *infoPtr, HWND from, INT cmd) { if (cmd == NF_REQUERY) { INT i = SendMessageW(from, WM_NOTIFYFORMAT, (WPARAM)infoPtr->Self, NF_QUERY); @@ -1099,14 +1097,13 @@ STATUSBAR_NotifyFormat (STATUSWINDOWINFO *infoPtr, HWND from, INT cmd) static LRESULT -STATUSBAR_SendNotify (HWND hwnd, UINT code) +STATUSBAR_SendNotify (STATUS_INFO *infoPtr, UINT code) { - STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr(hwnd); NMHDR nmhdr; TRACE("code %04x\n", code); - nmhdr.hwndFrom = hwnd; - nmhdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID); + nmhdr.hwndFrom = infoPtr->Self; + nmhdr.idFrom = GetWindowLongPtrW (infoPtr->Self, GWLP_ID); nmhdr.code = code; SendMessageW (infoPtr->Notify, WM_NOTIFY, 0, (LPARAM)&nmhdr); return 0; @@ -1117,7 +1114,7 @@ STATUSBAR_SendNotify (HWND hwnd, UINT code) static LRESULT WINAPI StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { - STATUSWINDOWINFO *infoPtr = STATUSBAR_GetInfoPtr(hwnd); + STATUS_INFO *infoPtr = (STATUS_INFO *)GetWindowLongPtrW (hwnd, 0); INT nPart = ((INT) wParam) & 0x00ff; LRESULT res; @@ -1206,10 +1203,10 @@ StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return STATUSBAR_GetTextLength (infoPtr, 0); case WM_LBUTTONDBLCLK: - return STATUSBAR_SendNotify (hwnd, NM_DBLCLK); + return STATUSBAR_SendNotify (infoPtr, NM_DBLCLK); case WM_LBUTTONUP: - return STATUSBAR_SendNotify (hwnd, NM_CLICK); + return STATUSBAR_SendNotify (infoPtr, NM_CLICK); case WM_MOUSEMOVE: return STATUSBAR_Relay2Tip (infoPtr, msg, wParam, lParam); @@ -1232,10 +1229,10 @@ StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) return STATUSBAR_WMPaint (infoPtr, (HDC)wParam); case WM_RBUTTONDBLCLK: - return STATUSBAR_SendNotify (hwnd, NM_RDBLCLK); + return STATUSBAR_SendNotify (infoPtr, NM_RDBLCLK); case WM_RBUTTONUP: - return STATUSBAR_SendNotify (hwnd, NM_RCLICK); + return STATUSBAR_SendNotify (infoPtr, NM_RCLICK); case WM_SETFONT: return STATUSBAR_WMSetFont (infoPtr, (HFONT)wParam, LOWORD(lParam)); @@ -1272,7 +1269,7 @@ STATUS_Register (void) wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS | CS_VREDRAW; wndClass.lpfnWndProc = StatusWindowProc; wndClass.cbClsExtra = 0; - wndClass.cbWndExtra = sizeof(STATUSWINDOWINFO *); + wndClass.cbWndExtra = sizeof(STATUS_INFO *); wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW); wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); wndClass.lpszClassName = STATUSCLASSNAMEW; diff --git a/reactos/lib/comctl32/syslink.c b/reactos/lib/comctl32/syslink.c index d8e7a29ddd5..f81fd81bdeb 100644 --- a/reactos/lib/comctl32/syslink.c +++ b/reactos/lib/comctl32/syslink.c @@ -1478,12 +1478,10 @@ static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message, case WM_SETCURSOR: { LHITTESTINFO ht; - POINTS pt; DWORD mp = GetMessagePos(); - pt = MAKEPOINTS(mp); - ht.pt.x = pt.x; - ht.pt.y = pt.y; + ht.pt.x = (short)LOWORD(mp); + ht.pt.y = (short)HIWORD(mp); ScreenToClient(infoPtr->Self, &ht.pt); if(SYSLINK_HitTest (infoPtr, &ht)) @@ -1662,7 +1660,7 @@ VOID SYSLINK_Register (void) ZeroMemory (&wndClass, sizeof(wndClass)); wndClass.style = CS_GLOBALCLASS | CS_VREDRAW | CS_HREDRAW; - wndClass.lpfnWndProc = (WNDPROC)SysLinkWindowProc; + wndClass.lpfnWndProc = SysLinkWindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof (SYSLINK_INFO *); wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW); diff --git a/reactos/lib/comctl32/tab.c b/reactos/lib/comctl32/tab.c index 44b42aa5188..efdf955db6f 100644 --- a/reactos/lib/comctl32/tab.c +++ b/reactos/lib/comctl32/tab.c @@ -1659,8 +1659,7 @@ TAB_DrawItemInterior dis.hwndItem = hwnd; /* */ dis.hDC = hdc; CopyRect(&dis.rcItem,drawRect); - dis.itemData = 0; - memcpy( &dis.itemData, TAB_GetItem(infoPtr, iItem)->extra, min(sizeof(dis.itemData),infoPtr->cbInfo) ); + dis.itemData = (ULONG_PTR)TAB_GetItem(infoPtr, iItem)->extra; /* * send the draw message diff --git a/reactos/lib/comctl32/toolbar.c b/reactos/lib/comctl32/toolbar.c index 4f2c0e028f5..ebd7f8df388 100644 --- a/reactos/lib/comctl32/toolbar.c +++ b/reactos/lib/comctl32/toolbar.c @@ -47,11 +47,11 @@ * - TB_INSERTMARKHITTEST * - TB_SAVERESTORE * - TB_SETMETRICS + * - WM_WININICHANGE * - Notifications: * - NM_CHAR * - NM_KEYDOWN * - TBN_GETOBJECT - * - TBN_RESTORE * - TBN_SAVE * - Button wrapping (under construction). * - Fix TB_SETROWS. @@ -73,6 +73,7 @@ #include "windef.h" #include "winbase.h" +#include "winreg.h" #include "wingdi.h" #include "winuser.h" #include "wine/unicode.h" @@ -157,10 +158,9 @@ typedef struct BOOL bBtnTranspnt; /* button transparency flag */ BOOL bAutoSize; /* auto size deadlock indicator */ BOOL bAnchor; /* anchor highlight enabled */ - BOOL bNtfUnicode; /* TRUE if NOTIFYs use {W} */ BOOL bDoRedraw; /* Redraw status */ BOOL bDragOutSent; /* has TBN_DRAGOUT notification been sent for this drag? */ - BOOL bUnicode; /* ASCII (FALSE) or Unicode (TRUE)? */ + BOOL bUnicode; /* Notifications are ASCII (FALSE) or Unicode (TRUE)? */ BOOL bCaptured; /* mouse captured? */ DWORD dwStyle; /* regular toolbar style */ DWORD dwExStyle; /* extended toolbar style */ @@ -208,6 +208,9 @@ typedef enum #define ARROW_HEIGHT 3 #define INSERTMARK_WIDTH 2 +#define DEFPAD_CX 7 +#define DEFPAD_CY 6 + /* gap between border of button and text/image */ #define OFFSET_X 1 #define OFFSET_Y 1 @@ -231,6 +234,10 @@ static inline int TOOLBAR_GetListTextOffset(TOOLBAR_INFO *infoPtr, INT iListGap) TBSTYLE_EX_MIXEDBUTTONS | \ TBSTYLE_EX_HIDECLIPPEDBUTTONS) +/* all of the CCS_ styles */ +#define COMMON_STYLES (CCS_TOP|CCS_NOMOVEY|CCS_BOTTOM|CCS_NORESIZE| \ + CCS_NOPARENTALIGN|CCS_ADJUSTABLE|CCS_NODIVIDER|CCS_VERT) + #define GETIBITMAP(infoPtr, i) (infoPtr->iVersion >= 5 ? LOWORD(i) : i) #define GETHIMLID(infoPtr, i) (infoPtr->iVersion >= 5 ? HIWORD(i) : 0) #define GETDEFIMAGELIST(infoPtr, id) TOOLBAR_GetImageList(infoPtr->himlDef, infoPtr->cimlDef, id) @@ -329,14 +336,10 @@ TOOLBAR_SendNotify (NMHDR *nmhdr, TOOLBAR_INFO *infoPtr, UINT code) nmhdr->code = code; TRACE("to window %p, code=%08x, %s\n", infoPtr->hwndNotify, code, - (infoPtr->bNtfUnicode) ? "via Unicode" : "via ANSI"); + (infoPtr->bUnicode) ? "via Unicode" : "via ANSI"); - if (infoPtr->bNtfUnicode) - return SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, - (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr); - else - return SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, - (WPARAM) nmhdr->idFrom, (LPARAM)nmhdr); + return SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, + (WPARAM)nmhdr->idFrom, (LPARAM)nmhdr); } /*********************************************************************** @@ -351,22 +354,22 @@ TOOLBAR_GetBitmapIndex(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr) { INT ret = btnPtr->iBitmap; - if (ret == I_IMAGECALLBACK) { - /* issue TBN_GETDISPINFO */ - NMTBDISPINFOA nmgd; + if (ret == I_IMAGECALLBACK) + { + /* issue TBN_GETDISPINFO */ + NMTBDISPINFOA nmgd; - nmgd.idCommand = btnPtr->idCommand; - nmgd.lParam = btnPtr->dwData; - nmgd.dwMask = TBNF_IMAGE; - TOOLBAR_SendNotify ((NMHDR *) &nmgd, infoPtr, - (infoPtr->bNtfUnicode) ? TBN_GETDISPINFOW : - TBN_GETDISPINFOA); - if (nmgd.dwMask & TBNF_DI_SETITEM) { - btnPtr->iBitmap = nmgd.iImage; - } - ret = nmgd.iImage; - TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n", - ret, nmgd.dwMask, infoPtr->nNumBitmaps); + memset(&nmgd, 0, sizeof(nmgd)); + nmgd.idCommand = btnPtr->idCommand; + nmgd.lParam = btnPtr->dwData; + nmgd.dwMask = TBNF_IMAGE; + TOOLBAR_SendNotify(&nmgd.hdr, infoPtr, + infoPtr->bUnicode ? TBN_GETDISPINFOW : TBN_GETDISPINFOA); + if (nmgd.dwMask & TBNF_DI_SETITEM) + btnPtr->iBitmap = nmgd.iImage; + ret = nmgd.iImage; + TRACE("TBN_GETDISPINFO returned bitmap id %d, mask=%08lx, nNumBitmaps=%d\n", + ret, nmgd.dwMask, infoPtr->nNumBitmaps); } if (ret != I_IMAGENONE) @@ -707,7 +710,7 @@ TOOLBAR_DrawImage(TOOLBAR_INFO *infoPtr, TBUTTON_INFO *btnPtr, INT left, INT top BOOL draw_masked = FALSE; INT index; INT offset = 0; - UINT draw_flags = ILD_NORMAL; + UINT draw_flags = ILD_TRANSPARENT; if (tbcd->nmcd.uItemState & (CDIS_DISABLED | CDIS_INDETERMINATE)) { @@ -868,12 +871,12 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) /* Center the bitmap horizontally and vertically */ if (dwStyle & TBSTYLE_LIST) - rcBitmap.left += GetSystemMetrics(SM_CXEDGE) + OFFSET_X; + rcBitmap.left += GetSystemMetrics(SM_CXEDGE); else rcBitmap.left+=(infoPtr->nButtonWidth - infoPtr->nBitmapWidth) / 2; if(lpText) - rcBitmap.top+= GetSystemMetrics(SM_CYEDGE) + OFFSET_Y; + rcBitmap.top+= GetSystemMetrics(SM_CYEDGE); else rcBitmap.top+=(infoPtr->nButtonHeight - infoPtr->nBitmapHeight) / 2; @@ -942,7 +945,7 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) tbcd.nmcd.dwDrawStage = CDDS_ITEMPREPAINT; tbcd.nmcd.dwItemSpec = btnPtr->idCommand; tbcd.nmcd.lItemlParam = btnPtr->dwData; - ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); + ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW); /* reset these fields so the user can't alter the behaviour like native */ tbcd.nmcd.hdc = hdc; tbcd.nmcd.rc = rc; @@ -1032,7 +1035,7 @@ FINALNOTIFY: tbcd.rcText = rcText; tbcd.nStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE; tbcd.nHLStringBkMode = (infoPtr->bBtnTranspnt) ? TRANSPARENT : OPAQUE; - ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); + ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW); } } @@ -1068,7 +1071,7 @@ TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps) tbcd.nmcd.dwDrawStage = CDDS_PREPAINT; tbcd.nmcd.hdc = hdc; tbcd.nmcd.rc = ps->rcPaint; - ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); + ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW); infoPtr->dwBaseCustDraw = ntfret & 0xffff; if (infoPtr->bBtnTranspnt) @@ -1117,7 +1120,7 @@ TOOLBAR_Refresh (HWND hwnd, HDC hdc, PAINTSTRUCT* ps) tbcd.nmcd.dwDrawStage = CDDS_POSTPAINT; tbcd.nmcd.hdc = hdc; tbcd.nmcd.rc = ps->rcPaint; - ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); + ntfret = TOOLBAR_SendNotify(&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW); } } @@ -1804,7 +1807,7 @@ static void TOOLBAR_Cust_MoveButton(PCUSTDLG_INFO custInfo, HWND hwnd, INT nInde /* MSDN states that iItem is the index of the button, rather than the * command ID as used by every other NMTOOLBAR notification */ nmtb.iItem = nIndexFrom; - if (TOOLBAR_SendNotify((NMHDR *)&nmtb, custInfo->tbInfo, TBN_QUERYINSERT)) + if (TOOLBAR_SendNotify(&nmtb.hdr, custInfo->tbInfo, TBN_QUERYINSERT)) { PCUSTOMBUTTON btnInfo; NMHDR hdr; @@ -1845,7 +1848,7 @@ static void TOOLBAR_Cust_AddButton(PCUSTDLG_INFO custInfo, HWND hwnd, INT nIndex /* MSDN states that iItem is the index of the button, rather than the * command ID as used by every other NMTOOLBAR notification */ nmtb.iItem = nIndexAvail; - if (TOOLBAR_SendNotify((NMHDR *)&nmtb, custInfo->tbInfo, TBN_QUERYINSERT)) + if (TOOLBAR_SendNotify(&nmtb.hdr, custInfo->tbInfo, TBN_QUERYINSERT)) { PCUSTOMBUTTON btnInfo; NMHDR hdr; @@ -2074,10 +2077,11 @@ TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) /* send TBN_QUERYINSERT notification */ nmtb.iItem = custInfo->tbInfo->nNumButtons; - if (!TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_QUERYINSERT)) + if (!TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_QUERYINSERT)) return FALSE; /* UNDOCUMENTED: dialog hwnd immediately follows NMHDR */ + /* FIXME: this hack won't work on 64-bit - we need to declare a structure for this */ nmtb.iItem = (int)hwnd; /* Send TBN_INITCUSTOMIZE notification */ if (TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_INITCUSTOMIZE) == @@ -2222,8 +2226,7 @@ TOOLBAR_CustomizeDialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) /* send TBN_QUERYINSERT notification */ nmtb.iItem = index; - TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, - TBN_QUERYINSERT); + TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_QUERYINSERT); /* get list box item */ btnInfo = (PCUSTOMBUTTON)SendDlgItemMessageW (hwnd, IDC_TOOLBARBTN_LBOX, LB_GETITEMDATA, index, 0); @@ -3029,7 +3032,7 @@ TOOLBAR_AutoSize (HWND hwnd) { x = y = 1; cy += GetSystemMetrics(SM_CYEDGE); - cx += GetSystemMetrics(SM_CYEDGE); + cx += GetSystemMetrics(SM_CXEDGE); } infoPtr->bAutoSize = TRUE; @@ -3056,12 +3059,6 @@ TOOLBAR_ButtonStructSize (HWND hwnd, WPARAM wParam, LPARAM lParam) { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); - if (infoPtr == NULL) { - ERR("(%p, 0x%x, 0x%lx)\n", hwnd, wParam, lParam); - ERR("infoPtr == NULL!\n"); - return 0; - } - infoPtr->dwStructSize = (DWORD)wParam; return 0; @@ -3162,8 +3159,7 @@ TOOLBAR_Customize (HWND hwnd) custInfo.tbHwnd = hwnd; /* send TBN_BEGINADJUST notification */ - TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr, - TBN_BEGINADJUST); + TOOLBAR_SendNotify (&nmhdr, infoPtr, TBN_BEGINADJUST); if (!(hRes = FindResourceW (COMCTL32_hModule, MAKEINTRESOURCEW(IDD_TBCUSTOMIZE), @@ -3180,8 +3176,7 @@ TOOLBAR_Customize (HWND hwnd) (LPARAM)&custInfo); /* send TBN_ENDADJUST notification */ - TOOLBAR_SendNotify ((NMHDR *) &nmhdr, infoPtr, - TBN_ENDADJUST); + TOOLBAR_SendNotify (&nmhdr, infoPtr, TBN_ENDADJUST); return ret; } @@ -3206,7 +3201,7 @@ TOOLBAR_DeleteButton (HWND hwnd, WPARAM wParam, LPARAM lParam) nmtb.tbButton.fsStyle = btnPtr->fsStyle; nmtb.tbButton.dwData = btnPtr->dwData; nmtb.tbButton.iString = btnPtr->iString; - TOOLBAR_SendNotify((NMHDR *)&nmtb, infoPtr, TBN_DELETINGBUTTON); + TOOLBAR_SendNotify(&nmtb.hdr, infoPtr, TBN_DELETINGBUTTON); if ((infoPtr->hwndToolTip) && !(btnPtr->fsStyle & BTNS_SEP)) { @@ -3325,9 +3320,6 @@ TOOLBAR_GetButton (HWND hwnd, WPARAM wParam, LPARAM lParam) INT nIndex = (INT)wParam; TBUTTON_INFO *btnPtr; - if (infoPtr == NULL) - return FALSE; - if (lpTbb == NULL) return FALSE; @@ -3356,8 +3348,6 @@ TOOLBAR_GetButtonInfoA (HWND hwnd, WPARAM wParam, LPARAM lParam) TBUTTON_INFO *btnPtr; INT nIndex; - if (infoPtr == NULL) - return -1; if (lpTbInfo == NULL) return -1; if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOA)) @@ -3404,8 +3394,6 @@ TOOLBAR_GetButtonInfoW (HWND hwnd, WPARAM wParam, LPARAM lParam) TBUTTON_INFO *btnPtr; INT nIndex; - if (infoPtr == NULL) - return -1; if (lpTbInfo == NULL) return -1; if (lpTbInfo->cbSize < sizeof(TBBUTTONINFOW)) @@ -3594,8 +3582,6 @@ TOOLBAR_GetItemRect (HWND hwnd, WPARAM wParam, LPARAM lParam) LPRECT lpRect; INT nIndex; - if (infoPtr == NULL) - return FALSE; nIndex = (INT)wParam; btnPtr = &infoPtr->buttons[nIndex]; if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) @@ -3657,8 +3643,6 @@ TOOLBAR_GetRect (HWND hwnd, WPARAM wParam, LPARAM lParam) LPRECT lpRect; INT nIndex; - if (infoPtr == NULL) - return FALSE; nIndex = TOOLBAR_GetButtonIndex (infoPtr, (INT)wParam, FALSE); btnPtr = &infoPtr->buttons[nIndex]; if ((nIndex < 0) || (nIndex >= infoPtr->nNumButtons)) @@ -3714,9 +3698,6 @@ TOOLBAR_GetTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam) { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); - if (infoPtr == NULL) - return 0; - return infoPtr->nMaxTextRows; } @@ -3726,8 +3707,6 @@ TOOLBAR_GetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam) { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); - if (infoPtr == NULL) - return 0; return (LRESULT)infoPtr->hwndToolTip; } @@ -4385,64 +4364,184 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) return TRUE; } -static LRESULT -TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPARAM lParam) + +/* helper for TOOLBAR_SaveRestoreW */ +static BOOL +TOOLBAR_Save(TOOLBAR_INFO *infoPtr, LPTBSAVEPARAMSW lpSave) { -#if 0 - TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); - LPTBSAVEPARAMSA lpSave = (LPTBSAVEPARAMSA)lParam; + FIXME("save to %s %s\n", debugstr_w(lpSave->pszSubKey), + debugstr_w(lpSave->pszValueName)); - if (lpSave == NULL) return 0; - - if ((BOOL)wParam) { - /* save toolbar information */ - FIXME("save to \"%s\" \"%s\"\n", - lpSave->pszSubKey, lpSave->pszValueName); + return FALSE; +} +/* helper for TOOLBAR_Restore */ +static void +TOOLBAR_DeleteAllButtons(TOOLBAR_INFO *infoPtr) +{ + INT i; + TTTOOLINFOW ti; + + ZeroMemory(&ti, sizeof(ti)); + ti.cbSize = sizeof(ti); + ti.hwnd = infoPtr->hwndSelf; + + for (i = 0; i < infoPtr->nNumButtons; i++) + { + if ((infoPtr->hwndToolTip) && + !(infoPtr->buttons[i].fsStyle & BTNS_SEP)) + { + ti.uId = infoPtr->buttons[i].idCommand; + SendMessageW(infoPtr->hwndToolTip, TTM_DELTOOLW, 0, (LPARAM)&ti); + } } - else { - /* restore toolbar information */ - FIXME("restore from \"%s\" \"%s\"\n", - lpSave->pszSubKey, lpSave->pszValueName); + Free(infoPtr->buttons); + infoPtr->buttons = NULL; + infoPtr->nNumButtons = 0; +} +/* helper for TOOLBAR_SaveRestoreW */ +static BOOL +TOOLBAR_Restore(TOOLBAR_INFO *infoPtr, LPTBSAVEPARAMSW lpSave) +{ + LONG res; + HKEY hkey = NULL; + BOOL ret = FALSE; + DWORD dwType; + DWORD dwSize = 0; + NMTBRESTORE nmtbr; + + /* restore toolbar information */ + TRACE("restore from %s %s\n", debugstr_w(lpSave->pszSubKey), + debugstr_w(lpSave->pszValueName)); + + memset(&nmtbr, 0, sizeof(nmtbr)); + + res = RegOpenKeyExW(lpSave->hkr, lpSave->pszSubKey, 0, + KEY_QUERY_VALUE, &hkey); + if (!res) + res = RegQueryValueExW(hkey, lpSave->pszValueName, NULL, &dwType, + NULL, &dwSize); + if (!res && dwType != REG_BINARY) + res = ERROR_FILE_NOT_FOUND; + if (!res) + { + nmtbr.pData = HeapAlloc(GetProcessHeap(), 0, dwSize); + nmtbr.cbData = (UINT)dwSize; + if (!nmtbr.pData) res = ERROR_OUTOFMEMORY; } -#endif + if (!res) + res = RegQueryValueExW(hkey, lpSave->pszValueName, NULL, &dwType, + (LPBYTE)nmtbr.pData, &dwSize); + if (!res) + { + nmtbr.pCurrent = nmtbr.pData; + nmtbr.iItem = -1; + nmtbr.cbBytesPerRecord = sizeof(DWORD); + nmtbr.cButtons = nmtbr.cbData / nmtbr.cbBytesPerRecord; - return 0; + if (!TOOLBAR_SendNotify(&nmtbr.hdr, infoPtr, TBN_RESTORE)) + { + INT i; + + /* remove all existing buttons as this function is designed to + * restore the toolbar to a previously saved state */ + TOOLBAR_DeleteAllButtons(infoPtr); + + for (i = 0; i < nmtbr.cButtons; i++) + { + nmtbr.iItem = i; + nmtbr.tbButton.iBitmap = -1; + nmtbr.tbButton.fsState = 0; + nmtbr.tbButton.fsStyle = 0; + nmtbr.tbButton.idCommand = 0; + if (*nmtbr.pCurrent == (DWORD)-1) + { + /* separator */ + nmtbr.tbButton.fsStyle = TBSTYLE_SEP; + nmtbr.tbButton.iBitmap = SEPARATOR_WIDTH; + } + else if (*nmtbr.pCurrent == (DWORD)-2) + /* hidden button */ + nmtbr.tbButton.fsState = TBSTATE_HIDDEN; + else + nmtbr.tbButton.idCommand = (int)*nmtbr.pCurrent; + + nmtbr.pCurrent++; + + TOOLBAR_SendNotify(&nmtbr.hdr, infoPtr, TBN_RESTORE); + + /* can't contain real string as we don't know whether + * the client put an ANSI or Unicode string in there */ + if (HIWORD(nmtbr.tbButton.iString)) + nmtbr.tbButton.iString = 0; + + TOOLBAR_InsertButtonW(infoPtr->hwndSelf, -1, + (LPARAM)&nmtbr.tbButton); + } + + /* do legacy notifications */ + if (infoPtr->iVersion < 5) + { + /* FIXME: send TBN_BEGINADJUST */ + FIXME("send TBN_GETBUTTONINFO for each button\n"); + /* FIXME: send TBN_ENDADJUST */ + } + + /* remove all uninitialised buttons + * note: loop backwards to avoid having to fixup i on a + * delete */ + for (i = infoPtr->nNumButtons - 1; i >= 0; i--) + if (infoPtr->buttons[i].iBitmap == -1) + TOOLBAR_DeleteButton(infoPtr->hwndSelf, i, 0); + + /* only indicate success if at least one button survived */ + if (infoPtr->nNumButtons > 0) ret = TRUE; + } + } + HeapFree(GetProcessHeap(), 0, nmtbr.pData); + RegCloseKey(hkey); + + return ret; } static LRESULT -TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPARAM lParam) +TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPTBSAVEPARAMSW lpSave) { -#if 0 TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); - LPTBSAVEPARAMSW lpSave = (LPTBSAVEPARAMSW)lParam; - if (lpSave == NULL) - return 0; + if (lpSave == NULL) return 0; - if ((BOOL)wParam) { - /* save toolbar information */ - FIXME("save to \"%s\" \"%s\"\n", - lpSave->pszSubKey, lpSave->pszValueName); + if (wParam) + return TOOLBAR_Save(infoPtr, lpSave); + else + return TOOLBAR_Restore(infoPtr, lpSave); +} - } - else { - /* restore toolbar information */ +static LRESULT +TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPTBSAVEPARAMSA lpSave) +{ + TBSAVEPARAMSW SaveW; + int len; - FIXME("restore from \"%s\" \"%s\"\n", - lpSave->pszSubKey, lpSave->pszValueName); + if (lpSave == NULL) return 0; + SaveW.hkr = lpSave->hkr; - } -#endif + len = MultiByteToWideChar(CP_ACP, 0, lpSave->pszSubKey, -1, NULL, 0); + SaveW.pszSubKey = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, lpSave->pszSubKey, -1, (LPWSTR)SaveW.pszSubKey, len); - return 0; + len = MultiByteToWideChar(CP_ACP, 0, lpSave->pszValueName, -1, NULL, 0); + SaveW.pszValueName = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + MultiByteToWideChar(CP_ACP, 0, lpSave->pszValueName, -1, (LPWSTR)SaveW.pszValueName, len); + + return TOOLBAR_SaveRestoreW(hwnd, wParam, &SaveW); } @@ -4613,9 +4712,11 @@ TOOLBAR_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam) if ((cx < 0) || (cy < 0)) { ERR("invalid parameter 0x%08lx\n", (DWORD)lParam); - return FALSE; + return FALSE; } + TRACE("%p, cx = %d, cy = %d\n", hwnd, cx, cy); + /* The documentation claims you can only change the button size before * any button has been added. But this is wrong. * WINZIP32.EXE (ver 8) calls this on one of its buttons after adding @@ -4638,11 +4739,6 @@ TOOLBAR_SetButtonWidth (HWND hwnd, WPARAM wParam, LPARAM lParam) { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); - if (infoPtr == NULL) { - TRACE("Toolbar not initialized yet?????\n"); - return FALSE; - } - /* if setting to current values, ignore */ if ((infoPtr->cxMin == (INT)LOWORD(lParam)) && (infoPtr->cxMax == (INT)HIWORD(lParam))) { @@ -4824,7 +4920,7 @@ TOOLBAR_SetHotItemEx (TOOLBAR_INFO *infoPtr, INT nHit, DWORD dwReason) else nmhotitem.dwFlags |= HICF_LEAVING; - no_highlight = TOOLBAR_SendNotify((NMHDR*)&nmhotitem, infoPtr, TBN_HOTITEMCHANGE); + no_highlight = TOOLBAR_SendNotify(&nmhotitem.hdr, infoPtr, TBN_HOTITEMCHANGE); /* now invalidate the old and new buttons so they will be painted */ if (oldBtnPtr) @@ -4879,10 +4975,15 @@ TOOLBAR_SetImageList (HWND hwnd, WPARAM wParam, LPARAM lParam) for (i = 0; i < infoPtr->cimlDef; i++) infoPtr->nNumBitmaps += ImageList_GetImageCount(infoPtr->himlDef[i]->himl); - ImageList_GetIconSize(himl, &infoPtr->nBitmapWidth, - &infoPtr->nBitmapHeight); - TRACE("hwnd %p, new himl=%08x, count=%d, bitmap w=%d, h=%d\n", - hwnd, (INT)infoPtr->himlDef, infoPtr->nNumBitmaps, + if (!ImageList_GetIconSize(himl, &infoPtr->nBitmapWidth, + &infoPtr->nBitmapHeight)) + { + infoPtr->nBitmapWidth = 0; + infoPtr->nBitmapHeight = 0; + } + + TRACE("hwnd %p, new himl=%p, id = %d, count=%d, bitmap w=%d, h=%d\n", + hwnd, infoPtr->himlDef, id, infoPtr->nNumBitmaps, infoPtr->nBitmapWidth, infoPtr->nBitmapHeight); InvalidateRect(hwnd, NULL, TRUE); @@ -4960,9 +5061,6 @@ TOOLBAR_SetMaxTextRows (HWND hwnd, WPARAM wParam, LPARAM lParam) { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); - if (infoPtr == NULL) - return FALSE; - infoPtr->nMaxTextRows = (INT)wParam; TOOLBAR_CalcToolbar(hwnd); @@ -5003,8 +5101,6 @@ TOOLBAR_SetParent (HWND hwnd, WPARAM wParam, LPARAM lParam) TRACE("\n"); - if (infoPtr == NULL) - return 0; hwndOldNotify = infoPtr->hwndNotify; infoPtr->hwndNotify = (HWND)wParam; @@ -5095,8 +5191,6 @@ TOOLBAR_SetToolTips (HWND hwnd, WPARAM wParam, LPARAM lParam) TRACE("hwnd=%p, hwndTooltip=%p, lParam=0x%lx\n", hwnd, (HWND)wParam, lParam); - if (infoPtr == NULL) - return 0; infoPtr->hwndToolTip = (HWND)wParam; return 0; } @@ -5370,7 +5464,6 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->nOldHit = -1; infoPtr->nHotItem = -1; infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent; - infoPtr->bUnicode = IsWindowUnicode (infoPtr->hwndNotify); infoPtr->bBtnTranspnt = (dwStyle & (TBSTYLE_FLAT | TBSTYLE_LIST)); infoPtr->dwDTFlags = (dwStyle & TBSTYLE_LIST) ? DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS: DT_CENTER | DT_END_ELLIPSIS; infoPtr->bAnchor = FALSE; /* no anchor highlighting */ @@ -5380,15 +5473,14 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->bDoRedraw = TRUE; infoPtr->clrBtnHighlight = CLR_DEFAULT; infoPtr->clrBtnShadow = CLR_DEFAULT; - /* not sure where the +1 comes from, but this comes to the same value - * as native so this is probably correct */ - infoPtr->szPadding.cx = 2*(GetSystemMetrics(SM_CXEDGE)+OFFSET_X) + 1; - infoPtr->szPadding.cy = 2*(GetSystemMetrics(SM_CYEDGE)+OFFSET_Y); + infoPtr->szPadding.cx = DEFPAD_CX; + infoPtr->szPadding.cy = DEFPAD_CY; infoPtr->iListGap = infoPtr->szPadding.cx / 2; infoPtr->dwStyle = dwStyle; infoPtr->tbim.iButton = -1; GetClientRect(hwnd, &infoPtr->client_rect); - TOOLBAR_NotifyFormat(infoPtr, (WPARAM)hwnd, (LPARAM)NF_REQUERY); + infoPtr->bUnicode = infoPtr->hwndNotify && + (NFR_UNICODE == SendMessageW(hwnd, WM_NOTIFYFORMAT, (WPARAM)hwnd, (LPARAM)NF_REQUERY)); SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectA (&logFont); @@ -5402,13 +5494,13 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) hwnd, 0, 0, 0); /* Send NM_TOOLTIPSCREATED notification */ - if (infoPtr->hwndToolTip) { + if (infoPtr->hwndToolTip) + { NMTOOLTIPSCREATED nmttc; nmttc.hwndToolTips = infoPtr->hwndToolTip; - TOOLBAR_SendNotify ((NMHDR *) &nmttc, infoPtr, - NM_TOOLTIPSCREATED); + TOOLBAR_SendNotify (&nmttc.hdr, infoPtr, NM_TOOLTIPSCREATED); } } @@ -5483,7 +5575,7 @@ TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam) ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW)); tbcd.nmcd.dwDrawStage = CDDS_PREERASE; tbcd.nmcd.hdc = (HDC)wParam; - ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); + ntfret = TOOLBAR_SendNotify (&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW); infoPtr->dwBaseCustDraw = ntfret & 0xffff; /* FIXME: in general the return flags *can* be or'ed together */ @@ -5523,7 +5615,7 @@ TOOLBAR_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam) ZeroMemory (&tbcd, sizeof(NMTBCUSTOMDRAW)); tbcd.nmcd.dwDrawStage = CDDS_POSTERASE; tbcd.nmcd.hdc = (HDC)wParam; - ntfret = TOOLBAR_SendNotify ((NMHDR *)&tbcd, infoPtr, NM_CUSTOMDRAW); + ntfret = TOOLBAR_SendNotify (&tbcd.nmcd.hdr, infoPtr, NM_CUSTOMDRAW); infoPtr->dwBaseCustDraw = ntfret & 0xffff; switch (infoPtr->dwBaseCustDraw) { @@ -5632,11 +5724,9 @@ TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) RedrawWindow(hwnd,&btnPtr->rect,0, RDW_ERASE|RDW_INVALIDATE|RDW_UPDATENOW); + memset(&nmtb, 0, sizeof(nmtb)); nmtb.iItem = btnPtr->idCommand; - memset(&nmtb.tbButton, 0, sizeof(TBBUTTON)); - nmtb.cchText = 0; - nmtb.pszText = 0; - CopyRect(&nmtb.rcButton, &btnPtr->rect); + nmtb.rcButton = btnPtr->rect; res = TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_DROPDOWN); TRACE("TBN_DROPDOWN responded with %ld\n", res); @@ -5686,22 +5776,15 @@ TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) if (nHit >=0) { + memset(&nmtb, 0, sizeof(nmtb)); nmtb.iItem = btnPtr->idCommand; - nmtb.tbButton.iBitmap = btnPtr->iBitmap; - nmtb.tbButton.idCommand = btnPtr->idCommand; - nmtb.tbButton.fsState = btnPtr->fsState; - nmtb.tbButton.fsStyle = btnPtr->fsStyle; - nmtb.tbButton.dwData = btnPtr->dwData; - nmtb.tbButton.iString = btnPtr->iString; - nmtb.cchText = 0; /* !!! not correct */ - nmtb.pszText = 0; /* !!! not correct */ TOOLBAR_SendNotify((NMHDR *)&nmtb, infoPtr, TBN_BEGINDRAG); } nmmouse.dwHitInfo = nHit; /* !!! Undocumented - sends NM_LDOWN with the NMMOUSE structure. */ - if (nmmouse.dwHitInfo < 0) + if (nHit < 0) nmmouse.dwItemSpec = -1; else { @@ -5712,7 +5795,7 @@ TOOLBAR_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) ClientToScreen(hwnd, &pt); nmmouse.pt = pt; - if (!TOOLBAR_SendNotify((LPNMHDR)&nmmouse, infoPtr, NM_LDOWN)) + if (!TOOLBAR_SendNotify(&nmmouse.hdr, infoPtr, NM_LDOWN)) return DefWindowProcW(hwnd, WM_LBUTTONDOWN, wParam, lParam); return 0; @@ -5847,15 +5930,8 @@ TOOLBAR_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) /* native issues TBN_ENDDRAG here, if _LBUTTONDOWN issued the * TBN_BEGINDRAG */ + memset(&nmtb, 0, sizeof(nmtb)); nmtb.iItem = btnPtr->idCommand; - nmtb.tbButton.iBitmap = btnPtr->iBitmap; - nmtb.tbButton.idCommand = btnPtr->idCommand; - nmtb.tbButton.fsState = btnPtr->fsState; - nmtb.tbButton.fsStyle = btnPtr->fsStyle; - nmtb.tbButton.dwData = btnPtr->dwData; - nmtb.tbButton.iString = btnPtr->iString; - nmtb.cchText = 0; /* !!! not correct */ - nmtb.pszText = 0; /* !!! not correct */ TOOLBAR_SendNotify ((NMHDR *) &nmtb, infoPtr, TBN_ENDDRAG); @@ -5891,16 +5967,17 @@ static LRESULT TOOLBAR_RButtonUp( HWND hwnd, WPARAM wParam, LPARAM lParam) { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); - + INT nHit; NMMOUSE nmmouse; POINT pt; pt.x = LOWORD(lParam); pt.y = HIWORD(lParam); - nmmouse.dwHitInfo = TOOLBAR_InternalHitTest(hwnd, &pt); + nHit = TOOLBAR_InternalHitTest(hwnd, &pt); + nmmouse.dwHitInfo = nHit; - if (nmmouse.dwHitInfo < 0) { + if (nHit < 0) { nmmouse.dwItemSpec = -1; } else { nmmouse.dwItemSpec = infoPtr->buttons[nmmouse.dwHitInfo].idCommand; @@ -6207,7 +6284,7 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm if (index < 0) return 0; - if (infoPtr->bNtfUnicode) + if (infoPtr->bUnicode) { WCHAR wszBuffer[INFOTIPSIZE+1]; NMTBGETINFOTIPW tbgit; @@ -6362,7 +6439,7 @@ TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam) return TOOLBAR_TTGetDispInfo(infoPtr, (LPNMTTDISPINFOW)lParam); case TTN_GETDISPINFOA: - FIXME("TTN_GETDISPINFOA - stub\n"); + FIXME("TTN_GETDISPINFOA - should not be received; please report\n"); return 0; default: @@ -6371,39 +6448,27 @@ TOOLBAR_Notify (HWND hwnd, WPARAM wParam, LPARAM lParam) } -static LRESULT -TOOLBAR_NotifyFormatFake(HWND hwnd, WPARAM wParam, LPARAM lParam) -{ - /* remove this routine when Toolbar is improved to pass infoPtr - * around instead of hwnd. - */ - TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr(hwnd); - return TOOLBAR_NotifyFormat(infoPtr, wParam, lParam); -} - - static LRESULT TOOLBAR_NotifyFormat(TOOLBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - INT i; + LRESULT format; TRACE("wParam = 0x%x, lParam = 0x%08lx\n", wParam, lParam); - if ((lParam == NF_QUERY) && ((HWND)wParam == infoPtr->hwndToolTip)) + if (lParam == NF_QUERY) return NFR_UNICODE; if (lParam == NF_REQUERY) { - i = SendMessageW(infoPtr->hwndNotify, + format = SendMessageW(infoPtr->hwndNotify, WM_NOTIFYFORMAT, (WPARAM)infoPtr->hwndSelf, NF_QUERY); - if ((i < NFR_ANSI) || (i > NFR_UNICODE)) { - ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", - i); - i = NFR_ANSI; + if ((format != NFR_ANSI) && (format != NFR_UNICODE)) { + ERR("wrong response to WM_NOTIFYFORMAT (%ld), assuming ANSI\n", + format); + format = NFR_ANSI; } - infoPtr->bNtfUnicode = (i == NFR_UNICODE) ? 1 : 0; - return (LRESULT)i; + return format; } - return (LRESULT)((infoPtr->bUnicode) ? NFR_UNICODE : NFR_ANSI); + return 0; } @@ -6541,7 +6606,7 @@ TOOLBAR_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) { x = y = 1; cy += GetSystemMetrics(SM_CYEDGE); - cx += GetSystemMetrics(SM_CYEDGE); + cx += GetSystemMetrics(SM_CXEDGE); } if(infoPtr->dwExStyle & TBSTYLE_EX_HIDECLIPPEDBUTTONS) @@ -6597,28 +6662,30 @@ TOOLBAR_StyleChanged (HWND hwnd, INT nType, LPSTYLESTRUCT lpStyle) { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); - if (nType == GWL_STYLE) { - if (lpStyle->styleNew & TBSTYLE_LIST) { - infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS; - } - else { - infoPtr->dwDTFlags = DT_CENTER | DT_END_ELLIPSIS; - } + if (nType == GWL_STYLE) + { + if (lpStyle->styleNew & TBSTYLE_LIST) + infoPtr->dwDTFlags = DT_LEFT | DT_VCENTER | DT_SINGLELINE | DT_END_ELLIPSIS; + else + infoPtr->dwDTFlags = DT_CENTER | DT_END_ELLIPSIS; + infoPtr->bBtnTranspnt = (lpStyle->styleNew & (TBSTYLE_FLAT | TBSTYLE_LIST)); - TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew); + TOOLBAR_CheckStyle (hwnd, lpStyle->styleNew); TRACE("new style 0x%08lx\n", lpStyle->styleNew); infoPtr->dwStyle = lpStyle->styleNew; + + /* only resize if one of the CCS_* styles was changed */ + if ((infoPtr->dwStyle ^ lpStyle->styleNew) & COMMON_STYLES) + { + TOOLBAR_AutoSize (hwnd); + + InvalidateRect(hwnd, NULL, TRUE); + } } - TOOLBAR_CalcToolbar(hwnd); - - TOOLBAR_AutoSize (hwnd); - - InvalidateRect(hwnd, NULL, TRUE); - return 0; } @@ -6641,7 +6708,7 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, /* SPY_GetMsgName(uMsg), */ wParam, lParam); - if (!TOOLBAR_GetInfoPtr(hwnd) && (uMsg != WM_NCCREATE)) + if (!infoPtr && (uMsg != WM_NCCREATE)) return DefWindowProcW( hwnd, uMsg, wParam, lParam ); switch (uMsg) @@ -6829,10 +6896,10 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TOOLBAR_ReplaceBitmap (hwnd, wParam, lParam); case TB_SAVERESTOREA: - return TOOLBAR_SaveRestoreA (hwnd, wParam, lParam); + return TOOLBAR_SaveRestoreA (hwnd, wParam, (LPTBSAVEPARAMSA)lParam); case TB_SAVERESTOREW: - return TOOLBAR_SaveRestoreW (hwnd, wParam, lParam); + return TOOLBAR_SaveRestoreW (hwnd, wParam, (LPTBSAVEPARAMSW)lParam); case TB_SETANCHORHIGHLIGHT: return TOOLBAR_SetAnchorHighlight (hwnd, wParam); @@ -6998,7 +7065,7 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TOOLBAR_Notify (hwnd, wParam, lParam); case WM_NOTIFYFORMAT: - return TOOLBAR_NotifyFormatFake (hwnd, wParam, lParam); + return TOOLBAR_NotifyFormat (infoPtr, wParam, lParam); case WM_PAINT: return TOOLBAR_Paint (hwnd, wParam); @@ -7145,7 +7212,7 @@ static HIMAGELIST TOOLBAR_GetImageList(PIMLENTRY *pies, INT cies, INT id) static BOOL TOOLBAR_GetButtonInfo(TOOLBAR_INFO *infoPtr, NMTOOLBARW *nmtb) { if (infoPtr->bUnicode) - return TOOLBAR_SendNotify ((NMHDR *) nmtb, infoPtr, TBN_GETBUTTONINFOW); + return TOOLBAR_SendNotify(&nmtb->hdr, infoPtr, TBN_GETBUTTONINFOW); else { CHAR Buffer[256]; @@ -7157,7 +7224,7 @@ static BOOL TOOLBAR_GetButtonInfo(TOOLBAR_INFO *infoPtr, NMTOOLBARW *nmtb) nmtba.cchText = 256; ZeroMemory(nmtba.pszText, nmtba.cchText); - if (TOOLBAR_SendNotify ((NMHDR *) &nmtba, infoPtr, TBN_GETBUTTONINFOA)) + if (TOOLBAR_SendNotify(&nmtba.hdr, infoPtr, TBN_GETBUTTONINFOA)) { int ccht = strlen(nmtba.pszText); if (ccht) diff --git a/reactos/lib/comctl32/tooltips.c b/reactos/lib/comctl32/tooltips.c index cd7628861db..b31f71917e4 100644 --- a/reactos/lib/comctl32/tooltips.c +++ b/reactos/lib/comctl32/tooltips.c @@ -1927,16 +1927,25 @@ TOOLTIPS_SetTitleA (HWND hwnd, WPARAM wParam, LPARAM lParam) { TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); LPCSTR pszTitle = (LPCSTR)lParam; - UINT uTitleIcon = (UINT)wParam; + UINT_PTR uTitleIcon = (UINT_PTR)wParam; UINT size; - TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, pszTitle, (void*)uTitleIcon); + TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_a(pszTitle), + (void*)uTitleIcon); + + Free(infoPtr->pszTitle); + + if (pszTitle) + { + size = sizeof(WCHAR)*MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, NULL, 0); + infoPtr->pszTitle = Alloc(size); + if (!infoPtr->pszTitle) + return FALSE; + MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, infoPtr->pszTitle, size/sizeof(WCHAR)); + } + else + infoPtr->pszTitle = NULL; - size = sizeof(WCHAR)*MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, NULL, 0); - infoPtr->pszTitle = Alloc(size); - if (!infoPtr->pszTitle) - return FALSE; - MultiByteToWideChar(CP_ACP, 0, pszTitle, -1, infoPtr->pszTitle, size/sizeof(WCHAR)); if (uTitleIcon <= TTI_ERROR) infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon]; else @@ -1951,16 +1960,25 @@ TOOLTIPS_SetTitleW (HWND hwnd, WPARAM wParam, LPARAM lParam) { TOOLTIPS_INFO *infoPtr = TOOLTIPS_GetInfoPtr (hwnd); LPCWSTR pszTitle = (LPCWSTR)lParam; - UINT uTitleIcon = (UINT)wParam; + UINT_PTR uTitleIcon = (UINT_PTR)wParam; UINT size; - TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_w(pszTitle), (void*)uTitleIcon); + TRACE("hwnd = %p, title = %s, icon = %p\n", hwnd, debugstr_w(pszTitle), + (void*)uTitleIcon); + + Free(infoPtr->pszTitle); + + if (pszTitle) + { + size = (strlenW(pszTitle)+1)*sizeof(WCHAR); + infoPtr->pszTitle = Alloc(size); + if (!infoPtr->pszTitle) + return FALSE; + memcpy(infoPtr->pszTitle, pszTitle, size); + } + else + infoPtr->pszTitle = NULL; - size = (strlenW(pszTitle)+1)*sizeof(WCHAR); - infoPtr->pszTitle = Alloc(size); - if (!infoPtr->pszTitle) - return FALSE; - memcpy(infoPtr->pszTitle, pszTitle, size); if (uTitleIcon <= TTI_ERROR) infoPtr->hTitleIcon = hTooltipIcons[uTitleIcon]; else diff --git a/reactos/lib/comctl32/trackbar.c b/reactos/lib/comctl32/trackbar.c index c18463caa9d..afd04428172 100644 --- a/reactos/lib/comctl32/trackbar.c +++ b/reactos/lib/comctl32/trackbar.c @@ -1418,9 +1418,12 @@ TRACKBAR_KillFocus (TRACKBAR_INFO *infoPtr, HWND hwndGetFocus) } static LRESULT -TRACKBAR_LButtonDown (TRACKBAR_INFO *infoPtr, DWORD fwKeys, POINTS pts) +TRACKBAR_LButtonDown (TRACKBAR_INFO *infoPtr, DWORD fwKeys, INT x, INT y) { - POINT clickPoint = { pts.x, pts.y }; + POINT clickPoint; + + clickPoint.x = x; + clickPoint.y = y; SetFocus(infoPtr->hwndSelf); @@ -1444,7 +1447,7 @@ TRACKBAR_LButtonDown (TRACKBAR_INFO *infoPtr, DWORD fwKeys, POINTS pts) static LRESULT -TRACKBAR_LButtonUp (TRACKBAR_INFO *infoPtr, DWORD fwKeys, POINTS pts) +TRACKBAR_LButtonUp (TRACKBAR_INFO *infoPtr, DWORD fwKeys, INT x, INT y) { if (infoPtr->flags & TB_DRAG_MODE) { notify_with_scroll (infoPtr, TB_THUMBPOSITION | (infoPtr->lPos<<16)); @@ -1526,17 +1529,18 @@ TRACKBAR_Timer (TRACKBAR_INFO *infoPtr, INT wTimerID, TIMERPROC *tmrpc) static LRESULT -TRACKBAR_MouseMove (TRACKBAR_INFO *infoPtr, DWORD fwKeys, POINTS pts) +TRACKBAR_MouseMove (TRACKBAR_INFO *infoPtr, DWORD fwKeys, INT x, INT y) { DWORD dwStyle = GetWindowLongW (infoPtr->hwndSelf, GWL_STYLE); - INT clickPlace = (dwStyle & TBS_VERT) ? pts.y : pts.x; + INT clickPlace = (dwStyle & TBS_VERT) ? y : x; LONG dragPos, oldPos = infoPtr->lPos; - TRACE("(x=%d. y=%d)\n", pts.x, pts.y); + TRACE("(x=%d. y=%d)\n", x, y); if (infoPtr->flags & TB_AUTO_PAGE) { POINT pt; - POINTSTOPOINT(pt, pts); + pt.x = x; + pt.y = y; TRACKBAR_AutoPage (infoPtr, pt); return TRUE; } @@ -1778,13 +1782,13 @@ TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return TRACKBAR_KillFocus (infoPtr, (HWND)wParam); case WM_LBUTTONDOWN: - return TRACKBAR_LButtonDown (infoPtr, wParam, MAKEPOINTS(lParam)); + return TRACKBAR_LButtonDown (infoPtr, wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_LBUTTONUP: - return TRACKBAR_LButtonUp (infoPtr, wParam, MAKEPOINTS(lParam)); + return TRACKBAR_LButtonUp (infoPtr, wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_MOUSEMOVE: - return TRACKBAR_MouseMove (infoPtr, wParam, MAKEPOINTS(lParam)); + return TRACKBAR_MouseMove (infoPtr, wParam, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); case WM_PAINT: return TRACKBAR_Paint (infoPtr, (HDC)wParam); diff --git a/reactos/lib/comctl32/treeview.c b/reactos/lib/comctl32/treeview.c index 102796fa19b..af6ca487512 100644 --- a/reactos/lib/comctl32/treeview.c +++ b/reactos/lib/comctl32/treeview.c @@ -130,6 +130,7 @@ typedef struct tagTREEVIEW_INFO COLORREF clrLine; COLORREF clrInsertMark; HFONT hFont; + HFONT hDefaultFont; HFONT hBoldFont; HWND hwndToolTip; @@ -255,11 +256,11 @@ TREEVIEW_ValidItem(TREEVIEW_INFO *infoPtr, HTREEITEM handle) static HFONT TREEVIEW_CreateBoldFont(HFONT hOrigFont) { - LOGFONTA font; + LOGFONTW font; - GetObjectA(hOrigFont, sizeof(font), &font); + GetObjectW(hOrigFont, sizeof(font), &font); font.lfWeight = FW_BOLD; - return CreateFontIndirectA(&font); + return CreateFontIndirectW(&font); } static inline HFONT @@ -1809,7 +1810,7 @@ TREEVIEW_SetFont(TREEVIEW_INFO *infoPtr, HFONT hFont, BOOL bRedraw) TRACE("%p %i\n", hFont, bRedraw); - infoPtr->hFont = hFont ? hFont : GetStockObject(SYSTEM_FONT); + infoPtr->hFont = hFont ? hFont : infoPtr->hDefaultFont; DeleteObject(infoPtr->hBoldFont); infoPtr->hBoldFont = TREEVIEW_CreateBoldFont(infoPtr->hFont); @@ -2328,7 +2329,7 @@ TREEVIEW_DrawItemLines(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item) SelectObject(hdc, hOldPen); DeleteObject(hNewPen); - if (height < 32 || width < 32) + if (height < 18 || width < 18) { MoveToEx(hdc, centerx - plussize + 1, centery, NULL); LineTo(hdc, centerx + plussize, centery); @@ -4684,6 +4685,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) static const WCHAR szDisplayW[] = { 'D','I','S','P','L','A','Y','\0' }; RECT rcClient; TREEVIEW_INFO *infoPtr; + LOGFONTW lf; TRACE("wnd %p, style %lx\n", hwnd, GetWindowLongW(hwnd, GWL_STYLE)); @@ -4749,7 +4751,8 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) infoPtr->items = DPA_Create(16); - infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT); + SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0); + infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectW(&lf); infoPtr->hBoldFont = TREEVIEW_CreateBoldFont(infoPtr->hFont); infoPtr->uItemHeight = TREEVIEW_NaturalHeight(infoPtr); @@ -4839,6 +4842,7 @@ TREEVIEW_Destroy(TREEVIEW_INFO *infoPtr) /* Deassociate treeview from the window before doing anything drastic. */ SetWindowLongPtrW(infoPtr->hwnd, 0, (DWORD_PTR)NULL); + DeleteObject(infoPtr->hDefaultFont); DeleteObject(infoPtr->hBoldFont); Free(infoPtr); @@ -5399,7 +5403,7 @@ TREEVIEW_Register(void) ZeroMemory(&wndClass, sizeof(WNDCLASSA)); wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; - wndClass.lpfnWndProc = (WNDPROC)TREEVIEW_WindowProc; + wndClass.lpfnWndProc = TREEVIEW_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(TREEVIEW_INFO *); diff --git a/reactos/lib/comctl32/updown.c b/reactos/lib/comctl32/updown.c index 8950b27ea2d..08d01f87656 100644 --- a/reactos/lib/comctl32/updown.c +++ b/reactos/lib/comctl32/updown.c @@ -92,12 +92,12 @@ typedef struct #define TIMER_ACCEL 2 #define TIMER_AUTOPRESS 3 -#define BUDDY_UPDOWN_HWND "buddyUpDownHWND" -#define BUDDY_SUPERCLASS_WNDPROC "buddySupperClassWndProc" - #define UPDOWN_GetInfoPtr(hwnd) ((UPDOWN_INFO *)GetWindowLongPtrW (hwnd,0)) #define COUNT_OF(a) (sizeof(a)/sizeof(a[0])) +static const WCHAR BUDDY_UPDOWN_HWND[] = { 'b', 'u', 'd', 'd', 'y', 'U', 'p', 'D', 'o', 'w', 'n', 'H', 'W', 'N', 'D', 0 }; +static const WCHAR BUDDY_SUPERCLASS_WNDPROC[] = { 'b', 'u', 'd', 'd', 'y', 'S', 'u', 'p', 'p', 'e', 'r', + 'C', 'l', 'a', 's', 's', 'W', 'n', 'd', 'P', 'r', 'o', 'c', 0 }; static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action); /*********************************************************************** @@ -427,12 +427,13 @@ static LRESULT UPDOWN_KeyPressed(UPDOWN_INFO *infoPtr, int key) static LRESULT CALLBACK UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - WNDPROC superClassWndProc = (WNDPROC)GetPropA(hwnd, BUDDY_SUPERCLASS_WNDPROC); - TRACE("hwnd=%p, wndProc=%d, uMsg=%04x, wParam=%d, lParam=%d\n", - hwnd, (INT)superClassWndProc, uMsg, wParam, (UINT)lParam); + WNDPROC superClassWndProc = (WNDPROC)GetPropW(hwnd, BUDDY_SUPERCLASS_WNDPROC); + + TRACE("hwnd=%p, wndProc=%p, uMsg=%04x, wParam=%08x, lParam=%08lx\n", + hwnd, superClassWndProc, uMsg, wParam, lParam); if (uMsg == WM_KEYDOWN) { - HWND upDownHwnd = GetPropA(hwnd, BUDDY_UPDOWN_HWND); + HWND upDownHwnd = GetPropW(hwnd, BUDDY_UPDOWN_HWND); UPDOWN_KeyPressed(UPDOWN_GetInfoPtr(upDownHwnd), (int)wParam); } @@ -452,11 +453,13 @@ UPDOWN_Buddy_SubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) */ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) { + static const WCHAR editW[] = { 'E', 'd', 'i', 't', 0 }; + static const WCHAR listboxW[] = { 'L', 'i', 's', 't', 'b', 'o', 'x', 0 }; DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE); RECT budRect; /* new coord for the buddy */ int x, width; /* new x position and width for the up-down */ WNDPROC baseWndProc; - CHAR buddyClass[40]; + WCHAR buddyClass[40]; HWND ret; TRACE("(hwnd=%p, bud=%p)\n", infoPtr->Self, bud); @@ -464,7 +467,7 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) ret = infoPtr->Buddy; /* there is already a body assigned */ - if (infoPtr->Buddy) RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND); + if (infoPtr->Buddy) RemovePropW(infoPtr->Buddy, BUDDY_UPDOWN_HWND); if(!IsWindow(bud)) bud = 0; @@ -475,14 +478,14 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) if(bud) { /* keep upDown ctrl hwnd in a buddy property */ - SetPropA( bud, BUDDY_UPDOWN_HWND, infoPtr->Self); + SetPropW( bud, BUDDY_UPDOWN_HWND, infoPtr->Self); /* Store buddy window class type */ infoPtr->BuddyType = BUDDY_TYPE_UNKNOWN; - if (GetClassNameA(bud, buddyClass, COUNT_OF(buddyClass))) { - if (lstrcmpiA(buddyClass, "Edit") == 0) + if (GetClassNameW(bud, buddyClass, COUNT_OF(buddyClass))) { + if (lstrcmpiW(buddyClass, editW) == 0) infoPtr->BuddyType = BUDDY_TYPE_EDIT; - else if (lstrcmpiA(buddyClass, "Listbox") == 0) + else if (lstrcmpiW(buddyClass, listboxW) == 0) infoPtr->BuddyType = BUDDY_TYPE_LISTBOX; } @@ -490,9 +493,9 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) /* Note that I don't clear the BUDDY_SUPERCLASS_WNDPROC property when we reset the upDown ctrl buddy to another buddy because it is not good to break the window proc chain. */ - if (!GetPropA(bud, BUDDY_SUPERCLASS_WNDPROC)) { + if (!GetPropW(bud, BUDDY_SUPERCLASS_WNDPROC)) { baseWndProc = (WNDPROC)SetWindowLongPtrW(bud, GWLP_WNDPROC, (LPARAM)UPDOWN_Buddy_SubclassProc); - SetPropA(bud, BUDDY_SUPERCLASS_WNDPROC, (HANDLE)baseWndProc); + SetPropW(bud, BUDDY_SUPERCLASS_WNDPROC, (HANDLE)baseWndProc); } } @@ -508,7 +511,8 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP; x = budRect.right+DEFAULT_XSEP; } else { - x = budRect.right+DEFAULT_XSEP; + /* nothing to do */ + return ret; } /* first adjust the buddy to accommodate the up/down */ @@ -533,7 +537,7 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) x -= DEFAULT_BUDDYBORDER; } - SetWindowPos(infoPtr->Self, infoPtr->Buddy, x, + SetWindowPos(infoPtr->Self, 0, x, budRect.top - DEFAULT_ADDTOP, width, budRect.bottom - budRect.top + DEFAULT_ADDTOP + DEFAULT_ADDBOT, SWP_NOACTIVATE|SWP_FRAMECHANGED|SWP_NOZORDER); @@ -568,6 +572,8 @@ static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action) delta *= (action & FLAG_INCR ? 1 : -1) * (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1); if ( (action & FLAG_INCR) && (action & FLAG_DECR) ) delta = 0; + TRACE("current %d, delta: %d\n", infoPtr->CurVal, delta); + /* We must notify parent now to obtain permission */ ni.iPos = infoPtr->CurVal; ni.iDelta = delta; @@ -579,6 +585,8 @@ static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action) /* Now adjust value with (maybe new) delta */ if (UPDOWN_OffsetVal (infoPtr, ni.iDelta)) { + TRACE("new %d, delta: %d\n", infoPtr->CurVal, ni.iDelta); + /* Now take care about our buddy */ if (dwStyle & UDS_SETBUDDYINT) UPDOWN_SetBuddyInt (infoPtr); } @@ -597,7 +605,7 @@ static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action) */ static BOOL UPDOWN_IsEnabled (UPDOWN_INFO *infoPtr) { - if(GetWindowLongW (infoPtr->Self, GWL_STYLE) & WS_DISABLED) + if (!IsWindowEnabled(infoPtr->Self)) return FALSE; if(infoPtr->Buddy) return IsWindowEnabled(infoPtr->Buddy); @@ -642,23 +650,32 @@ static BOOL UPDOWN_CancelMode (UPDOWN_INFO *infoPtr) * 'pt' is the location of the mouse event in client or * windows coordinates. */ -static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, POINTS pts) +static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT y) { DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE); - POINT pt = { pts.x, pts.y }; + POINT pt = { x, y }; RECT rect; int temp, arrow; + TRACE("msg %04x point %s\n", msg, wine_dbgstr_point(&pt)); + switch(msg) { case WM_LBUTTONDOWN: /* Initialise mouse tracking */ - /* If we are inside an arrow, then nothing to do */ - if(!(infoPtr->Flags & FLAG_MOUSEIN)) return; /* If the buddy is an edit, will set focus to it */ if (UPDOWN_IsBuddyEdit(infoPtr)) SetFocus(infoPtr->Buddy); /* Now see which one is the 'active' arrow */ + arrow = UPDOWN_GetArrowFromPoint (infoPtr, &rect, pt); + + /* Update the flags if we are in/out */ + infoPtr->Flags &= ~(FLAG_MOUSEIN | FLAG_ARROW); + if (arrow) + infoPtr->Flags |= FLAG_MOUSEIN | arrow; + else + if (infoPtr->AccelIndex != -1) infoPtr->AccelIndex = 0; + if (infoPtr->Flags & FLAG_ARROW) { /* Update the CurVal if necessary */ @@ -671,7 +688,8 @@ static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, POINTS pts) InvalidateRect (infoPtr->Self, NULL, FALSE); /* process the click */ - UPDOWN_DoAction (infoPtr, 1, infoPtr->Flags & FLAG_ARROW); + temp = (infoPtr->AccelCount && infoPtr->AccelVect) ? infoPtr->AccelVect[0].nInc : 1; + UPDOWN_DoAction (infoPtr, temp, infoPtr->Flags & FLAG_ARROW); /* now capture all mouse messages */ SetCapture (infoPtr->Self); @@ -710,13 +728,14 @@ static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, POINTS pts) /*********************************************************************** * UpDownWndProc */ -static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, - LPARAM lParam) +static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { UPDOWN_INFO *infoPtr = UPDOWN_GetInfoPtr (hwnd); DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); int temp; + TRACE("hwnd=%p msg=%04x wparam=%08x lparam=%08lx\n", hwnd, message, wParam, lParam); + if (!infoPtr && (message != WM_CREATE)) return DefWindowProcW (hwnd, message, wParam, lParam); @@ -750,7 +769,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, case WM_DESTROY: if(infoPtr->AccelVect) Free (infoPtr->AccelVect); - if(infoPtr->Buddy) RemovePropA(infoPtr->Buddy, BUDDY_UPDOWN_HWND); + if(infoPtr->Buddy) RemovePropW(infoPtr->Buddy, BUDDY_UPDOWN_HWND); Free (infoPtr); SetWindowLongPtrW (hwnd, 0, 0); @@ -821,7 +840,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, case WM_LBUTTONDOWN: case WM_MOUSEMOVE: if(UPDOWN_IsEnabled(infoPtr)) - UPDOWN_HandleMouseEvent (infoPtr, message, MAKEPOINTS(lParam)); + UPDOWN_HandleMouseEvent (infoPtr, message, (SHORT)LOWORD(lParam), (SHORT)HIWORD(lParam)); break; case WM_KEYDOWN: @@ -842,7 +861,8 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, return 0; case UDM_SETACCEL: - TRACE("UpDown Ctrl new accel info, hwnd=%p\n", hwnd); + TRACE("UDM_SETACCEL\n"); + if(infoPtr->AccelVect) { Free (infoPtr->AccelVect); infoPtr->AccelCount = 0; @@ -852,6 +872,11 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, infoPtr->AccelVect = Alloc (wParam*sizeof(UDACCEL)); if(infoPtr->AccelVect == 0) return FALSE; memcpy(infoPtr->AccelVect, (void*)lParam, wParam*sizeof(UDACCEL)); + infoPtr->AccelCount = wParam; + + for (temp = 0; temp < wParam; temp++) + TRACE("%d: nSec %u nInc %u\n", temp, infoPtr->AccelVect[temp].nSec, infoPtr->AccelVect[temp].nInc); + return TRUE; case UDM_GETBASE: diff --git a/reactos/lib/comctl32/winehq2ros.patch b/reactos/lib/comctl32/winehq2ros.patch index 7812822bc4e..eb9b61d98a3 100644 --- a/reactos/lib/comctl32/winehq2ros.patch +++ b/reactos/lib/comctl32/winehq2ros.patch @@ -4,7 +4,7 @@ RCS file: /home/wine/wine/dlls/comctl32/comctl32.spec,v retrieving revision 1.46 diff -u -r1.46 comctl32.spec --- comctl32.spec 19 Oct 2004 22:59:59 -0000 1.46 -+++ comctl32.spec 21 Oct 2004 08:50:24 -0000 ++++ comctl32.spec 5 Dec 2004 22:48:09 -0000 @@ -106,13 +106,13 @@ 412 stdcall RemoveWindowSubclass(long ptr long) 413 stdcall DefSubclassProc(long long long long) @@ -26,13 +26,49 @@ diff -u -r1.46 comctl32.spec # Functions imported by name +Index: commctrl.c +=================================================================== +RCS file: /home/wine/wine/dlls/comctl32/commctrl.c,v +retrieving revision 1.88 +diff -u -r1.88 commctrl.c +--- commctrl.c 19 Oct 2004 22:59:59 -0000 1.88 ++++ commctrl.c 5 Dec 2004 22:48:09 -0000 +@@ -482,7 +482,7 @@ + r.left += 3; + if (style & SBT_RTLREADING) + FIXME("Unsupported RTL style!\n"); +- DrawTextW (hdc, text, -1, &r, align|DT_VCENTER|DT_SINGLELINE); ++ DrawTextW (hdc, text, -1, &r, align|DT_VCENTER|DT_SINGLELINE|DT_NOPREFIX); + SetBkMode(hdc, oldbkmode); + } + } +Index: datetime.c +=================================================================== +RCS file: /home/wine/wine/dlls/comctl32/datetime.c,v +retrieving revision 1.49 +diff -u -r1.49 datetime.c +--- datetime.c 24 Nov 2004 18:28:31 -0000 1.49 ++++ datetime.c 5 Dec 2004 22:48:10 -0000 +@@ -814,10 +814,10 @@ + + TRACE("Height=%ld, Width=%ld\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right); + +- /* use DrawEdge to adjust the size of rcEdge to get rcDraw */ + memcpy((&infoPtr->rcDraw), (&infoPtr->rcClient), sizeof(infoPtr->rcDraw)); + +- DrawEdge(NULL, &(infoPtr->rcDraw), EDGE_SUNKEN, BF_RECT | BF_ADJUST); ++ /* subract the size of the edge drawn by DrawEdge */ ++ InflateRect(&infoPtr->rcDraw, -2, -2); + + /* set the size of the button that drops the calendar down */ + /* FIXME: account for style that allows button on left side */ Index: listview.c =================================================================== RCS file: /home/wine/wine/dlls/comctl32/listview.c,v -retrieving revision 1.394 -diff -u -r1.394 listview.c ---- listview.c 2 Sep 2004 23:00:53 -0000 1.394 -+++ listview.c 21 Oct 2004 08:50:32 -0000 +retrieving revision 1.398 +diff -u -r1.398 listview.c +--- listview.c 24 Nov 2004 18:28:31 -0000 1.398 ++++ listview.c 5 Dec 2004 22:48:13 -0000 @@ -146,6 +146,7 @@ #include #include @@ -41,7 +77,7 @@ diff -u -r1.394 listview.c #include #include #include -@@ -2022,7 +2023,8 @@ +@@ -2033,7 +2034,8 @@ infoPtr->iconSize.cy + ICON_BOTTOM_PADDING; Label.right = Label.left + labelSize.cx; Label.bottom = Label.top + infoPtr->nItemHeight; @@ -51,7 +87,7 @@ diff -u -r1.394 listview.c { labelSize.cy = min(Box.bottom - Label.top, labelSize.cy); labelSize.cy /= infoPtr->ntmHeight; -@@ -9511,7 +9513,8 @@ +@@ -9522,7 +9524,8 @@ hOldFont = SelectObject(hdc, infoPtr->hFont); /*Get String Length in pixels */ @@ -61,13 +97,35 @@ diff -u -r1.394 listview.c /*Add Extra spacing for the next character */ GetTextMetricsW(hdc, &textMetric); +Index: rebar.c +=================================================================== +RCS file: /home/wine/wine/dlls/comctl32/rebar.c,v +retrieving revision 1.100 +diff -u -r1.100 rebar.c +--- rebar.c 24 Nov 2004 18:28:31 -0000 1.100 ++++ rebar.c 5 Dec 2004 22:48:14 -0000 +@@ -3786,10 +3786,10 @@ + infoPtr->bands = NULL; + } + +- DeleteObject (infoPtr->hcurArrow); +- DeleteObject (infoPtr->hcurHorz); +- DeleteObject (infoPtr->hcurVert); +- DeleteObject (infoPtr->hcurDrag); ++ DestroyCursor (infoPtr->hcurArrow); ++ DestroyCursor (infoPtr->hcurHorz); ++ DestroyCursor (infoPtr->hcurVert); ++ DestroyCursor (infoPtr->hcurDrag); + if(infoPtr->hDefaultFont) DeleteObject (infoPtr->hDefaultFont); + SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0); + Index: string.c =================================================================== RCS file: /home/wine/wine/dlls/comctl32/string.c,v retrieving revision 1.5 diff -u -r1.5 string.c --- string.c 22 Sep 2004 19:10:27 -0000 1.5 -+++ string.c 21 Oct 2004 08:50:38 -0000 ++++ string.c 5 Dec 2004 22:48:15 -0000 @@ -264,7 +264,7 @@ { TRACE("(%s,%s)\n", debugstr_w(lpszStr), debugstr_w(lpszSearch)); @@ -86,19 +144,36 @@ diff -u -r1.5 string.c } /************************************************************************* +Index: tooltips.c +=================================================================== +RCS file: /home/wine/wine/dlls/comctl32/tooltips.c,v +retrieving revision 1.74 +diff -u -r1.74 tooltips.c +--- tooltips.c 25 Oct 2004 21:44:50 -0000 1.74 ++++ tooltips.c 5 Dec 2004 22:48:16 -0000 +@@ -2836,7 +2836,7 @@ + TOOLTIPS_Unregister (void) + { + int i; +- for (i = 0; i < TTI_ERROR+1; i++) +- DeleteObject(hTooltipIcons[i]); ++ for (i = TTI_INFO; i <= TTI_ERROR; i++) ++ DestroyIcon(hTooltipIcons[i]); + UnregisterClassW (TOOLTIPS_CLASSW, NULL); + } Index: treeview.c =================================================================== RCS file: /home/wine/wine/dlls/comctl32/treeview.c,v -retrieving revision 1.156 -diff -u -r1.156 treeview.c ---- treeview.c 7 Oct 2004 17:34:31 -0000 1.156 -+++ treeview.c 21 Oct 2004 08:50:45 -0000 -@@ -2328,7 +2328,7 @@ +retrieving revision 1.158 +diff -u -r1.158 treeview.c +--- treeview.c 21 Nov 2004 15:41:08 -0000 1.158 ++++ treeview.c 5 Dec 2004 22:48:18 -0000 +@@ -2329,7 +2329,7 @@ SelectObject(hdc, hOldPen); DeleteObject(hNewPen); - if (height < 16 || width < 16) -+ if (height < 32 || width < 32) ++ if (height < 18 || width < 18) { MoveToEx(hdc, centerx - plussize + 1, centery, NULL); LineTo(hdc, centerx + plussize, centery); diff --git a/reactos/w32api/include/commctrl.h b/reactos/w32api/include/commctrl.h index 460f957cf27..e75116283b5 100644 --- a/reactos/w32api/include/commctrl.h +++ b/reactos/w32api/include/commctrl.h @@ -1992,6 +1992,17 @@ typedef struct _TBBUTTON { int iString; } TBBUTTON,*PTBBUTTON,*LPTBBUTTON; typedef const TBBUTTON *LPCTBBUTTON; +typedef struct tagNMTBRESTORE +{ + NMHDR hdr; + DWORD* pData; + DWORD* pCurrent; + UINT cbData; + int iItem; + int cButtons; + int cbBytesPerRecord; + TBBUTTON tbButton; +} NMTBRESTORE, *LPNMTBRESTORE; #if _WIN32_IE >= 0x400 typedef struct { UINT cbSize; @@ -2045,11 +2056,6 @@ typedef struct { int cchText; LPTSTR pszText; } TBNOTIFY,*LPTBNOTIFY; -typedef struct { - HKEY hkr; - LPCTSTR pszSubKey; - LPCTSTR pszValueName; -} TBSAVEPARAMS; typedef struct _IMAGEINFO { HBITMAP hbmImage; HBITMAP hbmMask; @@ -2246,12 +2252,12 @@ typedef struct tagTBSAVEPARAMSA { HKEY hkr; LPCSTR pszSubKey; LPCSTR pszValueName; -} TBSAVEPARAMSA; +} TBSAVEPARAMSA, *LPTBSAVEPARAMSA; typedef struct tagTBSAVEPARAMSW { HKEY hkr; LPCWSTR pszSubKey; LPCWSTR pszValueName; -} TBSAVEPARAMSW; +} TBSAVEPARAMSW, *LPTBSAVEPARAMSW, *LPTBSAVEPARAMW; typedef struct { HINSTANCE hInstOld; UINT nIDOld;