From fe687a094d33cf999812ded63b5d95fb42134f29 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9=20van=20Geldorp?= Date: Tue, 11 Jan 2005 22:44:10 +0000 Subject: [PATCH] Sync to Wine-20050111: Eric Pouech - Removed excessive statement (break after return or goto, not useful break, not needed vars...) Michael Stefaniuc - Do not check for non NULL pointer before HeapFree'ing it. It's redundant. Ulrich Czekalla - Add partial handler for WM_PRINTCLIENT. - WM_GETTEXTLENGTH should return zero for owner drawn status bars. Jon Griffiths - Remove unneeded headers to reduce unneeded rebuilds. - Implement the remaining MRU functions, fix a couple of differences from native comctl32, add tests of MRU behaviour and documentation. Francois Gouget - Assorted spelling fixes. Eric Kohl - DrawStatusText() must not process prefix characters. Filip Navara - Don't use DrawEdge with NULL device context, it's invalid call and sets last error. - Tooltip icons must be destroyed with DestroyIcon and not with DeleteObject. - Rebar cursors must be destroyed with DestroyCursor and not with DeleteObject. Robert Shearman - Use the DrawFocusRect function to draw the focus rect, instead of a broken home-brewed solution. - Don't highlight text in non-TVS_TRACKSELECT mode. - Add code for hot tracking. - Draw hot items with underline and with highlight colour with TVS_TRACKSELECT style. - Set cursor to hand cursor with TVS_TRACKSELECT style. - Make sure uInternalStatus is consistent with actual scrollbar state by forcing scrollbars off in WM_CREATE handler. - Make the month calendar child window auto-size instead of using a hard coded 200px. - Use SetFocus when the control is clicked on to get the correct behaviour when another control clicked on. - Force the WS_EX_CLIENTEDGE style, instead of emulating it. - Implement WM_ENABLE handler to update cached control style when the control is disabled. - Move background drawing into WM_ERASEBKGND handler and draw the background differently when disabled. - Change WM_PAINT handler to draw text with transparent background and with the correct colour for the style. - Initialize selected field to -1 instead of 0 so that the control notices when field 0 is selected. Vitaly Lipatov - Add comments, fix negative value from GetCurFocus. Alexandre Julliard : - Janitorial: C booleans must not be compared against TRUE. Mike McCormack - Fix image list mask and blending. Evan Deaubl - GetItemA/W on header controls should handle message even if index is invalid. Crestez Leonard - Fix bug with Treeview_SelectItem reselecting the same item. Thomas Weidenmnller - Free allocated font handles when control is destroyed. svn path=/trunk/; revision=12933 --- reactos/lib/comctl32/animate.c | 28 +- reactos/lib/comctl32/comboex.c | 2 - reactos/lib/comctl32/comctl32undoc.c | 446 ++++++++++++++------------- reactos/lib/comctl32/commctrl.c | 2 +- reactos/lib/comctl32/datetime.c | 138 ++++++--- reactos/lib/comctl32/flatsb.c | 3 - reactos/lib/comctl32/header.c | 55 ++-- reactos/lib/comctl32/imagelist.c | 66 ++-- reactos/lib/comctl32/listview.c | 34 +- reactos/lib/comctl32/monthcal.c | 10 +- reactos/lib/comctl32/nativefont.c | 1 - reactos/lib/comctl32/pager.c | 2 - reactos/lib/comctl32/propsheet.c | 2 - reactos/lib/comctl32/rebar.c | 1 - reactos/lib/comctl32/smoothscroll.c | 5 - reactos/lib/comctl32/status.c | 3 +- reactos/lib/comctl32/syslink.c | 13 +- reactos/lib/comctl32/tab.c | 22 +- reactos/lib/comctl32/toolbar.c | 11 +- reactos/lib/comctl32/tooltips.c | 5 - reactos/lib/comctl32/trackbar.c | 1 - reactos/lib/comctl32/treeview.c | 128 +++++++- 22 files changed, 602 insertions(+), 376 deletions(-) diff --git a/reactos/lib/comctl32/animate.c b/reactos/lib/comctl32/animate.c index 66cf7f28b51..ce9b3f3f41a 100644 --- a/reactos/lib/comctl32/animate.c +++ b/reactos/lib/comctl32/animate.c @@ -187,32 +187,20 @@ static void ANIMATE_Free(ANIMATE_INFO *infoPtr) FreeResource(infoPtr->hRes); infoPtr->hRes = 0; } - if (infoPtr->lpIndex) { - HeapFree(GetProcessHeap(), 0, infoPtr->lpIndex); - infoPtr->lpIndex = NULL; - } + HeapFree(GetProcessHeap(), 0, infoPtr->lpIndex); + infoPtr->lpIndex = NULL; if (infoPtr->hic) { fnIC.fnICClose(infoPtr->hic); infoPtr->hic = 0; } - if (infoPtr->inbih) { - HeapFree(GetProcessHeap(), 0, infoPtr->inbih); - infoPtr->inbih = NULL; - } - if (infoPtr->outbih) { - HeapFree(GetProcessHeap(), 0, infoPtr->outbih); - infoPtr->outbih = NULL; - } - if( infoPtr->indata ) - { + HeapFree(GetProcessHeap(), 0, infoPtr->inbih); + infoPtr->inbih = NULL; + HeapFree(GetProcessHeap(), 0, infoPtr->outbih); + infoPtr->outbih = NULL; HeapFree(GetProcessHeap(), 0, infoPtr->indata); - infoPtr->indata = NULL; - } - if( infoPtr->outdata ) - { + infoPtr->indata = NULL; HeapFree(GetProcessHeap(), 0, infoPtr->outdata); - infoPtr->outdata = NULL; - } + infoPtr->outdata = NULL; if( infoPtr->hbmPrevFrame ) { DeleteObject(infoPtr->hbmPrevFrame); diff --git a/reactos/lib/comctl32/comboex.c b/reactos/lib/comctl32/comboex.c index 5551b58d7a8..8cff35a286a 100644 --- a/reactos/lib/comctl32/comboex.c +++ b/reactos/lib/comctl32/comboex.c @@ -1840,7 +1840,6 @@ COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return CallWindowProcW (infoPtr->prevEditWndProc, hwnd, uMsg, wParam, lParam); } - return 0; } @@ -2243,7 +2242,6 @@ COMBOEX_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ERR("unknown msg %04x wp=%08x lp=%08lx\n",uMsg,wParam,lParam); return DefWindowProcW (hwnd, uMsg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/comctl32undoc.c b/reactos/lib/comctl32/comctl32undoc.c index fd7cbfab4fd..3eae1aebf57 100644 --- a/reactos/lib/comctl32/comctl32undoc.c +++ b/reactos/lib/comctl32/comctl32undoc.c @@ -106,9 +106,8 @@ typedef HRESULT (CALLBACK *DPALOADPROC)(LPLOADDATA,IStream*,LPARAM); * NOTES * No more information available yet! */ - -HRESULT WINAPI -DPA_LoadStream (HDPA *phDpa, DPALOADPROC loadProc, IStream *pStream, LPARAM lParam) +HRESULT WINAPI DPA_LoadStream (HDPA *phDpa, DPALOADPROC loadProc, + IStream *pStream, LPARAM lParam) { HRESULT errCode; LARGE_INTEGER position; @@ -205,9 +204,8 @@ DPA_LoadStream (HDPA *phDpa, DPALOADPROC loadProc, IStream *pStream, LPARAM lPar * NOTES * No more information available yet! */ - -HRESULT WINAPI -DPA_SaveStream (const HDPA hDpa, DPALOADPROC loadProc, IStream *pStream, LPARAM lParam) +HRESULT WINAPI DPA_SaveStream (const HDPA hDpa, DPALOADPROC loadProc, + IStream *pStream, LPARAM lParam) { FIXME ("hDpa=%p loadProc=%p pStream=%p lParam=%lx\n", @@ -220,6 +218,8 @@ DPA_SaveStream (const HDPA hDpa, DPALOADPROC loadProc, IStream *pStream, LPARAM /************************************************************************** * DPA_Merge [COMCTL32.11] * + * Merge two dynamic pointers arrays. + * * PARAMS * hdpa1 [I] handle to a dynamic pointer array * hdpa2 [I] handle to a dynamic pointer array @@ -235,10 +235,9 @@ DPA_SaveStream (const HDPA hDpa, DPALOADPROC loadProc, IStream *pStream, LPARAM * NOTES * No more information available yet! */ - -BOOL WINAPI -DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags, - PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, LPARAM lParam) +BOOL WINAPI DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags, + PFNDPACOMPARE pfnCompare, PFNDPAMERGE pfnMerge, + LPARAM lParam) { INT nCount; LPVOID *pWork1, *pWork2; @@ -373,7 +372,6 @@ DPA_Merge (const HDPA hdpa1, const HDPA hdpa2, DWORD dwFlags, * Success: pointer to allocated memory block * Failure: NULL */ - LPVOID WINAPI Alloc (DWORD dwSize) { return LocalAlloc( LMEM_ZEROINIT, dwSize ); @@ -398,7 +396,6 @@ LPVOID WINAPI Alloc (DWORD dwSize) * If lpSrc is a NULL-pointer, then ReAlloc allocates a memory * block like Alloc. */ - LPVOID WINAPI ReAlloc (LPVOID lpSrc, DWORD dwSize) { if (lpSrc) @@ -420,7 +417,6 @@ LPVOID WINAPI ReAlloc (LPVOID lpSrc, DWORD dwSize) * Success: TRUE * Failure: FALSE */ - BOOL WINAPI Free (LPVOID lpMem) { return !LocalFree( lpMem ); @@ -440,7 +436,6 @@ BOOL WINAPI Free (LPVOID lpMem) * Success: size of the specified memory block * Failure: 0 */ - DWORD WINAPI GetSize (LPVOID lpMem) { return LocalSize( lpMem ); @@ -448,33 +443,90 @@ DWORD WINAPI GetSize (LPVOID lpMem) /************************************************************************** - * The MRU-API is a set of functions to manipulate MRU(Most Recently Used) - * lists. + * MRU-Functions {COMCTL32} * - * Stored in the reg. as a set of values under a single key. Each item in the - * list has a value name that is a single char. 'a' - 'z', '{', '|' or '}'. - * The order of the list is stored with value name 'MRUList' which is a string - * containing the value names (i.e. 'a', 'b', etc.) in the relevant order. + * NOTES + * The MRU-Api is a set of functions to manipulate lists of M.R.U. (Most Recently + * Used) items. It is an undocumented Api that is used (at least) by the shell + * and explorer to implement their recent documents feature. + * + * Since these functions are undocumented, they are unsupported by MS and + * may change at any time. + * + * Internally, the list is implemented as a last in, last out list of items + * persisted into the system registry under a caller chosen key. Each list + * item is given a one character identifier in the Ascii range from 'a' to + * '}'. A list of the identifiers in order from newest to oldest is stored + * under the same key in a value named "MRUList". + * + * Items are re-ordered by changing the order of the values in the MRUList + * value. When a new item is added, it becomes the new value of the oldest + * identifier, and that identifier is moved to the front of the MRUList value. + * + * Wine stores MRU-lists in the same registry format as Windows, so when + * switching between the builtin and native comctl32.dll no problems or + * incompatibilities should occur. + * + * The following undocumented structure is used to create an MRU-list: + *|typedef INT (CALLBACK *MRUStringCmpFn)(LPCTSTR lhs, LPCTSTR rhs); + *|typedef INT (CALLBACK *MRUBinaryCmpFn)(LPCVOID lhs, LPCVOID rhs, DWORD length); + *| + *|typedef struct tagCREATEMRULIST + *|{ + *| DWORD cbSize; + *| DWORD nMaxItems; + *| DWORD dwFlags; + *| HKEY hKey; + *| LPCTSTR lpszSubKey; + *| PROC lpfnCompare; + *|} CREATEMRULIST, *LPCREATEMRULIST; + * + * MEMBERS + * cbSize [I] The size of the CREATEMRULIST structure. This must be set + * to sizeof(CREATEMRULIST) by the caller. + * nMaxItems [I] The maximum number of items allowed in the list. Because + * of the limited number of identifiers, this should be set to + * a value from 1 to 30 by the caller. + * dwFlags [I] If bit 0 is set, the list will be used to store binary + * data, otherwise it is assumed to store strings. If bit 1 + * is set, every change made to the list will be reflected in + * the registry immediately, otherwise changes will only be + * written when the list is closed. + * hKey [I] The registry key that the list should be written under. + * This must be supplied by the caller. + * lpszSubKey [I] A caller supplied name of a subkey under hKey to write + * the list to. This may not be blank. + * lpfnCompare [I] A caller supplied comparison function, which may be either + * an MRUStringCmpFn if dwFlags does not have bit 0 set, or a + * MRUBinaryCmpFn otherwise. + * + * FUNCTIONS + * - Create an MRU-list with CreateMRUList() or CreateMRUListLazy(). + * - Add items to an MRU-list with AddMRUString() or AddMRUData(). + * - Remove items from an MRU-list with DelMRUString(). + * - Find data in an MRU-list with FindMRUString() or FindMRUData(). + * - Iterate through an MRU-list with EnumMRUList(). + * - Free an MRU-list with FreeMRUList(). */ typedef struct tagCREATEMRULISTA { - DWORD cbSize; /* size of struct */ - DWORD nMaxItems; /* max no. of items in list */ - DWORD dwFlags; /* see below */ - HKEY hKey; /* root reg. key under which list is saved */ - LPCSTR lpszSubKey; /* reg. subkey */ - PROC lpfnCompare; /* item compare proc */ + DWORD cbSize; + DWORD nMaxItems; + DWORD dwFlags; + HKEY hKey; + LPCSTR lpszSubKey; + PROC lpfnCompare; } CREATEMRULISTA, *LPCREATEMRULISTA; typedef struct tagCREATEMRULISTW { - DWORD cbSize; /* size of struct */ - DWORD nMaxItems; /* max no. of items in list */ - DWORD dwFlags; /* see below */ - HKEY hKey; /* root reg. key under which list is saved */ - LPCWSTR lpszSubKey; /* reg. subkey */ - PROC lpfnCompare; /* item compare proc */ + DWORD cbSize; + DWORD nMaxItems; + DWORD dwFlags; + HKEY hKey; + LPCWSTR lpszSubKey; + PROC lpfnCompare; } CREATEMRULISTW, *LPCREATEMRULISTW; /* dwFlags */ @@ -517,9 +569,9 @@ typedef struct tagWINEMRULIST /************************************************************************** * MRU_SaveChanged (internal) * - * Localize MRU saving code + * Local MRU saving code */ -VOID MRU_SaveChanged( LPWINEMRULIST mp ) +static void MRU_SaveChanged ( LPWINEMRULIST mp ) { UINT i, err; HKEY newkey; @@ -587,16 +639,17 @@ VOID MRU_SaveChanged( LPWINEMRULIST mp ) * hMRUList [I] Handle to list. * * RETURNS - * Success: TRUE - * Failure: FALSE + * Nothing. */ -BOOL WINAPI -FreeMRUList (HANDLE hMRUList) +void WINAPI FreeMRUList (HANDLE hMRUList) { LPWINEMRULIST mp = (LPWINEMRULIST)hMRUList; UINT i; - TRACE("\n"); + TRACE("(%p)\n", hMRUList); + if (!hMRUList) + return; + if (mp->wineFlags & WMRUF_CHANGED) { /* need to open key and then save the info */ MRU_SaveChanged( mp ); @@ -609,7 +662,7 @@ FreeMRUList (HANDLE hMRUList) Free(mp->realMRU); Free(mp->array); Free((LPWSTR)mp->extview.lpszSubKey); - return Free(mp); + Free(mp); } @@ -629,8 +682,8 @@ FreeMRUList (HANDLE hMRUList) * RETURNS * Position in list 0 -> MRU. -1 if item not found. */ -INT WINAPI -FindMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum) +INT WINAPI FindMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData, + LPINT lpRegNum) { LPWINEMRULIST mp = (LPWINEMRULIST)hList; INT ret; @@ -707,14 +760,22 @@ FindMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData, LPINT lpRegNum) * No. corresponding to registry name where value is stored 'a' -> 0 etc. * -1 on error. */ -INT WINAPI -AddMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData) +INT WINAPI AddMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData) { LPWINEMRULIST mp = (LPWINEMRULIST)hList; LPWINEMRUITEM witem; - INT i, replace, ret; + INT i, replace; - if ((replace = FindMRUData (hList, lpData, cbData, NULL)) < 0) { + if ((replace = FindMRUData (hList, lpData, cbData, NULL)) >= 0) { + /* Item exists, just move it to the front */ + LPSTR pos = strchr(mp->realMRU, replace + 'a'); + while (pos > mp->realMRU) + { + pos[0] = pos[-1]; + pos--; + } + } + else { /* either add a new entry or replace oldest */ if (mp->cursize < mp->extview.nMaxItems) { /* Add in a new item */ @@ -726,57 +787,73 @@ AddMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData) replace = mp->realMRU[mp->cursize - 1] - 'a'; Free(mp->array[replace]); } - } - else { - /* free up the old data */ - Free(mp->array[replace]); + + /* Allocate space for new item and move in the data */ + mp->array[replace] = witem = Alloc(cbData + sizeof(WINEMRUITEM)); + witem->itemFlag |= WMRUIF_CHANGED; + witem->size = cbData; + memcpy( &witem->datastart, lpData, cbData); + + /* now rotate MRU list */ + for(i=mp->cursize-1; i>=1; i--) + mp->realMRU[i] = mp->realMRU[i-1]; } - /* Allocate space for new item and move in the data */ - mp->array[replace] = witem = Alloc(cbData + sizeof(WINEMRUITEM)); - witem->itemFlag |= WMRUIF_CHANGED; - witem->size = cbData; - memcpy( &witem->datastart, lpData, cbData); - - /* now rotate MRU list */ + /* The new item gets the front spot */ mp->wineFlags |= WMRUF_CHANGED; - for(i=mp->cursize-1; i>=1; i--) { - mp->realMRU[i] = mp->realMRU[i-1]; - } mp->realMRU[0] = replace + 'a'; + TRACE("(%p, %p, %ld) adding data, /%c/ now most current\n", - hList, lpData, cbData, replace+'a'); - ret = replace; + hList, lpData, cbData, replace+'a'); if (!(mp->extview.dwFlags & MRUF_DELAYED_SAVE)) { /* save changed stuff right now */ MRU_SaveChanged( mp ); } - return ret; + return replace; } /************************************************************************** * AddMRUStringW [COMCTL32.401] * - * Add item to MRU string list. If item already exists in list them it is - * simply moved up to the top of the list and not added again. If list is - * full then the least recently used item is removed to make room. + * Add an item to an MRU string list. * * PARAMS - * hList [I] Handle to list. - * lpszString [I] ptr to string to add. + * hList [I] Handle to list. + * lpszString [I] The string to add. * * RETURNS - * No. corresponding to registry name where value is stored 'a' -> 0 etc. - * -1 on error. + * Success: The number corresponding to the registry name where the string + * has been stored (0 maps to 'a', 1 to 'b' and so on). + * Failure: -1, if hList is NULL or memory allocation fails. If lpszString + * is invalid, the function returns 0, and GetLastError() returns + * ERROR_INVALID_PARAMETER. The last error value is set only in + * this case. + * + * NOTES + * -If lpszString exists in the list already, it is moved to the top of the + * MRU list (it is not duplicated). + * -If the list is full the least recently used list entry is replaced with + * lpszString. + * -If this function returns 0 you should check the last error value to + * ensure the call really succeeded. */ -INT WINAPI -AddMRUStringW(HANDLE hList, LPCWSTR lpszString) +INT WINAPI AddMRUStringW(HANDLE hList, LPCWSTR lpszString) { - FIXME("(%p, %s) empty stub!\n", hList, debugstr_w(lpszString)); + TRACE("(%p,%s)\n", hList, debugstr_w(lpszString)); - return 0; + if (!hList) + return -1; + + if (!lpszString || IsBadStringPtrW(lpszString, -1)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + return AddMRUData(hList, lpszString, + (strlenW(lpszString) + 1) * sizeof(WCHAR)); } /************************************************************************** @@ -784,12 +861,32 @@ AddMRUStringW(HANDLE hList, LPCWSTR lpszString) * * See AddMRUStringW. */ -INT WINAPI -AddMRUStringA(HANDLE hList, LPCSTR lpszString) +INT WINAPI AddMRUStringA(HANDLE hList, LPCSTR lpszString) { - FIXME("(%p, %s) empty stub!\n", hList, debugstr_a(lpszString)); + DWORD len; + LPWSTR stringW; + INT ret; - return 0; + TRACE("(%p,%s)\n", hList, debugstr_a(lpszString)); + + if (!hList) + return -1; + + if (IsBadStringPtrA(lpszString, -1)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + len = MultiByteToWideChar(CP_ACP, 0, lpszString, -1, NULL, 0) * sizeof(WCHAR); + stringW = Alloc(len); + if (!stringW) + return -1; + + MultiByteToWideChar(CP_ACP, 0, lpszString, -1, stringW, len); + ret = AddMRUData(hList, stringW, len); + Free(stringW); + return ret; } /************************************************************************** @@ -804,8 +901,7 @@ AddMRUStringA(HANDLE hList, LPCSTR lpszString) * RETURNS * TRUE if successful, FALSE if nItemPos is out of range. */ -BOOL WINAPI -DelMRUString(HANDLE hList, INT nItemPos) +BOOL WINAPI DelMRUString(HANDLE hList, INT nItemPos) { FIXME("(%p, %d): stub\n", hList, nItemPos); return TRUE; @@ -816,11 +912,10 @@ DelMRUString(HANDLE hList, INT nItemPos) * * See FindMRUStringA. */ -INT WINAPI -FindMRUStringW (HANDLE hList, LPCWSTR lpszString, LPINT lpRegNum) +INT WINAPI FindMRUStringW (HANDLE hList, LPCWSTR lpszString, LPINT lpRegNum) { - FIXME("stub\n"); - return -1; + return FindMRUData(hList, lpszString, + (lstrlenW(lpszString) + 1) * sizeof(WCHAR), lpRegNum); } /************************************************************************** @@ -838,8 +933,7 @@ FindMRUStringW (HANDLE hList, LPCWSTR lpszString, LPINT lpRegNum) * RETURNS * Position in list 0 -> MRU. -1 if item not found. */ -INT WINAPI -FindMRUStringA (HANDLE hList, LPCSTR lpszString, LPINT lpRegNum) +INT WINAPI FindMRUStringA (HANDLE hList, LPCSTR lpszString, LPINT lpRegNum) { DWORD len = MultiByteToWideChar(CP_ACP, 0, lpszString, -1, NULL, 0); LPWSTR stringW = Alloc(len * sizeof(WCHAR)); @@ -854,7 +948,7 @@ FindMRUStringA (HANDLE hList, LPCSTR lpszString, LPINT lpRegNum) /************************************************************************* * CreateMRUListLazy_common (internal) */ -HANDLE CreateMRUListLazy_common(LPWINEMRULIST mp) +static HANDLE CreateMRUListLazy_common(LPWINEMRULIST mp) { UINT i, err; HKEY newkey; @@ -901,7 +995,7 @@ HANDLE CreateMRUListLazy_common(LPWINEMRULIST mp) *mp->realMRU = 0; } - TRACE("MRU list = %s\n", mp->realMRU); + TRACE("MRU list = %s, datasize = %ld\n", mp->realMRU, datasize); mp->cursize = datasize - 1; /* datasize now has number of items in the MRUList */ @@ -939,16 +1033,16 @@ HANDLE CreateMRUListLazy_common(LPWINEMRULIST mp) * * See CreateMRUListLazyA. */ -HANDLE WINAPI -CreateMRUListLazyW (LPCREATEMRULISTW lpcml, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4) +HANDLE WINAPI CreateMRUListLazyW (LPCREATEMRULISTW lpcml, DWORD dwParam2, + DWORD dwParam3, DWORD dwParam4) { LPWINEMRULIST mp; - if (lpcml == NULL) - return 0; + /* Native does not check for a NULL lpcml */ - if (lpcml->cbSize < sizeof(CREATEMRULISTW)) - return 0; + if (lpcml->cbSize != sizeof(CREATEMRULISTW) || !lpcml->hKey || + IsBadStringPtrW(lpcml->lpszSubKey, -1)) + return NULL; mp = Alloc(sizeof(WINEMRULIST)); memcpy(&mp->extview, lpcml, sizeof(CREATEMRULISTW)); @@ -973,16 +1067,16 @@ CreateMRUListLazyW (LPCREATEMRULISTW lpcml, DWORD dwParam2, DWORD dwParam3, DWOR * RETURNS * Handle to MRU list. */ -HANDLE WINAPI -CreateMRUListLazyA (LPCREATEMRULISTA lpcml, DWORD dwParam2, DWORD dwParam3, DWORD dwParam4) +HANDLE WINAPI CreateMRUListLazyA (LPCREATEMRULISTA lpcml, DWORD dwParam2, + DWORD dwParam3, DWORD dwParam4) { LPWINEMRULIST mp; DWORD len; - if (lpcml == NULL) - return 0; + /* Native does not check for a NULL lpcml */ - if (lpcml->cbSize < sizeof(CREATEMRULISTA)) + if (lpcml->cbSize != sizeof(CREATEMRULISTA) || !lpcml->hKey || + IsBadStringPtrA(lpcml->lpszSubKey, -1)) return 0; mp = Alloc(sizeof(WINEMRULIST)); @@ -1000,8 +1094,7 @@ CreateMRUListLazyA (LPCREATEMRULISTA lpcml, DWORD dwParam2, DWORD dwParam3, DWOR * * See CreateMRUListA. */ -HANDLE WINAPI -CreateMRUListW (LPCREATEMRULISTW lpcml) +HANDLE WINAPI CreateMRUListW (LPCREATEMRULISTW lpcml) { return CreateMRUListLazyW(lpcml, 0, 0, 0); } @@ -1017,8 +1110,7 @@ CreateMRUListW (LPCREATEMRULISTW lpcml) * RETURNS * Handle to MRU list. */ -HANDLE WINAPI -CreateMRUListA (LPCREATEMRULISTA lpcml) +HANDLE WINAPI CreateMRUListA (LPCREATEMRULISTA lpcml) { return CreateMRUListLazyA (lpcml, 0, 0, 0); } @@ -1042,8 +1134,8 @@ CreateMRUListA (LPCREATEMRULISTA lpcml) * If lpBuffer == NULL or nItemPos is -ve return value is no. of items in * the list. */ -INT WINAPI EnumMRUListW(HANDLE hList, INT nItemPos, LPVOID lpBuffer, -DWORD nBufferSize) +INT WINAPI EnumMRUListW (HANDLE hList, INT nItemPos, LPVOID lpBuffer, + DWORD nBufferSize) { LPWINEMRULIST mp = (LPWINEMRULIST) hList; LPWINEMRUITEM witem; @@ -1067,8 +1159,8 @@ DWORD nBufferSize) * * See EnumMRUListW. */ -INT WINAPI EnumMRUListA(HANDLE hList, INT nItemPos, LPVOID lpBuffer, -DWORD nBufferSize) +INT WINAPI EnumMRUListA (HANDLE hList, INT nItemPos, LPVOID lpBuffer, + DWORD nBufferSize) { LPWINEMRULIST mp = (LPWINEMRULIST) hList; LPWINEMRUITEM witem; @@ -1110,9 +1202,7 @@ DWORD nBufferSize) * RETURNS * The number of characters copied. */ - -INT WINAPI -Str_GetPtrA (LPCSTR lpSrc, LPSTR lpDest, INT nMaxLen) +INT WINAPI Str_GetPtrA (LPCSTR lpSrc, LPSTR lpDest, INT nMaxLen) { INT len; @@ -1157,9 +1247,7 @@ Str_GetPtrA (LPCSTR lpSrc, LPSTR lpDest, INT nMaxLen) * Set lpSrc to NULL to free the memory allocated by a previous call * to this function. */ - -BOOL WINAPI -Str_SetPtrA (LPSTR *lppDest, LPCSTR lpSrc) +BOOL WINAPI Str_SetPtrA (LPSTR *lppDest, LPCSTR lpSrc) { TRACE("(%p %p)\n", lppDest, lpSrc); @@ -1186,9 +1274,7 @@ Str_SetPtrA (LPSTR *lppDest, LPCSTR lpSrc) * * See Str_GetPtrA. */ - -INT WINAPI -Str_GetPtrW (LPCWSTR lpSrc, LPWSTR lpDest, INT nMaxLen) +INT WINAPI Str_GetPtrW (LPCWSTR lpSrc, LPWSTR lpDest, INT nMaxLen) { INT len; @@ -1221,9 +1307,7 @@ Str_GetPtrW (LPCWSTR lpSrc, LPWSTR lpDest, INT nMaxLen) * * See Str_SetPtrA. */ - -BOOL WINAPI -Str_SetPtrW (LPWSTR *lppDest, LPCWSTR lpSrc) +BOOL WINAPI Str_SetPtrW (LPWSTR *lppDest, LPCWSTR lpSrc) { TRACE("(%p %p)\n", lppDest, lpSrc); @@ -1260,8 +1344,7 @@ Str_SetPtrW (LPWSTR *lppDest, LPCWSTR lpSrc) * Length, in bytes, of the converted string. */ -INT -Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen) +INT Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen) { INT len; @@ -1306,9 +1389,7 @@ Str_GetPtrWtoA (LPCWSTR lpSrc, LPSTR lpDest, INT nMaxLen) * TRUE: conversion successful * FALSE: error */ - -BOOL -Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc) +BOOL Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc) { TRACE("(%p %s)\n", lppDest, lpSrc); @@ -1350,9 +1431,7 @@ Str_SetPtrAtoW (LPWSTR *lppDest, LPCSTR lpSrc) * fixed-size memory blocks. These arrays can store any kind of data * (e.g. strings and icons). */ - -HDSA WINAPI -DSA_Create (INT nSize, INT nGrow) +HDSA WINAPI DSA_Create (INT nSize, INT nGrow) { HDSA hdsa; @@ -1384,9 +1463,7 @@ DSA_Create (INT nSize, INT nGrow) * Success: TRUE * Failure: FALSE */ - -BOOL WINAPI -DSA_Destroy (const HDSA hdsa) +BOOL WINAPI DSA_Destroy (const HDSA hdsa) { TRACE("(%p)\n", hdsa); @@ -1414,9 +1491,7 @@ DSA_Destroy (const HDSA hdsa) * Success: TRUE * Failure: FALSE */ - -BOOL WINAPI -DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest) +BOOL WINAPI DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest) { LPVOID pSrc; @@ -1447,9 +1522,7 @@ DSA_GetItem (const HDSA hdsa, INT nIndex, LPVOID pDest) * Success: pointer to an item * Failure: NULL */ - -LPVOID WINAPI -DSA_GetItemPtr (const HDSA hdsa, INT nIndex) +LPVOID WINAPI DSA_GetItemPtr (const HDSA hdsa, INT nIndex) { LPVOID pSrc; @@ -1482,9 +1555,7 @@ DSA_GetItemPtr (const HDSA hdsa, INT nIndex) * Success: TRUE * Failure: FALSE */ - -BOOL WINAPI -DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc) +BOOL WINAPI DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc) { INT nSize, nNewItems; LPVOID pDest, lpTemp; @@ -1540,9 +1611,7 @@ DSA_SetItem (const HDSA hdsa, INT nIndex, LPVOID pSrc) * Success: position of the new item * Failure: -1 */ - -INT WINAPI -DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc) +INT WINAPI DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc) { INT nNewItems, nSize; LPVOID lpTemp, lpDest; @@ -1603,9 +1672,7 @@ DSA_InsertItem (const HDSA hdsa, INT nIndex, LPVOID pSrc) * Success: number of the deleted element * Failure: -1 */ - -INT WINAPI -DSA_DeleteItem (const HDSA hdsa, INT nIndex) +INT WINAPI DSA_DeleteItem (const HDSA hdsa, INT nIndex) { LPVOID lpDest,lpSrc; INT nSize; @@ -1657,9 +1724,7 @@ DSA_DeleteItem (const HDSA hdsa, INT nIndex) * Success: TRUE * Failure: FALSE */ - -BOOL WINAPI -DSA_DeleteAllItems (const HDSA hdsa) +BOOL WINAPI DSA_DeleteAllItems (const HDSA hdsa) { TRACE("(%p)\n", hdsa); @@ -1688,9 +1753,7 @@ DSA_DeleteAllItems (const HDSA hdsa) * Success: TRUE * Failure: FALSE */ - -BOOL WINAPI -DPA_Destroy (const HDPA hdpa) +BOOL WINAPI DPA_Destroy (const HDPA hdpa) { TRACE("(%p)\n", hdpa); @@ -1717,9 +1780,7 @@ DPA_Destroy (const HDPA hdpa) * Success: TRUE * Failure: FALSE */ - -BOOL WINAPI -DPA_Grow (const HDPA hdpa, INT nGrow) +BOOL WINAPI DPA_Grow (const HDPA hdpa, INT nGrow) { TRACE("(%p %d)\n", hdpa, nGrow); @@ -1751,9 +1812,7 @@ DPA_Grow (const HDPA hdpa, INT nGrow) * - If 'hdpa' is a NULL-Pointer, the original implementation crashes, * this implementation just returns NULL. */ - -HDPA WINAPI -DPA_Clone (const HDPA hdpa, const HDPA hdpaNew) +HDPA WINAPI DPA_Clone (const HDPA hdpa, const HDPA hdpaNew) { INT nNewItems, nSize; HDPA hdpaTemp; @@ -1811,9 +1870,7 @@ DPA_Clone (const HDPA hdpa, const HDPA hdpaNew) * Success: pointer * Failure: NULL */ - -LPVOID WINAPI -DPA_GetPtr (const HDPA hdpa, INT nIndex) +LPVOID WINAPI DPA_GetPtr (const HDPA hdpa, INT nIndex) { TRACE("(%p %d)\n", hdpa, nIndex); @@ -1847,9 +1904,7 @@ DPA_GetPtr (const HDPA hdpa, INT nIndex) * Success: index of the specified pointer * Failure: -1 */ - -INT WINAPI -DPA_GetPtrIndex (const HDPA hdpa, LPVOID p) +INT WINAPI DPA_GetPtrIndex (const HDPA hdpa, LPVOID p) { INT i; @@ -1879,9 +1934,7 @@ DPA_GetPtrIndex (const HDPA hdpa, LPVOID p) * Success: index of the inserted pointer * Failure: -1 */ - -INT WINAPI -DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p) +INT WINAPI DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p) { TRACE("(%p %d %p)\n", hdpa, i, p); @@ -1914,9 +1967,7 @@ DPA_InsertPtr (const HDPA hdpa, INT i, LPVOID p) * Success: TRUE * Failure: FALSE */ - -BOOL WINAPI -DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p) +BOOL WINAPI DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p) { LPVOID *lpTemp; @@ -1967,9 +2018,7 @@ DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p) * Success: deleted pointer * Failure: NULL */ - -LPVOID WINAPI -DPA_DeletePtr (const HDPA hdpa, INT i) +LPVOID WINAPI DPA_DeletePtr (const HDPA hdpa, INT i) { LPVOID *lpDest, *lpSrc, lpTemp = NULL; INT nSize; @@ -2022,9 +2071,7 @@ DPA_DeletePtr (const HDPA hdpa, INT i) * Success: TRUE * Failure: FALSE */ - -BOOL WINAPI -DPA_DeleteAllPtrs (const HDPA hdpa) +BOOL WINAPI DPA_DeleteAllPtrs (const HDPA hdpa) { TRACE("(%p)\n", hdpa); @@ -2058,10 +2105,8 @@ DPA_DeleteAllPtrs (const HDPA hdpa) * RETURNS * NONE */ - -static VOID -DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r, - PFNDPACOMPARE pfnCompare, LPARAM lParam) +static VOID DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r, + PFNDPACOMPARE pfnCompare, LPARAM lParam) { INT m; LPVOID t; @@ -2109,9 +2154,7 @@ DPA_QuickSort (LPVOID *lpPtrs, INT l, INT r, * Success: TRUE * Failure: FALSE */ - -BOOL WINAPI -DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam) +BOOL WINAPI DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam) { if (!hdpa || !pfnCompare) return FALSE; @@ -2148,10 +2191,8 @@ DPA_Sort (const HDPA hdpa, PFNDPACOMPARE pfnCompare, LPARAM lParam) * Function is NOT tested! * If something goes wrong, blame HIM not ME! (Eric Kohl) */ - -INT WINAPI -DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart, - PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions) +INT WINAPI DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart, + PFNDPACOMPARE pfnCompare, LPARAM lParam, UINT uOptions) { if (!hdpa || !pfnCompare || !pFind) return -1; @@ -2232,9 +2273,7 @@ DPA_Search (const HDPA hdpa, LPVOID pFind, INT nStart, * The DPA_ functions can be used to create and manipulate arrays of * pointers. */ - -HDPA WINAPI -DPA_CreateEx (INT nGrow, HANDLE hHeap) +HDPA WINAPI DPA_CreateEx (INT nGrow, HANDLE hHeap) { HDPA hdpa; @@ -2275,9 +2314,7 @@ DPA_CreateEx (INT nGrow, HANDLE hHeap) * The DPA_ functions can be used to create and manipulate arrays of * pointers. */ - -HDPA WINAPI -DPA_Create (INT nGrow) +HDPA WINAPI DPA_Create (INT nGrow) { return DPA_CreateEx( nGrow, 0 ); } @@ -2302,8 +2339,7 @@ typedef struct tagNOTIFYDATA * DoNotify [Internal] */ -static LRESULT -DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr) +static LRESULT DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr) { NMHDR nmhdr; LPNMHDR lpNmh = NULL; @@ -2355,7 +2391,6 @@ DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr) * message is taken from the NMHDR structure. * If hwndFrom is not -1 then lpHdr can be NULL. */ - LRESULT WINAPI SendNotify (HWND hwndTo, HWND hwndFrom, UINT uCode, LPNMHDR lpHdr) { NOTIFYDATA notify; @@ -2393,7 +2428,6 @@ LRESULT WINAPI SendNotify (HWND hwndTo, HWND hwndFrom, UINT uCode, LPNMHDR lpHdr * message is taken from the NMHDR structure. * If hwndFrom is not -1 then lpHdr can be NULL. */ - LRESULT WINAPI SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode, LPNMHDR lpHdr, DWORD dwParam5) { @@ -2436,9 +2470,8 @@ LRESULT WINAPI SendNotifyEx (HWND hwndTo, HWND hwndFrom, UINT uCode, * RETURNS * none */ - -VOID WINAPI -DPA_EnumCallback (HDPA hdpa, PFNDPAENUMCALLBACK enumProc, LPVOID lParam) +VOID WINAPI DPA_EnumCallback (HDPA hdpa, PFNDPAENUMCALLBACK enumProc, + LPVOID lParam) { INT i; @@ -2471,9 +2504,8 @@ DPA_EnumCallback (HDPA hdpa, PFNDPAENUMCALLBACK enumProc, LPVOID lParam) * RETURNS * none */ - -void WINAPI -DPA_DestroyCallback (HDPA hdpa, PFNDPAENUMCALLBACK enumProc, LPVOID lParam) +void WINAPI DPA_DestroyCallback (HDPA hdpa, PFNDPAENUMCALLBACK enumProc, + LPVOID lParam) { TRACE("(%p %p %p)\n", hdpa, enumProc, lParam); @@ -2495,9 +2527,8 @@ DPA_DestroyCallback (HDPA hdpa, PFNDPAENUMCALLBACK enumProc, LPVOID lParam) * RETURNS * none */ - -VOID WINAPI -DSA_EnumCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, LPVOID lParam) +VOID WINAPI DSA_EnumCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, + LPVOID lParam) { INT i; @@ -2531,9 +2562,8 @@ DSA_EnumCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, LPVOID lParam) * RETURNS * none */ - -void WINAPI -DSA_DestroyCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, LPVOID lParam) +void WINAPI DSA_DestroyCallback (HDSA hdsa, PFNDSAENUMCALLBACK enumProc, + LPVOID lParam) { TRACE("(%p %p %p)\n", hdsa, enumProc, lParam); diff --git a/reactos/lib/comctl32/commctrl.c b/reactos/lib/comctl32/commctrl.c index cabb51de2ea..0fbbc940710 100644 --- a/reactos/lib/comctl32/commctrl.c +++ b/reactos/lib/comctl32/commctrl.c @@ -336,7 +336,7 @@ MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu, * Handle to the window that contains the menu and controls. * * uFlags - * Identifier of the menu item to receive or loose a check mark. + * Identifier of the menu item to receive or lose a check mark. * * lpInfo * The array of integers contains pairs of values. BOTH values of diff --git a/reactos/lib/comctl32/datetime.c b/reactos/lib/comctl32/datetime.c index 54a33e2958c..8b8af308a8d 100644 --- a/reactos/lib/comctl32/datetime.c +++ b/reactos/lib/comctl32/datetime.c @@ -487,22 +487,17 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc) 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; + COLORREF 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) { HFONT oldFont = SelectObject (hdc, infoPtr->hFont); + INT oldBkMode = SetBkMode (hdc, TRANSPARENT); WCHAR txt[80]; DATETIME_ReturnTxt (infoPtr, 0, txt, sizeof(txt)/sizeof(txt[0])); @@ -521,18 +516,23 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc) field->bottom = rcDraw->bottom; prevright = field->right; - if ((infoPtr->haveFocus) && (i == infoPtr->select)) { - hbr = CreateSolidBrush (GetSysColor (COLOR_ACTIVECAPTION)); + if (infoPtr->dwStyle & WS_DISABLED) + oldTextColor = SetTextColor (hdc, comctl32_color.clrGrayText); + else if ((infoPtr->haveFocus) && (i == infoPtr->select)) { + /* fill if focussed */ + HBRUSH hbr = CreateSolidBrush (comctl32_color.clrActiveCaption); 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 - DrawTextW ( hdc, txt, strlenW(txt), field, DT_RIGHT | DT_VCENTER | DT_SINGLELINE ); + oldTextColor = SetTextColor (hdc, comctl32_color.clrWindow); + } + else + oldTextColor = SetTextColor (hdc, comctl32_color.clrWindowText); + + /* draw the date text using the colour set above */ + DrawTextW (hdc, txt, strlenW(txt), field, DT_RIGHT | DT_VCENTER | DT_SINGLELINE); + SetTextColor (hdc, oldTextColor); } + SetBkMode (hdc, oldBkMode); SelectObject (hdc, oldFont); } @@ -576,25 +576,29 @@ DATETIME_LButtonDown (DATETIME_INFO *infoPtr, WORD wKey, INT x, INT y) /* FIXME: might be conditions where we don't want to update infoPtr->select */ infoPtr->select = new; - if (infoPtr->select != old) - infoPtr->haveFocus = DTHT_GOTFOCUS; + SetFocus(infoPtr->hwndSelf); if (infoPtr->select == DTHT_MCPOPUP) { + RECT rcMonthCal; + SendMessageW(infoPtr->hMonthCal, MCM_GETMINREQRECT, 0, (LPARAM)&rcMonthCal); + /* 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(infoPtr->dwStyle & DTS_RIGHTALIGN) - infoPtr->monthcal_pos.x = infoPtr->rcClient.right - - ((infoPtr->calbutton.right - infoPtr->calbutton.left) + 200); + infoPtr->monthcal_pos.x = infoPtr->calbutton.left - + (rcMonthCal.right - rcMonthCal.left); else - infoPtr->monthcal_pos.x = 8; + /* FIXME: this should be after the area reserved for the checkbox */ + infoPtr->monthcal_pos.x = infoPtr->rcDraw.left; 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); + SetWindowPos(infoPtr->hMonthCal, 0, infoPtr->monthcal_pos.x, + infoPtr->monthcal_pos.y, rcMonthCal.right - rcMonthCal.left, + rcMonthCal.bottom - rcMonthCal.top, 0); if(IsWindowVisible(infoPtr->hMonthCal)) { ShowWindow(infoPtr->hMonthCal, SW_HIDE); @@ -611,7 +615,7 @@ DATETIME_LButtonDown (DATETIME_INFO *infoPtr, WORD wKey, INT x, INT y) DATETIME_SendSimpleNotify (infoPtr, DTN_DROPDOWN); } - InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); return 0; } @@ -620,7 +624,7 @@ DATETIME_LButtonDown (DATETIME_INFO *infoPtr, WORD wKey, INT x, INT y) static LRESULT DATETIME_LButtonUp (DATETIME_INFO *infoPtr, WORD wKey) { - if(infoPtr->bCalDepressed == TRUE) { + if(infoPtr->bCalDepressed) { infoPtr->bCalDepressed = FALSE; InvalidateRect(infoPtr->hwndSelf, &(infoPtr->calbutton), TRUE); } @@ -667,6 +671,45 @@ DATETIME_Command (DATETIME_INFO *infoPtr, WPARAM wParam, LPARAM lParam) } +static LRESULT +DATETIME_Enable (DATETIME_INFO *infoPtr, BOOL bEnable) +{ + TRACE("%p %s\n", infoPtr, bEnable ? "TRUE" : "FALSE"); + if (bEnable) + infoPtr->dwStyle &= ~WS_DISABLED; + else + infoPtr->dwStyle |= WS_DISABLED; + return 0; +} + + +static LRESULT +DATETIME_EraseBackground (DATETIME_INFO *infoPtr, HDC hdc) +{ + HBRUSH hBrush, hSolidBrush = NULL; + RECT rc; + + if (infoPtr->dwStyle & WS_DISABLED) + hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrBtnFace); + else + { + hBrush = (HBRUSH)SendMessageW(infoPtr->hwndNotify, WM_CTLCOLOREDIT, + (WPARAM)hdc, (LPARAM)infoPtr->hwndSelf); + if (!hBrush) + hBrush = hSolidBrush = CreateSolidBrush(comctl32_color.clrWindow); + } + + GetClientRect (infoPtr->hwndSelf, &rc); + + FillRect (hdc, &rc, hBrush); + + if (hSolidBrush) + DeleteObject(hSolidBrush); + + return -1; +} + + static LRESULT DATETIME_Notify (DATETIME_INFO *infoPtr, int idCtrl, LPNMHDR lpnmh) { @@ -749,6 +792,8 @@ DATETIME_KeyDown (DATETIME_INFO *infoPtr, DWORD vkCode, LPARAM flags) static LRESULT DATETIME_KillFocus (DATETIME_INFO *infoPtr, HWND lostFocus) { + TRACE("lost focus to %p\n", lostFocus); + if (infoPtr->haveFocus) { DATETIME_SendSimpleNotify (infoPtr, NM_KILLFOCUS); infoPtr->haveFocus = 0; @@ -760,9 +805,23 @@ DATETIME_KillFocus (DATETIME_INFO *infoPtr, HWND lostFocus) } +static LRESULT +DATETIME_NCCreate (HWND hwnd, LPCREATESTRUCTW lpcs) +{ + DWORD dwExStyle = GetWindowLongW(hwnd, GWL_EXSTYLE); + /* force control to have client edge */ + dwExStyle |= WS_EX_CLIENTEDGE; + SetWindowLongW(hwnd, GWL_EXSTYLE, dwExStyle); + + return DefWindowProcW(hwnd, WM_NCCREATE, 0, (LPARAM)lpcs); +} + + static LRESULT DATETIME_SetFocus (DATETIME_INFO *infoPtr, HWND lostFocus) { + TRACE("got focus from %p\n", lostFocus); + if (infoPtr->haveFocus == 0) { DATETIME_SendSimpleNotify (infoPtr, NM_SETFOCUS); infoPtr->haveFocus = DTHT_GOTFOCUS; @@ -814,10 +873,7 @@ DATETIME_Size (DATETIME_INFO *infoPtr, WORD flags, INT width, INT height) TRACE("Height=%ld, Width=%ld\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right); - memcpy((&infoPtr->rcDraw), (&infoPtr->rcClient), sizeof(infoPtr->rcDraw)); - - /* subract the size of the edge drawn by DrawEdge */ - InflateRect(&infoPtr->rcDraw, -2, -2); + infoPtr->rcDraw = infoPtr->rcClient; /* set the size of the button that drops the calendar down */ /* FIXME: account for style that allows button on left side */ @@ -833,17 +889,6 @@ DATETIME_Size (DATETIME_INFO *infoPtr, WORD flags, INT width, INT height) 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; - - 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); - InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); return 0; @@ -903,6 +948,7 @@ DATETIME_Create (HWND hwnd, LPCREATESTRUCTW lpcs) infoPtr->fieldRect = (RECT *) Alloc (infoPtr->nrFieldsAllocated * sizeof(RECT)); infoPtr->buflen = (int *) Alloc (infoPtr->nrFieldsAllocated * sizeof(int)); infoPtr->hwndNotify = lpcs->hwndParent; + infoPtr->select = -1; /* initially, nothing is selected */ DATETIME_StyleChanged(infoPtr, GWL_STYLE, &ss); DATETIME_SetFormatW (infoPtr, 0); @@ -946,7 +992,7 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) TRACE ("%x, %x, %lx\n", uMsg, wParam, lParam); - if (!infoPtr && (uMsg != WM_CREATE)) + if (!infoPtr && (uMsg != WM_CREATE) && (uMsg != WM_NCCREATE)) return DefWindowProcW( hwnd, uMsg, wParam, lParam ); switch (uMsg) { @@ -988,6 +1034,12 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_NOTIFY: return DATETIME_Notify (infoPtr, (int)wParam, (LPNMHDR)lParam); + case WM_ENABLE: + return DATETIME_Enable (infoPtr, (BOOL)wParam); + + case WM_ERASEBKGND: + return DATETIME_EraseBackground (infoPtr, (HDC)wParam); + case WM_GETDLGCODE: return DLGC_WANTARROWS | DLGC_WANTCHARS; @@ -1000,6 +1052,9 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_KILLFOCUS: return DATETIME_KillFocus (infoPtr, (HWND)wParam); + case WM_NCCREATE: + return DATETIME_NCCreate (hwnd, (LPCREATESTRUCTW)lParam); + case WM_SETFOCUS: return DATETIME_SetFocus (infoPtr, (HWND)wParam); @@ -1030,7 +1085,6 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) uMsg, wParam, lParam); return DefWindowProcW (hwnd, uMsg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/flatsb.c b/reactos/lib/comctl32/flatsb.c index 2980b6b9a6a..1c5fa66236a 100644 --- a/reactos/lib/comctl32/flatsb.c +++ b/reactos/lib/comctl32/flatsb.c @@ -34,9 +34,7 @@ #include "windef.h" #include "winbase.h" #include "winerror.h" -#include "wingdi.h" #include "winuser.h" -#include "winnls.h" #include "commctrl.h" #include "wine/debug.h" @@ -263,7 +261,6 @@ FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) uMsg, wParam, lParam); return DefWindowProcA (hwnd, uMsg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/header.c b/reactos/lib/comctl32/header.c index 892c7dfce0b..03b80845264 100644 --- a/reactos/lib/comctl32/header.c +++ b/reactos/lib/comctl32/header.c @@ -688,29 +688,36 @@ HEADER_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) if (!phdi) return FALSE; - if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) - return FALSE; TRACE("[nItem=%d]\n", nItem); if (phdi->mask == 0) return TRUE; - lpItem = &infoPtr->items[nItem]; + if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) { + lpItem = NULL; + } + else { + lpItem = &infoPtr->items[nItem]; + } + if (phdi->mask & HDI_BITMAP) - phdi->hbm = lpItem->hbm; + phdi->hbm = (lpItem != NULL) ? lpItem->hbm : 0; if (phdi->mask & HDI_FORMAT) - phdi->fmt = lpItem->fmt; + phdi->fmt = (lpItem != NULL) ? lpItem->fmt : 0; if (phdi->mask & HDI_WIDTH) - phdi->cxy = lpItem->cxy; + phdi->cxy = (lpItem != NULL) ? lpItem->cxy : 0; if (phdi->mask & HDI_LPARAM) - phdi->lParam = lpItem->lParam; + phdi->lParam = (lpItem != NULL) ? lpItem->lParam : 0; if (phdi->mask & HDI_TEXT) { - if (lpItem->pszText != LPSTR_TEXTCALLBACKW) { + if (lpItem == NULL) { + *phdi->pszText = 0; + } + else if (lpItem->pszText != LPSTR_TEXTCALLBACKW) { if (lpItem->pszText) WideCharToMultiByte (CP_ACP, 0, lpItem->pszText, -1, phdi->pszText, phdi->cchTextMax, NULL, NULL); @@ -722,10 +729,10 @@ HEADER_GetItemA (HWND hwnd, WPARAM wParam, LPARAM lParam) } if (phdi->mask & HDI_IMAGE) - phdi->iImage = lpItem->iImage; + phdi->iImage = (lpItem != NULL) ? lpItem->iImage : 0; if (phdi->mask & HDI_ORDER) - phdi->iOrder = lpItem->iOrder; + phdi->iOrder = (lpItem != NULL) ? lpItem->iOrder : 0; return TRUE; } @@ -741,29 +748,36 @@ HEADER_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) if (!phdi) return FALSE; - if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) - return FALSE; TRACE("[nItem=%d]\n", nItem); if (phdi->mask == 0) return TRUE; - lpItem = &infoPtr->items[nItem]; + if ((nItem < 0) || (nItem >= (INT)infoPtr->uNumItem)) { + lpItem = NULL; + } + else { + lpItem = &infoPtr->items[nItem]; + } + if (phdi->mask & HDI_BITMAP) - phdi->hbm = lpItem->hbm; + phdi->hbm = (lpItem != NULL) ? lpItem->hbm : 0; if (phdi->mask & HDI_FORMAT) - phdi->fmt = lpItem->fmt; + phdi->fmt = (lpItem != NULL) ? lpItem->fmt : 0; if (phdi->mask & HDI_WIDTH) - phdi->cxy = lpItem->cxy; + phdi->cxy = (lpItem != NULL) ? lpItem->cxy : 0; if (phdi->mask & HDI_LPARAM) - phdi->lParam = lpItem->lParam; + phdi->lParam = (lpItem != NULL) ? lpItem->lParam : 0; if (phdi->mask & HDI_TEXT) { - if (lpItem->pszText != LPSTR_TEXTCALLBACKW) { + if (lpItem == NULL) { + *phdi->pszText = 0; + } + else if (lpItem->pszText != LPSTR_TEXTCALLBACKW) { if (lpItem->pszText) lstrcpynW (phdi->pszText, lpItem->pszText, phdi->cchTextMax); else @@ -774,10 +788,10 @@ HEADER_GetItemW (HWND hwnd, WPARAM wParam, LPARAM lParam) } if (phdi->mask & HDI_IMAGE) - phdi->iImage = lpItem->iImage; + phdi->iImage = (lpItem != NULL) ? lpItem->iImage : 0; if (phdi->mask & HDI_ORDER) - phdi->iOrder = lpItem->iOrder; + phdi->iOrder = (lpItem != NULL) ? lpItem->iOrder : 0; return TRUE; } @@ -1831,7 +1845,6 @@ HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) msg, wParam, lParam ); return DefWindowProcA (hwnd, msg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/imagelist.c b/reactos/lib/comctl32/imagelist.c index 99e1dd11e42..37f7def4b5e 100644 --- a/reactos/lib/comctl32/imagelist.c +++ b/reactos/lib/comctl32/imagelist.c @@ -612,6 +612,8 @@ ImageList_Create (INT cx, INT cy, UINT flags, } SelectObject(himl->hdcMask, himl->hbmMask); } + else + himl->hbmMask = 0; /* create blending brushes */ hbmTemp = CreateBitmap (8, 8, 1, 1, &aBitBlend25); @@ -1056,10 +1058,10 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) INT cx, cy, lx, ly, nOvlIdx; DWORD fState, dwRop; UINT fStyle; - COLORREF clrBk, oldImageBk, oldImageFg; + COLORREF oldImageBk, oldImageFg; HDC hImageDC, hImageListDC, hMaskListDC; HBITMAP hImageBmp, hOldImageBmp, hBlendMaskBmp; - BOOL bIsTransparent, bBlend, bResult = FALSE; + BOOL bIsTransparent, bBlend, bResult = FALSE, bMask; HIMAGELIST himl; if (!pimldp || !(himl = pimldp->himl)) return FALSE; @@ -1073,9 +1075,14 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) fStyle = pimldp->fStyle & ~ILD_OVERLAYMASK; cx = (pimldp->cx == 0) ? himl->cx : pimldp->cx; cy = (pimldp->cy == 0) ? himl->cy : pimldp->cy; - clrBk = (pimldp->rgbBk == CLR_DEFAULT) ? himl->clrBk : pimldp->rgbBk; - bIsTransparent = (fStyle & ILD_TRANSPARENT) || clrBk == CLR_NONE; - bBlend = fStyle & (ILD_BLEND25 | ILD_BLEND50); + + bIsTransparent = (fStyle & ILD_TRANSPARENT); + if( pimldp->rgbBk == CLR_NONE ) + bIsTransparent = TRUE; + if( ( pimldp->rgbBk == CLR_DEFAULT ) && ( himl->clrBk == CLR_NONE ) ) + bIsTransparent = TRUE; + bMask = (himl->flags & ILC_MASK) && (fStyle & ILD_MASK) ; + bBlend = (fStyle & (ILD_BLEND25 | ILD_BLEND50) ) && !bMask; TRACE("himl(0x%lx) hbmMask(%p) iImage(%d) x(%d) y(%d) cx(%d) cy(%d)\n", (DWORD)himl, himl->hbmMask, pimldp->i, pimldp->x, pimldp->y, cx, cy); @@ -1107,24 +1114,43 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) /* * Draw the initial image */ - if (fStyle & ILD_MASK) { + if( bMask ) { if (himl->hbmMask) { - BitBlt(hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCCOPY); + HBRUSH hOldBrush; + hOldBrush = SelectObject (hImageDC, CreateSolidBrush (GetTextColor(pimldp->hdcDst))); + PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY ); + BitBlt(hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCPAINT); + DeleteObject (SelectObject (hImageDC, hOldBrush)); + if( bIsTransparent ) + { + BitBlt ( pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hImageDC, 0, 0, SRCAND); + bResult = TRUE; + goto end; + } } else { HBRUSH hOldBrush = SelectObject (hImageDC, GetStockObject(BLACK_BRUSH)); PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY); SelectObject(hImageDC, hOldBrush); } - } else if (himl->hbmMask && !bIsTransparent) { + } else { /* blend the image with the needed solid background */ - HBRUSH hOldBrush = SelectObject (hImageDC, CreateSolidBrush (clrBk)); + COLORREF colour = RGB(0,0,0); + HBRUSH hOldBrush; + + if( !bIsTransparent ) + { + colour = pimldp->rgbBk; + if( colour == CLR_DEFAULT ) + colour = himl->clrBk; + if( colour == CLR_NONE ) + colour = GetBkColor(pimldp->hdcDst); + } + + hOldBrush = SelectObject (hImageDC, CreateSolidBrush (colour)); PatBlt( hImageDC, 0, 0, cx, cy, PATCOPY ); BitBlt( hImageDC, 0, 0, cx, cy, hMaskListDC, lx, ly, SRCAND ); BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCPAINT ); DeleteObject (SelectObject (hImageDC, hOldBrush)); - } else { - /* start off with the image, if we have a mask, we'll use it later */ - BitBlt( hImageDC, 0, 0, cx, cy, hImageListDC, lx, ly, SRCCOPY); } /* Time for blending, if required */ @@ -1179,7 +1205,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) /* now copy the image to the screen */ dwRop = SRCCOPY; - if (himl->hbmMask && bIsTransparent && !(fStyle & ILD_MASK)) { + if (himl->hbmMask && bIsTransparent ) { COLORREF oldDstFg = SetTextColor(pimldp->hdcDst, RGB( 0, 0, 0 ) ); COLORREF oldDstBk = SetBkColor(pimldp->hdcDst, RGB( 0xff, 0xff, 0xff )); BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hMaskListDC, lx, ly, SRCAND); @@ -1191,7 +1217,7 @@ ImageList_DrawIndirect (IMAGELISTDRAWPARAMS *pimldp) BitBlt (pimldp->hdcDst, pimldp->x, pimldp->y, cx, cy, hImageDC, 0, 0, dwRop); bResult = TRUE; - +end: /* cleanup the mess */ SetBkColor(hImageDC, oldImageBk); SetTextColor(hImageDC, oldImageFg); @@ -1388,14 +1414,18 @@ ImageList_GetIcon (HIMAGELIST himl, INT i, UINT fStyle) /* draw mask*/ ii.hbmMask = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); hOldDstBitmap = SelectObject (hdcDst, ii.hbmMask); - PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, WHITENESS); - ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle | ILD_MASK); + if (himl->hbmMask) { + BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, + himl->hdcMask, i * himl->cx, 0, SRCCOPY); + } + else + PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS); /* draw image*/ ii.hbmColor = CreateCompatibleBitmap (himl->hdcImage, himl->cx, himl->cy); SelectObject (hdcDst, ii.hbmColor); - PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS); - ImageList_Draw(himl, i, hdcDst, 0, 0, fStyle | ILD_TRANSPARENT); + BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, + himl->hdcImage, i * himl->cx, 0, SRCCOPY); /* * CreateIconIndirect requires us to deselect the bitmaps from diff --git a/reactos/lib/comctl32/listview.c b/reactos/lib/comctl32/listview.c index 7ae622cefea..dd7d8d40e91 100644 --- a/reactos/lib/comctl32/listview.c +++ b/reactos/lib/comctl32/listview.c @@ -8348,6 +8348,36 @@ static LRESULT LISTVIEW_Paint(LISTVIEW_INFO *infoPtr, HDC hdc) return 0; } + +/*** + * DESCRIPTION: + * Paints/Repaints the listview control. + * + * PARAMETER(S): + * [I] infoPtr : valid pointer to the listview structure + * [I] hdc : device context handle + * [I] options : drawing options + * + * RETURN: + * Zero + */ +static LRESULT LISTVIEW_PrintClient(LISTVIEW_INFO *infoPtr, HDC hdc, DWORD options) +{ + FIXME("Partial Stub: (hdc=%p options=0x%08lx)\n", hdc, options); + + if ((options & PRF_CHECKVISIBLE) && !IsWindowVisible(infoPtr->hwndSelf)) + return 0; + + if (options & PRF_ERASEBKGND) + LISTVIEW_EraseBkgnd(infoPtr, hdc); + + if (options & PRF_CLIENT) + LISTVIEW_Paint(infoPtr, hdc); + + return 0; +} + + /*** * DESCRIPTION: * Processes double click messages (right mouse button). @@ -9195,6 +9225,9 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_NOTIFYFORMAT: return LISTVIEW_NotifyFormat(infoPtr, (HWND)wParam, (INT)lParam); + case WM_PRINTCLIENT: + return LISTVIEW_PrintClient(infoPtr, (HDC)wParam, (DWORD)lParam); + case WM_PAINT: return LISTVIEW_Paint(infoPtr, (HDC)wParam); @@ -9262,7 +9295,6 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) return DefWindowProcW(hwnd, uMsg, wParam, lParam); } - return 0; } /*** diff --git a/reactos/lib/comctl32/monthcal.c b/reactos/lib/comctl32/monthcal.c index 7c53fcca4dd..961fcae6e69 100644 --- a/reactos/lib/comctl32/monthcal.c +++ b/reactos/lib/comctl32/monthcal.c @@ -337,7 +337,6 @@ static void MONTHCAL_DrawDay(MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month RECT r; static int haveBoldFont, haveSelectedDay = FALSE; HBRUSH hbr; - HPEN hNewPen, hOldPen = 0; COLORREF oldCol = 0; COLORREF oldBk = 0; @@ -394,12 +393,8 @@ static void MONTHCAL_DrawDay(MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month DrawTextA(hdc, buf, -1, &r, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); /* draw a rectangle around the currently selected days text */ - if((day==infoPtr->curSelDay) && (month==infoPtr->currentMonth)) { - hNewPen = CreatePen(PS_ALTERNATE, 0, GetSysColor(COLOR_WINDOWTEXT) ); - hbr = GetSysColorBrush(COLOR_WINDOWTEXT); - FrameRect(hdc, &r, hbr); - SelectObject(hdc, hOldPen); - } + if((day==infoPtr->curSelDay) && (month==infoPtr->currentMonth)) + DrawFocusRect(hdc, &r); } @@ -2016,7 +2011,6 @@ MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ERR( "unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); return DefWindowProcA(hwnd, uMsg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/nativefont.c b/reactos/lib/comctl32/nativefont.c index 4e6fd78ac6a..4955a8c83b1 100644 --- a/reactos/lib/comctl32/nativefont.c +++ b/reactos/lib/comctl32/nativefont.c @@ -106,7 +106,6 @@ NATIVEFONT_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) uMsg, wParam, lParam); return DefWindowProcW (hwnd, uMsg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/pager.c b/reactos/lib/comctl32/pager.c index 74d765e633d..0cd5e67b8a3 100644 --- a/reactos/lib/comctl32/pager.c +++ b/reactos/lib/comctl32/pager.c @@ -1368,8 +1368,6 @@ PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) default: return DefWindowProcW (hwnd, uMsg, wParam, lParam); } - - return 0; } diff --git a/reactos/lib/comctl32/propsheet.c b/reactos/lib/comctl32/propsheet.c index d38dc1f6cd1..2ad24f2a151 100644 --- a/reactos/lib/comctl32/propsheet.c +++ b/reactos/lib/comctl32/propsheet.c @@ -3690,6 +3690,4 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) default: return FALSE; } - - return FALSE; } diff --git a/reactos/lib/comctl32/rebar.c b/reactos/lib/comctl32/rebar.c index 532e21ea82b..b01295bf0ef 100644 --- a/reactos/lib/comctl32/rebar.c +++ b/reactos/lib/comctl32/rebar.c @@ -4696,7 +4696,6 @@ REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) uMsg, wParam, lParam); return DefWindowProcA (hwnd, uMsg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/smoothscroll.c b/reactos/lib/comctl32/smoothscroll.c index fbed31eb5bc..5c0030fc355 100644 --- a/reactos/lib/comctl32/smoothscroll.c +++ b/reactos/lib/comctl32/smoothscroll.c @@ -27,10 +27,7 @@ #include "winbase.h" #include "winreg.h" #include "winerror.h" -#include "wingdi.h" #include "winuser.h" -#include "winnls.h" -#include "commctrl.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(commctrl); @@ -75,7 +72,6 @@ BOOL WINAPI SmoothScrollWindow( SMOOTHSCROLLSTRUCT *smooth ) { LPRECT lpupdaterect = smooth->lpupdaterect; HRGN hrgnupdate = smooth->hrgnupdate; RECT tmprect; - BOOL ret = TRUE; DWORD flags = smooth->flags; if (smooth->dwSize!=sizeof(SMOOTHSCROLLSTRUCT)) @@ -132,5 +128,4 @@ BOOL WINAPI SmoothScrollWindow( SMOOTHSCROLLSTRUCT *smooth ) { smooth->lpcliprect,hrgnupdate,lpupdaterect, flags & 0xffff ); - return ret; } diff --git a/reactos/lib/comctl32/status.c b/reactos/lib/comctl32/status.c index fd82bb59f23..068564651ef 100644 --- a/reactos/lib/comctl32/status.c +++ b/reactos/lib/comctl32/status.c @@ -455,7 +455,7 @@ STATUSBAR_GetTextLength (STATUS_INFO *infoPtr, INT nPart) else part = &infoPtr->parts[nPart]; - if (part->text) + if ((~part->style & SBT_OWNERDRAW) && part->text) result = strlenW(part->text); else result = 0; @@ -1252,7 +1252,6 @@ StatusWindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) msg, wParam, lParam); return DefWindowProcW (hwnd, msg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/syslink.c b/reactos/lib/comctl32/syslink.c index 4eeff7533a9..3567c96a3a4 100644 --- a/reactos/lib/comctl32/syslink.c +++ b/reactos/lib/comctl32/syslink.c @@ -33,7 +33,6 @@ #include "winuser.h" #include "winnls.h" #include "commctrl.h" -#include "comctl32.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -116,14 +115,8 @@ static VOID SYSLINK_FreeDocItem (PDOC_ITEM DocItem) { if(DocItem->Type == slLink) { - if(DocItem->u.Link.szID != NULL) - { - SYSLINK_Free(DocItem->u.Link.szID); - } - if(DocItem->u.Link.szUrl != NULL) - { - SYSLINK_Free(DocItem->u.Link.szUrl); - } + SYSLINK_Free(DocItem->u.Link.szID); + SYSLINK_Free(DocItem->u.Link.szUrl); } if(DocItem->Type == slLink && DocItem->u.Link.hRgn != NULL) @@ -1637,6 +1630,8 @@ static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message, case WM_DESTROY: TRACE("SysLink Ctrl destruction, hwnd=%p\n", hwnd); SYSLINK_ClearDoc(infoPtr); + if(infoPtr->Font != 0) DeleteObject(infoPtr->Font); + if(infoPtr->LinkFont != 0) DeleteObject(infoPtr->LinkFont); SYSLINK_Free (infoPtr); SetWindowLongPtrW(hwnd, 0, 0); return 0; diff --git a/reactos/lib/comctl32/tab.c b/reactos/lib/comctl32/tab.c index 6a930398b54..a4b843c5520 100644 --- a/reactos/lib/comctl32/tab.c +++ b/reactos/lib/comctl32/tab.c @@ -201,6 +201,8 @@ TAB_DumpItemInternal(TAB_INFO *infoPtr, UINT iItem) } } +/* RETURNS + * the index of the selected tab, or -1 if no tab is selected. */ static LRESULT TAB_GetCurSel (HWND hwnd) { @@ -209,11 +211,21 @@ TAB_GetCurSel (HWND hwnd) return infoPtr->iSelected; } +/* RETURNS + * the index of the tab item that has the focus + * NOTE + * we have not to return negative value + * TODO + * test for windows */ static LRESULT TAB_GetCurFocus (HWND hwnd) { TAB_INFO *infoPtr = TAB_GetInfoPtr(hwnd); - + if (infoPtr->uFocus<0) + { + FIXME("we have not to return negative value"); + return 0; + } return infoPtr->uFocus; } @@ -255,10 +267,10 @@ TAB_SetCurFocus (HWND hwnd,WPARAM wParam) FIXME("Should set input focus\n"); } else { int oldFocus = infoPtr->uFocus; - if (infoPtr->iSelected != iItem || infoPtr->uFocus == -1 ) { + if (infoPtr->iSelected != iItem || oldFocus == -1 ) { infoPtr->uFocus = iItem; if (oldFocus != -1) { - if (TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING)!=TRUE) { + if (!TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING)) { infoPtr->iSelected = iItem; TAB_SendSimpleNotify(hwnd, TCN_SELCHANGE); } @@ -611,7 +623,7 @@ TAB_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) if ((newItem != -1) && (infoPtr->iSelected != newItem)) { - if (TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING) != TRUE) + if (!TAB_SendSimpleNotify(hwnd, TCN_SELCHANGING)) { infoPtr->iSelected = newItem; infoPtr->uFocus = newItem; @@ -3258,8 +3270,6 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) uMsg, wParam, lParam); return DefWindowProcW(hwnd, uMsg, wParam, lParam); } - - return 0; } diff --git a/reactos/lib/comctl32/toolbar.c b/reactos/lib/comctl32/toolbar.c index 9ca3072b71b..8eb9266f83f 100644 --- a/reactos/lib/comctl32/toolbar.c +++ b/reactos/lib/comctl32/toolbar.c @@ -5522,8 +5522,7 @@ TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) DestroyWindow (infoPtr->hwndToolTip); /* delete temporary buffer for tooltip text */ - if (infoPtr->pszTooltipText) - HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText); + HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText); /* delete button data */ if (infoPtr->buttons) @@ -6275,11 +6274,8 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm TRACE("button index = %d\n", index); - if (infoPtr->pszTooltipText) - { - HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText); - infoPtr->pszTooltipText = NULL; - } + HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText); + infoPtr->pszTooltipText = NULL; if (index < 0) return 0; @@ -7101,7 +7097,6 @@ ToolbarWindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) uMsg, wParam, lParam); return DefWindowProcW (hwnd, uMsg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/tooltips.c b/reactos/lib/comctl32/tooltips.c index 802363a454a..e7499ad7353 100644 --- a/reactos/lib/comctl32/tooltips.c +++ b/reactos/lib/comctl32/tooltips.c @@ -1400,8 +1400,6 @@ TOOLTIPS_GetCurrentToolA (HWND hwnd, WPARAM wParam, LPARAM lParam) } else return (infoPtr->nCurrentTool != -1); - - return FALSE; } @@ -1438,8 +1436,6 @@ TOOLTIPS_GetCurrentToolW (HWND hwnd, WPARAM wParam, LPARAM lParam) } else return (infoPtr->nCurrentTool != -1); - - return FALSE; } @@ -2802,7 +2798,6 @@ TOOLTIPS_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) uMsg, wParam, lParam); return DefWindowProcW (hwnd, uMsg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/trackbar.c b/reactos/lib/comctl32/trackbar.c index fae5a562660..8a364d9a5e4 100644 --- a/reactos/lib/comctl32/trackbar.c +++ b/reactos/lib/comctl32/trackbar.c @@ -1810,7 +1810,6 @@ TRACKBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ERR("unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); return DefWindowProcW (hwnd, uMsg, wParam, lParam); } - return 0; } diff --git a/reactos/lib/comctl32/treeview.c b/reactos/lib/comctl32/treeview.c index 52b4fe4c3d1..b7320f14e1b 100644 --- a/reactos/lib/comctl32/treeview.c +++ b/reactos/lib/comctl32/treeview.c @@ -31,7 +31,6 @@ * TVN_SETDISPINFO, TVN_SINGLEEXPAND * * missing styles: TVS_FULLROWSELECT, TVS_INFOTIP, TVS_RTLREADING, - * TVS_TRACKSELECT * * missing item styles: TVIS_CUT, TVIS_EXPANDPARTIAL * @@ -132,6 +131,8 @@ typedef struct tagTREEVIEW_INFO HFONT hFont; HFONT hDefaultFont; HFONT hBoldFont; + HFONT hUnderlineFont; + HCURSOR hcurHand; HWND hwndToolTip; HWND hwndEdit; @@ -263,10 +264,24 @@ TREEVIEW_CreateBoldFont(HFONT hOrigFont) return CreateFontIndirectW(&font); } +static HFONT +TREEVIEW_CreateUnderlineFont(HFONT hOrigFont) +{ + LOGFONTW font; + + GetObjectW(hOrigFont, sizeof(font), &font); + font.lfUnderline = TRUE; + return CreateFontIndirectW(&font); +} + static inline HFONT TREEVIEW_FontForItem(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *item) { - return (item->state & TVIS_BOLD) ? infoPtr->hBoldFont : infoPtr->hFont; + if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (item == infoPtr->hotItem)) + return infoPtr->hUnderlineFont; + if (item->state & TVIS_BOLD) + return infoPtr->hBoldFont; + return infoPtr->hFont; } /* for trace/debugging purposes only */ @@ -1814,6 +1829,7 @@ TREEVIEW_SetFont(TREEVIEW_INFO *infoPtr, HFONT hFont, BOOL bRedraw) DeleteObject(infoPtr->hBoldFont); infoPtr->hBoldFont = TREEVIEW_CreateBoldFont(infoPtr->hFont); + infoPtr->hUnderlineFont = TREEVIEW_CreateUnderlineFont(infoPtr->hFont); if (!infoPtr->bHeightSet) infoPtr->uItemHeight = TREEVIEW_NaturalHeight(infoPtr); @@ -2486,7 +2502,9 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem) } else { - if (infoPtr->clrText == -1) + if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem == infoPtr->hotItem)) + oldTextColor = SetTextColor(hdc, comctl32_color.clrHighlight); + else if (infoPtr->clrText == -1) oldTextColor = SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); else @@ -3177,7 +3195,7 @@ TREEVIEW_Expand(TREEVIEW_INFO *infoPtr, TREEVIEW_ITEM *wineItem, TREEVIEW_UpdateScrollBars(infoPtr); /* Scroll up so that as many children as possible are visible. - * This looses when expanding causes an HScroll bar to appear, but we + * This fails when expanding causes an HScroll bar to appear, but we * don't know that yet, so the last item is obscured. */ if (wineItem->firstChild != NULL) { @@ -4112,9 +4130,6 @@ TREEVIEW_DoSelectItem(TREEVIEW_INFO *infoPtr, INT action, HTREEITEM newSelect, case TVGN_CARET: prevSelect = infoPtr->selectedItem; - if (prevSelect == newSelect) - return FALSE; - if (TREEVIEW_SendTreeviewNotify(infoPtr, TVN_SELCHANGINGW, cause, @@ -4701,7 +4716,6 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) infoPtr->hwnd = hwnd; infoPtr->dwStyle = GetWindowLongW(hwnd, GWL_STYLE); - infoPtr->uInternalStatus = 0; infoPtr->Timer = 0; infoPtr->uNumItems = 0; infoPtr->cdmode = 0; @@ -4713,6 +4727,7 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) /* No scroll bars yet. */ infoPtr->clientWidth = rcClient.right; infoPtr->clientHeight = rcClient.bottom; + infoPtr->uInternalStatus = 0; infoPtr->treeWidth = 0; infoPtr->treeHeight = 0; @@ -4754,6 +4769,8 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0); infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectW(&lf); infoPtr->hBoldFont = TREEVIEW_CreateBoldFont(infoPtr->hFont); + infoPtr->hUnderlineFont = TREEVIEW_CreateUnderlineFont(infoPtr->hFont); + infoPtr->hcurHand = LoadCursorW(NULL, (LPWSTR)IDC_HAND); infoPtr->uItemHeight = TREEVIEW_NaturalHeight(infoPtr); @@ -4821,6 +4838,11 @@ TREEVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs) infoPtr->stateImageWidth = 16; infoPtr->stateImageHeight = 16; } + + /* Make sure actual scrollbar state is consistent with uInternalStatus */ + ShowScrollBar(hwnd, SB_VERT, FALSE); + ShowScrollBar(hwnd, SB_HORZ, FALSE); + return 0; } @@ -4844,6 +4866,7 @@ TREEVIEW_Destroy(TREEVIEW_INFO *infoPtr) DeleteObject(infoPtr->hDefaultFont); DeleteObject(infoPtr->hBoldFont); + DeleteObject(infoPtr->hUnderlineFont); Free(infoPtr); return 0; @@ -5011,6 +5034,63 @@ TREEVIEW_KeyDown(TREEVIEW_INFO *infoPtr, WPARAM wParam) return FALSE; } +static LRESULT +TREEVIEW_MouseLeave (TREEVIEW_INFO * infoPtr) +{ + if (infoPtr->hotItem) + { + /* remove hot effect from item */ + InvalidateRect(infoPtr->hwnd, &infoPtr->hotItem->rect, TRUE); + infoPtr->hotItem = NULL; + } + return 0; +} + +static LRESULT +TREEVIEW_MouseMove (TREEVIEW_INFO * infoPtr, WPARAM wParam, LPARAM lParam) +{ + POINT pt; + TRACKMOUSEEVENT trackinfo; + TREEVIEW_ITEM * item; + + /* fill in the TRACKMOUSEEVENT struct */ + trackinfo.cbSize = sizeof(TRACKMOUSEEVENT); + trackinfo.dwFlags = TME_QUERY; + trackinfo.hwndTrack = infoPtr->hwnd; + trackinfo.dwHoverTime = HOVER_DEFAULT; + + /* call _TrackMouseEvent to see if we are currently tracking for this hwnd */ + _TrackMouseEvent(&trackinfo); + + /* Make sure tracking is enabled so we receive a WM_MOUSELEAVE message */ + if(!(trackinfo.dwFlags & TME_LEAVE)) + { + trackinfo.dwFlags = TME_LEAVE; /* notify upon leaving */ + + /* call TRACKMOUSEEVENT so we receive a WM_MOUSELEAVE message */ + /* and can properly deactivate the hot item */ + _TrackMouseEvent(&trackinfo); + } + + pt.x = (INT)LOWORD(lParam); + pt.y = (INT)HIWORD(lParam); + + item = TREEVIEW_HitTestPoint(infoPtr, pt); + + if (item != infoPtr->hotItem) + { + /* redraw old hot item */ + if (infoPtr->hotItem) + InvalidateRect(infoPtr->hwnd, &infoPtr->hotItem->rect, TRUE); + infoPtr->hotItem = item; + /* redraw new hot item */ + if (infoPtr->hotItem) + InvalidateRect(infoPtr->hwnd, &infoPtr->hotItem->rect, TRUE); + } + + return 0; +} + static LRESULT TREEVIEW_Notify(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { @@ -5107,6 +5187,28 @@ TREEVIEW_StyleChanged(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) return 0; } +static LRESULT +TREEVIEW_SetCursor(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) +{ + POINT pt; + TREEVIEW_ITEM * item; + + GetCursorPos(&pt); + ScreenToClient(infoPtr->hwnd, &pt); + + item = TREEVIEW_HitTestPoint(infoPtr, pt); + + /* FIXME: send NM_SETCURSOR */ + + if (item && (infoPtr->dwStyle & TVS_TRACKSELECT)) + { + SetCursor(infoPtr->hcurHand); + return 0; + } + else + return DefWindowProcW(infoPtr->hwnd, WM_SETCURSOR, wParam, lParam); +} + static LRESULT TREEVIEW_SetFocus(TREEVIEW_INFO *infoPtr) { @@ -5329,7 +5431,11 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) /* WM_MBUTTONDOWN */ - /* WM_MOUSEMOVE */ + case WM_MOUSELEAVE: + return TREEVIEW_MouseLeave(infoPtr); + + case WM_MOUSEMOVE: + return TREEVIEW_MouseMove(infoPtr, wParam, lParam); case WM_NOTIFY: return TREEVIEW_Notify(infoPtr, wParam, lParam); @@ -5345,6 +5451,9 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_RBUTTONDOWN: return TREEVIEW_RButtonDown(infoPtr, lParam); + case WM_SETCURSOR: + return TREEVIEW_SetCursor(infoPtr, wParam, lParam); + case WM_SETFOCUS: return TREEVIEW_SetFocus(infoPtr); @@ -5388,7 +5497,6 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) def: return DefWindowProcA(hwnd, uMsg, wParam, lParam); } - return 0; }