diff --git a/reactos/include/wine/commctrl.h b/reactos/include/wine/commctrl.h index b7f8ff630b4..b1d0f1a9680 100644 --- a/reactos/include/wine/commctrl.h +++ b/reactos/include/wine/commctrl.h @@ -61,6 +61,16 @@ typedef LPFINDINFOW LPLVFINDINFOW; #define SB_SETBORDERS (WM_USER+5) #define FLATSB_CLASSA "flatsb_class32" +#if defined(__GNUC__) +# define FLATSB_CLASSW (const WCHAR []){ 'f','l','a','t','s','b','_', \ + 'c','l','a','s','s','3','2',0 } +#elif defined(_MSC_VER) +# define FLATSB_CLASSW L"flatsb_class32" +#else +static const WCHAR FLATSB_CLASSW[] = { 'f','l','a','t','s','b','_', + 'c','l','a','s','s','3','2',0 }; +#endif + #define DRAGLISTMSGSTRINGA "commctrl_DragListMsg" #if defined(__GNUC__) # define DRAGLISTMSGSTRINGW (const WCHAR []){ 'c','o','m','m','c','t','r','l', \ diff --git a/reactos/lib/comctl32/animate.c b/reactos/lib/comctl32/animate.c index ce9b3f3f41a..b1fe5cad053 100644 --- a/reactos/lib/comctl32/animate.c +++ b/reactos/lib/comctl32/animate.c @@ -3,7 +3,8 @@ * Animation control * * Copyright 1998, 1999 Eric Kohl - * 1999 Eric Pouech + * Copyright 1999 Eric Pouech + * Copyright 2005 Dimitrie O. Paun * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -20,12 +21,16 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * NOTES - * I will only improve this control once in a while. - * Eric * + * This code was audited for completeness against the documented features + * of Comctl32.dll version 6.0 on Mar. 15, 2005, 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: * - check for the 'rec ' list in some AVI files - * - concurrent access to infoPtr */ #define COM_NO_WINDOWS_H @@ -59,6 +64,7 @@ typedef struct HMMIO hMMio; /* handle to mmio stream */ HWND hwndSelf; HWND hwndNotify; + DWORD dwStyle; /* information on the loaded AVI file */ MainAVIHeader mah; AVIStreamHeader ash; @@ -86,23 +92,23 @@ typedef struct HBITMAP hbmPrevFrame; } ANIMATE_INFO; -#define ANIMATE_GetInfoPtr(hWnd) ((ANIMATE_INFO *)GetWindowLongPtrW(hWnd, 0)) #define ANIMATE_COLOR_NONE 0xffffffff -static void ANIMATE_Notify(ANIMATE_INFO* infoPtr, UINT notif) +static void ANIMATE_Notify(ANIMATE_INFO *infoPtr, UINT notif) { - SendMessageA(infoPtr->hwndNotify, WM_COMMAND, + SendMessageW(infoPtr->hwndNotify, WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(infoPtr->hwndSelf), notif), (LPARAM)infoPtr->hwndSelf); } -static BOOL ANIMATE_LoadResA(ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPSTR lpName) +static BOOL ANIMATE_LoadResW(ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPWSTR lpName) { + static const WCHAR aviW[] = { 'A', 'V', 'I', 0 }; HRSRC hrsrc; MMIOINFO mminfo; LPVOID lpAvi; - hrsrc = FindResourceA(hInst, lpName, "AVI"); + hrsrc = FindResourceW(hInst, lpName, aviW); if (!hrsrc) return FALSE; @@ -118,8 +124,9 @@ static BOOL ANIMATE_LoadResA(ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPSTR lpNam mminfo.fccIOProc = FOURCC_MEM; mminfo.pchBuffer = (LPSTR)lpAvi; mminfo.cchBuffer = SizeofResource(hInst, hrsrc); - infoPtr->hMMio = mmioOpenA(NULL, &mminfo, MMIO_READ); - if (!infoPtr->hMMio) { + infoPtr->hMMio = mmioOpenW(NULL, &mminfo, MMIO_READ); + if (!infoPtr->hMMio) + { FreeResource(infoPtr->hRes); return FALSE; } @@ -128,19 +135,15 @@ static BOOL ANIMATE_LoadResA(ANIMATE_INFO *infoPtr, HINSTANCE hInst, LPSTR lpNam } -static BOOL ANIMATE_LoadFileA(ANIMATE_INFO *infoPtr, LPSTR lpName) +static BOOL ANIMATE_LoadFileW(ANIMATE_INFO *infoPtr, LPWSTR lpName) { - infoPtr->hMMio = mmioOpenA((LPSTR)lpName, NULL, - MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); + infoPtr->hMMio = mmioOpenW(lpName, 0, MMIO_ALLOCBUF | MMIO_READ | MMIO_DENYWRITE); - if (!infoPtr->hMMio) - return FALSE; - - return TRUE; + return (BOOL)infoPtr->hMMio; } -static LRESULT ANIMATE_DoStop(ANIMATE_INFO *infoPtr) +static BOOL ANIMATE_DoStop(ANIMATE_INFO *infoPtr) { EnterCriticalSection(&infoPtr->cs); @@ -187,28 +190,25 @@ static void ANIMATE_Free(ANIMATE_INFO *infoPtr) FreeResource(infoPtr->hRes); infoPtr->hRes = 0; } - HeapFree(GetProcessHeap(), 0, infoPtr->lpIndex); + Free (infoPtr->lpIndex); infoPtr->lpIndex = NULL; if (infoPtr->hic) { fnIC.fnICClose(infoPtr->hic); infoPtr->hic = 0; } - HeapFree(GetProcessHeap(), 0, infoPtr->inbih); + Free (infoPtr->inbih); infoPtr->inbih = NULL; - HeapFree(GetProcessHeap(), 0, infoPtr->outbih); + Free (infoPtr->outbih); infoPtr->outbih = NULL; - HeapFree(GetProcessHeap(), 0, infoPtr->indata); + Free (infoPtr->indata); infoPtr->indata = NULL; - HeapFree(GetProcessHeap(), 0, infoPtr->outdata); + Free (infoPtr->outdata); infoPtr->outdata = NULL; if( infoPtr->hbmPrevFrame ) { DeleteObject(infoPtr->hbmPrevFrame); infoPtr->hbmPrevFrame = 0; } - infoPtr->indata = infoPtr->outdata = NULL; - infoPtr->hwndSelf = 0; - infoPtr->hMMio = 0; memset(&infoPtr->mah, 0, sizeof(infoPtr->mah)); memset(&infoPtr->ash, 0, sizeof(infoPtr->ash)); @@ -217,7 +217,7 @@ static void ANIMATE_Free(ANIMATE_INFO *infoPtr) infoPtr->transparentColor = ANIMATE_COLOR_NONE; } -static void ANIMATE_TransparentBlt(ANIMATE_INFO* infoPtr, HDC hdcDest, HDC hdcSource) +static void ANIMATE_TransparentBlt(ANIMATE_INFO *infoPtr, HDC hdcDest, HDC hdcSource) { HDC hdcMask; HBITMAP hbmMask; @@ -249,7 +249,7 @@ static void ANIMATE_TransparentBlt(ANIMATE_INFO* infoPtr, HDC hdcDest, HDC hdcSo DeleteDC(hdcMask); } -static LRESULT ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC) +static BOOL ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC) { void* pBitmapData = NULL; LPBITMAPINFO pBitmapInfo = NULL; @@ -273,7 +273,8 @@ static LRESULT ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC) nWidth = infoPtr->outbih->biWidth; nHeight = infoPtr->outbih->biHeight; - } else + } + else { pBitmapData = infoPtr->indata; pBitmapInfo = (LPBITMAPINFO)infoPtr->inbih; @@ -302,7 +303,7 @@ static LRESULT ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC) infoPtr->transparentColor = GetPixel(hdcMem,0,0); } - if(GetWindowLongA(infoPtr->hwndSelf, GWL_STYLE) & ACS_TRANSPARENT) + if(infoPtr->dwStyle & ACS_TRANSPARENT) { HDC hdcFinal = CreateCompatibleDC(hDC); HBITMAP hbmFinal = CreateCompatibleBitmap(hDC,nWidth, nHeight); @@ -325,15 +326,15 @@ static LRESULT ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC) DeleteDC(hdcFinal); DeleteObject(infoPtr->hbmPrevFrame); infoPtr->hbmPrevFrame = hbmFinal; - } + } - if (GetWindowLongA(infoPtr->hwndSelf, GWL_STYLE) & ACS_CENTER) + if (infoPtr->dwStyle & ACS_CENTER) { - RECT rect; + RECT rect; - GetWindowRect(infoPtr->hwndSelf, &rect); - nOffsetX = ((rect.right - rect.left) - nWidth)/2; - nOffsetY = ((rect.bottom - rect.top) - nHeight)/2; + GetWindowRect(infoPtr->hwndSelf, &rect); + nOffsetX = ((rect.right - rect.left) - nWidth)/2; + nOffsetY = ((rect.bottom - rect.top) - nHeight)/2; } BitBlt(hDC, nOffsetX, nOffsetY, nWidth, nHeight, hdcMem, 0, 0, SRCCOPY); @@ -342,21 +343,18 @@ static LRESULT ANIMATE_PaintFrame(ANIMATE_INFO* infoPtr, HDC hDC) return TRUE; } -static LRESULT ANIMATE_DrawFrame(ANIMATE_INFO* infoPtr) +static BOOL ANIMATE_DrawFrame(ANIMATE_INFO *infoPtr) { HDC hDC; TRACE("Drawing frame %d (loop %d)\n", infoPtr->currFrame, infoPtr->nLoop); - EnterCriticalSection(&infoPtr->cs); - mmioSeek(infoPtr->hMMio, infoPtr->lpIndex[infoPtr->currFrame], SEEK_SET); mmioRead(infoPtr->hMMio, infoPtr->indata, infoPtr->ash.dwSuggestedBufferSize); if (infoPtr->hic && fnIC.fnICDecompress(infoPtr->hic, 0, infoPtr->inbih, infoPtr->indata, infoPtr->outbih, infoPtr->outdata) != ICERR_OK) { - LeaveCriticalSection(&infoPtr->cs); WARN("Decompression error\n"); return FALSE; } @@ -374,14 +372,27 @@ static LRESULT ANIMATE_DrawFrame(ANIMATE_INFO* infoPtr) } } } - LeaveCriticalSection(&infoPtr->cs); return TRUE; } +static LRESULT ANIMATE_Timer(ANIMATE_INFO *infoPtr) +{ + /* FIXME: we should pass the hDC instead of 0 to WM_CTLCOLORSTATIC */ + if (infoPtr->dwStyle & ACS_TRANSPARENT) + infoPtr->hbrushBG = (HBRUSH)SendMessageW(infoPtr->hwndNotify, + WM_CTLCOLORSTATIC, + 0, (LPARAM)infoPtr->hwndSelf); + EnterCriticalSection(&infoPtr->cs); + ANIMATE_DrawFrame(infoPtr); + LeaveCriticalSection(&infoPtr->cs); + + return 0; +} + static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_) { - ANIMATE_INFO* infoPtr = (ANIMATE_INFO*)ptr_; + ANIMATE_INFO *infoPtr = (ANIMATE_INFO *)ptr_; HANDLE event; DWORD timeout; @@ -400,10 +411,8 @@ static DWORD CALLBACK ANIMATE_AnimationThread(LPVOID ptr_) return TRUE; } -static LRESULT ANIMATE_Play(HWND hWnd, WPARAM wParam, LPARAM lParam) +static LRESULT ANIMATE_Play(ANIMATE_INFO *infoPtr, UINT cRepeat, WORD wFrom, WORD wTo) { - ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd); - /* nothing opened */ if (!infoPtr->hMMio) return FALSE; @@ -413,9 +422,9 @@ static LRESULT ANIMATE_Play(HWND hWnd, WPARAM wParam, LPARAM lParam) return TRUE; } - infoPtr->nFromFrame = (INT)LOWORD(lParam); - infoPtr->nToFrame = (INT)HIWORD(lParam); - infoPtr->nLoop = (INT)wParam; + infoPtr->nFromFrame = wFrom; + infoPtr->nToFrame = wTo; + infoPtr->nLoop = cRepeat; if (infoPtr->nToFrame == 0xFFFF) infoPtr->nToFrame = infoPtr->mah.dwTotalFrames - 1; @@ -429,25 +438,25 @@ static LRESULT ANIMATE_Play(HWND hWnd, WPARAM wParam, LPARAM lParam) infoPtr->currFrame = infoPtr->nFromFrame; - if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TIMER) { + if (infoPtr->dwStyle & ACS_TIMER) + { TRACE("Using a timer\n"); /* create a timer to display AVI */ - infoPtr->uTimer = SetTimer(hWnd, 1, infoPtr->mah.dwMicroSecPerFrame / 1000, NULL); - } else { - if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) - { - infoPtr->hbrushBG = (HBRUSH)SendMessageA(infoPtr->hwndNotify, - WM_CTLCOLORSTATIC, 0, (LPARAM)hWnd); - } + infoPtr->uTimer = SetTimer(infoPtr->hwndSelf, 1, + infoPtr->mah.dwMicroSecPerFrame / 1000, NULL); + } + else + { + if(infoPtr->dwStyle & ACS_TRANSPARENT) + infoPtr->hbrushBG = (HBRUSH)SendMessageW(infoPtr->hwndNotify, + WM_CTLCOLORSTATIC, 0, + (LPARAM)infoPtr->hwndSelf); TRACE("Using an animation thread\n"); infoPtr->hStopEvent = CreateEventW( NULL, TRUE, FALSE, NULL ); - infoPtr->hThread = CreateThread(0,0,ANIMATE_AnimationThread,(LPVOID)infoPtr, 0, &infoPtr->threadId); - if(!infoPtr->hThread) - { - ERR("Could not create animation thread!\n"); - return FALSE; - } + infoPtr->hThread = CreateThread(0, 0, ANIMATE_AnimationThread, + (LPVOID)infoPtr, 0, &infoPtr->threadId); + if(!infoPtr->hThread) return FALSE; } @@ -548,7 +557,7 @@ static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr) return FALSE; } - infoPtr->inbih = HeapAlloc(GetProcessHeap(), 0, mmckInfo.cksize); + infoPtr->inbih = Alloc(mmckInfo.cksize); if (!infoPtr->inbih) { WARN("Can't alloc input BIH\n"); return FALSE; @@ -595,12 +604,9 @@ static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr) /* FIXME: should handle the 'rec ' LIST when present */ - infoPtr->lpIndex = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, - infoPtr->mah.dwTotalFrames * sizeof(DWORD)); - if (!infoPtr->lpIndex) { - WARN("Can't alloc index array\n"); + infoPtr->lpIndex = Alloc(infoPtr->mah.dwTotalFrames * sizeof(DWORD)); + if (!infoPtr->lpIndex) return FALSE; - } numFrame = insize = 0; while (mmioDescend(infoPtr->hMMio, &mmckInfo, &mmckList, 0) == 0 && @@ -620,17 +626,15 @@ static BOOL ANIMATE_GetAviInfo(ANIMATE_INFO *infoPtr) infoPtr->ash.dwSuggestedBufferSize = insize; } - infoPtr->indata = HeapAlloc(GetProcessHeap(), 0, infoPtr->ash.dwSuggestedBufferSize); - if (!infoPtr->indata) { - WARN("Can't alloc input buffer\n"); + infoPtr->indata = Alloc(infoPtr->ash.dwSuggestedBufferSize); + if (!infoPtr->indata) return FALSE; - } return TRUE; } -static BOOL ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr) +static BOOL ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr) { DWORD outSize; @@ -653,23 +657,20 @@ static BOOL ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr) outSize = fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, (DWORD)infoPtr->inbih, 0L); - infoPtr->outbih = HeapAlloc(GetProcessHeap(), 0, outSize); - if (!infoPtr->outbih) { - WARN("Can't alloc output BIH\n"); + infoPtr->outbih = Alloc(outSize); + if (!infoPtr->outbih) return FALSE; - } if (fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_GET_FORMAT, - (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != outSize) { + (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != outSize) + { WARN("Can't get output BIH\n"); return FALSE; } - infoPtr->outdata = HeapAlloc(GetProcessHeap(), 0, infoPtr->outbih->biSizeImage); - if (!infoPtr->outdata) { - WARN("Can't alloc output buffer\n"); + infoPtr->outdata = Alloc(infoPtr->outbih->biSizeImage); + if (!infoPtr->outdata) return FALSE; - } if (fnIC.fnICSendMessage(infoPtr->hic, ICM_DECOMPRESS_BEGIN, (DWORD)infoPtr->inbih, (DWORD)infoPtr->outbih) != ICERR_OK) { @@ -680,74 +681,93 @@ static BOOL ANIMATE_GetAviCodec(ANIMATE_INFO *infoPtr) return TRUE; } -static LRESULT ANIMATE_OpenA(HWND hWnd, WPARAM wParam, LPARAM lParam) + +static BOOL ANIMATE_OpenW(ANIMATE_INFO *infoPtr, HINSTANCE hInstance, LPWSTR lpszName) { - ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd); - HINSTANCE hInstance = (HINSTANCE)wParam; - ANIMATE_Free(infoPtr); - infoPtr->hwndSelf = hWnd; - if (!lParam) { + if (!lpszName) + { TRACE("Closing avi!\n"); /* installer of thebat! v1.62 requires FALSE here */ return (infoPtr->hMMio != 0); } if (!hInstance) - hInstance = (HINSTANCE)GetWindowLongPtrW(hWnd, GWLP_HINSTANCE); + hInstance = (HINSTANCE)GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_HINSTANCE); - if (HIWORD(lParam)) { - TRACE("(\"%s\");\n", (LPSTR)lParam); + if (HIWORD(lpszName)) + { + TRACE("(\"%s\");\n", debugstr_w(lpszName)); - if (!ANIMATE_LoadResA(infoPtr, hInstance, (LPSTR)lParam)) { + if (!ANIMATE_LoadResW(infoPtr, hInstance, lpszName)) + { TRACE("No AVI resource found!\n"); - if (!ANIMATE_LoadFileA(infoPtr, (LPSTR)lParam)) { + if (!ANIMATE_LoadFileW(infoPtr, lpszName)) + { WARN("No AVI file found!\n"); return FALSE; } } - } else { - TRACE("(%u);\n", (WORD)LOWORD(lParam)); + } + else + { + TRACE("(%u);\n", (WORD)(DWORD)lpszName); - if (!ANIMATE_LoadResA(infoPtr, hInstance, - MAKEINTRESOURCEA((INT)lParam))) { + if (!ANIMATE_LoadResW(infoPtr, hInstance, MAKEINTRESOURCEW((INT)lpszName))) + { WARN("No AVI resource found!\n"); return FALSE; } } - if (!ANIMATE_GetAviInfo(infoPtr)) { + if (!ANIMATE_GetAviInfo(infoPtr)) + { WARN("Can't get AVI information\n"); ANIMATE_Free(infoPtr); return FALSE; } - if (!ANIMATE_GetAviCodec(infoPtr)) { + if (!ANIMATE_GetAviCodec(infoPtr)) + { WARN("Can't get AVI Codec\n"); ANIMATE_Free(infoPtr); return FALSE; } - if (!GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) { - SetWindowPos(hWnd, 0, 0, 0, infoPtr->mah.dwWidth, infoPtr->mah.dwHeight, + if (!(infoPtr->dwStyle & ACS_CENTER)) + SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, infoPtr->mah.dwWidth, infoPtr->mah.dwHeight, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOZORDER); - } - if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_AUTOPLAY) { - return ANIMATE_Play(hWnd, -1, (LPARAM)MAKELONG(0, infoPtr->mah.dwTotalFrames-1)); - } + if (infoPtr->dwStyle & ACS_AUTOPLAY) + return ANIMATE_Play(infoPtr, -1, 0, infoPtr->mah.dwTotalFrames - 1); return TRUE; } -/* << ANIMATE_Open32W >> */ - -static LRESULT ANIMATE_Stop(HWND hWnd, WPARAM wParam, LPARAM lParam) +static BOOL ANIMATE_OpenA(ANIMATE_INFO *infoPtr, HINSTANCE hInstance, LPSTR lpszName) { - ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd); + LPWSTR lpwszName; + LRESULT result; + INT len; + if (!HIWORD(lpszName)) + return ANIMATE_OpenW(infoPtr, hInstance, (LPWSTR)lpszName); + + len = MultiByteToWideChar(CP_ACP, 0, lpszName, -1, NULL, 0); + lpwszName = Alloc(len * sizeof(WCHAR)); + if (!lpwszName) return FALSE; + MultiByteToWideChar(CP_ACP, 0, lpszName, -1, lpwszName, len); + + result = ANIMATE_OpenW(infoPtr, hInstance, lpwszName); + Free (lpwszName); + return result; +} + + +static BOOL ANIMATE_Stop(ANIMATE_INFO *infoPtr) +{ /* nothing opened */ if (!infoPtr->hMMio) return FALSE; @@ -757,18 +777,14 @@ static LRESULT ANIMATE_Stop(HWND hWnd, WPARAM wParam, LPARAM lParam) } -static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam) +static BOOL ANIMATE_Create(HWND hWnd, LPCREATESTRUCTW lpcs) { - ANIMATE_INFO* infoPtr; + static const WCHAR msvfw32W[] = { 'm', 's', 'v', 'f', 'w', '3', '2', '.', 'd', 'l', 'l', 0 }; + ANIMATE_INFO *infoPtr; - if (!fnIC.hModule) /* FIXME: not thread safe */ + if (!fnIC.hModule) { - /* since there's a circular dep between msvfw32 and comctl32, we could either: - * - fix the build chain to allow this circular dep - * - handle it by hand - * AJ wants the latter :-( - */ - fnIC.hModule = LoadLibraryA("msvfw32.dll"); + fnIC.hModule = LoadLibraryW(msvfw32W); if (!fnIC.hModule) return FALSE; fnIC.fnICOpen = (void*)GetProcAddress(fnIC.hModule, "ICOpen"); @@ -779,19 +795,17 @@ static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam) /* allocate memory for info structure */ infoPtr = (ANIMATE_INFO *)Alloc(sizeof(ANIMATE_INFO)); - if (!infoPtr) { - ERR("could not allocate info memory!\n"); - return 0; - } + if (!infoPtr) return FALSE; /* store crossref hWnd <-> info structure */ SetWindowLongPtrW(hWnd, 0, (DWORD_PTR)infoPtr); infoPtr->hwndSelf = hWnd; - infoPtr->hwndNotify = ((LPCREATESTRUCTA)lParam)->hwndParent; + infoPtr->hwndNotify = lpcs->hwndParent; infoPtr->transparentColor = ANIMATE_COLOR_NONE; infoPtr->hbmPrevFrame = 0; + infoPtr->dwStyle = lpcs->style; - TRACE("Animate style=0x%08lx, parent=%p\n", GetWindowLongA(hWnd, GWL_STYLE), infoPtr->hwndNotify); + TRACE("Animate style=0x%08lx, parent=%p\n", infoPtr->dwStyle, infoPtr->hwndNotify); InitializeCriticalSection(&infoPtr->cs); @@ -799,97 +813,98 @@ static LRESULT ANIMATE_Create(HWND hWnd, WPARAM wParam, LPARAM lParam) } -static LRESULT ANIMATE_Destroy(HWND hWnd, WPARAM wParam, LPARAM lParam) +static LRESULT ANIMATE_Destroy(ANIMATE_INFO *infoPtr) { - ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd); - - /* free avi data */ ANIMATE_Free(infoPtr); /* free animate info data */ + SetWindowLongPtrW(infoPtr->hwndSelf, 0, 0); + + DeleteCriticalSection(&infoPtr->cs); Free(infoPtr); - SetWindowLongPtrW(hWnd, 0, 0); return 0; } -static LRESULT ANIMATE_EraseBackground(HWND hWnd, WPARAM wParam, LPARAM lParam) +static BOOL ANIMATE_EraseBackground(ANIMATE_INFO *infoPtr, HDC hdc) { - ANIMATE_INFO *infoPtr = ANIMATE_GetInfoPtr(hWnd); RECT rect; HBRUSH hBrush = 0; - if(GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) + if(infoPtr->dwStyle & ACS_TRANSPARENT) { - hBrush = (HBRUSH)SendMessageA(infoPtr->hwndNotify,WM_CTLCOLORSTATIC, - wParam, (LPARAM)hWnd); + hBrush = (HBRUSH)SendMessageW(infoPtr->hwndNotify, WM_CTLCOLORSTATIC, + (WPARAM)hdc, (LPARAM)infoPtr->hwndSelf); } - GetClientRect(hWnd, &rect); - FillRect((HDC)wParam, &rect, hBrush ? hBrush : GetCurrentObject((HDC)wParam, OBJ_BRUSH)); + GetClientRect(infoPtr->hwndSelf, &rect); + FillRect(hdc, &rect, hBrush ? hBrush : GetCurrentObject(hdc, OBJ_BRUSH)); return TRUE; } -static LRESULT WINAPI ANIMATE_Size(HWND hWnd, WPARAM wParam, LPARAM lParam) + +static LRESULT ANIMATE_StyleChanged(ANIMATE_INFO *infoPtr, WPARAM wStyleType, LPSTYLESTRUCT lpss) { - if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_CENTER) { - InvalidateRect(hWnd, NULL, TRUE); - } - return TRUE; + TRACE("(styletype=%x, styleOld=0x%08lx, styleNew=0x%08lx)\n", + wStyleType, lpss->styleOld, lpss->styleNew); + + if (wStyleType != GWL_STYLE) return 0; + + infoPtr->dwStyle = lpss->styleNew; + + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); + return 0; } + static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { + ANIMATE_INFO *infoPtr = (ANIMATE_INFO *)GetWindowLongPtrW(hWnd, 0); + TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hWnd, uMsg, wParam, lParam); - if (!ANIMATE_GetInfoPtr(hWnd) && (uMsg != WM_NCCREATE)) - return DefWindowProcA(hWnd, uMsg, wParam, lParam); + if (!infoPtr && (uMsg != WM_NCCREATE)) + return DefWindowProcW(hWnd, uMsg, wParam, lParam); switch (uMsg) { case ACM_OPENA: - return ANIMATE_OpenA(hWnd, wParam, lParam); + return ANIMATE_OpenA(infoPtr, (HINSTANCE)wParam, (LPSTR)lParam); case ACM_OPENW: - FIXME("ACM_OPENW: stub!\n"); - /* return ANIMATE_Open32W(hWnd, wParam, lParam); */ - return 0; + return ANIMATE_OpenW(infoPtr, (HINSTANCE)wParam, (LPWSTR)lParam); case ACM_PLAY: - return ANIMATE_Play(hWnd, wParam, lParam); + return ANIMATE_Play(infoPtr, (INT)wParam, LOWORD(lParam), HIWORD(lParam)); case ACM_STOP: - return ANIMATE_Stop(hWnd, wParam, lParam); + return ANIMATE_Stop(infoPtr); + + case WM_CLOSE: + ANIMATE_Free(infoPtr); + return 0; case WM_NCCREATE: - return ANIMATE_Create(hWnd, wParam, lParam); + return ANIMATE_Create(hWnd, (LPCREATESTRUCTW)lParam); case WM_NCHITTEST: return HTTRANSPARENT; case WM_DESTROY: - return ANIMATE_Destroy(hWnd, wParam, lParam); + return ANIMATE_Destroy(infoPtr); case WM_ERASEBKGND: - return ANIMATE_EraseBackground(hWnd, wParam, lParam); + return ANIMATE_EraseBackground(infoPtr, (HDC)wParam); - /* case WM_STYLECHANGED: FIXME shall we do something ?? */ + case WM_STYLECHANGED: + return ANIMATE_StyleChanged(infoPtr, wParam, (LPSTYLESTRUCT)lParam); case WM_TIMER: - if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) - { - ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd); - infoPtr->hbrushBG = (HBRUSH)SendMessageA(infoPtr->hwndNotify, - WM_CTLCOLORSTATIC, - wParam, (LPARAM)hWnd); - } - return ANIMATE_DrawFrame(ANIMATE_GetInfoPtr(hWnd)); + return ANIMATE_Timer(infoPtr); case WM_PAINT: { - ANIMATE_INFO* infoPtr = ANIMATE_GetInfoPtr(hWnd); - /* the animation isn't playing, or has not decompressed * (and displayed) the first frame yet, don't paint */ @@ -897,13 +912,13 @@ static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP !infoPtr->hbmPrevFrame) { /* default paint handling */ - return DefWindowProcA(hWnd, uMsg, wParam, lParam); + return DefWindowProcW(hWnd, uMsg, wParam, lParam); } - if (GetWindowLongA(hWnd, GWL_STYLE) & ACS_TRANSPARENT) - infoPtr->hbrushBG = (HBRUSH)SendMessageA(infoPtr->hwndNotify, - WM_CTLCOLORSTATIC, - wParam, (LPARAM)hWnd); + if (infoPtr->dwStyle & ACS_TRANSPARENT) + infoPtr->hbrushBG = (HBRUSH)SendMessageW(infoPtr->hwndNotify, + WM_CTLCOLORSTATIC, + wParam, (LPARAM)infoPtr->hwndSelf); if (wParam) { @@ -913,48 +928,50 @@ static LRESULT WINAPI ANIMATE_WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LP } else { - PAINTSTRUCT ps; - HDC hDC = BeginPaint(hWnd, &ps); + PAINTSTRUCT ps; + HDC hDC = BeginPaint(infoPtr->hwndSelf, &ps); EnterCriticalSection(&infoPtr->cs); ANIMATE_PaintFrame(infoPtr, hDC); LeaveCriticalSection(&infoPtr->cs); - EndPaint(hWnd, &ps); - } + EndPaint(infoPtr->hwndSelf, &ps); + } } - break; + break; case WM_SIZE: - return ANIMATE_Size(hWnd, wParam, lParam); + if (infoPtr->dwStyle & ACS_CENTER) + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); + return DefWindowProcW(hWnd, uMsg, wParam, 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 ANIMATE_Register(void) { - WNDCLASSA wndClass; + WNDCLASSW wndClass; - ZeroMemory(&wndClass, sizeof(WNDCLASSA)); + ZeroMemory(&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; wndClass.lpfnWndProc = ANIMATE_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(ANIMATE_INFO *); - wndClass.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); + wndClass.hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW); wndClass.hbrBackground = (HBRUSH)(COLOR_BTNFACE + 1); - wndClass.lpszClassName = ANIMATE_CLASSA; + wndClass.lpszClassName = ANIMATE_CLASSW; - RegisterClassA(&wndClass); + RegisterClassW(&wndClass); } void ANIMATE_Unregister(void) { - UnregisterClassA(ANIMATE_CLASSA, NULL); + UnregisterClassW(ANIMATE_CLASSW, NULL); } diff --git a/reactos/lib/comctl32/comboex.c b/reactos/lib/comctl32/comboex.c index 8cff35a286a..5037365db13 100644 --- a/reactos/lib/comctl32/comboex.c +++ b/reactos/lib/comctl32/comboex.c @@ -121,7 +121,11 @@ typedef struct /* Offset between image and text */ #define CBE_SEP 4 -#define COMBOEX_SUBCLASS_PROP "CCComboEx32SubclassInfo" +static const WCHAR COMBOEX_SUBCLASS_PROP[] = { + 'C','C','C','o','m','b','o','E','x','3','2', + 'S','u','b','c','l','a','s','s','I','n','f','o',0 +}; + #define COMBOEX_GetInfoPtr(hwnd) ((COMBOEX_INFO *)GetWindowLongPtrW (hwnd, 0)) @@ -317,13 +321,14 @@ static LPCWSTR COMBOEX_GetText(COMBOEX_INFO *infoPtr, CBE_ITEMDATA *item) static void COMBOEX_GetComboFontSize (COMBOEX_INFO *infoPtr, SIZE *size) { + static const WCHAR strA[] = { 'A', 0 }; HFONT nfont, ofont; HDC mydc; mydc = GetDC (0); /* why the entire screen???? */ nfont = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); ofont = (HFONT) SelectObject (mydc, nfont); - GetTextExtentPointA (mydc, "A", 1, size); + GetTextExtentPointW (mydc, strA, 1, size); SelectObject (mydc, ofont); ReleaseDC (0, mydc); TRACE("selected font hwnd=%p, height=%ld\n", nfont, size->cy); @@ -949,7 +954,7 @@ static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs) /* Native version of ComboEx creates the ComboBox with DROPDOWNLIST */ /* specified. It then creates it's own version of the EDIT control */ /* and makes the ComboBox the parent. This is because a normal */ - /* DROPDOWNLIST does not have a EDIT control, but we need one. */ + /* DROPDOWNLIST does not have an EDIT control, but we need one. */ /* We also need to place the edit control at the proper location */ /* (allow space for the icons). */ @@ -976,7 +981,7 @@ static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs) * Setup a property to hold the pointer to the COMBOBOXEX * data structure. */ - SetPropA(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd); + SetPropW(infoPtr->hwndCombo, COMBOEX_SUBCLASS_PROP, hwnd); infoPtr->prevComboWndProc = (WNDPROC)SetWindowLongPtrW(infoPtr->hwndCombo, GWLP_WNDPROC, (DWORD_PTR)COMBOEX_ComboWndProc); infoPtr->font = (HFONT)SendMessageW (infoPtr->hwndCombo, WM_GETFONT, 0, 0); @@ -1005,7 +1010,7 @@ static LRESULT COMBOEX_Create (HWND hwnd, LPCREATESTRUCTA cs) * Setup a property to hold the pointer to the COMBOBOXEX * data structure. */ - SetPropA(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd); + SetPropW(infoPtr->hwndEdit, COMBOEX_SUBCLASS_PROP, hwnd); infoPtr->prevEditWndProc = (WNDPROC)SetWindowLongPtrW(infoPtr->hwndEdit, GWLP_WNDPROC, (DWORD_PTR)COMBOEX_EditWndProc); infoPtr->font = (HFONT)SendMessageW(infoPtr->hwndCombo, WM_GETFONT, 0, 0); @@ -1547,11 +1552,12 @@ static LRESULT COMBOEX_Destroy (COMBOEX_INFO *infoPtr) static LRESULT COMBOEX_MeasureItem (COMBOEX_INFO *infoPtr, MEASUREITEMSTRUCT *mis) { + static const WCHAR strW[] = { 'W', 0 }; SIZE mysize; HDC hdc; hdc = GetDC (0); - GetTextExtentPointA (hdc, "W", 1, &mysize); + GetTextExtentPointW (hdc, strW, 1, &mysize); ReleaseDC (0, hdc); mis->itemHeight = mysize.cy + CBE_EXTRA; @@ -1647,7 +1653,7 @@ static LRESULT COMBOEX_WindowPosChanging (COMBOEX_INFO *infoPtr, WINDOWPOS *wp) static LRESULT WINAPI COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP); + HWND hwndComboex = (HWND)GetPropW(hwnd, COMBOEX_SUBCLASS_PROP); COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex); NMCBEENDEDITW cbeend; WCHAR edit_text[260]; @@ -1694,7 +1700,7 @@ COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case VK_ESCAPE: /* native version seems to do following for COMBOEX */ /* - * GetWindowTextA(Edit,&?, 0x104) x + * GetWindowTextW(Edit,&?, 0x104) x * CB_GETCURSEL to Combo rets -1 x * WM_NOTIFY to COMBOEX parent (rebar) x * (CBEN_ENDEDIT{A|W} @@ -1735,7 +1741,7 @@ COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case VK_RETURN: /* native version seems to do following for COMBOEX */ /* - * GetWindowTextA(Edit,&?, 0x104) x + * GetWindowTextW(Edit,&?, 0x104) x * CB_GETCURSEL to Combo rets -1 x * CB_GETCOUNT to Combo rets 0 * if >0 loop @@ -1846,7 +1852,7 @@ COMBOEX_EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) static LRESULT WINAPI COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - HWND hwndComboex = (HWND)GetPropA(hwnd, COMBOEX_SUBCLASS_PROP); + HWND hwndComboex = (HWND)GetPropW(hwnd, COMBOEX_SUBCLASS_PROP); COMBOEX_INFO *infoPtr = COMBOEX_GetInfoPtr (hwndComboex); NMCBEENDEDITW cbeend; NMMOUSE nmmse; @@ -1955,7 +1961,7 @@ COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) * Native does: * * GetFocus() retns AA - * GetWindowTextA(Edit) + * GetWindowTextW(Edit) * CB_GETCURSEL(Combo) (got -1) * WM_NOTIFY(CBEN_ENDEDITA) with CBENF_KILLFOCUS * CB_GETCURSEL(Combo) (got -1) @@ -2019,7 +2025,7 @@ COMBOEX_ComboWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) INT selected = SendMessageW (infoPtr->hwndCombo, CB_GETCURSEL, 0, 0); - /* lstrlenA( lastworkingURL ) */ + /* lstrlenW( lastworkingURL ) */ GetWindowTextW (infoPtr->hwndEdit, edit_text, 260); if (selected == -1) { diff --git a/reactos/lib/comctl32/comctl32undoc.c b/reactos/lib/comctl32/comctl32undoc.c index 3eae1aebf57..e86c0a4885c 100644 --- a/reactos/lib/comctl32/comctl32undoc.c +++ b/reactos/lib/comctl32/comctl32undoc.c @@ -88,6 +88,8 @@ typedef struct _LOADDATA typedef HRESULT (CALLBACK *DPALOADPROC)(LPLOADDATA,IStream*,LPARAM); +static const WCHAR strMRUList[] = { 'M','R','U','L','i','s','t',0 }; + /************************************************************************** * DPA_LoadStream [COMCTL32.9] * @@ -558,7 +560,7 @@ typedef struct tagWINEMRULIST BOOL isUnicode; /* is compare fn Unicode */ DWORD wineFlags; /* internal flags */ DWORD cursize; /* current size of realMRU */ - LPSTR realMRU; /* pointer to string of index names */ + LPWSTR realMRU; /* pointer to string of index names */ LPWINEMRUITEM *array; /* array of pointers to data */ /* in 'a' to 'z' order */ } WINEMRULIST, *LPWINEMRULIST; @@ -603,12 +605,12 @@ static void MRU_SaveChanged ( LPWINEMRULIST mp ) } if (mp->wineFlags & WMRUF_CHANGED) { mp->wineFlags &= ~WMRUF_CHANGED; - err = RegSetValueExA(newkey, "MRUList", 0, REG_SZ, - mp->realMRU, strlen(mp->realMRU) + 1); + err = RegSetValueExW(newkey, strMRUList, 0, REG_SZ, (LPBYTE)mp->realMRU, + (strlenW(mp->realMRU) + 1)*sizeof(WCHAR)); if (err) { ERR("error saving MRUList, err=%d\n", err); } - TRACE("saving MRUList=/%s/\n", mp->realMRU); + TRACE("saving MRUList=/%s/\n", debugstr_w(mp->realMRU)); } realname[1] = 0; for(i=0; icursize; i++) { @@ -768,7 +770,7 @@ INT WINAPI AddMRUData (HANDLE hList, LPCVOID lpData, DWORD cbData) if ((replace = FindMRUData (hList, lpData, cbData, NULL)) >= 0) { /* Item exists, just move it to the front */ - LPSTR pos = strchr(mp->realMRU, replace + 'a'); + LPWSTR pos = strchrW(mp->realMRU, replace + 'a'); while (pos > mp->realMRU) { pos[0] = pos[-1]; @@ -961,7 +963,7 @@ static HANDLE CreateMRUListLazy_common(LPWINEMRULIST mp) /* get space to save indices that will turn into names * but in order of most to least recently used */ - mp->realMRU = Alloc(mp->extview.nMaxItems + 2); + mp->realMRU = Alloc((mp->extview.nMaxItems + 2) * sizeof(WCHAR)); /* get space to save pointers to actual data in order of * 'a' to 'z' (0 to n). @@ -988,14 +990,14 @@ static HANDLE CreateMRUListLazy_common(LPWINEMRULIST mp) /* get values from key 'MRUList' */ if (newkey) { datasize = mp->extview.nMaxItems + 1; - if((err=RegQueryValueExA( newkey, "MRUList", 0, &type, mp->realMRU, - &datasize))) { + if((err=RegQueryValueExW( newkey, strMRUList, 0, &type, + (LPBYTE)mp->realMRU, &datasize))) { /* not present - set size to 1 (will become 0 later) */ datasize = 1; *mp->realMRU = 0; } - TRACE("MRU list = %s, datasize = %ld\n", mp->realMRU, datasize); + TRACE("MRU list = %s, datasize = %ld\n", debugstr_w(mp->realMRU), datasize); mp->cursize = datasize - 1; /* datasize now has number of items in the MRUList */ @@ -1824,7 +1826,7 @@ HDPA WINAPI DPA_Clone (const HDPA hdpa, const HDPA hdpaNew) if (!hdpaNew) { /* create a new DPA */ - hdpaTemp = (HDPA)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, + hdpaTemp = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, sizeof(*hdpaTemp)); hdpaTemp->hHeap = hdpa->hHeap; hdpaTemp->nGrow = hdpa->nGrow; @@ -1844,8 +1846,7 @@ HDPA WINAPI DPA_Clone (const HDPA hdpa, const HDPA hdpaNew) nNewItems = hdpaTemp->nGrow * ((INT)((hdpa->nItemCount - 1) / hdpaTemp->nGrow) + 1); nSize = nNewItems * sizeof(LPVOID); - hdpaTemp->ptrs = - (LPVOID*)HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize); + hdpaTemp->ptrs = HeapAlloc (hdpaTemp->hHeap, HEAP_ZERO_MEMORY, nSize); hdpaTemp->nMaxCount = nNewItems; /* clone the pointer array */ @@ -1985,9 +1986,9 @@ BOOL WINAPI DPA_SetPtr (const HDPA hdpa, INT i, LPVOID p) INT nSize = nNewItems * sizeof(LPVOID); if (hdpa->ptrs) - lpTemp = (LPVOID*)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, hdpa->ptrs, nSize); + lpTemp = HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, hdpa->ptrs, nSize); else - lpTemp = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, nSize); + lpTemp = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, nSize); if (!lpTemp) return FALSE; @@ -2046,7 +2047,7 @@ LPVOID WINAPI DPA_DeletePtr (const HDPA hdpa, INT i) if ((hdpa->nMaxCount - hdpa->nItemCount) >= hdpa->nGrow) { INT nNewItems = max(hdpa->nGrow * 2, hdpa->nItemCount); nSize = nNewItems * sizeof(LPVOID); - lpDest = (LPVOID)HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, + lpDest = HeapReAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, hdpa->ptrs, nSize); if (!lpDest) return NULL; @@ -2083,7 +2084,7 @@ BOOL WINAPI DPA_DeleteAllPtrs (const HDPA hdpa) hdpa->nItemCount = 0; hdpa->nMaxCount = hdpa->nGrow * 2; - hdpa->ptrs = (LPVOID*)HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, + hdpa->ptrs = HeapAlloc (hdpa->hHeap, HEAP_ZERO_MEMORY, hdpa->nMaxCount * sizeof(LPVOID)); return TRUE; @@ -2280,7 +2281,7 @@ HDPA WINAPI DPA_CreateEx (INT nGrow, HANDLE hHeap) TRACE("(%d %p)\n", nGrow, hHeap); if (hHeap) - hdpa = (HDPA)HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(*hdpa)); + hdpa = HeapAlloc (hHeap, HEAP_ZERO_MEMORY, sizeof(*hdpa)); else hdpa = Alloc (sizeof(*hdpa)); @@ -2367,7 +2368,7 @@ static LRESULT DoNotify (LPNOTIFYDATA lpNotify, UINT uCode, LPNMHDR lpHdr) lpNmh->code = uCode; } - return SendMessageA (lpNotify->hwndTo, WM_NOTIFY, idFrom, (LPARAM)lpNmh); + return SendMessageW (lpNotify->hwndTo, WM_NOTIFY, idFrom, (LPARAM)lpNmh); } diff --git a/reactos/lib/comctl32/comctl_Sv.rc b/reactos/lib/comctl32/comctl_Sv.rc index cea2d6b12d3..273ee861da0 100644 --- a/reactos/lib/comctl32/comctl_Sv.rc +++ b/reactos/lib/comctl32/comctl_Sv.rc @@ -1,87 +1,87 @@ -/* - * Copyright 2005 Andreas Bjerkeholt - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -LANGUAGE LANG_SWEDISH, SUBLANG_SWEDISH - -IDD_PROPSHEET DIALOG DISCARDABLE 0, 0, 220, 140 -STYLE DS_CONTEXTHELP | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE -CAPTION "Egenskaper för " -FONT 8, "MS Shell Dlg" -BEGIN - DEFPUSHBUTTON "OK", IDOK,4,122,50,14, WS_TABSTOP | WS_GROUP - PUSHBUTTON "Avbryt", IDCANCEL,58,122,50,14 - PUSHBUTTON "&Verkställ", IDC_APPLY_BUTTON,112,122,50,14,WS_DISABLED - PUSHBUTTON "Hjälp", IDHELP,166,122,50,14,WS_TABSTOP|WS_GROUP - CONTROL "Tab", IDC_TABCONTROL,"SysTabControl32",WS_CLIPSIBLINGS|WS_GROUP|WS_TABSTOP|TCS_MULTILINE,4,4,212,114 -END - - -IDD_WIZARD DIALOG DISCARDABLE 0, 0, 290, 159 -STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE -CAPTION "Guide" -FONT 8, "MS Shell Dlg" -BEGIN - DEFPUSHBUTTON "Slutför", IDC_FINISH_BUTTON,121,138,50,14 - DEFPUSHBUTTON "&Nästa >", IDC_NEXT_BUTTON,121,138,50,14 - PUSHBUTTON "< &Föregående", IDC_BACK_BUTTON,71,138,50,14 - PUSHBUTTON "Avbryt", IDCANCEL,178,138,50,14 - PUSHBUTTON "Hjälp", IDHELP,235,138,50,14,WS_GROUP - LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN - CONTROL "Tab", IDC_TABCONTROL,"SysTabControl32",WS_CLIPSIBLINGS | WS_DISABLED,7,7,258,5 - LTEXT "", IDC_SUNKEN_LINEHEADER,0,35,290,1,SS_LEFT | SS_SUNKEN | WS_CHILD | WS_VISIBLE -END - - -IDD_TBCUSTOMIZE DIALOG DISCARDABLE 10, 20, 357, 125 -STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU -CAPTION "Anpassa verktygsfältet" -FONT 8, "MS Shell Dlg" -BEGIN - DEFPUSHBUTTON "&Stäng", IDCANCEL,308,6,44,14 - PUSHBUTTON "&Återställ", IDC_RESET_BTN,308,23,44,14 - PUSHBUTTON "&Hjälp", IDC_HELP_BTN,308,40,44,14 - PUSHBUTTON "Flytta &upp", IDC_MOVEUP_BTN,308,74,44,14 - PUSHBUTTON "Flytta &ned", IDC_MOVEDN_BTN,308,91,44,14 - LTEXT "T&illgängliga knappar:", -1,4,5,84,10 - LISTBOX IDC_AVAILBTN_LBOX,4,17,120,100, LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP - PUSHBUTTON "&Lägg till ->", IDOK, 131, 42, 44, 14 - PUSHBUTTON "<- &Ta bort", IDC_REMOVE_BTN,131,62,44,14 - LTEXT "Knappar i v&erktygsfältet:", -1,182,5,85,10 - LISTBOX IDC_TOOLBARBTN_LBOX, 182,17,120,100,LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP -END - -STRINGTABLE DISCARDABLE -{ - IDS_CLOSE "Stäng" -} - -STRINGTABLE DISCARDABLE -{ - IDM_TODAY "Idag:" - IDM_GOTODAY "Gå till idag" -} - -STRINGTABLE DISCARDABLE -{ - IDS_SEPARATOR "Separator" -} - -STRINGTABLE DISCARDABLE -{ - HKY_NONE "Ingen" -} +/* + * Copyright 2005 Andreas Bjerkeholt + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT + +IDD_PROPSHEET DIALOG DISCARDABLE 0, 0, 220, 140 +STYLE DS_CONTEXTHELP | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE +CAPTION "Egenskaper för " +FONT 8, "MS Shell Dlg" +BEGIN + DEFPUSHBUTTON "OK", IDOK,4,122,50,14, WS_TABSTOP | WS_GROUP + PUSHBUTTON "Avbryt", IDCANCEL,58,122,50,14 + PUSHBUTTON "&Verkställ", IDC_APPLY_BUTTON,112,122,50,14,WS_DISABLED + PUSHBUTTON "Hjälp", IDHELP,166,122,50,14,WS_TABSTOP|WS_GROUP + CONTROL "Tab", IDC_TABCONTROL,"SysTabControl32",WS_CLIPSIBLINGS|WS_GROUP|WS_TABSTOP|TCS_MULTILINE,4,4,212,114 +END + + +IDD_WIZARD DIALOG DISCARDABLE 0, 0, 290, 159 +STYLE DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU | WS_VISIBLE +CAPTION "Guide" +FONT 8, "MS Shell Dlg" +BEGIN + DEFPUSHBUTTON "Slutför", IDC_FINISH_BUTTON,121,138,50,14 + DEFPUSHBUTTON "&Nästa >", IDC_NEXT_BUTTON,121,138,50,14 + PUSHBUTTON "< &Föregående", IDC_BACK_BUTTON,71,138,50,14 + PUSHBUTTON "Avbryt", IDCANCEL,178,138,50,14 + PUSHBUTTON "Hjälp", IDHELP,235,138,50,14,WS_GROUP + LTEXT "", IDC_SUNKEN_LINE,7,129,278,1,SS_SUNKEN + CONTROL "Tab", IDC_TABCONTROL,"SysTabControl32",WS_CLIPSIBLINGS | WS_DISABLED,7,7,258,5 + LTEXT "", IDC_SUNKEN_LINEHEADER,0,35,290,1,SS_LEFT | SS_SUNKEN | WS_CHILD | WS_VISIBLE +END + + +IDD_TBCUSTOMIZE DIALOG DISCARDABLE 10, 20, 357, 125 +STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU +CAPTION "Anpassa verktygsfältet" +FONT 8, "MS Shell Dlg" +BEGIN + DEFPUSHBUTTON "&Stäng", IDCANCEL,308,6,44,14 + PUSHBUTTON "&Återställ", IDC_RESET_BTN,308,23,44,14 + PUSHBUTTON "&Hjälp", IDC_HELP_BTN,308,40,44,14 + PUSHBUTTON "Flytta &upp", IDC_MOVEUP_BTN,308,74,44,14 + PUSHBUTTON "Flytta &ned", IDC_MOVEDN_BTN,308,91,44,14 + LTEXT "T&illgängliga knappar:", -1,4,5,84,10 + LISTBOX IDC_AVAILBTN_LBOX,4,17,120,100, LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP + PUSHBUTTON "&Lägg till ->", IDOK, 131, 42, 44, 14 + PUSHBUTTON "<- &Ta bort", IDC_REMOVE_BTN,131,62,44,14 + LTEXT "Knappar i v&erktygsfältet:", -1,182,5,85,10 + LISTBOX IDC_TOOLBARBTN_LBOX, 182,17,120,100,LBS_NOTIFY | LBS_OWNERDRAWFIXED | LBS_HASSTRINGS | LBS_NOINTEGRALHEIGHT | LBS_DISABLENOSCROLL | WS_BORDER | WS_VSCROLL | WS_HSCROLL | WS_TABSTOP +END + +STRINGTABLE DISCARDABLE +{ + IDS_CLOSE "Stäng" +} + +STRINGTABLE DISCARDABLE +{ + IDM_TODAY "Idag:" + IDM_GOTODAY "Gå till idag" +} + +STRINGTABLE DISCARDABLE +{ + IDS_SEPARATOR "Separator" +} + +STRINGTABLE DISCARDABLE +{ + HKY_NONE "Ingen" +} diff --git a/reactos/lib/comctl32/commctrl.c b/reactos/lib/comctl32/commctrl.c index 0fbbc940710..c10adeddd3c 100644 --- a/reactos/lib/comctl32/commctrl.c +++ b/reactos/lib/comctl32/commctrl.c @@ -118,7 +118,7 @@ extern void UPDOWN_Unregister(void); LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam); -LPSTR COMCTL32_aSubclass = NULL; +LPWSTR COMCTL32_wSubclass = NULL; HMODULE COMCTL32_hModule = 0; LANGID COMCTL32_uiLang = MAKELANGID(LANG_NEUTRAL, SUBLANG_NEUTRAL); HBRUSH COMCTL32_hPattern55AABrush = NULL; @@ -132,6 +132,9 @@ static const WORD wPattern55AA[] = 0x5555, 0xaaaa, 0x5555, 0xaaaa }; +static const WCHAR strCC32SubclassInfo[] = { + 'C','C','3','2','S','u','b','c','l','a','s','s','I','n','f','o',0 +}; /*********************************************************************** * DllMain [Internal] @@ -159,8 +162,8 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) COMCTL32_hModule = (HMODULE)hinstDLL; /* add global subclassing atom (used by 'tooltip' and 'updown') */ - COMCTL32_aSubclass = (LPSTR)(DWORD)GlobalAddAtomA ("CC32SubclassInfo"); - TRACE("Subclassing atom added: %p\n", COMCTL32_aSubclass); + COMCTL32_wSubclass = (LPWSTR)(DWORD)GlobalAddAtomW (strCC32SubclassInfo); + TRACE("Subclassing atom added: %p\n", COMCTL32_wSubclass); /* create local pattern brush */ COMCTL32_hPattern55AABitmap = CreateBitmap (8, 8, 1, 1, wPattern55AA); @@ -217,9 +220,9 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) COMCTL32_hPattern55AABitmap = NULL; /* delete global subclassing atom */ - GlobalDeleteAtom (LOWORD(COMCTL32_aSubclass)); - TRACE("Subclassing atom deleted: %p\n", COMCTL32_aSubclass); - COMCTL32_aSubclass = NULL; + GlobalDeleteAtom (LOWORD(COMCTL32_wSubclass)); + TRACE("Subclassing atom deleted: %p\n", COMCTL32_wSubclass); + COMCTL32_wSubclass = NULL; break; } @@ -274,7 +277,7 @@ MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu, if ((HIWORD(wParam) == 0xFFFF) && (lParam == 0)) { /* menu was closed */ TRACE("menu was closed!\n"); - SendMessageA (hwndStatus, SB_SIMPLE, FALSE, 0); + SendMessageW (hwndStatus, SB_SIMPLE, FALSE, 0); } else { /* menu item was selected */ @@ -285,14 +288,14 @@ MenuHelp (UINT uMsg, WPARAM wParam, LPARAM lParam, HMENU hMainMenu, TRACE("uMenuID = %u\n", uMenuID); if (uMenuID) { - CHAR szText[256]; + WCHAR szText[256]; - if (!LoadStringA (hInst, uMenuID, szText, 256)) + if (!LoadStringW (hInst, uMenuID, szText, sizeof(szText)/sizeof(szText[0]))) szText[0] = '\0'; - SendMessageA (hwndStatus, SB_SETTEXTA, + SendMessageW (hwndStatus, SB_SETTEXTW, 255 | SBT_NOBORDERS, (LPARAM)szText); - SendMessageA (hwndStatus, SB_SIMPLE, TRUE, 0); + SendMessageW (hwndStatus, SB_SIMPLE, TRUE, 0); } } break; @@ -425,7 +428,7 @@ GetEffectiveClientRect (HWND hwnd, LPRECT lpRect, LPINT lpInfo) return; lpRun++; hwndCtrl = GetDlgItem (hwnd, *lpRun); - if (GetWindowLongA (hwndCtrl, GWL_STYLE) & WS_VISIBLE) { + if (GetWindowLongW (hwndCtrl, GWL_STYLE) & WS_VISIBLE) { TRACE("control id 0x%x\n", *lpRun); GetWindowRect (hwndCtrl, &rcCtrl); MapWindowPoints (NULL, hwnd, (LPPOINT)&rcCtrl, 2); @@ -511,12 +514,12 @@ void WINAPI DrawStatusTextA (HDC hdc, LPRECT lprc, LPCSTR text, UINT style) if ( text ) { if ( (len = MultiByteToWideChar( CP_ACP, 0, text, -1, NULL, 0 )) ) { - if ( (textW = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) )) ) + if ( (textW = Alloc( len * sizeof(WCHAR) )) ) MultiByteToWideChar( CP_ACP, 0, text, -1, textW, len ); } } DrawStatusTextW( hdc, lprc, textW, style ); - HeapFree( GetProcessHeap(), 0, textW ); + Free( textW ); } @@ -603,12 +606,12 @@ CreateUpDownControl (DWORD style, INT x, INT y, INT cx, INT cy, HWND buddy, INT maxVal, INT minVal, INT curVal) { HWND hUD = - CreateWindowA (UPDOWN_CLASSA, 0, style, x, y, cx, cy, + CreateWindowW (UPDOWN_CLASSW, 0, style, x, y, cx, cy, parent, (HMENU)id, inst, 0); if (hUD) { - SendMessageA (hUD, UDM_SETBUDDY, (WPARAM)buddy, 0); - SendMessageA (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal)); - SendMessageA (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0)); + SendMessageW (hUD, UDM_SETBUDDY, (WPARAM)buddy, 0); + SendMessageW (hUD, UDM_SETRANGE, 0, MAKELONG(maxVal, minVal)); + SendMessageW (hUD, UDM_SETPOS, 0, MAKELONG(curVal, 0)); } return hUD; @@ -764,13 +767,12 @@ CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps, HWND hwndTB; hwndTB = - CreateWindowExA(0, TOOLBARCLASSNAMEA, NULL, style|WS_CHILD, 0,0,100,30, + CreateWindowExW(0, TOOLBARCLASSNAMEW, NULL, style|WS_CHILD, 0,0,100,30, hwnd, (HMENU)wID, COMCTL32_hModule, NULL); if(hwndTB) { TBADDBITMAP tbab; - SendMessageA (hwndTB, TB_BUTTONSTRUCTSIZE, - (WPARAM)uStructSize, 0); + SendMessageW (hwndTB, TB_BUTTONSTRUCTSIZE, (WPARAM)uStructSize, 0); /* set bitmap and button size */ /*If CreateToolbarEx receives 0, windows sets default values*/ @@ -778,29 +780,28 @@ CreateToolbarEx (HWND hwnd, DWORD style, UINT wID, INT nBitmaps, dxBitmap = 16; if (dyBitmap <= 0) dyBitmap = 15; - SendMessageA (hwndTB, TB_SETBITMAPSIZE, 0, - MAKELPARAM((WORD)dxBitmap, (WORD)dyBitmap)); + SendMessageW (hwndTB, TB_SETBITMAPSIZE, 0, + MAKELPARAM((WORD)dxBitmap, (WORD)dyBitmap)); if (dxButton <= 0) dxButton = 24; if (dyButton <= 0) dyButton = 22; - SendMessageA (hwndTB, TB_SETBUTTONSIZE, 0, - MAKELPARAM((WORD)dxButton, (WORD)dyButton)); + SendMessageW (hwndTB, TB_SETBUTTONSIZE, 0, + MAKELPARAM((WORD)dxButton, (WORD)dyButton)); /* add bitmaps */ if (nBitmaps > 0) { - tbab.hInst = hBMInst; - tbab.nID = wBMID; + tbab.hInst = hBMInst; + tbab.nID = wBMID; - SendMessageA (hwndTB, TB_ADDBITMAP, - (WPARAM)nBitmaps, (LPARAM)&tbab); + SendMessageW (hwndTB, TB_ADDBITMAP, (WPARAM)nBitmaps, (LPARAM)&tbab); } /* add buttons */ if(iNumButtons > 0) - SendMessageA (hwndTB, TB_ADDBUTTONSA, + SendMessageW (hwndTB, TB_ADDBUTTONSW, (WPARAM)iNumButtons, (LPARAM)lpButtons); } @@ -856,7 +857,7 @@ CreateMappedBitmap (HINSTANCE hInstance, INT idBitmap, UINT wFlags, sysColorMap = (LPCOLORMAP)internalColorMap; } - hRsrc = FindResourceA (hInstance, (LPSTR)idBitmap, (LPSTR)RT_BITMAP); + hRsrc = FindResourceW (hInstance, (LPWSTR)idBitmap, (LPWSTR)RT_BITMAP); if (hRsrc == 0) return 0; hglb = LoadResource (hInstance, hRsrc); @@ -1103,16 +1104,15 @@ BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass, * from there. */ /* See if we have been called for this window */ - stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass); + stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass); if (!stack) { /* allocate stack */ - stack = (LPSUBCLASS_INFO)HeapAlloc (GetProcessHeap(), HEAP_ZERO_MEMORY, - sizeof(SUBCLASS_INFO)); + stack = Alloc (sizeof(SUBCLASS_INFO)); if (!stack) { ERR ("Failed to allocate our Subclassing stack\n"); return FALSE; } - SetPropA (hWnd, COMCTL32_aSubclass, (HANDLE)stack); + SetPropW (hWnd, COMCTL32_wSubclass, (HANDLE)stack); /* set window procedure to our own and save the current one */ if (IsWindowUnicode (hWnd)) @@ -1136,15 +1136,15 @@ BOOL WINAPI SetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass, } } - proc = HeapAlloc(GetProcessHeap(), 0, sizeof(SUBCLASSPROCS)); + proc = Alloc(sizeof(SUBCLASSPROCS)); if (!proc) { ERR ("Failed to allocate subclass entry in stack\n"); if (IsWindowUnicode (hWnd)) SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); else SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); - HeapFree (GetProcessHeap (), 0, stack); - RemovePropA( hWnd, COMCTL32_aSubclass ); + Free (stack); + RemovePropW( hWnd, COMCTL32_wSubclass ); return FALSE; } @@ -1183,7 +1183,7 @@ BOOL WINAPI GetWindowSubclass (HWND hWnd, SUBCLASSPROC pfnSubclass, TRACE ("(%p, %p, %x, %p)\n", hWnd, pfnSubclass, uID, pdwRef); /* See if we have been called for this window */ - stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass); + stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass); if (!stack) return FALSE; @@ -1226,7 +1226,7 @@ BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR u TRACE ("(%p, %p, %x)\n", hWnd, pfnSubclass, uID); /* Find the Subclass to remove */ - stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass); + stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass); if (!stack) return FALSE; @@ -1243,7 +1243,7 @@ BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR u if (stack->stackpos == proc) stack->stackpos = stack->stackpos->next; - HeapFree (GetProcessHeap (), 0, proc); + Free (proc); ret = TRUE; break; } @@ -1258,8 +1258,8 @@ BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR u SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); else SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); - HeapFree (GetProcessHeap (), 0, stack); - RemovePropA( hWnd, COMCTL32_aSubclass ); + Free (stack); + RemovePropW( hWnd, COMCTL32_wSubclass ); } return ret; @@ -1279,7 +1279,7 @@ LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARA TRACE ("(%p, 0x%08x, 0x%08x, 0x%08lx)\n", hWnd, uMsg, wParam, lParam); - stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass); + stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass); if (!stack) { ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd); return 0; @@ -1300,8 +1300,8 @@ LRESULT WINAPI COMCTL32_SubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARA SetWindowLongPtrW (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); else SetWindowLongPtrA (hWnd, GWLP_WNDPROC, (DWORD_PTR)stack->origproc); - HeapFree (GetProcessHeap (), 0, stack); - RemovePropA( hWnd, COMCTL32_aSubclass ); + Free (stack); + RemovePropW( hWnd, COMCTL32_wSubclass ); } return ret; } @@ -1330,7 +1330,7 @@ LRESULT WINAPI DefSubclassProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar TRACE ("(%p, 0x%08x, 0x%08x, 0x%08lx)\n", hWnd, uMsg, wParam, lParam); /* retrieve our little stack from the Properties */ - stack = (LPSUBCLASS_INFO)GetPropA (hWnd, COMCTL32_aSubclass); + stack = (LPSUBCLASS_INFO)GetPropW (hWnd, COMCTL32_wSubclass); if (!stack) { ERR ("Our sub classing stack got erased for %p!! Nothing we can do\n", hWnd); return 0; @@ -1374,7 +1374,7 @@ COMCTL32_CreateToolTip(HWND hwndOwner) { HWND hwndToolTip; - hwndToolTip = CreateWindowExA(0, TOOLTIPS_CLASSA, NULL, 0, + hwndToolTip = CreateWindowExW(0, TOOLTIPS_CLASSW, NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwndOwner, 0, 0, 0); @@ -1390,9 +1390,9 @@ COMCTL32_CreateToolTip(HWND hwndOwner) nmttc.hdr.code = NM_TOOLTIPSCREATED; nmttc.hwndToolTips = hwndToolTip; - SendMessageA(GetParent(hwndTrueOwner), WM_NOTIFY, + SendMessageW(GetParent(hwndTrueOwner), WM_NOTIFY, (WPARAM)GetWindowLongPtrW(hwndTrueOwner, GWLP_ID), - (LPARAM)&nmttc); + (LPARAM)&nmttc); } return hwndToolTip; diff --git a/reactos/lib/comctl32/datetime.c b/reactos/lib/comctl32/datetime.c index 8b8af308a8d..5fed3f7bda1 100644 --- a/reactos/lib/comctl32/datetime.c +++ b/reactos/lib/comctl32/datetime.c @@ -82,6 +82,7 @@ typedef struct int *buflen; WCHAR textbuf[256]; POINT monthcal_pos; + int pendingUpdown; } DATETIME_INFO, *LPDATETIME_INFO; /* in monthcal.c */ @@ -256,7 +257,7 @@ DATETIME_SetFormatW (DATETIME_INFO *infoPtr, LPCWSTR lpszFormat) if (infoPtr->dwStyle & DTS_LONGDATEFORMAT) format_item = LOCALE_SLONGDATE; - else if (infoPtr->dwStyle & DTS_TIMEFORMAT) + else if ((infoPtr->dwStyle & DTS_TIMEFORMAT) == DTS_TIMEFORMAT) format_item = LOCALE_STIMEFORMAT; else /* DTS_SHORTDATEFORMAT */ format_item = LOCALE_SSHORTDATE; @@ -265,6 +266,7 @@ DATETIME_SetFormatW (DATETIME_INFO *infoPtr, LPCWSTR lpszFormat) } DATETIME_UseFormat (infoPtr, lpszFormat); + InvalidateRect (infoPtr->hwndSelf, NULL, TRUE); return infoPtr->nrFields; } @@ -338,10 +340,22 @@ DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, LPWSTR result, int result GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_SDAYNAME1+(date.wDayOfWeek+6)%7, result, resultSize); break; case ONEDIGIT12HOUR: - wsprintfW (result, fmt_dW, date.wHour - (date.wHour > 12 ? 12 : 0)); + if (date.wHour == 0) { + result[0] = '1'; + result[1] = '2'; + result[2] = 0; + } + else + wsprintfW (result, fmt_dW, date.wHour - (date.wHour > 12 ? 12 : 0)); break; case TWODIGIT12HOUR: - wsprintfW (result, fmt__2dW, date.wHour - (date.wHour > 12 ? 12 : 0)); + if (date.wHour == 0) { + result[0] = '1'; + result[1] = '2'; + result[2] = 0; + } + else + wsprintfW (result, fmt__2dW, date.wHour - (date.wHour > 12 ? 12 : 0)); break; case ONEDIGIT24HOUR: wsprintfW (result, fmt_dW, date.wHour); @@ -405,6 +419,19 @@ DATETIME_ReturnTxt (DATETIME_INFO *infoPtr, int count, LPWSTR result, int result TRACE ("arg%d=%x->[%s]\n", count, infoPtr->fieldspec[count], debugstr_w(result)); } +/* Offsets of days in the week to the weekday of january 1 in a leap year. */ +static const int DayOfWeekTable[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; + +/* returns the day in the week(0 == sunday, 6 == saturday) */ +/* day(1 == 1st, 2 == 2nd... etc), year is the year value */ +static int DATETIME_CalculateDayOfWeek(DWORD day, DWORD month, DWORD year) +{ + year-=(month < 3); + + return((year + year/4 - year/100 + year/400 + + DayOfWeekTable[month-1] + day ) % 7); +} + static int wrap(int val, int delta, int minVal, int maxVal) { val += delta; @@ -428,12 +455,14 @@ DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number, int delta) case TWODIGITYEAR: case FULLYEAR: date->wYear = wrap(date->wYear, delta, 1752, 9999); + date->wDayOfWeek = DATETIME_CalculateDayOfWeek(date->wDay,date->wMonth,date->wYear); break; case ONEDIGITMONTH: case TWODIGITMONTH: case THREECHARMONTH: case FULLMONTH: date->wMonth = wrap(date->wMonth, delta, 1, 12); + date->wDayOfWeek = DATETIME_CalculateDayOfWeek(date->wDay,date->wMonth,date->wYear); delta = 0; /* fall through */ case ONEDIGITDAY: @@ -441,6 +470,7 @@ DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number, int delta) case THREECHARDAY: case FULLDAY: date->wDay = wrap(date->wDay, delta, 1, MONTHCAL_MonthLength(date->wMonth, date->wYear)); + date->wDayOfWeek = DATETIME_CalculateDayOfWeek(date->wDay,date->wMonth,date->wYear); break; case ONELETTERAMPM: case TWOLETTERAMPM: @@ -481,6 +511,92 @@ DATETIME_IncreaseField (DATETIME_INFO *infoPtr, int number, int delta) } +static void +DATETIME_ReturnFieldWidth (DATETIME_INFO *infoPtr, HDC hdc, int count, SHORT *fieldWidthPtr) +{ + /* fields are a fixed width, determined by the largest possible string */ + /* presumably, these widths should be language dependent */ + static const WCHAR fld_d1W[] = { '2', 0 }; + static const WCHAR fld_d2W[] = { '2', '2', 0 }; + static const WCHAR fld_d4W[] = { '2', '2', '2', '2', 0 }; + static const WCHAR fld_am1[] = { 'A', 0 }; + static const WCHAR fld_am2[] = { 'A', 'M', 0 }; + static const WCHAR fld_day[] = { 'W', 'e', 'd', 'n', 'e', 's', 'd', 'a', 'y', 0 }; + static const WCHAR fld_day3[] = { 'W', 'e', 'd', 0 }; + static const WCHAR fld_mon[] = { 'S', 'e', 'p', 't', 'e', 'm', 'b', 'e', 'r', 0 }; + static const WCHAR fld_mon3[] = { 'D', 'e', 'c', 0 }; + int spec; + WCHAR buffer[80], *bufptr; + SIZE size; + + 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; + + spec = infoPtr->fieldspec[count]; + if (spec & DT_STRING) { + int txtlen = infoPtr->buflen[count]; + + if (txtlen > 79) + txtlen = 79; + memcpy (buffer, infoPtr->textbuf + (spec &~ DT_STRING), txtlen * sizeof(WCHAR)); + buffer[txtlen] = 0; + bufptr = buffer; + } + else { + switch (spec) { + case ONEDIGITDAY: + case ONEDIGIT12HOUR: + case ONEDIGIT24HOUR: + case ONEDIGITSECOND: + case ONEDIGITMINUTE: + case ONEDIGITMONTH: + case ONEDIGITYEAR: + /* these seem to use a two byte field */ + case TWODIGITDAY: + case TWODIGIT12HOUR: + case TWODIGIT24HOUR: + case TWODIGITSECOND: + case TWODIGITMINUTE: + case TWODIGITMONTH: + case TWODIGITYEAR: + bufptr = (WCHAR *)fld_d2W; + break; + case INVALIDFULLYEAR: + case FULLYEAR: + bufptr = (WCHAR *)fld_d4W; + break; + case THREECHARDAY: + bufptr = (WCHAR *)fld_day3; + break; + case FULLDAY: + bufptr = (WCHAR *)fld_day; + break; + case THREECHARMONTH: + bufptr = (WCHAR *)fld_mon3; + break; + case FULLMONTH: + bufptr = (WCHAR *)fld_mon; + break; + case ONELETTERAMPM: + bufptr = (WCHAR *)fld_am1; + break; + case TWOLETTERAMPM: + bufptr = (WCHAR *)fld_am2; + break; + default: + bufptr = (WCHAR *)fld_d1W; + break; + } + } + GetTextExtentPoint32W (hdc, bufptr, strlenW(bufptr), &size); + *fieldWidthPtr = size.cx; +} + static void DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc) { @@ -491,6 +607,7 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc) RECT *checkbox = &infoPtr->checkbox; SIZE size; COLORREF oldTextColor; + SHORT fieldWidth; /* draw control edge */ TRACE("\n"); @@ -509,9 +626,10 @@ DATETIME_Refresh (DATETIME_INFO *infoPtr, HDC hdc) for (i = 0; i < infoPtr->nrFields; i++) { DATETIME_ReturnTxt (infoPtr, i, txt, sizeof(txt)/sizeof(txt[0])); GetTextExtentPoint32W (hdc, txt, strlenW(txt), &size); + DATETIME_ReturnFieldWidth (infoPtr, hdc, i, &fieldWidth); field = &infoPtr->fieldRect[i]; field->left = prevright; - field->right = prevright+size.cx; + field->right = prevright + fieldWidth; field->top = rcDraw->top; field->bottom = rcDraw->bottom; prevright = field->right; @@ -720,12 +838,17 @@ DATETIME_Notify (DATETIME_INFO *infoPtr, int idCtrl, LPNMHDR lpnmh) 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); + TRACE("got from calendar %04d/%02d/%02d day of week %d\n", + infoPtr->date.wYear, infoPtr->date.wMonth, infoPtr->date.wDay, infoPtr->date.wDayOfWeek); SendMessageW (infoPtr->hwndCheckbut, BM_SETCHECK, BST_CHECKED, 0); InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); DATETIME_SendDateTimeChangeNotify (infoPtr); } + if ((lpnmh->hwndFrom == infoPtr->hUpdown) && (lpnmh->code == UDN_DELTAPOS)) { + LPNMUPDOWN lpnmud = (LPNMUPDOWN)lpnmh; + TRACE("Delta pos %d\n", lpnmud->iDelta); + infoPtr->pendingUpdown = lpnmud->iDelta; + } return 0; } @@ -743,6 +866,83 @@ DATETIME_KeyDown (DATETIME_INFO *infoPtr, DWORD vkCode, LPARAM flags) FIXME ("Callbacks not implemented yet\n"); } + if (vkCode >= '0' && vkCode <= '9') { + /* this is a somewhat simplified version of what Windows does */ + SYSTEMTIME *date = &infoPtr->date; + switch (infoPtr->fieldspec[fieldNum]) { + case ONEDIGITYEAR: + case TWODIGITYEAR: + date->wYear = date->wYear - (date->wYear%100) + + (date->wYear%10)*10 + (vkCode-'0'); + date->wDayOfWeek = DATETIME_CalculateDayOfWeek( + date->wDay,date->wMonth,date->wYear); + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; + case INVALIDFULLYEAR: + case FULLYEAR: + date->wYear = (date->wYear%1000)*10 + (vkCode-'0'); + date->wDayOfWeek = DATETIME_CalculateDayOfWeek( + date->wDay,date->wMonth,date->wYear); + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; + case ONEDIGITMONTH: + case TWODIGITMONTH: + if ((date->wMonth%10) > 1 || (vkCode-'0') > 2) + date->wMonth = vkCode-'0'; + else + date->wMonth = (date->wMonth%10)*10+vkCode-'0'; + date->wDayOfWeek = DATETIME_CalculateDayOfWeek( + date->wDay,date->wMonth,date->wYear); + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; + case ONEDIGITDAY: + case TWODIGITDAY: + /* probably better checking here would help */ + if ((date->wDay%10) >= 3 && (vkCode-'0') > 1) + date->wDay = vkCode-'0'; + else + date->wDay = (date->wDay%10)*10+vkCode-'0'; + date->wDayOfWeek = DATETIME_CalculateDayOfWeek( + date->wDay,date->wMonth,date->wYear); + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; + case ONEDIGIT12HOUR: + case TWODIGIT12HOUR: + if ((date->wHour%10) > 1 || (vkCode-'0') > 2) + date->wHour = vkCode-'0'; + else + date->wHour = (date->wHour%10)*10+vkCode-'0'; + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; + case ONEDIGIT24HOUR: + case TWODIGIT24HOUR: + if ((date->wHour%10) > 2) + date->wHour = vkCode-'0'; + else if ((date->wHour%10) == 2 && (vkCode-'0') > 3) + date->wHour = vkCode-'0'; + else + date->wHour = (date->wHour%10)*10+vkCode-'0'; + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; + case ONEDIGITMINUTE: + case TWODIGITMINUTE: + if ((date->wMinute%10) > 5) + date->wMinute = vkCode-'0'; + else + date->wMinute = (date->wMinute%10)*10+vkCode-'0'; + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; + case ONEDIGITSECOND: + case TWODIGITSECOND: + if ((date->wSecond%10) > 5) + date->wSecond = vkCode-'0'; + else + date->wSecond = (date->wSecond%10)*10+vkCode-'0'; + DATETIME_SendDateTimeChangeNotify (infoPtr); + break; + } + } + switch (vkCode) { case VK_ADD: case VK_UP: @@ -783,7 +983,31 @@ DATETIME_KeyDown (DATETIME_INFO *infoPtr, DWORD vkCode, LPARAM flags) break; } - InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); + + return 0; +} + + +static LRESULT +DATETIME_VScroll (DATETIME_INFO *infoPtr, WORD wScroll) +{ + int fieldNum = infoPtr->select & DTHT_DATEFIELD; + + if ((SHORT)LOWORD(wScroll) != SB_THUMBPOSITION) return 0; + if (!(infoPtr->haveFocus)) return 0; + if ((fieldNum==0) && (infoPtr->select)) return 0; + + if (infoPtr->pendingUpdown >= 0) { + DATETIME_IncreaseField (infoPtr, fieldNum, 1); + DATETIME_SendDateTimeChangeNotify (infoPtr); + } + else { + DATETIME_IncreaseField (infoPtr, fieldNum, -1); + DATETIME_SendDateTimeChangeNotify (infoPtr); + } + + InvalidateRect(infoPtr->hwndSelf, NULL, TRUE); return 0; } @@ -874,13 +1098,21 @@ DATETIME_Size (DATETIME_INFO *infoPtr, WORD flags, INT width, INT height) TRACE("Height=%ld, Width=%ld\n", infoPtr->rcClient.bottom, infoPtr->rcClient.right); 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 */ - 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; + + if (infoPtr->dwStyle & DTS_UPDOWN) { + SetWindowPos(infoPtr->hUpdown, NULL, + infoPtr->rcClient.right-14, 0, + 15, infoPtr->rcClient.bottom - infoPtr->rcClient.top, + SWP_NOACTIVATE | SWP_NOZORDER); + } + else { + /* 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 */ @@ -958,7 +1190,7 @@ DATETIME_Create (HWND hwnd, LPCREATESTRUCTW lpcs) 0, 0, 0, 0, infoPtr->hwndSelf, 0, 0, 0); /* initialize info structure */ - GetSystemTime (&infoPtr->date); + GetLocalTime (&infoPtr->date); infoPtr->dateValid = TRUE; infoPtr->hFont = GetStockObject(DEFAULT_GUI_FONT); @@ -1067,6 +1299,9 @@ DATETIME_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_LBUTTONUP: return DATETIME_LButtonUp (infoPtr, (WORD)wParam); + case WM_VSCROLL: + return DATETIME_VScroll (infoPtr, (WORD)wParam); + case WM_CREATE: return DATETIME_Create (hwnd, (LPCREATESTRUCTW)lParam); diff --git a/reactos/lib/comctl32/flatsb.c b/reactos/lib/comctl32/flatsb.c index 1c5fa66236a..baebbe68244 100644 --- a/reactos/lib/comctl32/flatsb.c +++ b/reactos/lib/comctl32/flatsb.c @@ -245,7 +245,7 @@ static LRESULT WINAPI FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (!FlatSB_GetInfoPtr(hwnd) && (uMsg != WM_CREATE)) - return DefWindowProcA( hwnd, uMsg, wParam, lParam ); + return DefWindowProcW( hwnd, uMsg, wParam, lParam ); switch (uMsg) { @@ -259,7 +259,7 @@ FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 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); } } @@ -267,23 +267,23 @@ FlatSB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) VOID FLATSB_Register (void) { - WNDCLASSA wndClass; + WNDCLASSW wndClass; - ZeroMemory (&wndClass, sizeof(WNDCLASSA)); + ZeroMemory (&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS; wndClass.lpfnWndProc = FlatSB_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(FLATSB_INFO *); - wndClass.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW); + wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW); wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wndClass.lpszClassName = FLATSB_CLASSA; + wndClass.lpszClassName = FLATSB_CLASSW; - RegisterClassA (&wndClass); + RegisterClassW (&wndClass); } VOID FLATSB_Unregister (void) { - UnregisterClassA (FLATSB_CLASSA, NULL); + UnregisterClassW (FLATSB_CLASSW, NULL); } diff --git a/reactos/lib/comctl32/header.c b/reactos/lib/comctl32/header.c index 601a0c886fe..56d0b747ff8 100644 --- a/reactos/lib/comctl32/header.c +++ b/reactos/lib/comctl32/header.c @@ -83,7 +83,7 @@ typedef struct INT iHotItem; /* index of hot item (cursor is over this item) */ INT iMargin; /* width of the margin that surrounds a bitmap */ - HIMAGELIST himl; /* handle to a image list (may be 0) */ + HIMAGELIST himl; /* handle to an image list (may be 0) */ HEADER_ITEM *items; /* pointer to array of HEADER_ITEM's */ BOOL bRectsValid; /* validity flag for bounding rectangles */ } HEADER_INFO; @@ -174,7 +174,7 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack) if (r.right - r.left == 0) return phdi->rect.right; - if (GetWindowLongA (hwnd, GWL_STYLE) & HDS_BUTTONS) { + if (GetWindowLongW (hwnd, GWL_STYLE) & HDS_BUTTONS) { if (phdi->bDown) { DrawEdge (hdc, &r, BDR_RAISEDOUTER, BF_RECT | BF_FLAT | BF_MIDDLE | BF_ADJUST); @@ -200,7 +200,7 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack) dis.rcItem = r; dis.itemData = phdi->lParam; oldBkMode = SetBkMode(hdc, TRANSPARENT); - SendMessageA (infoPtr->hwndNotify, WM_DRAWITEM, + SendMessageW (infoPtr->hwndNotify, WM_DRAWITEM, (WPARAM)dis.CtlID, (LPARAM)&dis); if (oldBkMode != TRANSPARENT) SetBkMode(hdc, oldBkMode); @@ -218,7 +218,7 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack) HDC hdcBitmap; INT yD, yS, cx, cy, rx, ry; - GetObjectA (phdi->hbm, sizeof(BITMAP), (LPVOID)&bmp); + GetObjectW (phdi->hbm, sizeof(BITMAP), (LPVOID)&bmp); ry = r.bottom - r.top; rx = r.right - r.left; @@ -257,7 +257,7 @@ HEADER_DrawItem (HWND hwnd, HDC hdc, INT iItem, BOOL bHotTrack) INT xD, yD, yS, cx, cy, rx, ry, tx; RECT textRect; - GetObjectA (phdi->hbm, sizeof(BITMAP), (LPVOID)&bmp); + GetObjectW (phdi->hbm, sizeof(BITMAP), (LPVOID)&bmp); textRect = r; if (phdi->fmt & HDF_STRING) { @@ -385,7 +385,7 @@ HEADER_Refresh (HWND hwnd, HDC hdc) if ((x <= rect.right) && (infoPtr->uNumItem > 0)) { rect.left = x; - if (GetWindowLongA (hwnd, GWL_STYLE) & HDS_BUTTONS) + if (GetWindowLongW (hwnd, GWL_STYLE) & HDS_BUTTONS) DrawEdge (hdc, &rect, EDGE_RAISED, BF_TOP|BF_LEFT|BF_BOTTOM|BF_SOFT); else DrawEdge (hdc, &rect, EDGE_ETCHED, BF_BOTTOM); @@ -558,7 +558,7 @@ HEADER_SendSimpleNotify (HWND hwnd, UINT code) nmhdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID); nmhdr.code = code; - return (BOOL)SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, + return (BOOL)SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); } @@ -587,7 +587,7 @@ HEADER_SendHeaderNotify (HWND hwnd, UINT code, INT iItem, INT mask) nmitem.iOrder = infoPtr->items[iItem].iOrder; nmitem.iImage = infoPtr->items[iItem].iImage; - return (BOOL)SendMessageA (infoPtr->hwndNotify, WM_NOTIFY, + return (BOOL)SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmhdr.hdr.idFrom, (LPARAM)&nmhdr); } @@ -1106,7 +1106,7 @@ HEADER_Layout (HWND hwnd, WPARAM wParam, LPARAM lParam) lpLayout->pwpos->x = lpLayout->prc->left; lpLayout->pwpos->y = lpLayout->prc->top; lpLayout->pwpos->cx = lpLayout->prc->right - lpLayout->prc->left; - if (GetWindowLongA (hwnd, GWL_STYLE) & HDS_HIDDEN) + if (GetWindowLongW (hwnd, GWL_STYLE) & HDS_HIDDEN) lpLayout->pwpos->cy = 0; else { lpLayout->pwpos->cy = infoPtr->nHeight; @@ -1304,21 +1304,21 @@ static LRESULT HEADER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) { HEADER_INFO *infoPtr; - TEXTMETRICA tm; + TEXTMETRICW tm; HFONT hOldFont; HDC hdc; infoPtr = (HEADER_INFO *)Alloc (sizeof(HEADER_INFO)); - SetWindowLongPtrA (hwnd, 0, (DWORD_PTR)infoPtr); + SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); infoPtr->hwndNotify = ((LPCREATESTRUCTA)lParam)->hwndParent; infoPtr->uNumItem = 0; infoPtr->hFont = 0; infoPtr->items = 0; infoPtr->bRectsValid = FALSE; - infoPtr->hcurArrow = LoadCursorA (0, (LPSTR)IDC_ARROW); - infoPtr->hcurDivider = LoadCursorA (COMCTL32_hModule, MAKEINTRESOURCEA(IDC_DIVIDER)); - infoPtr->hcurDivopen = LoadCursorA (COMCTL32_hModule, MAKEINTRESOURCEA(IDC_DIVIDEROPEN)); + infoPtr->hcurArrow = LoadCursorW (0, (LPWSTR)IDC_ARROW); + infoPtr->hcurDivider = LoadCursorW (COMCTL32_hModule, MAKEINTRESOURCEW(IDC_DIVIDER)); + infoPtr->hcurDivopen = LoadCursorW (COMCTL32_hModule, MAKEINTRESOURCEW(IDC_DIVIDEROPEN)); infoPtr->bPressed = FALSE; infoPtr->bTracking = FALSE; infoPtr->iMoveItem = 0; @@ -1327,11 +1327,11 @@ HEADER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->bUnicode = IsWindowUnicode (hwnd); infoPtr->iMargin = 3*GetSystemMetrics(SM_CXEDGE); infoPtr->nNotifyFormat = - SendMessageA (infoPtr->hwndNotify, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY); + SendMessageW (infoPtr->hwndNotify, WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY); hdc = GetDC (0); hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT)); - GetTextMetricsA (hdc, &tm); + GetTextMetricsW (hdc, &tm); infoPtr->nHeight = tm.tmHeight + VERT_BORDER; SelectObject (hdc, hOldFont); ReleaseDC (0, hdc); @@ -1359,8 +1359,8 @@ HEADER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) if (infoPtr->himl) ImageList_Destroy (infoPtr->himl); + SetWindowLongPtrW (hwnd, 0, 0); Free (infoPtr); - SetWindowLongPtrA (hwnd, 0, 0); return 0; } @@ -1385,7 +1385,7 @@ HEADER_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam) pt.y = (INT)HIWORD(lParam); HEADER_InternalHitTest (hwnd, &pt, &flags, &nItem); - if ((GetWindowLongA (hwnd, GWL_STYLE) & HDS_BUTTONS) && (flags == HHT_ONHEADER)) + if ((GetWindowLongW (hwnd, GWL_STYLE) & HDS_BUTTONS) && (flags == HHT_ONHEADER)) HEADER_SendHeaderNotify (hwnd, HDN_ITEMDBLCLICKA, nItem,0); else if ((flags == HHT_ONDIVIDER) || (flags == HHT_ONDIVOPEN)) HEADER_SendHeaderNotify (hwnd, HDN_DIVIDERDBLCLICKA, nItem,0); @@ -1398,7 +1398,7 @@ static LRESULT HEADER_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) { HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd); - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); + DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); POINT pt; UINT flags; INT nItem; @@ -1452,7 +1452,7 @@ HEADER_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) { HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd); /* - *DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); + *DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); */ POINT pt; UINT flags; @@ -1551,7 +1551,7 @@ HEADER_NotifyFormat (HWND hwnd, WPARAM wParam, LPARAM lParam) case NF_REQUERY: infoPtr->nNotifyFormat = - SendMessageA ((HWND)wParam, WM_NOTIFYFORMAT, + SendMessageW ((HWND)wParam, WM_NOTIFYFORMAT, (WPARAM)hwnd, (LPARAM)NF_QUERY); return infoPtr->nNotifyFormat; } @@ -1564,7 +1564,7 @@ static LRESULT HEADER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) { HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd); - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); + DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); POINT pt; UINT flags; INT nItem, nWidth; @@ -1661,7 +1661,7 @@ HEADER_RButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) ClientToScreen(hwnd, &pt); /* Send a WM_CONTEXTMENU message in response to the RBUTTONUP */ - SendMessageA( hwnd, WM_CONTEXTMENU, (WPARAM) hwnd, MAKELPARAM(pt.x, pt.y)); + SendMessageW( hwnd, WM_CONTEXTMENU, (WPARAM) hwnd, MAKELPARAM(pt.x, pt.y)); return bRet; } @@ -1697,7 +1697,7 @@ static LRESULT HEADER_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) { HEADER_INFO *infoPtr = HEADER_GetInfoPtr (hwnd); - TEXTMETRICA tm; + TEXTMETRICW tm; HFONT hFont, hOldFont; HDC hdc; @@ -1707,7 +1707,7 @@ HEADER_SetFont (HWND hwnd, WPARAM wParam, LPARAM lParam) hdc = GetDC (0); hOldFont = SelectObject (hdc, hFont); - GetTextMetricsA (hdc, &tm); + GetTextMetricsW (hdc, &tm); infoPtr->nHeight = tm.tmHeight + VERT_BORDER; SelectObject (hdc, hOldFont); ReleaseDC (0, hdc); @@ -1727,7 +1727,7 @@ HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { TRACE("hwnd=%p msg=%x wparam=%x lParam=%lx\n", hwnd, msg, wParam, lParam); if (!HEADER_GetInfoPtr (hwnd) && (msg != WM_CREATE)) - return DefWindowProcA (hwnd, msg, wParam, lParam); + return DefWindowProcW (hwnd, msg, wParam, lParam); switch (msg) { /* case HDM_CLEARFILTER: */ @@ -1857,22 +1857,22 @@ HEADER_WindowProc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) VOID HEADER_Register (void) { - WNDCLASSA wndClass; + WNDCLASSW wndClass; - ZeroMemory (&wndClass, sizeof(WNDCLASSA)); + ZeroMemory (&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; wndClass.lpfnWndProc = HEADER_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(HEADER_INFO *); - wndClass.hCursor = LoadCursorA (0, (LPSTR)IDC_ARROW); - wndClass.lpszClassName = WC_HEADERA; + wndClass.hCursor = LoadCursorW (0, (LPWSTR)IDC_ARROW); + wndClass.lpszClassName = WC_HEADERW; - RegisterClassA (&wndClass); + RegisterClassW (&wndClass); } VOID HEADER_Unregister (void) { - UnregisterClassA (WC_HEADERA, NULL); + UnregisterClassW (WC_HEADERW, NULL); } diff --git a/reactos/lib/comctl32/imagelist.c b/reactos/lib/comctl32/imagelist.c index db098b2cc11..f392f131ba2 100644 --- a/reactos/lib/comctl32/imagelist.c +++ b/reactos/lib/comctl32/imagelist.c @@ -1405,14 +1405,19 @@ ImageList_GetIcon (HIMAGELIST himl, INT i, UINT fStyle) TRACE("%p %d %d\n", himl, i, fStyle); if (!is_valid(himl) || (i < 0) || (i >= himl->cCurImage)) return NULL; - hdcDst = CreateCompatibleDC(0); - ii.fIcon = TRUE; ii.xHotspot = 0; ii.yHotspot = 0; + /* create colour bitmap */ + hdcDst = GetDC(0); + ii.hbmColor = CreateCompatibleBitmap(hdcDst, himl->cx, himl->cy); + ReleaseDC(0, hdcDst); + + hdcDst = CreateCompatibleDC(0); + /* draw mask*/ - ii.hbmMask = CreateCompatibleBitmap (hdcDst, himl->cx, himl->cy); + ii.hbmMask = CreateBitmap (himl->cx, himl->cy, 1, 1, NULL); hOldDstBitmap = SelectObject (hdcDst, ii.hbmMask); if (himl->hbmMask) { BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, @@ -1422,7 +1427,6 @@ ImageList_GetIcon (HIMAGELIST himl, INT i, UINT fStyle) PatBlt (hdcDst, 0, 0, himl->cx, himl->cy, BLACKNESS); /* draw image*/ - ii.hbmColor = CreateCompatibleBitmap (himl->hdcImage, himl->cx, himl->cy); SelectObject (hdcDst, ii.hbmColor); BitBlt (hdcDst, 0, 0, himl->cx, himl->cy, himl->hdcImage, i * himl->cx, 0, SRCCOPY); @@ -1594,11 +1598,11 @@ ImageList_LoadImageA (HINSTANCE hi, LPCSTR lpbmp, INT cx, INT cGrow, uType, uFlags); len = MultiByteToWideChar(CP_ACP, 0, lpbmp, -1, NULL, 0); - lpbmpW = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + lpbmpW = Alloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, lpbmp, -1, lpbmpW, len); himl = ImageList_LoadImageW(hi, lpbmpW, cx, cGrow, clrMask, uType, uFlags); - HeapFree(GetProcessHeap(), 0, lpbmpW); + Free (lpbmpW); return himl; } @@ -2786,7 +2790,7 @@ static HBITMAP ImageList_CreateImage(HDC hdc, HIMAGELIST himl, UINT width, UINT BYTE temp; colors = 1 << himl->uBitsPixel; - bmi = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER) + + bmi = Alloc(sizeof(BITMAPINFOHEADER) + sizeof(PALETTEENTRY) * colors); pal = (LPPALETTEENTRY)bmi->bmiColors; @@ -2803,7 +2807,7 @@ static HBITMAP ImageList_CreateImage(HDC hdc, HIMAGELIST himl, UINT width, UINT } else { - bmi = HeapAlloc(GetProcessHeap(), 0, sizeof(BITMAPINFOHEADER)); + bmi = Alloc(sizeof(BITMAPINFOHEADER)); } bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); @@ -2820,7 +2824,7 @@ static HBITMAP ImageList_CreateImage(HDC hdc, HIMAGELIST himl, UINT width, UINT hbmNewBitmap = CreateDIBSection(hdc, bmi, DIB_RGB_COLORS, &bits, 0, 0); - HeapFree(GetProcessHeap(), 0, bmi); + Free (bmi); } else /*if (ilc == ILC_COLORDDB)*/ { diff --git a/reactos/lib/comctl32/listview.c b/reactos/lib/comctl32/listview.c index e35c4f57582..df00d220e50 100644 --- a/reactos/lib/comctl32/listview.c +++ b/reactos/lib/comctl32/listview.c @@ -40,8 +40,7 @@ * * Bugs * -- Expand large item in ICON mode when the cursor is flying over the icon or text. - * -- Support CustonDraw options for _WIN32_IE >= 0x560 (see NMLVCUSTOMDRAW docs. - * -- in LISTVIEW_AddGroupSelection, we would send LVN_ODSTATECHANGED + * -- Support CustomDraw options for _WIN32_IE >= 0x560 (see NMLVCUSTOMDRAW docs). * -- LVA_SNAPTOGRID not implemented * -- LISTVIEW_ApproximateViewRect partially implemented * -- LISTVIEW_[GS]etColumnOrderArray stubs @@ -98,7 +97,6 @@ * -- LVN_HOTTRACK * -- LVN_MARQUEEBEGIN * -- LVN_ODFINDITEM - * -- LVN_ODSTATECHANGED * -- LVN_SETDISPINFO * -- NM_HOVER * @@ -441,7 +439,7 @@ static inline LPWSTR textdupTtoW(LPCWSTR text, BOOL isW) if (!isW && is_textT(text, isW)) { INT len = MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text, -1, NULL, 0); - wstr = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + wstr = Alloc(len * sizeof(WCHAR)); if (wstr) MultiByteToWideChar(CP_ACP, 0, (LPCSTR)text, -1, wstr, len); } TRACE(" wstr=%s\n", text == LPSTR_TEXTCALLBACKW ? "(callback)" : debugstr_w(wstr)); @@ -450,7 +448,7 @@ static inline LPWSTR textdupTtoW(LPCWSTR text, BOOL isW) static inline void textfreeT(LPWSTR wstr, BOOL isW) { - if (!isW && is_textT(wstr, isW)) HeapFree(GetProcessHeap(), 0, wstr); + if (!isW && is_textT(wstr, isW)) Free (wstr); } /* @@ -558,7 +556,7 @@ static inline const char* debugrect(const RECT *rect) } else return "(null)"; } -static const char * debugscrollinfo(const SCROLLINFO *pScrollInfo) +static const char* debugscrollinfo(const SCROLLINFO *pScrollInfo) { char* buf = debug_getbuf(), *text = buf; int len, size = DEBUG_BUFFER_SIZE; @@ -853,8 +851,7 @@ static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNML *pdi->item.pszText = 0; /* make sure we don't process garbage */ } - pszTempBuf = HeapAlloc(GetProcessHeap(), 0, - (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax); + pszTempBuf = Alloc( (convertToUnicode ? sizeof(WCHAR) : sizeof(CHAR)) * cchTempBufMax); if (!pszTempBuf) return FALSE; if (convertToUnicode) @@ -887,7 +884,7 @@ static BOOL notify_dispinfoT(LISTVIEW_INFO *infoPtr, INT notificationCode, LPNML savPszText, savCchTextMax); pdi->item.pszText = savPszText; /* restores our buffer */ pdi->item.cchTextMax = savCchTextMax; - HeapFree(GetProcessHeap(), 0, pszTempBuf); + Free (pszTempBuf); } return bResult; } @@ -1023,7 +1020,7 @@ static inline BOOL ranges_delitem(RANGES ranges, INT nItem) * five versa, should leave the iterator at the same item: * prev * n, next * n = next * n, prev * n * - * The iterator has a notion of a out-of-order, special item, + * The iterator has a notion of an out-of-order, special item, * which sits at the start of the list. This is used in * LVS_ICON, and LVS_SMALLICON mode to handle the focused item, * which needs to be first, as it may overlap other items. @@ -2970,22 +2967,35 @@ static void LISTVIEW_AddGroupSelection(LISTVIEW_INFO *infoPtr, INT nItem) { INT nFirst = min(infoPtr->nSelectionMark, nItem); INT nLast = max(infoPtr->nSelectionMark, nItem); - INT i; + NMLVODSTATECHANGE nmlv; LVITEMW item; + BOOL bOldChange; + INT i; + + /* Temporarily disable change notification + * If the control is LVS_OWNERDATA, we need to send + * only one LVN_ODSTATECHANGED notification. + * See MSDN documentation for LVN_ITEMCHANGED. + */ + bOldChange = infoPtr->bDoChangeNotify; + if (infoPtr->dwStyle & LVS_OWNERDATA) infoPtr->bDoChangeNotify = FALSE; if (nFirst == -1) nFirst = nItem; item.state = LVIS_SELECTED; item.stateMask = LVIS_SELECTED; - /* FIXME: this is not correct LVS_OWNERDATA - * setting the item states individually will generate - * a LVN_ITEMCHANGED notification for each one. Instead, - * we have to send a LVN_ODSTATECHANGED notification. - * See MSDN documentation for LVN_ITEMCHANGED. - */ for (i = nFirst; i <= nLast; i++) LISTVIEW_SetItemState(infoPtr,i,&item); + + ZeroMemory(&nmlv, sizeof(nmlv)); + nmlv.iFrom = nFirst; + nmlv.iTo = nLast; + nmlv.uNewState = 0; + nmlv.uOldState = item.state; + + notify_hdr(infoPtr, LVN_ODSTATECHANGED, (LPNMHDR)&nmlv); + infoPtr->bDoChangeNotify = bOldChange; } @@ -7075,7 +7085,7 @@ static BOOL LISTVIEW_SetItemState(LISTVIEW_INFO *infoPtr, INT nItem, const LVITE bResult = LISTVIEW_SetItemT(infoPtr, &lvItem, TRUE); /* - *update selection mark + * Update selection mark * * Investigation on windows 2k showed that selection mark was updated * whenever a new selection was made, but if the selected item was @@ -9551,7 +9561,7 @@ static HWND CreateEditLabelT(LISTVIEW_INFO *infoPtr, LPCWSTR text, DWORD style, TRACE("(text=%s, ..., isW=%d)\n", debugtext_t(text, isW), isW); - style |= WS_CHILDWINDOW|WS_CLIPSIBLINGS|ES_LEFT|WS_BORDER; + style |= WS_CHILDWINDOW|WS_CLIPSIBLINGS|ES_LEFT|ES_AUTOHSCROLL|WS_BORDER; hdc = GetDC(infoPtr->hwndSelf); /* Select the font to get appropriate metric dimensions */ diff --git a/reactos/lib/comctl32/monthcal.c b/reactos/lib/comctl32/monthcal.c index 961fcae6e69..84aa1dbca6e 100644 --- a/reactos/lib/comctl32/monthcal.c +++ b/reactos/lib/comctl32/monthcal.c @@ -33,12 +33,11 @@ * TODO: * -- 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 + * infoPtr->rangeValid; an invalid range is simply filled * with zeros in SetRange. Is this the right behavior? * -- search for FIXME */ @@ -56,6 +55,7 @@ #include "winnls.h" #include "commctrl.h" #include "comctl32.h" +#include "wine/unicode.h" #include "wine/debug.h" WINE_DEFAULT_DEBUG_CHANNEL(monthcal); @@ -70,6 +70,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(monthcal); #define MC_NEXTMONTHTIMER 1 /* Timer ID's */ #define MC_PREVMONTHTIMER 2 +#define countof(arr) (sizeof(arr)/sizeof(arr[0])) + typedef struct { HWND hwndSelf; @@ -120,7 +122,7 @@ typedef struct } MONTHCAL_INFO, *LPMONTHCAL_INFO; -/* Offsets of days in the week to the weekday of january 1. */ +/* Offsets of days in the week to the weekday of january 1 in a leap year */ static const int DayOfWeekTable[] = {0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4}; @@ -185,17 +187,17 @@ void MONTHCAL_CopyTime(const SYSTEMTIME *from, SYSTEMTIME *to) Need to find out if we're on a DST place & adjust the clock accordingly. Above function assumes we have a valid data. Valid for year>1752; 1 <= d <= 31, 1 <= m <= 12. - 0 = Monday. + 0 = Sunday. */ -/* returns the day in the week(0 == monday, 6 == sunday) */ +/* returns the day in the week(0 == sunday, 6 == saturday) */ /* day(1 == 1st, 2 == 2nd... etc), year is the year value */ static int MONTHCAL_CalculateDayOfWeek(DWORD day, DWORD month, DWORD year) { year-=(month < 3); return((year + year/4 - year/100 + year/400 + - DayOfWeekTable[month-1] + day - 1 ) % 7); + DayOfWeekTable[month-1] + day ) % 7); } /* From a given point, calculate the row (weekpos), column(daypos) @@ -333,14 +335,15 @@ static void MONTHCAL_CircleDay(MONTHCAL_INFO *infoPtr, HDC hdc, int day, int mon static void MONTHCAL_DrawDay(MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month, int x, int y, int bold) { - char buf[10]; + static const WCHAR fmtW[] = { '%','d',0 }; + WCHAR buf[10]; RECT r; static int haveBoldFont, haveSelectedDay = FALSE; HBRUSH hbr; COLORREF oldCol = 0; COLORREF oldBk = 0; - sprintf(buf, "%d", day); + wsprintfW(buf, fmtW, day); /* No need to check styles: when selection is not valid, it is set to zero. * 1curSelDay) && (month==infoPtr->currentMonth)) @@ -400,6 +403,10 @@ static void MONTHCAL_DrawDay(MONTHCAL_INFO *infoPtr, HDC hdc, int day, int month static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, PAINTSTRUCT* ps) { + static const WCHAR todayW[] = { 'T','o','d','a','y',':',0 }; + static const WCHAR fmt1W[] = { '%','s',' ','%','l','d',0 }; + static const WCHAR fmt2W[] = { '%','s',' ','%','s',0 }; + static const WCHAR fmt3W[] = { '%','d',0 }; RECT *title=&infoPtr->title; RECT *prev=&infoPtr->titlebtnprev; RECT *next=&infoPtr->titlebtnnext; @@ -413,9 +420,9 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, PAINTSTRUCT* ps) SIZE size; HBRUSH hbr; HFONT currentFont; - char buf[20]; - char buf1[20]; - char buf2[32]; + WCHAR buf[20]; + WCHAR buf1[20]; + WCHAR buf2[32]; COLORREF oldTextColor, oldBkColor; DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); RECT rcTemp; @@ -470,13 +477,13 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, PAINTSTRUCT* ps) titlemonth->left = title->left; titlemonth->right = title->right; - GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1, - buf1,sizeof(buf1)); - sprintf(buf, "%s %ld", buf1, infoPtr->currentYear); + GetLocaleInfoW( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+infoPtr->currentMonth -1, + buf1,countof(buf1)); + wsprintfW(buf, fmt1W, buf1, infoPtr->currentYear); if(IntersectRect(&rcTemp, &(ps->rcPaint), titlemonth)) { - DrawTextA(hdc, buf, strlen(buf), titlemonth, + DrawTextW(hdc, buf, strlenW(buf), titlemonth, DT_CENTER | DT_VCENTER | DT_SINGLELINE); } @@ -486,10 +493,10 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, PAINTSTRUCT* ps) * MCM_HitTestInfo wants month & year rects, so prepare these now. *(no, we can't draw them separately; the whole text is centered) */ - GetTextExtentPoint32A(hdc, buf, strlen(buf), &size); + GetTextExtentPoint32W(hdc, buf, strlenW(buf), &size); titlemonth->left = title->right / 2 - size.cx / 2; titleyear->right = title->right / 2 + size.cx / 2; - GetTextExtentPoint32A(hdc, buf1, strlen(buf1), &size); + GetTextExtentPoint32W(hdc, buf1, strlenW(buf1), &size); titlemonth->right = titlemonth->left + size.cx; titleyear->left = titlemonth->right; @@ -530,10 +537,8 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, PAINTSTRUCT* ps) i = infoPtr->firstDay; for(j=0; j<7; j++) { - GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SABBREVDAYNAME1 + (i +j)%7, - buf,sizeof(buf)); - DrawTextA(hdc, buf, strlen(buf), days, - DT_CENTER | DT_VCENTER | DT_SINGLELINE ); + GetLocaleInfoW( LOCALE_USER_DEFAULT,LOCALE_SABBREVDAYNAME1 + (i+j+6)%7, buf, countof(buf)); + DrawTextW(hdc, buf, strlenW(buf), days, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); days->left+=infoPtr->width_increment; days->right+=infoPtr->width_increment; } @@ -657,21 +662,21 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, PAINTSTRUCT* ps) infoPtr->currentMonth); offset+=textWidth; } - if (!LoadStringA(COMCTL32_hModule,IDM_TODAY,buf1,sizeof(buf1))) + if (!LoadStringW(COMCTL32_hModule,IDM_TODAY,buf1,countof(buf1))) { WARN("Can't load resource\n"); - strcpy(buf1,"Today:"); + strcpyW(buf1, todayW); } MONTHCAL_CalcDayRect(infoPtr, &rtoday, 1, 6); MONTHCAL_CopyTime(&infoPtr->todaysDate,&localtime); - GetDateFormatA(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&localtime,NULL,buf2,sizeof(buf2)); - sprintf(buf, "%s %s", buf1,buf2); + GetDateFormatW(LOCALE_USER_DEFAULT,DATE_SHORTDATE,&localtime,NULL,buf2,countof(buf2)); + wsprintfW(buf, fmt2W, buf1, buf2); SelectObject(hdc, infoPtr->hBoldFont); if(IntersectRect(&rcTemp, &(ps->rcPaint), &rtoday)) { - DrawTextA(hdc, buf, -1, &rtoday, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE); - DrawTextA(hdc, buf, -1, &rtoday, DT_LEFT | DT_VCENTER | DT_SINGLELINE); + DrawTextW(hdc, buf, -1, &rtoday, DT_CALCRECT | DT_LEFT | DT_VCENTER | DT_SINGLELINE); + DrawTextW(hdc, buf, -1, &rtoday, DT_LEFT | DT_VCENTER | DT_SINGLELINE); } SelectObject(hdc, infoPtr->hFont); } @@ -689,9 +694,8 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, PAINTSTRUCT* ps) LOCALE_IFIRSTWEEKOFYEAR == 1 (what contries?) The first week of the year must contain only days of the new year */ - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR, - buf, sizeof(buf)); - sscanf(buf, "%d", &weeknum); + GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IFIRSTWEEKOFYEAR, buf, countof(buf)); + weeknum = atoiW(buf); switch (weeknum) { case 1: mindays = 6; @@ -738,16 +742,16 @@ static void MONTHCAL_Refresh(MONTHCAL_INFO *infoPtr, HDC hdc, PAINTSTRUCT* ps) for(i=0; i<6; i++) { if((i==0)&&(weeknum>50)) { - sprintf(buf, "%d", weeknum); + wsprintfW(buf, fmt3W, weeknum); weeknum=0; } else if((i==5)&&(weeknum>47)) { - sprintf(buf, "%d", 1); + wsprintfW(buf, fmt3W, 1); } else - sprintf(buf, "%d", weeknum + i); - DrawTextA(hdc, buf, -1, days, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); + wsprintfW(buf, fmt3W, weeknum + i); + DrawTextW(hdc, buf, -1, days, DT_CENTER | DT_VCENTER | DT_SINGLELINE ); days->top+=infoPtr->height_increment; days->bottom+=infoPtr->height_increment; } @@ -882,15 +886,14 @@ MONTHCAL_GetFirstDayOfWeek(MONTHCAL_INFO *infoPtr) /* sets the first day of the week that will appear in the control */ -/* 0 == Monday, 6 == Sunday */ +/* 0 == Sunday, 6 == Saturday */ /* FIXME: this needs to be implemented properly in MONTHCAL_Refresh() */ /* FIXME: we need more error checking here */ static LRESULT MONTHCAL_SetFirstDayOfWeek(MONTHCAL_INFO *infoPtr, LPARAM lParam) { int prev = infoPtr->firstDay; - char buf[40]; - int day; + WCHAR buf[40]; TRACE("day %ld\n", lParam); @@ -899,13 +902,9 @@ MONTHCAL_SetFirstDayOfWeek(MONTHCAL_INFO *infoPtr, LPARAM lParam) } else { - GetLocaleInfoA(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, - buf, sizeof(buf)); - TRACE("%s %d\n", buf, strlen(buf)); - if(sscanf(buf, "%d", &day) == 1) - infoPtr->firstDay = day; - else - infoPtr->firstDay = 0; + GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IFIRSTDAYOFWEEK, buf, countof(buf)); + TRACE("%s %d\n", debugstr_w(buf), strlenW(buf)); + infoPtr->firstDay = (atoiW(buf)+1)%7; } return prev; } @@ -1151,6 +1150,7 @@ MONTHCAL_HitTest(MONTHCAL_INFO *infoPtr, LPARAM lParam) y = lpht->pt.y; retval = MCHT_NOWHERE; + ZeroMemory(&lpht->st, sizeof(lpht->st)); /* Comment in for debugging... TRACE("%d %d wd[%d %d %d %d] d[%d %d %d %d] t[%d %d %d %d] wn[%d %d %d %d]\n", x, y, @@ -1238,6 +1238,7 @@ MONTHCAL_HitTest(MONTHCAL_INFO *infoPtr, LPARAM lParam) retval = MCHT_CALENDARDATE; lpht->st.wMonth = infoPtr->currentMonth; lpht->st.wDay = day; + lpht->st.wDayOfWeek = MONTHCAL_CalculateDayOfWeek(day,lpht->st.wMonth,lpht->st.wYear); } goto done; } @@ -1278,7 +1279,7 @@ static void MONTHCAL_GoToNextMonth(MONTHCAL_INFO *infoPtr) nmds.cDayState = infoPtr->monthRange; nmds.prgDayState = Alloc(infoPtr->monthRange * sizeof(MONTHDAYSTATE)); - SendMessageA(infoPtr->hwndNotify, WM_NOTIFY, + SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmds.nmhdr.idFrom, (LPARAM)&nmds); for(i=0; imonthRange; i++) infoPtr->monthdayState[i] = nmds.prgDayState[i]; @@ -1309,7 +1310,7 @@ static void MONTHCAL_GoToPrevMonth(MONTHCAL_INFO *infoPtr) nmds.prgDayState = Alloc (infoPtr->monthRange * sizeof(MONTHDAYSTATE)); - SendMessageA(infoPtr->hwndNotify, WM_NOTIFY, + SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmds.nmhdr.idFrom, (LPARAM)&nmds); for(i=0; imonthRange; i++) infoPtr->monthdayState[i] = nmds.prgDayState[i]; @@ -1319,17 +1320,18 @@ static void MONTHCAL_GoToPrevMonth(MONTHCAL_INFO *infoPtr) static LRESULT MONTHCAL_RButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) { + static const WCHAR todayW[] = { 'G','o',' ','t','o',' ','T','o','d','a','y',':',0 }; HMENU hMenu; POINT menupoint; - char buf[32]; + WCHAR buf[32]; hMenu = CreatePopupMenu(); - if (!LoadStringA(COMCTL32_hModule,IDM_GOTODAY,buf,sizeof(buf))) + if (!LoadStringW(COMCTL32_hModule,IDM_GOTODAY,buf,countof(buf))) { WARN("Can't load resource\n"); - strcpy(buf,"Go to Today:"); + strcpyW(buf, todayW); } - AppendMenuA(hMenu, MF_STRING|MF_ENABLED,1, buf); + AppendMenuW(hMenu, MF_STRING|MF_ENABLED,1, buf); menupoint.x=(INT)LOWORD(lParam); menupoint.y=(INT)HIWORD(lParam); ClientToScreen(infoPtr->hwndSelf, &menupoint); @@ -1346,11 +1348,12 @@ MONTHCAL_RButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) static LRESULT MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) { + static const WCHAR EditW[] = { 'E','D','I','T',0 }; MCHITTESTINFO ht; DWORD hit; HMENU hMenu; RECT rcDay; /* used in determining area to invalidate */ - char buf[32]; + WCHAR buf[32]; int i; POINT menupoint; @@ -1358,7 +1361,7 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) if (infoPtr->hWndYearUpDown) { - infoPtr->currentYear=SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS, (WPARAM) 0,(LPARAM)0); + infoPtr->currentYear=SendMessageW( infoPtr->hWndYearUpDown, UDM_SETPOS, (WPARAM) 0,(LPARAM)0); if(!DestroyWindow(infoPtr->hWndYearUpDown)) { FIXME("Can't destroy Updown Control\n"); @@ -1401,9 +1404,8 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) for (i=0; i<12;i++) { - GetLocaleInfoA( LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i, - buf,sizeof(buf)); - AppendMenuA(hMenu, MF_STRING|MF_ENABLED,i+1, buf); + GetLocaleInfoW(LOCALE_USER_DEFAULT,LOCALE_SMONTHNAME1+i, buf,countof(buf)); + AppendMenuW(hMenu, MF_STRING|MF_ENABLED,i+1, buf); } menupoint.x=infoPtr->titlemonth.right; menupoint.y=infoPtr->titlemonth.bottom; @@ -1417,8 +1419,8 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) } } if(hit == MCHT_TITLEYEAR) { - infoPtr->hWndYearEdit=CreateWindowExA(0, - "EDIT", + infoPtr->hWndYearEdit=CreateWindowExW(0, + EditW, 0, WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT, infoPtr->titleyear.left+3,infoPtr->titlebtnnext.top, @@ -1428,8 +1430,8 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) NULL, NULL, NULL); - infoPtr->hWndYearUpDown=CreateWindowExA(0, - UPDOWN_CLASSA, + infoPtr->hWndYearUpDown=CreateWindowExW(0, + UPDOWN_CLASSW, 0, WS_VISIBLE | WS_CHILD |UDS_SETBUDDYINT|UDS_NOTHOUSANDS|UDS_ARROWKEYS, infoPtr->titleyear.right+6,infoPtr->titlebtnnext.top, @@ -1439,9 +1441,9 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) NULL, NULL, NULL); - SendMessageA( infoPtr->hWndYearUpDown, UDM_SETRANGE, (WPARAM) 0, MAKELONG (9999, 1753)); - SendMessageA( infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM) infoPtr->hWndYearEdit, (LPARAM)0 ); - SendMessageA( infoPtr->hWndYearUpDown, UDM_SETPOS, (WPARAM) 0,(LPARAM)infoPtr->currentYear ); + SendMessageW( infoPtr->hWndYearUpDown, UDM_SETRANGE, (WPARAM) 0, MAKELONG (9999, 1753)); + SendMessageW( infoPtr->hWndYearUpDown, UDM_SETBUDDY, (WPARAM) infoPtr->hWndYearEdit, (LPARAM)0 ); + SendMessageW( infoPtr->hWndYearUpDown, UDM_SETPOS, (WPARAM) 0,(LPARAM)infoPtr->currentYear ); return TRUE; } @@ -1466,7 +1468,7 @@ MONTHCAL_LButtonDown(MONTHCAL_INFO *infoPtr, LPARAM lParam) MONTHCAL_CopyTime(&infoPtr->minSel,&nmsc.stSelStart); MONTHCAL_CopyTime(&infoPtr->maxSel,&nmsc.stSelEnd); - SendMessageA(infoPtr->hwndNotify, WM_NOTIFY, + SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmsc.nmhdr.idFrom,(LPARAM)&nmsc); @@ -1532,8 +1534,7 @@ MONTHCAL_LButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam) nmhdr.code = NM_RELEASEDCAPTURE; TRACE("Sent notification from %p to %p\n", infoPtr->hwndSelf, infoPtr->hwndNotify); - SendMessageA(infoPtr->hwndNotify, WM_NOTIFY, - (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); + SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); /* redraw if necessary */ if(redraw) InvalidateRect(infoPtr->hwndSelf, NULL, FALSE); @@ -1545,8 +1546,7 @@ MONTHCAL_LButtonUp(MONTHCAL_INFO *infoPtr, LPARAM lParam) MONTHCAL_CopyTime(&infoPtr->minSel, &nmsc.stSelStart); MONTHCAL_CopyTime(&infoPtr->maxSel, &nmsc.stSelEnd); - SendMessageA(infoPtr->hwndNotify, WM_NOTIFY, - (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc); + SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmsc.nmhdr.idFrom, (LPARAM)&nmsc); } return 0; @@ -1699,6 +1699,8 @@ MONTHCAL_SetFocus(MONTHCAL_INFO *infoPtr) /* sets the size information */ static void MONTHCAL_UpdateSize(MONTHCAL_INFO *infoPtr) { + static const WCHAR SunW[] = { 'S','u','n',0 }; + static const WCHAR O0W[] = { '0','0',0 }; HDC hdc = GetDC(infoPtr->hwndSelf); RECT *title=&infoPtr->title; RECT *prev=&infoPtr->titlebtnprev; @@ -1710,7 +1712,7 @@ static void MONTHCAL_UpdateSize(MONTHCAL_INFO *infoPtr) RECT *days=&infoPtr->days; RECT *todayrect=&infoPtr->todayrect; SIZE size; - TEXTMETRICA tm; + TEXTMETRICW tm; DWORD dwStyle = GetWindowLongW(infoPtr->hwndSelf, GWL_STYLE); HFONT currentFont; int xdiv, left_offset; @@ -1721,13 +1723,13 @@ static void MONTHCAL_UpdateSize(MONTHCAL_INFO *infoPtr) currentFont = SelectObject(hdc, infoPtr->hFont); /* get the height and width of each day's text */ - GetTextMetricsA(hdc, &tm); + GetTextMetricsW(hdc, &tm); infoPtr->textHeight = tm.tmHeight + tm.tmExternalLeading + tm.tmInternalLeading; - GetTextExtentPoint32A(hdc, "Sun", 3, &size); + GetTextExtentPoint32W(hdc, SunW, 3, &size); infoPtr->textWidth = size.cx + 2; /* recalculate the height and width increments and offsets */ - GetTextExtentPoint32A(hdc, "00", 2, &size); + GetTextExtentPoint32W(hdc, O0W, 2, &size); xdiv = (dwStyle & MCS_WEEKNUMBERS) ? 8 : 7; @@ -1898,7 +1900,7 @@ MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) infoPtr = MONTHCAL_GetInfoPtr(hwnd); if (!infoPtr && (uMsg != WM_CREATE)) - return DefWindowProcA(hwnd, uMsg, wParam, lParam); + return DefWindowProcW(hwnd, uMsg, wParam, lParam); switch(uMsg) { case MCM_GETCURSEL: @@ -2009,7 +2011,7 @@ MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM 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); } } @@ -2017,23 +2019,23 @@ MONTHCAL_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) void MONTHCAL_Register(void) { - WNDCLASSA wndClass; + WNDCLASSW wndClass; - ZeroMemory(&wndClass, sizeof(WNDCLASSA)); + ZeroMemory(&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS; wndClass.lpfnWndProc = MONTHCAL_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(MONTHCAL_INFO *); - wndClass.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); + wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW); wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); - wndClass.lpszClassName = MONTHCAL_CLASSA; + wndClass.lpszClassName = MONTHCAL_CLASSW; - RegisterClassA(&wndClass); + RegisterClassW(&wndClass); } void MONTHCAL_Unregister(void) { - UnregisterClassA(MONTHCAL_CLASSA, NULL); + UnregisterClassW(MONTHCAL_CLASSW, NULL); } diff --git a/reactos/lib/comctl32/pager.c b/reactos/lib/comctl32/pager.c index bde664dd3bd..021489ef04d 100644 --- a/reactos/lib/comctl32/pager.c +++ b/reactos/lib/comctl32/pager.c @@ -18,8 +18,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * NOTES - * Tested primarily with the controlspy Pager application. - * Susan Farley (susan@codeweavers.com) * * This code was audited for completeness against the documented features * of Comctl32.dll version 6.0 on Sep. 18, 2004, by Robert Shearman. @@ -36,6 +34,20 @@ * PGS_DRAGNDROP * Notifications: * PGN_HOTITEMCHANGE + * + * TESTING: + * Tested primarily with the controlspy Pager application. + * Susan Farley (susan@codeweavers.com) + * + * IMPLEMENTATION NOTES: + * This control uses WM_NCPAINT instead of WM_PAINT to paint itself + * as we need to scroll a child window. In order to do this we move + * the child window in the control's client area, using the clipping + * region that is automatically set around the client area. As the + * entire client area now consists of the child window, we must + * allocate space (WM_NCCALCSIZE) for the buttons and draw them as + * a non-client area (WM_NCPAINT). + * Robert Shearman */ #include @@ -45,6 +57,7 @@ #include "wingdi.h" #include "winuser.h" #include "winnls.h" +#include "windowsx.h" #include "commctrl.h" #include "comctl32.h" #include "wine/debug.h" @@ -53,9 +66,10 @@ WINE_DEFAULT_DEBUG_CHANNEL(pager); typedef struct { + HWND hwndSelf; /* handle of the control wnd */ HWND hwndChild; /* handle of the contained wnd */ HWND hwndNotify; /* handle of the parent wnd */ - BOOL bNoResize; /* set when created with CCS_NORESIZE */ + DWORD dwStyle; /* styles for this control */ COLORREF clrBk; /* background color */ INT nBorder; /* border size for the control */ INT nButtonSize;/* size of the pager btns */ @@ -69,9 +83,6 @@ typedef struct INT direction; /* direction of the scroll, (e.g. PGF_SCROLLUP) */ } PAGER_INFO; -#define PAGER_GetInfoPtr(hwnd) ((PAGER_INFO *)GetWindowLongPtrW(hwnd, 0)) -#define PAGER_IsHorizontal(hwnd) ((GetWindowLongA (hwnd, GWL_STYLE) & PGS_HORZ)) - #define MIN_ARROW_WIDTH 8 #define MIN_ARROW_HEIGHT 5 @@ -81,22 +92,22 @@ typedef struct #define REPEAT_DELAY 50 static void -PAGER_GetButtonRects(HWND hwnd, PAGER_INFO* infoPtr, RECT* prcTopLeft, RECT* prcBottomRight, BOOL bClientCoords) +PAGER_GetButtonRects(PAGER_INFO* infoPtr, RECT* prcTopLeft, RECT* prcBottomRight, BOOL bClientCoords) { RECT rcWindow; - GetWindowRect (hwnd, &rcWindow); + GetWindowRect (infoPtr->hwndSelf, &rcWindow); if (bClientCoords) { POINT pt = {rcWindow.left, rcWindow.top}; - ScreenToClient(hwnd, &pt); + ScreenToClient(infoPtr->hwndSelf, &pt); OffsetRect(&rcWindow, -(rcWindow.left-pt.x), -(rcWindow.top-pt.y)); } else OffsetRect(&rcWindow, -rcWindow.left, -rcWindow.top); *prcTopLeft = *prcBottomRight = rcWindow; - if (PAGER_IsHorizontal(hwnd)) + if (infoPtr->dwStyle & PGS_HORZ) { prcTopLeft->right = prcTopLeft->left + infoPtr->nButtonSize; prcBottomRight->left = prcBottomRight->right - infoPtr->nButtonSize; @@ -277,23 +288,20 @@ PAGER_DrawButton(HDC hdc, COLORREF clrBk, RECT arrowRect, /* << PAGER_GetDropTarget >> */ static inline LRESULT -PAGER_ForwardMouse (HWND hwnd, WPARAM wParam) +PAGER_ForwardMouse (PAGER_INFO* infoPtr, BOOL bFwd) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - TRACE("[%p]\n", hwnd); + TRACE("[%p]\n", infoPtr->hwndSelf); - infoPtr->bForward = (BOOL)wParam; + infoPtr->bForward = bFwd; return 0; } static inline LRESULT -PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_GetButtonState (PAGER_INFO* infoPtr, INT btn) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); LRESULT btnState = PGF_INVISIBLE; - INT btn = (INT)lParam; - TRACE("[%p]\n", hwnd); + TRACE("[%p]\n", infoPtr->hwndSelf); if (btn == PGB_TOPORLEFT) btnState = infoPtr->TLbtnState; @@ -304,46 +312,41 @@ PAGER_GetButtonState (HWND hwnd, WPARAM wParam, LPARAM lParam) } -static inline LRESULT -PAGER_GetPos(HWND hwnd) +static inline INT +PAGER_GetPos(PAGER_INFO *infoPtr) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - TRACE("[%p] returns %d\n", hwnd, infoPtr->nPos); - return (LRESULT)infoPtr->nPos; + TRACE("[%p] returns %d\n", infoPtr->hwndSelf, infoPtr->nPos); + return infoPtr->nPos; } -static inline LRESULT -PAGER_GetButtonSize(HWND hwnd) +static inline INT +PAGER_GetButtonSize(PAGER_INFO *infoPtr) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - TRACE("[%p] returns %d\n", hwnd, infoPtr->nButtonSize); - return (LRESULT)infoPtr->nButtonSize; + TRACE("[%p] returns %d\n", infoPtr->hwndSelf, infoPtr->nButtonSize); + return infoPtr->nButtonSize; } -static inline LRESULT -PAGER_GetBorder(HWND hwnd) +static inline INT +PAGER_GetBorder(PAGER_INFO *infoPtr) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - TRACE("[%p] returns %d\n", hwnd, infoPtr->nBorder); - return (LRESULT)infoPtr->nBorder; + TRACE("[%p] returns %d\n", infoPtr->hwndSelf, infoPtr->nBorder); + return infoPtr->nBorder; } -static inline LRESULT -PAGER_GetBkColor(HWND hwnd) +static inline COLORREF +PAGER_GetBkColor(PAGER_INFO *infoPtr) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - TRACE("[%p] returns %06lx\n", hwnd, infoPtr->clrBk); - return (LRESULT)infoPtr->clrBk; + TRACE("[%p] returns %06lx\n", infoPtr->hwndSelf, infoPtr->clrBk); + return infoPtr->clrBk; } static void -PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) +PAGER_CalcSize (PAGER_INFO *infoPtr, INT* size, BOOL getWidth) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); NMPGCALCSIZE nmpgcs; ZeroMemory (&nmpgcs, sizeof (NMPGCALCSIZE)); - nmpgcs.hdr.hwndFrom = hwnd; - nmpgcs.hdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID); + nmpgcs.hdr.hwndFrom = infoPtr->hwndSelf; + nmpgcs.hdr.idFrom = GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_ID); nmpgcs.hdr.code = PGN_CALCSIZE; nmpgcs.dwFlag = getWidth ? PGF_CALCWIDTH : PGF_CALCHEIGHT; nmpgcs.iWidth = getWidth ? *size : 0; @@ -353,12 +356,12 @@ PAGER_CalcSize (HWND hwnd, INT* size, BOOL getWidth) *size = getWidth ? nmpgcs.iWidth : nmpgcs.iHeight; - TRACE("[%p] PGN_CALCSIZE returns %s=%d\n", hwnd, + TRACE("[%p] PGN_CALCSIZE returns %s=%d\n", infoPtr->hwndSelf, getWidth ? "width" : "height", *size); } static void -PAGER_PositionChildWnd(HWND hwnd, PAGER_INFO* infoPtr) +PAGER_PositionChildWnd(PAGER_INFO* infoPtr) { if (infoPtr->hwndChild) { @@ -369,15 +372,15 @@ PAGER_PositionChildWnd(HWND hwnd, PAGER_INFO* infoPtr) if (infoPtr->TLbtnState == PGF_GRAYED) nPos += infoPtr->nButtonSize; - GetClientRect(hwnd, &rcClient); + GetClientRect(infoPtr->hwndSelf, &rcClient); - if (PAGER_IsHorizontal(hwnd)) + if (infoPtr->dwStyle & PGS_HORZ) { int wndSize = max(0, rcClient.right - rcClient.left); if (infoPtr->nWidth < wndSize) infoPtr->nWidth = wndSize; - TRACE("[%p] SWP %dx%d at (%d,%d)\n", hwnd, + TRACE("[%p] SWP %dx%d at (%d,%d)\n", infoPtr->hwndSelf, infoPtr->nWidth, infoPtr->nHeight, -nPos, 0); SetWindowPos(infoPtr->hwndChild, 0, @@ -391,7 +394,7 @@ PAGER_PositionChildWnd(HWND hwnd, PAGER_INFO* infoPtr) if (infoPtr->nHeight < wndSize) infoPtr->nHeight = wndSize; - TRACE("[%p] SWP %dx%d at (%d,%d)\n", hwnd, + TRACE("[%p] SWP %dx%d at (%d,%d)\n", infoPtr->hwndSelf, infoPtr->nWidth, infoPtr->nHeight, 0, -nPos); SetWindowPos(infoPtr->hwndChild, 0, @@ -405,7 +408,7 @@ PAGER_PositionChildWnd(HWND hwnd, PAGER_INFO* infoPtr) } static INT -PAGER_GetScrollRange(HWND hwnd, PAGER_INFO* infoPtr) +PAGER_GetScrollRange(PAGER_INFO* infoPtr) { INT scrollRange = 0; @@ -413,18 +416,18 @@ PAGER_GetScrollRange(HWND hwnd, PAGER_INFO* infoPtr) { INT wndSize, childSize; RECT wndRect; - GetWindowRect(hwnd, &wndRect); + GetWindowRect(infoPtr->hwndSelf, &wndRect); - if (PAGER_IsHorizontal(hwnd)) + if (infoPtr->dwStyle & PGS_HORZ) { wndSize = wndRect.right - wndRect.left; - PAGER_CalcSize(hwnd, &infoPtr->nWidth, TRUE); + PAGER_CalcSize(infoPtr, &infoPtr->nWidth, TRUE); childSize = infoPtr->nWidth; } else { wndSize = wndRect.bottom - wndRect.top; - PAGER_CalcSize(hwnd, &infoPtr->nHeight, FALSE); + PAGER_CalcSize(infoPtr, &infoPtr->nHeight, FALSE); childSize = infoPtr->nHeight; } @@ -433,13 +436,12 @@ PAGER_GetScrollRange(HWND hwnd, PAGER_INFO* infoPtr) scrollRange = childSize - wndSize + infoPtr->nButtonSize; } - TRACE("[%p] returns %d\n", hwnd, scrollRange); + TRACE("[%p] returns %d\n", infoPtr->hwndSelf, scrollRange); return scrollRange; } static void -PAGER_UpdateBtns(HWND hwnd, PAGER_INFO *infoPtr, - INT scrollRange, BOOL hideGrayBtns) +PAGER_UpdateBtns(PAGER_INFO *infoPtr, INT scrollRange, BOOL hideGrayBtns) { BOOL resizeClient; BOOL repaintBtns; @@ -449,7 +451,7 @@ PAGER_UpdateBtns(HWND hwnd, PAGER_INFO *infoPtr, RECT rcTopLeft, rcBottomRight; /* get button rects */ - PAGER_GetButtonRects(hwnd, infoPtr, &rcTopLeft, &rcBottomRight, FALSE); + PAGER_GetButtonRects(infoPtr, &rcTopLeft, &rcBottomRight, FALSE); GetCursorPos(&pt); @@ -485,7 +487,7 @@ PAGER_UpdateBtns(HWND hwnd, PAGER_INFO *infoPtr, ((oldBRbtnState == PGF_INVISIBLE) != (infoPtr->BRbtnState == PGF_INVISIBLE)); /* initiate NCCalcSize to resize client wnd if necessary */ if (resizeClient) - SetWindowPos(hwnd, 0,0,0,0,0, + SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); @@ -493,14 +495,13 @@ PAGER_UpdateBtns(HWND hwnd, PAGER_INFO *infoPtr, repaintBtns = (oldTLbtnState != infoPtr->TLbtnState) || (oldBRbtnState != infoPtr->BRbtnState); if (repaintBtns) - SendMessageW(hwnd, WM_NCPAINT, 0, 0); + SendMessageW(infoPtr->hwndSelf, WM_NCPAINT, 0, 0); } static LRESULT -PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress) +PAGER_SetPos(PAGER_INFO* infoPtr, INT newPos, BOOL fromBtnPress) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - INT scrollRange = PAGER_GetScrollRange(hwnd, infoPtr); + INT scrollRange = PAGER_GetScrollRange(infoPtr); INT oldPos = infoPtr->nPos; if ((scrollRange <= 0) || (newPos < 0)) @@ -510,24 +511,22 @@ PAGER_SetPos(HWND hwnd, INT newPos, BOOL fromBtnPress) else infoPtr->nPos = newPos; - TRACE("[%p] pos=%d, oldpos=%d\n", hwnd, infoPtr->nPos, oldPos); + TRACE("[%p] pos=%d, oldpos=%d\n", infoPtr->hwndSelf, infoPtr->nPos, oldPos); if (infoPtr->nPos != oldPos) { /* gray and restore btns, and if from WM_SETPOS, hide the gray btns */ - PAGER_UpdateBtns(hwnd, infoPtr, scrollRange, !fromBtnPress); - PAGER_PositionChildWnd(hwnd, infoPtr); + PAGER_UpdateBtns(infoPtr, scrollRange, !fromBtnPress); + PAGER_PositionChildWnd(infoPtr); } return 0; } static LRESULT -PAGER_HandleWindowPosChanging(HWND hwnd, WPARAM wParam, WINDOWPOS *winpos) +PAGER_WindowPosChanging(PAGER_INFO* infoPtr, WINDOWPOS *winpos) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - - if (infoPtr->bNoResize && !(winpos->flags & SWP_NOSIZE)) + if ((infoPtr->dwStyle & CCS_NORESIZE) && !(winpos->flags & SWP_NOSIZE)) { /* don't let the app resize the nonscrollable dimension of a control * that was created with CCS_NORESIZE style @@ -536,7 +535,7 @@ PAGER_HandleWindowPosChanging(HWND hwnd, WPARAM wParam, WINDOWPOS *winpos) /* except if the current dimension is 0 and app is setting for * first time, then save amount as dimension. - GA 8/01 */ - if (PAGER_IsHorizontal(hwnd)) + if (infoPtr->dwStyle & PGS_HORZ) if (!infoPtr->nHeight && winpos->cy) infoPtr->nHeight = winpos->cy; else @@ -549,13 +548,11 @@ PAGER_HandleWindowPosChanging(HWND hwnd, WPARAM wParam, WINDOWPOS *winpos) return 0; } - DefWindowProcW (hwnd, WM_WINDOWPOSCHANGING, wParam, (LPARAM)winpos); - - return 1; + return DefWindowProcW (infoPtr->hwndSelf, WM_WINDOWPOSCHANGING, 0, (LPARAM)winpos); } static INT -PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr) +PAGER_SetFixedWidth(PAGER_INFO* infoPtr) { /* Must set the non-scrollable dimension to be less than the full height/width * so that NCCalcSize is called. The Msoft docs mention 3/4 factor for button @@ -563,12 +560,12 @@ PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr) RECT wndRect; INT delta, h; - GetWindowRect(hwnd, &wndRect); + GetWindowRect(infoPtr->hwndSelf, &wndRect); /* see what the app says for btn width */ - PAGER_CalcSize(hwnd, &infoPtr->nWidth, TRUE); + PAGER_CalcSize(infoPtr, &infoPtr->nWidth, TRUE); - if (infoPtr->bNoResize) + if (infoPtr->dwStyle & CCS_NORESIZE) { delta = wndRect.right - wndRect.left - infoPtr->nWidth; if (delta > infoPtr->nButtonSize) @@ -580,13 +577,13 @@ PAGER_SetFixedWidth(HWND hwnd, PAGER_INFO* infoPtr) h = wndRect.bottom - wndRect.top + infoPtr->nButtonSize; TRACE("[%p] infoPtr->nWidth set to %d\n", - hwnd, infoPtr->nWidth); + infoPtr->hwndSelf, infoPtr->nWidth); return h; } static INT -PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr) +PAGER_SetFixedHeight(PAGER_INFO* infoPtr) { /* Must set the non-scrollable dimension to be less than the full height/width * so that NCCalcSize is called. The Msoft docs mention 3/4 factor for button @@ -594,12 +591,12 @@ PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr) RECT wndRect; INT delta, w; - GetWindowRect(hwnd, &wndRect); + GetWindowRect(infoPtr->hwndSelf, &wndRect); /* see what the app says for btn height */ - PAGER_CalcSize(hwnd, &infoPtr->nHeight, FALSE); + PAGER_CalcSize(infoPtr, &infoPtr->nHeight, FALSE); - if (infoPtr->bNoResize) + if (infoPtr->dwStyle & CCS_NORESIZE) { delta = wndRect.bottom - wndRect.top - infoPtr->nHeight; if (delta > infoPtr->nButtonSize) @@ -611,7 +608,7 @@ PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr) w = wndRect.right - wndRect.left + infoPtr->nButtonSize; TRACE("[%p] infoPtr->nHeight set to %d\n", - hwnd, infoPtr->nHeight); + infoPtr->hwndSelf, infoPtr->nHeight); return w; } @@ -629,102 +626,96 @@ PAGER_SetFixedHeight(HWND hwnd, PAGER_INFO* infoPtr) ******************************************************************/ static LRESULT -PAGER_RecalcSize(HWND hwnd) +PAGER_RecalcSize(PAGER_INFO *infoPtr) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - - TRACE("[%p]\n", hwnd); + TRACE("[%p]\n", infoPtr->hwndSelf); if (infoPtr->hwndChild) { - INT scrollRange = PAGER_GetScrollRange(hwnd, infoPtr); + INT scrollRange = PAGER_GetScrollRange(infoPtr); if (scrollRange <= 0) { infoPtr->nPos = -1; - PAGER_SetPos(hwnd, 0, FALSE); + PAGER_SetPos(infoPtr, 0, FALSE); } else - PAGER_PositionChildWnd(hwnd, infoPtr); + PAGER_PositionChildWnd(infoPtr); } return 1; } -static LRESULT -PAGER_SetBkColor (HWND hwnd, WPARAM wParam, LPARAM lParam) +static COLORREF +PAGER_SetBkColor (PAGER_INFO* infoPtr, COLORREF clrBk) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); COLORREF clrTemp = infoPtr->clrBk; - infoPtr->clrBk = (COLORREF)lParam; - TRACE("[%p] %06lx\n", hwnd, infoPtr->clrBk); + infoPtr->clrBk = clrBk; + TRACE("[%p] %06lx\n", infoPtr->hwndSelf, infoPtr->clrBk); /* the native control seems to do things this way */ - SetWindowPos(hwnd, 0,0,0,0,0, + SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); - RedrawWindow(hwnd, 0, 0, RDW_ERASE | RDW_INVALIDATE); + RedrawWindow(infoPtr->hwndSelf, 0, 0, RDW_ERASE | RDW_INVALIDATE); - return (LRESULT)clrTemp; + return clrTemp; } -static LRESULT -PAGER_SetBorder (HWND hwnd, WPARAM wParam, LPARAM lParam) +static INT +PAGER_SetBorder (PAGER_INFO* infoPtr, INT iBorder) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); INT nTemp = infoPtr->nBorder; - infoPtr->nBorder = (INT)lParam; - TRACE("[%p] %d\n", hwnd, infoPtr->nBorder); + infoPtr->nBorder = iBorder; + TRACE("[%p] %d\n", infoPtr->hwndSelf, infoPtr->nBorder); - PAGER_RecalcSize(hwnd); + PAGER_RecalcSize(infoPtr); - return (LRESULT)nTemp; + return nTemp; } -static LRESULT -PAGER_SetButtonSize (HWND hwnd, WPARAM wParam, LPARAM lParam) +static INT +PAGER_SetButtonSize (PAGER_INFO* infoPtr, INT iButtonSize) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); INT nTemp = infoPtr->nButtonSize; - infoPtr->nButtonSize = (INT)lParam; - TRACE("[%p] %d\n", hwnd, infoPtr->nButtonSize); + infoPtr->nButtonSize = iButtonSize; + TRACE("[%p] %d\n", infoPtr->hwndSelf, infoPtr->nButtonSize); - PAGER_RecalcSize(hwnd); + PAGER_RecalcSize(infoPtr); - return (LRESULT)nTemp; + return nTemp; } static LRESULT -PAGER_SetChild (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_SetChild (PAGER_INFO* infoPtr, HWND hwndChild) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); INT hw; - infoPtr->hwndChild = IsWindow ((HWND)lParam) ? (HWND)lParam : 0; + infoPtr->hwndChild = IsWindow (hwndChild) ? hwndChild : 0; if (infoPtr->hwndChild) { - TRACE("[%p] hwndChild=%p\n", hwnd, infoPtr->hwndChild); + TRACE("[%p] hwndChild=%p\n", infoPtr->hwndSelf, infoPtr->hwndChild); - if (PAGER_IsHorizontal(hwnd)) { - hw = PAGER_SetFixedHeight(hwnd, infoPtr); + if (infoPtr->dwStyle & PGS_HORZ) { + hw = PAGER_SetFixedHeight(infoPtr); /* adjust non-scrollable dimension to fit the child */ - SetWindowPos(hwnd, 0, 0,0, hw, infoPtr->nHeight, + SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, hw, infoPtr->nHeight, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); } else { - hw = PAGER_SetFixedWidth(hwnd, infoPtr); + hw = PAGER_SetFixedWidth(infoPtr); /* adjust non-scrollable dimension to fit the child */ - SetWindowPos(hwnd, 0, 0,0, infoPtr->nWidth, hw, + SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, infoPtr->nWidth, hw, SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE); } @@ -735,32 +726,31 @@ PAGER_SetChild (HWND hwnd, WPARAM wParam, LPARAM lParam) SWP_SHOWWINDOW | SWP_NOSIZE); /* native is 0 */ infoPtr->nPos = -1; - PAGER_SetPos(hwnd, 0, FALSE); + PAGER_SetPos(infoPtr, 0, FALSE); } return 0; } static void -PAGER_Scroll(HWND hwnd, INT dir) +PAGER_Scroll(PAGER_INFO* infoPtr, INT dir) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); NMPGSCROLL nmpgScroll; RECT rcWnd; if (infoPtr->hwndChild) { ZeroMemory (&nmpgScroll, sizeof (NMPGSCROLL)); - nmpgScroll.hdr.hwndFrom = hwnd; - nmpgScroll.hdr.idFrom = GetWindowLongPtrW (hwnd, GWLP_ID); + nmpgScroll.hdr.hwndFrom = infoPtr->hwndSelf; + nmpgScroll.hdr.idFrom = GetWindowLongPtrW (infoPtr->hwndSelf, GWLP_ID); nmpgScroll.hdr.code = PGN_SCROLL; - GetWindowRect(hwnd, &rcWnd); - GetClientRect(hwnd, &nmpgScroll.rcParent); + GetWindowRect(infoPtr->hwndSelf, &rcWnd); + GetClientRect(infoPtr->hwndSelf, &nmpgScroll.rcParent); nmpgScroll.iXpos = nmpgScroll.iYpos = 0; nmpgScroll.iDir = dir; - if (PAGER_IsHorizontal(hwnd)) + if (infoPtr->dwStyle & PGS_HORZ) { nmpgScroll.iScroll = rcWnd.right - rcWnd.left; nmpgScroll.iXpos = infoPtr->nPos; @@ -775,16 +765,16 @@ PAGER_Scroll(HWND hwnd, INT dir) SendMessageW (infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmpgScroll.hdr.idFrom, (LPARAM)&nmpgScroll); - TRACE("[%p] PGN_SCROLL returns iScroll=%d\n", hwnd, nmpgScroll.iScroll); + TRACE("[%p] PGN_SCROLL returns iScroll=%d\n", infoPtr->hwndSelf, nmpgScroll.iScroll); if (nmpgScroll.iScroll > 0) { infoPtr->direction = dir; if (dir == PGF_SCROLLLEFT || dir == PGF_SCROLLUP) - PAGER_SetPos(hwnd, infoPtr->nPos - nmpgScroll.iScroll, TRUE); + PAGER_SetPos(infoPtr, infoPtr->nPos - nmpgScroll.iScroll, TRUE); else - PAGER_SetPos(hwnd, infoPtr->nPos + nmpgScroll.iScroll, TRUE); + PAGER_SetPos(infoPtr, infoPtr->nPos + nmpgScroll.iScroll, TRUE); } else infoPtr->direction = -1; @@ -792,12 +782,10 @@ PAGER_Scroll(HWND hwnd, INT dir) } static LRESULT -PAGER_FmtLines(HWND hwnd) +PAGER_FmtLines(PAGER_INFO *infoPtr) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - /* initiate NCCalcSize to resize client wnd and get size */ - SetWindowPos(hwnd, 0, 0,0,0,0, + SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); @@ -805,23 +793,24 @@ PAGER_FmtLines(HWND hwnd) 0,0,infoPtr->nWidth,infoPtr->nHeight, 0); - return DefWindowProcW (hwnd, EM_FMTLINES, 0, 0); + return DefWindowProcW (infoPtr->hwndSelf, EM_FMTLINES, 0, 0); } static LRESULT -PAGER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_Create (HWND hwnd, LPCREATESTRUCTW lpcs) { PAGER_INFO *infoPtr; - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); /* allocate memory for info structure */ infoPtr = (PAGER_INFO *)Alloc (sizeof(PAGER_INFO)); + if (!infoPtr) return -1; SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); /* set default settings */ + infoPtr->hwndSelf = hwnd; infoPtr->hwndChild = NULL; - infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent; - infoPtr->bNoResize = dwStyle & CCS_NORESIZE; + infoPtr->hwndNotify = lpcs->hwndParent; + infoPtr->dwStyle = lpcs->style; infoPtr->clrBk = GetSysColor(COLOR_BTNFACE); infoPtr->nBorder = 0; infoPtr->nButtonSize = 12; @@ -834,50 +823,46 @@ PAGER_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->BRbtnState = PGF_INVISIBLE; infoPtr->direction = -1; - if (dwStyle & PGS_DRAGNDROP) - FIXME("[%p] Drag and Drop style is not implemented yet.\n", hwnd); + if (infoPtr->dwStyle & PGS_DRAGNDROP) + FIXME("[%p] Drag and Drop style is not implemented yet.\n", infoPtr->hwndSelf); return 0; } static LRESULT -PAGER_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_Destroy (PAGER_INFO *infoPtr) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - /* free pager info data */ - Free (infoPtr); - SetWindowLongPtrW (hwnd, 0, 0); + SetWindowLongPtrW (infoPtr->hwndSelf, 0, 0); + Free (infoPtr); /* free pager info data */ return 0; } static LRESULT -PAGER_NCCalcSize(HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_NCCalcSize(PAGER_INFO* infoPtr, WPARAM wParam, LPRECT lpRect) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - LPRECT lpRect = (LPRECT)lParam; RECT rcChild, rcWindow; INT scrollRange; /* - * lParam points to a RECT struct. On entry, the struct + * lpRect points to a RECT struct. On entry, the struct * contains the proposed wnd rectangle for the window. * On exit, the struct should contain the screen * coordinates of the corresponding window's client area. */ - DefWindowProcW (hwnd, WM_NCCALCSIZE, wParam, lParam); + DefWindowProcW (infoPtr->hwndSelf, WM_NCCALCSIZE, wParam, (LPARAM)lpRect); TRACE("orig rect=%s\n", wine_dbgstr_rect(lpRect)); GetWindowRect (infoPtr->hwndChild, &rcChild); - MapWindowPoints (0, hwnd, (LPPOINT)&rcChild, 2); /* FIXME: RECT != 2 POINTS */ - GetWindowRect (hwnd, &rcWindow); + MapWindowPoints (0, infoPtr->hwndSelf, (LPPOINT)&rcChild, 2); /* FIXME: RECT != 2 POINTS */ + GetWindowRect (infoPtr->hwndSelf, &rcWindow); - if (PAGER_IsHorizontal(hwnd)) + if (infoPtr->dwStyle & PGS_HORZ) { infoPtr->nWidth = lpRect->right - lpRect->left; - PAGER_CalcSize (hwnd, &infoPtr->nWidth, TRUE); + PAGER_CalcSize (infoPtr, &infoPtr->nWidth, TRUE); scrollRange = infoPtr->nWidth - (rcWindow.right - rcWindow.left); @@ -889,7 +874,7 @@ PAGER_NCCalcSize(HWND hwnd, WPARAM wParam, LPARAM lParam) else { infoPtr->nHeight = lpRect->bottom - lpRect->top; - PAGER_CalcSize (hwnd, &infoPtr->nHeight, FALSE); + PAGER_CalcSize (infoPtr, &infoPtr->nHeight, FALSE); scrollRange = infoPtr->nHeight - (rcWindow.bottom - rcWindow.top); @@ -904,7 +889,7 @@ PAGER_NCCalcSize(HWND hwnd, WPARAM wParam, LPARAM lParam) wine_dbgstr_rect(&rcWindow)); TRACE("[%p] client rect set to %ldx%ld at (%ld,%ld) BtnState[%d,%d]\n", - hwnd, lpRect->right-lpRect->left, lpRect->bottom-lpRect->top, + infoPtr->hwndSelf, lpRect->right-lpRect->left, lpRect->bottom-lpRect->top, lpRect->left, lpRect->top, infoPtr->TLbtnState, infoPtr->BRbtnState); @@ -912,41 +897,37 @@ PAGER_NCCalcSize(HWND hwnd, WPARAM wParam, LPARAM lParam) } static LRESULT -PAGER_NCPaint (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_NCPaint (PAGER_INFO* infoPtr, HRGN hRgn) { - PAGER_INFO* infoPtr = PAGER_GetInfoPtr(hwnd); - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); RECT rcBottomRight, rcTopLeft; HDC hdc; - BOOL bHorizontal = PAGER_IsHorizontal(hwnd); - if (dwStyle & WS_MINIMIZE) + if (infoPtr->dwStyle & WS_MINIMIZE) return 0; - DefWindowProcW (hwnd, WM_NCPAINT, wParam, lParam); + DefWindowProcW (infoPtr->hwndSelf, WM_NCPAINT, (WPARAM)hRgn, 0); - if (!(hdc = GetDCEx (hwnd, 0, DCX_USESTYLE | DCX_WINDOW))) + if (!(hdc = GetDCEx (infoPtr->hwndSelf, 0, DCX_USESTYLE | DCX_WINDOW))) return 0; - PAGER_GetButtonRects(hwnd, infoPtr, &rcTopLeft, &rcBottomRight, FALSE); + PAGER_GetButtonRects(infoPtr, &rcTopLeft, &rcBottomRight, FALSE); PAGER_DrawButton(hdc, infoPtr->clrBk, rcTopLeft, - bHorizontal, TRUE, infoPtr->TLbtnState); + infoPtr->dwStyle & PGS_HORZ, TRUE, infoPtr->TLbtnState); PAGER_DrawButton(hdc, infoPtr->clrBk, rcBottomRight, - bHorizontal, FALSE, infoPtr->BRbtnState); + infoPtr->dwStyle & PGS_HORZ, FALSE, infoPtr->BRbtnState); - ReleaseDC( hwnd, hdc ); + ReleaseDC( infoPtr->hwndSelf, hdc ); return 0; } static INT -PAGER_HitTest (HWND hwnd, const POINT * pt) +PAGER_HitTest (PAGER_INFO* infoPtr, const POINT * pt) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); RECT clientRect, rcTopLeft, rcBottomRight; POINT ptWindow; - GetClientRect (hwnd, &clientRect); + GetClientRect (infoPtr->hwndSelf, &clientRect); if (PtInRect(&clientRect, *pt)) { @@ -955,7 +936,7 @@ PAGER_HitTest (HWND hwnd, const POINT * pt) } ptWindow = *pt; - PAGER_GetButtonRects(hwnd, infoPtr, &rcTopLeft, &rcBottomRight, TRUE); + PAGER_GetButtonRects(infoPtr, &rcTopLeft, &rcBottomRight, TRUE); if ((infoPtr->TLbtnState != PGF_INVISIBLE) && PtInRect(&rcTopLeft, ptWindow)) { @@ -973,46 +954,43 @@ PAGER_HitTest (HWND hwnd, const POINT * pt) } static LRESULT -PAGER_NCHitTest (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_NCHitTest (PAGER_INFO* infoPtr, INT x, INT y) { POINT pt; INT nHit; - pt.x = (short)LOWORD(lParam); - pt.y = (short)HIWORD(lParam); + pt.x = x; + pt.y = y; - ScreenToClient (hwnd, &pt); - nHit = PAGER_HitTest(hwnd, &pt); - if (nHit < 0) - return HTTRANSPARENT; - return HTCLIENT; + ScreenToClient (infoPtr->hwndSelf, &pt); + nHit = PAGER_HitTest(infoPtr, &pt); + + return (nHit < 0) ? HTTRANSPARENT : HTCLIENT; } static LRESULT -PAGER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_MouseMove (PAGER_INFO* infoPtr, INT keys, INT x, INT y) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); POINT clpt, pt; RECT wnrect, *btnrect = NULL; - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); BOOL topLeft = FALSE; INT btnstate = 0; INT hit; HDC hdc; - pt.x = (short)LOWORD(lParam); - pt.y = (short)HIWORD(lParam); + pt.x = x; + pt.y = y; - TRACE("[%p] to (%ld,%ld)\n", hwnd, pt.x, pt.y); - ClientToScreen(hwnd, &pt); - GetWindowRect(hwnd, &wnrect); + TRACE("[%p] to (%d,%d)\n", infoPtr->hwndSelf, x, y); + ClientToScreen(infoPtr->hwndSelf, &pt); + GetWindowRect(infoPtr->hwndSelf, &wnrect); if (PtInRect(&wnrect, pt)) { RECT TLbtnrect, BRbtnrect; - PAGER_GetButtonRects(hwnd, infoPtr, &TLbtnrect, &BRbtnrect, FALSE); + PAGER_GetButtonRects(infoPtr, &TLbtnrect, &BRbtnrect, FALSE); clpt = pt; - MapWindowPoints(0, hwnd, &clpt, 1); - hit = PAGER_HitTest(hwnd, &clpt); + MapWindowPoints(0, infoPtr->hwndSelf, &clpt, 1); + hit = PAGER_HitTest(infoPtr, &clpt); if ((hit == PGB_TOPORLEFT) && (infoPtr->TLbtnState == PGF_NORMAL)) { topLeft = TRUE; @@ -1032,42 +1010,42 @@ PAGER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) if (btnrect) { TRACE("[%p] draw btn (%ld,%ld)-(%ld,%ld), Capture %s, style %08lx\n", - hwnd, btnrect->left, btnrect->top, + infoPtr->hwndSelf, btnrect->left, btnrect->top, btnrect->right, btnrect->bottom, (infoPtr->bCapture) ? "TRUE" : "FALSE", - dwStyle); + infoPtr->dwStyle); if (!infoPtr->bCapture) { - TRACE("[%p] SetCapture\n", hwnd); - SetCapture(hwnd); + TRACE("[%p] SetCapture\n", infoPtr->hwndSelf); + SetCapture(infoPtr->hwndSelf); infoPtr->bCapture = TRUE; } - if (dwStyle & PGS_AUTOSCROLL) - SetTimer(hwnd, TIMERID1, 0x3e, 0); - hdc = GetWindowDC(hwnd); + if (infoPtr->dwStyle & PGS_AUTOSCROLL) + SetTimer(infoPtr->hwndSelf, TIMERID1, 0x3e, 0); + hdc = GetWindowDC(infoPtr->hwndSelf); /* OffsetRect(wnrect, 0 | 1, 0 | 1) */ PAGER_DrawButton(hdc, infoPtr->clrBk, *btnrect, - PAGER_IsHorizontal(hwnd), topLeft, btnstate); - ReleaseDC(hwnd, hdc); + infoPtr->dwStyle & PGS_HORZ, topLeft, btnstate); + ReleaseDC(infoPtr->hwndSelf, hdc); return 0; } } /* If we think we are captured, then do release */ - if (infoPtr->bCapture && (WindowFromPoint(pt) != hwnd)) + if (infoPtr->bCapture && (WindowFromPoint(pt) != infoPtr->hwndSelf)) { NMHDR nmhdr; infoPtr->bCapture = FALSE; - if (GetCapture() == hwnd) + if (GetCapture() == infoPtr->hwndSelf) { ReleaseCapture(); if (infoPtr->TLbtnState == PGF_GRAYED) { infoPtr->TLbtnState = PGF_INVISIBLE; - SetWindowPos(hwnd, 0,0,0,0,0, + SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); } @@ -1075,13 +1053,13 @@ PAGER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) { infoPtr->TLbtnState = PGF_NORMAL; /* FIXME: just invalidate button rect */ - RedrawWindow(hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); + RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); } if (infoPtr->BRbtnState == PGF_GRAYED) { infoPtr->BRbtnState = PGF_INVISIBLE; - SetWindowPos(hwnd, 0,0,0,0,0, + SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); } @@ -1089,96 +1067,94 @@ PAGER_MouseMove (HWND hwnd, WPARAM wParam, LPARAM lParam) { infoPtr->BRbtnState = PGF_NORMAL; /* FIXME: just invalidate button rect */ - RedrawWindow(hwnd, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); + RedrawWindow(infoPtr->hwndSelf, NULL, NULL, RDW_FRAME | RDW_INVALIDATE); } /* Notify parent of released mouse capture */ memset(&nmhdr, 0, sizeof(NMHDR)); - nmhdr.hwndFrom = hwnd; - nmhdr.idFrom = GetWindowLongPtrW(hwnd, GWLP_ID); + nmhdr.hwndFrom = infoPtr->hwndSelf; + nmhdr.idFrom = GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_ID); nmhdr.code = NM_RELEASEDCAPTURE; SendMessageW(infoPtr->hwndNotify, WM_NOTIFY, (WPARAM)nmhdr.idFrom, (LPARAM)&nmhdr); } - if (IsWindow(hwnd)) - KillTimer(hwnd, TIMERID1); + if (IsWindow(infoPtr->hwndSelf)) + KillTimer(infoPtr->hwndSelf, TIMERID1); } return 0; } static LRESULT -PAGER_LButtonDown (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_LButtonDown (PAGER_INFO* infoPtr, INT keys, INT x, INT y) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); BOOL repaintBtns = FALSE; POINT pt; INT hit; - pt.x = (short)LOWORD(lParam); - pt.y = (short)HIWORD(lParam); + pt.x = x; + pt.y = y; - TRACE("[%p] at (%d,%d)\n", hwnd, (short)LOWORD(lParam), (short)HIWORD(lParam)); + TRACE("[%p] at (%d,%d)\n", infoPtr->hwndSelf, x, y); - hit = PAGER_HitTest(hwnd, &pt); + hit = PAGER_HitTest(infoPtr, &pt); /* put btn in DEPRESSED state */ if (hit == PGB_TOPORLEFT) { repaintBtns = infoPtr->TLbtnState != PGF_DEPRESSED; infoPtr->TLbtnState = PGF_DEPRESSED; - SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); + SetTimer(infoPtr->hwndSelf, TIMERID1, INITIAL_DELAY, 0); } else if (hit == PGB_BOTTOMORRIGHT) { repaintBtns = infoPtr->BRbtnState != PGF_DEPRESSED; infoPtr->BRbtnState = PGF_DEPRESSED; - SetTimer(hwnd, TIMERID1, INITIAL_DELAY, 0); + SetTimer(infoPtr->hwndSelf, TIMERID1, INITIAL_DELAY, 0); } if (repaintBtns) - SendMessageW(hwnd, WM_NCPAINT, 0, 0); + SendMessageW(infoPtr->hwndSelf, WM_NCPAINT, 0, 0); switch(hit) { case PGB_TOPORLEFT: - if (PAGER_IsHorizontal(hwnd)) + if (infoPtr->dwStyle & PGS_HORZ) { - TRACE("[%p] PGF_SCROLLLEFT\n", hwnd); - PAGER_Scroll(hwnd, PGF_SCROLLLEFT); + TRACE("[%p] PGF_SCROLLLEFT\n", infoPtr->hwndSelf); + PAGER_Scroll(infoPtr, PGF_SCROLLLEFT); } else { - TRACE("[%p] PGF_SCROLLUP\n", hwnd); - PAGER_Scroll(hwnd, PGF_SCROLLUP); + TRACE("[%p] PGF_SCROLLUP\n", infoPtr->hwndSelf); + PAGER_Scroll(infoPtr, PGF_SCROLLUP); } break; case PGB_BOTTOMORRIGHT: - if (PAGER_IsHorizontal(hwnd)) + if (infoPtr->dwStyle & PGS_HORZ) { - TRACE("[%p] PGF_SCROLLRIGHT\n", hwnd); - PAGER_Scroll(hwnd, PGF_SCROLLRIGHT); + TRACE("[%p] PGF_SCROLLRIGHT\n", infoPtr->hwndSelf); + PAGER_Scroll(infoPtr, PGF_SCROLLRIGHT); } else { - TRACE("[%p] PGF_SCROLLDOWN\n", hwnd); - PAGER_Scroll(hwnd, PGF_SCROLLDOWN); + TRACE("[%p] PGF_SCROLLDOWN\n", infoPtr->hwndSelf); + PAGER_Scroll(infoPtr, PGF_SCROLLDOWN); } break; default: break; } - return TRUE; + return 0; } static LRESULT -PAGER_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_LButtonUp (PAGER_INFO* infoPtr, INT keys, INT x, INT y) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - TRACE("[%p]\n", hwnd); + TRACE("[%p]\n", infoPtr->hwndSelf); - KillTimer (hwnd, TIMERID1); - KillTimer (hwnd, TIMERID2); + KillTimer (infoPtr->hwndSelf, TIMERID1); + KillTimer (infoPtr->hwndSelf, TIMERID2); /* make PRESSED btns NORMAL but don't hide gray btns */ if (infoPtr->TLbtnState & (PGF_HOT | PGF_DEPRESSED)) @@ -1190,26 +1166,25 @@ PAGER_LButtonUp (HWND hwnd, WPARAM wParam, LPARAM lParam) } static LRESULT -PAGER_Timer (HWND hwnd, WPARAM wParam) +PAGER_Timer (PAGER_INFO* infoPtr, INT nTimerId) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); INT dir; /* if initial timer, kill it and start the repeat timer */ - if (wParam == TIMERID1) { + if (nTimerId == TIMERID1) { if (infoPtr->TLbtnState == PGF_HOT) - dir = PAGER_IsHorizontal(hwnd) ? + dir = (infoPtr->dwStyle & PGS_HORZ) ? PGF_SCROLLLEFT : PGF_SCROLLUP; else - dir = PAGER_IsHorizontal(hwnd) ? + dir = (infoPtr->dwStyle & PGS_HORZ) ? PGF_SCROLLRIGHT : PGF_SCROLLDOWN; - TRACE("[%p] TIMERID1: style=%08lx, dir=%d\n", hwnd, dwStyle, dir); - KillTimer(hwnd, TIMERID1); - SetTimer(hwnd, TIMERID1, REPEAT_DELAY, 0); - if (dwStyle & PGS_AUTOSCROLL) { - PAGER_Scroll(hwnd, dir); - SetWindowPos(hwnd, 0,0,0,0,0, + TRACE("[%p] TIMERID1: style=%08lx, dir=%d\n", + infoPtr->hwndSelf, infoPtr->dwStyle, dir); + KillTimer(infoPtr->hwndSelf, TIMERID1); + SetTimer(infoPtr->hwndSelf, TIMERID1, REPEAT_DELAY, 0); + if (infoPtr->dwStyle & PGS_AUTOSCROLL) { + PAGER_Scroll(infoPtr, dir); + SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, 0, 0, SWP_FRAMECHANGED | SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE); } @@ -1217,55 +1192,73 @@ PAGER_Timer (HWND hwnd, WPARAM wParam) } - TRACE("[%p] TIMERID2: dir=%d\n", hwnd, infoPtr->direction); - KillTimer(hwnd, TIMERID2); + TRACE("[%p] TIMERID2: dir=%d\n", infoPtr->hwndSelf, infoPtr->direction); + KillTimer(infoPtr->hwndSelf, TIMERID2); if (infoPtr->direction > 0) { - PAGER_Scroll(hwnd, infoPtr->direction); - SetTimer(hwnd, TIMERID2, REPEAT_DELAY, 0); + PAGER_Scroll(infoPtr, infoPtr->direction); + SetTimer(infoPtr->hwndSelf, TIMERID2, REPEAT_DELAY, 0); } return 0; } static LRESULT -PAGER_EraseBackground (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_EraseBackground (PAGER_INFO* infoPtr, HDC hdc) { POINT pt, ptorig; - HDC hdc = (HDC)wParam; HWND parent; pt.x = 0; pt.y = 0; - parent = GetParent(hwnd); - MapWindowPoints(hwnd, parent, &pt, 1); + parent = GetParent(infoPtr->hwndSelf); + MapWindowPoints(infoPtr->hwndSelf, parent, &pt, 1); OffsetWindowOrgEx (hdc, pt.x, pt.y, &ptorig); - SendMessageW (parent, WM_ERASEBKGND, wParam, lParam); + SendMessageW (parent, WM_ERASEBKGND, (WPARAM)hdc, 0); SetWindowOrgEx (hdc, ptorig.x, ptorig.y, 0); - return TRUE; + return 0; } static LRESULT -PAGER_Size (HWND hwnd, WPARAM wParam, LPARAM lParam) +PAGER_Size (PAGER_INFO* infoPtr, INT type, INT x, INT y) { /* note that WM_SIZE is sent whenever NCCalcSize resizes the client wnd */ - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); - TRACE("[%p] %dx%d\n", hwnd, (short)LOWORD(lParam), (short)HIWORD(lParam)); + TRACE("[%p] %d,%d\n", infoPtr->hwndSelf, x, y); - if (PAGER_IsHorizontal(hwnd)) - infoPtr->nHeight = (short)HIWORD(lParam); + if (infoPtr->dwStyle & PGS_HORZ) + infoPtr->nHeight = x; else - infoPtr->nWidth = (short)LOWORD(lParam); + infoPtr->nWidth = y; - return PAGER_RecalcSize(hwnd); + return PAGER_RecalcSize(infoPtr); } +static LRESULT +PAGER_StyleChanged(PAGER_INFO *infoPtr, WPARAM wStyleType, LPSTYLESTRUCT lpss) +{ + DWORD oldStyle = infoPtr->dwStyle; + + TRACE("(styletype=%x, styleOld=0x%08lx, styleNew=0x%08lx)\n", + wStyleType, lpss->styleOld, lpss->styleNew); + + if (wStyleType != GWL_STYLE) return 0; + + infoPtr->dwStyle = lpss->styleNew; + + if ((oldStyle ^ lpss->styleNew) & (PGS_HORZ | PGS_VERT)) + { + PAGER_RecalcSize(infoPtr); + } + + return 0; +} + static LRESULT WINAPI PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { - PAGER_INFO *infoPtr = PAGER_GetInfoPtr (hwnd); + PAGER_INFO *infoPtr = (PAGER_INFO *)GetWindowLongPtrW(hwnd, 0); if (!infoPtr && (uMsg != WM_CREATE)) return DefWindowProcW (hwnd, uMsg, wParam, lParam); @@ -1273,83 +1266,86 @@ PAGER_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) switch (uMsg) { case EM_FMTLINES: - return PAGER_FmtLines(hwnd); + return PAGER_FmtLines(infoPtr); case PGM_FORWARDMOUSE: - return PAGER_ForwardMouse (hwnd, wParam); + return PAGER_ForwardMouse (infoPtr, (BOOL)wParam); case PGM_GETBKCOLOR: - return PAGER_GetBkColor(hwnd); + return PAGER_GetBkColor(infoPtr); case PGM_GETBORDER: - return PAGER_GetBorder(hwnd); + return PAGER_GetBorder(infoPtr); case PGM_GETBUTTONSIZE: - return PAGER_GetButtonSize(hwnd); + return PAGER_GetButtonSize(infoPtr); case PGM_GETPOS: - return PAGER_GetPos(hwnd); + return PAGER_GetPos(infoPtr); case PGM_GETBUTTONSTATE: - return PAGER_GetButtonState (hwnd, wParam, lParam); + return PAGER_GetButtonState (infoPtr, (INT)lParam); /* case PGM_GETDROPTARGET: */ case PGM_RECALCSIZE: - return PAGER_RecalcSize(hwnd); + return PAGER_RecalcSize(infoPtr); case PGM_SETBKCOLOR: - return PAGER_SetBkColor (hwnd, wParam, lParam); + return PAGER_SetBkColor (infoPtr, (COLORREF)lParam); case PGM_SETBORDER: - return PAGER_SetBorder (hwnd, wParam, lParam); + return PAGER_SetBorder (infoPtr, (INT)lParam); case PGM_SETBUTTONSIZE: - return PAGER_SetButtonSize (hwnd, wParam, lParam); + return PAGER_SetButtonSize (infoPtr, (INT)lParam); case PGM_SETCHILD: - return PAGER_SetChild (hwnd, wParam, lParam); + return PAGER_SetChild (infoPtr, (HWND)lParam); case PGM_SETPOS: - return PAGER_SetPos(hwnd, (INT)lParam, FALSE); + return PAGER_SetPos(infoPtr, (INT)lParam, FALSE); case WM_CREATE: - return PAGER_Create (hwnd, wParam, lParam); + return PAGER_Create (hwnd, (LPCREATESTRUCTW)lParam); case WM_DESTROY: - return PAGER_Destroy (hwnd, wParam, lParam); + return PAGER_Destroy (infoPtr); case WM_SIZE: - return PAGER_Size (hwnd, wParam, lParam); + return PAGER_Size (infoPtr, (INT)wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); case WM_NCPAINT: - return PAGER_NCPaint (hwnd, wParam, lParam); + return PAGER_NCPaint (infoPtr, (HRGN)wParam); case WM_WINDOWPOSCHANGING: - return PAGER_HandleWindowPosChanging (hwnd, wParam, (WINDOWPOS*)lParam); + return PAGER_WindowPosChanging (infoPtr, (WINDOWPOS*)lParam); + + case WM_STYLECHANGED: + return PAGER_StyleChanged(infoPtr, wParam, (LPSTYLESTRUCT)lParam); case WM_NCCALCSIZE: - return PAGER_NCCalcSize (hwnd, wParam, lParam); + return PAGER_NCCalcSize (infoPtr, wParam, (LPRECT)lParam); case WM_NCHITTEST: - return PAGER_NCHitTest (hwnd, wParam, lParam); + return PAGER_NCHitTest (infoPtr, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); case WM_MOUSEMOVE: if (infoPtr->bForward && infoPtr->hwndChild) PostMessageW(infoPtr->hwndChild, WM_MOUSEMOVE, wParam, lParam); - return PAGER_MouseMove (hwnd, wParam, lParam); + return PAGER_MouseMove (infoPtr, (INT)wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); case WM_LBUTTONDOWN: - return PAGER_LButtonDown (hwnd, wParam, lParam); + return PAGER_LButtonDown (infoPtr, (INT)wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); case WM_LBUTTONUP: - return PAGER_LButtonUp (hwnd, wParam, lParam); + return PAGER_LButtonUp (infoPtr, (INT)wParam, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam)); case WM_ERASEBKGND: - return PAGER_EraseBackground (hwnd, wParam, lParam); + return PAGER_EraseBackground (infoPtr, (HDC)wParam); case WM_TIMER: - return PAGER_Timer (hwnd, wParam); + return PAGER_Timer (infoPtr, (INT)wParam); case WM_NOTIFY: case WM_COMMAND: diff --git a/reactos/lib/comctl32/propsheet.c b/reactos/lib/comctl32/propsheet.c index 2ad24f2a151..f61463aa741 100644 --- a/reactos/lib/comctl32/propsheet.c +++ b/reactos/lib/comctl32/propsheet.c @@ -323,7 +323,7 @@ static void PROPSHEET_AtoW(LPCWSTR *tostr, LPCSTR frstr) TRACE("<%s>\n", frstr); len = MultiByteToWideChar(CP_ACP, 0, frstr, -1, 0, 0); - *tostr = (LPWSTR)HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR)); + *tostr = Alloc(len * sizeof(WCHAR)); MultiByteToWideChar(CP_ACP, 0, frstr, -1, (LPWSTR)*tostr, len); } @@ -357,7 +357,7 @@ static BOOL PROPSHEET_CollectSheetInfoA(LPCPROPSHEETHEADERA lppsh, if (HIWORD(lppsh->pszCaption)) { int len = MultiByteToWideChar(CP_ACP, 0, lppsh->pszCaption, -1, NULL, 0); - psInfo->ppshheader.pszCaption = HeapAlloc( GetProcessHeap(), 0, len*sizeof (WCHAR) ); + psInfo->ppshheader.pszCaption = Alloc( len*sizeof (WCHAR) ); MultiByteToWideChar(CP_ACP, 0, lppsh->pszCaption, -1, (LPWSTR) psInfo->ppshheader.pszCaption, len); } } @@ -411,7 +411,7 @@ static BOOL PROPSHEET_CollectSheetInfoW(LPCPROPSHEETHEADERW lppsh, if (HIWORD(lppsh->pszCaption)) { int len = strlenW(lppsh->pszCaption); - psInfo->ppshheader.pszCaption = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof(WCHAR) ); + psInfo->ppshheader.pszCaption = Alloc( (len+1)*sizeof(WCHAR) ); strcpyW( (WCHAR *)psInfo->ppshheader.pszCaption, lppsh->pszCaption ); } } @@ -951,7 +951,7 @@ static BOOL PROPSHEET_AdjustButtons(HWND hwndParent, PropSheetInfo* psInfo) SetWindowPos(hwndButton, 0, x, y, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE); - SendMessageA(hwndParent, DM_SETDEFID, IDOK, 0); + SendMessageW(hwndParent, DM_SETDEFID, IDOK, 0); /* @@ -1708,7 +1708,7 @@ static BOOL PROPSHEET_Next(HWND hwndDlg) hwndPage = psInfo->proppage[psInfo->active_page].hwndPage; - msgResult = SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); + msgResult = SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); if (msgResult == -1) return FALSE; else if (msgResult == 0) @@ -1789,7 +1789,7 @@ static BOOL PROPSHEET_Apply(HWND hwndDlg, LPARAM lParam) hwndPage = psInfo->proppage[psInfo->active_page].hwndPage; - if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn) != FALSE) + if (SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn) != FALSE) return FALSE; /* @@ -1803,7 +1803,7 @@ static BOOL PROPSHEET_Apply(HWND hwndDlg, LPARAM lParam) hwndPage = psInfo->proppage[i].hwndPage; if (hwndPage) { - switch (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn)) + switch (SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn)) { case PSNRET_INVALID: PROPSHEET_ShowPage(hwndDlg, i, psInfo); @@ -1823,7 +1823,7 @@ static BOOL PROPSHEET_Apply(HWND hwndDlg, LPARAM lParam) psn.hdr.code = PSN_SETACTIVE; psn.lParam = 0; hwndPage = psInfo->proppage[psInfo->active_page].hwndPage; - SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); + SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); } return TRUE; @@ -1850,7 +1850,7 @@ static void PROPSHEET_Cancel(HWND hwndDlg, LPARAM lParam) psn.hdr.idFrom = 0; psn.lParam = 0; - if (SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn)) + if (SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn)) return; psn.hdr.code = PSN_RESET; @@ -1861,7 +1861,7 @@ static void PROPSHEET_Cancel(HWND hwndDlg, LPARAM lParam) hwndPage = psInfo->proppage[i].hwndPage; if (hwndPage) - SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); + SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); } if (psInfo->isModeless) @@ -1893,7 +1893,7 @@ static void PROPSHEET_Help(HWND hwndDlg) psn.hdr.idFrom = 0; psn.lParam = 0; - SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); + SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); } /****************************************************************************** @@ -2036,7 +2036,7 @@ static BOOL PROPSHEET_CanSetCurSel(HWND hwndDlg) psn.hdr.idFrom = 0; psn.lParam = 0; - res = !SendMessageA(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); + res = !SendMessageW(hwndPage, WM_NOTIFY, 0, (LPARAM) &psn); end: TRACE("<-- %d\n", res); @@ -2222,7 +2222,7 @@ static void PROPSHEET_SetFinishTextA(HWND hwndDlg, LPCSTR lpszText) EnableWindow(hwndButton, TRUE); /* Make it default pushbutton */ - SendMessageA(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0); + SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0); /* Hide Back button */ hwndButton = GetDlgItem(hwndDlg, IDC_BACK_BUTTON); @@ -2267,13 +2267,12 @@ static LRESULT PROPSHEET_QuerySiblings(HWND hwndDlg, int i = 0; HWND hwndPage; LRESULT msgResult = 0; - PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg, - PropSheetInfoStr); + PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwndDlg, PropSheetInfoStr); while ((i < psInfo->nPages) && (msgResult == 0)) { hwndPage = psInfo->proppage[i].hwndPage; - msgResult = SendMessageA(hwndPage, PSM_QUERYSIBLINGS, wParam, lParam); + msgResult = SendMessageW(hwndPage, PSM_QUERYSIBLINGS, wParam, lParam); i++; } @@ -2423,7 +2422,7 @@ static BOOL PROPSHEET_RemovePage(HWND hwndDlg, PROPSHEETPAGEW* psp = (PROPSHEETPAGEW*)psInfo->proppage[index].hpage; if ((psp->dwFlags & PSP_USETITLE) && psInfo->proppage[index].pszText) - HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->proppage[index].pszText); + Free ((LPVOID)psInfo->proppage[index].pszText); DestroyPropertySheetPage(psInfo->proppage[index].hpage); } @@ -2480,7 +2479,7 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags) EnableWindow(hwndNext, TRUE); /* Set the Next button as the default pushbutton */ - SendMessageA(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0); + SendMessageW(hwndDlg, DM_SETDEFID, IDC_NEXT_BUTTON, 0); } if ((dwFlags & PSWIZB_FINISH) || (dwFlags & PSWIZB_DISABLEDFINISH)) @@ -2495,7 +2494,7 @@ static void PROPSHEET_SetWizButtons(HWND hwndDlg, DWORD dwFlags) EnableWindow(hwndFinish, TRUE); /* Set the Finish button as the default pushbutton */ - SendMessageA(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0); + SendMessageW(hwndDlg, DM_SETDEFID, IDC_FINISH_BUTTON, 0); } } @@ -2694,7 +2693,7 @@ static void PROPSHEET_CleanUp(HWND hwndDlg) TRACE("\n"); if (!psInfo) return; if (HIWORD(psInfo->ppshheader.pszCaption)) - HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->ppshheader.pszCaption); + Free ((LPVOID)psInfo->ppshheader.pszCaption); for (i = 0; i < psInfo->nPages; i++) { @@ -2715,7 +2714,7 @@ static void PROPSHEET_CleanUp(HWND hwndDlg) if(psp) { if ((psp->dwFlags & PSP_USETITLE) && psInfo->proppage[i].pszText) - HeapFree(GetProcessHeap(), 0, (LPVOID)psInfo->proppage[i].pszText); + Free ((LPVOID)psInfo->proppage[i].pszText); DestroyPropertySheetPage(psInfo->proppage[i].hpage); } @@ -2866,7 +2865,7 @@ HPROPSHEETPAGE WINAPI CreatePropertySheetPageA( { int len = strlen(lpPropSheetPage->u.pszTemplate); - ppsp->u.pszTemplate = HeapAlloc( GetProcessHeap(),0,len+1 ); + ppsp->u.pszTemplate = Alloc( len+1 ); strcpy( (LPSTR)ppsp->u.pszTemplate, lpPropSheetPage->u.pszTemplate ); } if ( (ppsp->dwFlags & PSP_USEICONID) && HIWORD( ppsp->u2.pszIcon ) ) @@ -2901,20 +2900,20 @@ HPROPSHEETPAGE WINAPI CreatePropertySheetPageW(LPCPROPSHEETPAGEW lpPropSheetPage { int len = strlenW(lpPropSheetPage->u.pszTemplate); - ppsp->u.pszTemplate = HeapAlloc( GetProcessHeap(),0,(len+1)*sizeof (WCHAR) ); + ppsp->u.pszTemplate = Alloc( (len+1)*sizeof (WCHAR) ); strcpyW( (WCHAR *)ppsp->u.pszTemplate, lpPropSheetPage->u.pszTemplate ); } if ( (ppsp->dwFlags & PSP_USEICONID) && HIWORD( ppsp->u2.pszIcon ) ) { int len = strlenW(lpPropSheetPage->u2.pszIcon); - ppsp->u2.pszIcon = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof (WCHAR) ); + ppsp->u2.pszIcon = Alloc( (len+1)*sizeof (WCHAR) ); strcpyW( (WCHAR *)ppsp->u2.pszIcon, lpPropSheetPage->u2.pszIcon ); } if ((ppsp->dwFlags & PSP_USETITLE) && HIWORD( ppsp->pszTitle )) { int len = strlenW(lpPropSheetPage->pszTitle); - ppsp->pszTitle = HeapAlloc( GetProcessHeap(), 0, (len+1)*sizeof (WCHAR) ); + ppsp->pszTitle = Alloc( (len+1)*sizeof (WCHAR) ); strcpyW( (WCHAR *)ppsp->pszTitle, lpPropSheetPage->pszTitle ); } else if ( !(ppsp->dwFlags & PSP_USETITLE) ) @@ -2942,13 +2941,13 @@ BOOL WINAPI DestroyPropertySheetPage(HPROPSHEETPAGE hPropPage) return FALSE; if ( !(psp->dwFlags & PSP_DLGINDIRECT) && HIWORD( psp->u.pszTemplate ) ) - HeapFree(GetProcessHeap(), 0, (LPVOID)psp->u.pszTemplate); + Free ((LPVOID)psp->u.pszTemplate); if ( (psp->dwFlags & PSP_USEICONID) && HIWORD( psp->u2.pszIcon ) ) - HeapFree(GetProcessHeap(), 0, (LPVOID)psp->u2.pszIcon); + Free ((LPVOID)psp->u2.pszIcon); if ((psp->dwFlags & PSP_USETITLE) && HIWORD( psp->pszTitle )) - HeapFree(GetProcessHeap(), 0, (LPVOID)psp->pszTitle); + Free ((LPVOID)psp->pszTitle); Free(hPropPage); @@ -2969,7 +2968,7 @@ static BOOL PROPSHEET_IsDialogMessage(HWND hwnd, LPMSG lpMsg) if (lpMsg->message == WM_KEYDOWN && (GetKeyState(VK_CONTROL) & 0x8000)) { int new_page = 0; - INT dlgCode = SendMessageA(lpMsg->hwnd, WM_GETDLGCODE, 0, (LPARAM)lpMsg); + INT dlgCode = SendMessageW(lpMsg->hwnd, WM_GETDLGCODE, 0, (LPARAM)lpMsg); if (!(dlgCode & DLGC_WANTMESSAGE)) { @@ -3005,7 +3004,7 @@ static BOOL PROPSHEET_IsDialogMessage(HWND hwnd, LPMSG lpMsg) } } - return IsDialogMessageA(hwnd, lpMsg); + return IsDialogMessageW(hwnd, lpMsg); } /****************************************************************************** @@ -3078,7 +3077,7 @@ static BOOL PROPSHEET_DoCommand(HWND hwnd, WORD wID) /****************************************************************************** * PROPSHEET_Paint */ -static LRESULT PROPSHEET_Paint(HWND hwnd) +static LRESULT PROPSHEET_Paint(HWND hwnd, HDC hdcParam) { PropSheetInfo* psInfo = (PropSheetInfo*) GetPropW(hwnd, PropSheetInfoStr); PAINTSTRUCT ps; @@ -3093,7 +3092,7 @@ static LRESULT PROPSHEET_Paint(HWND hwnd) WCHAR szBuffer[256]; int nLength; - hdc = BeginPaint(hwnd, &ps); + hdc = hdcParam ? hdcParam : BeginPaint(hwnd, &ps); if (!hdc) return 1; hdcSrc = CreateCompatibleDC(0); @@ -3118,7 +3117,7 @@ static LRESULT PROPSHEET_Paint(HWND hwnd) MapWindowPoints(hwndLineHeader, hwnd, (LPPOINT) &r, 2); SetRect(&rzone, 0, 0, r.right + 1, r.top - 1); - GetObjectA(psInfo->ppshheader.u5.hbmHeader, sizeof(BITMAP), (LPVOID)&bm); + GetObjectW(psInfo->ppshheader.u5.hbmHeader, sizeof(BITMAP), (LPVOID)&bm); if (psInfo->ppshheader.dwFlags & PSH_WIZARD97_OLD) { @@ -3241,7 +3240,7 @@ static LRESULT PROPSHEET_Paint(HWND hwnd) hbr = GetSysColorBrush(COLOR_WINDOW); FillRect(hdc, &rzone, hbr); - GetObjectA(psInfo->ppshheader.u4.hbmWatermark, sizeof(BITMAP), (LPVOID)&bm); + GetObjectW(psInfo->ppshheader.u4.hbmWatermark, sizeof(BITMAP), (LPVOID)&bm); hbmp = SelectObject(hdcSrc, psInfo->ppshheader.u4.hbmWatermark); BitBlt(hdc, 0, offsety, min(bm.bmWidth, r.right), @@ -3267,7 +3266,7 @@ static LRESULT PROPSHEET_Paint(HWND hwnd) DeleteDC(hdcSrc); - EndPaint(hwnd, &ps); + if (!hdcParam) EndPaint(hwnd, &ps); return 0; } @@ -3290,7 +3289,7 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) HWND hwndTabCtrl = GetDlgItem(hwnd, IDC_TABCONTROL); LPCPROPSHEETPAGEW ppshpage; int idx; - LOGFONTA logFont; + LOGFONTW logFont; /* Using PropSheetInfoStr to store extra data doesn't match the native * common control: native uses TCM_[GS]ETITEM @@ -3310,10 +3309,10 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) PROPSHEET_SetWizButtons(hwnd, PSWIZB_BACK|PSWIZB_NEXT); /* Set up fonts */ - SystemParametersInfoA (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); - psInfo->hFont = CreateFontIndirectA (&logFont); + SystemParametersInfoW (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); + psInfo->hFont = CreateFontIndirectW (&logFont); logFont.lfWeight = FW_BOLD; - psInfo->hFontBold = CreateFontIndirectA (&logFont); + psInfo->hFontBold = CreateFontIndirectW (&logFont); /* * Small icon in the title bar. @@ -3397,7 +3396,7 @@ PROPSHEET_DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } case WM_PAINT: - PROPSHEET_Paint(hwnd); + PROPSHEET_Paint(hwnd, (HDC)wParam); return TRUE; case WM_DESTROY: diff --git a/reactos/lib/comctl32/rebar.c b/reactos/lib/comctl32/rebar.c index 1b0f4a793cc..74caef36918 100644 --- a/reactos/lib/comctl32/rebar.c +++ b/reactos/lib/comctl32/rebar.c @@ -17,6 +17,7 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * NOTES * * This code was audited for completeness against the documented features * of Comctl32.dll version 6.0 on Oct. 19, 2004, by Robert Shearman. @@ -1245,8 +1246,9 @@ REBAR_ForceResize (REBAR_INFO *infoPtr) static VOID REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus) { + const static WCHAR strComboBox[] = { 'C','o','m','b','o','B','o','x',0 }; REBAR_BAND *lpBand; - CHAR szClassName[40]; + WCHAR szClassName[40]; UINT i; NMREBARCHILDSIZE rbcz; NMHDR heightchange; @@ -1291,9 +1293,9 @@ REBAR_MoveChildWindows (REBAR_INFO *infoPtr, UINT start, UINT endplus) * set flag outside of loop */ - GetClassNameA (lpBand->hwndChild, szClassName, 40); - if (!lstrcmpA (szClassName, "ComboBox") || - !lstrcmpA (szClassName, WC_COMBOBOXEXA)) { + GetClassNameW (lpBand->hwndChild, szClassName, sizeof(szClassName)/sizeof(szClassName[0])); + if (!lstrcmpW (szClassName, strComboBox) || + !lstrcmpW (szClassName, WC_COMBOBOXEXW)) { INT nEditHeight, yPos; RECT rc; @@ -2276,7 +2278,7 @@ REBAR_InternalEraseBkGnd (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam, REC lpBand->rcBand.right,lpBand->rcBand.bottom, clip->left, clip->top, clip->right, clip->bottom); - ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0); + ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &rect, NULL, 0, 0); if (lpBand->clrBack != CLR_NONE) SetBkColor (hdc, old); } @@ -2473,7 +2475,7 @@ REBAR_HandleLRDrag (REBAR_INFO *infoPtr, const POINT *ptsmove) if (imindBand == -1) imindBand = i; /* minimum size of each band is size of header plus */ /* size of minimum child plus offset of child from header plus */ - /* a one to separate each band. */ + /* one to separate each band. */ if (i < ihitBand) LHeaderSum += (band->lcx + SEP_WIDTH); else @@ -3755,7 +3757,7 @@ REBAR_SizeToRect (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) static LRESULT REBAR_Create (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) { - LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam; + LPCREATESTRUCTW cs = (LPCREATESTRUCTW) lParam; RECT wnrc1, clrc1; if (TRACE_ON(rebar)) { @@ -4063,10 +4065,10 @@ REBAR_NCCalcSize (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) static LRESULT REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) { - LPCREATESTRUCTA cs = (LPCREATESTRUCTA) lParam; + LPCREATESTRUCTW cs = (LPCREATESTRUCTW) lParam; REBAR_INFO *infoPtr = REBAR_GetInfoPtr (hwnd); RECT wnrc1, clrc1; - NONCLIENTMETRICSA ncm; + NONCLIENTMETRICSW ncm; HFONT tfont; INT i; @@ -4098,37 +4100,35 @@ REBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->iGrabbedBand = -1; infoPtr->hwndSelf = hwnd; infoPtr->DoRedraw = TRUE; - infoPtr->hcurArrow = LoadCursorA (0, (LPSTR)IDC_ARROW); - infoPtr->hcurHorz = LoadCursorA (0, (LPSTR)IDC_SIZEWE); - infoPtr->hcurVert = LoadCursorA (0, (LPSTR)IDC_SIZENS); - infoPtr->hcurDrag = LoadCursorA (0, (LPSTR)IDC_SIZE); + infoPtr->hcurArrow = LoadCursorW (0, (LPWSTR)IDC_ARROW); + infoPtr->hcurHorz = LoadCursorW (0, (LPWSTR)IDC_SIZEWE); + infoPtr->hcurVert = LoadCursorW (0, (LPWSTR)IDC_SIZENS); + infoPtr->hcurDrag = LoadCursorW (0, (LPWSTR)IDC_SIZE); infoPtr->bUnicode = IsWindowUnicode (hwnd); infoPtr->fStatus = CREATE_RUNNING; infoPtr->hFont = GetStockObject (SYSTEM_FONT); /* issue WM_NOTIFYFORMAT to get unicode status of parent */ - i = SendMessageA(REBAR_GetNotifyParent (infoPtr), + i = SendMessageW(REBAR_GetNotifyParent (infoPtr), WM_NOTIFYFORMAT, (WPARAM)hwnd, NF_QUERY); if ((i < NFR_ANSI) || (i > NFR_UNICODE)) { - ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", - i); + ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i); i = NFR_ANSI; } infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0; /* add necessary styles to the requested styles */ infoPtr->dwStyle = cs->style | WS_VISIBLE | CCS_TOP; - SetWindowLongA (hwnd, GWL_STYLE, infoPtr->dwStyle); + SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle); /* get font handle for Caption Font */ - ncm.cbSize = sizeof(NONCLIENTMETRICSA); - SystemParametersInfoA (SPI_GETNONCLIENTMETRICS, - ncm.cbSize, &ncm, 0); + ncm.cbSize = sizeof(ncm); + SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, ncm.cbSize, &ncm, 0); /* if the font is bold, set to normal */ if (ncm.lfCaptionFont.lfWeight > FW_NORMAL) { ncm.lfCaptionFont.lfWeight = FW_NORMAL; } - tfont = CreateFontIndirectA (&ncm.lfCaptionFont); + tfont = CreateFontIndirectW (&ncm.lfCaptionFont); if (tfont) { infoPtr->hFont = infoPtr->hDefaultFont = tfont; } @@ -4228,11 +4228,10 @@ REBAR_NotifyFormat (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) INT i; if (lParam == NF_REQUERY) { - i = SendMessageA(REBAR_GetNotifyParent (infoPtr), + i = SendMessageW(REBAR_GetNotifyParent (infoPtr), 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); + ERR("wrong response to WM_NOTIFYFORMAT (%d), assuming ANSI\n", i); i = NFR_ANSI; } infoPtr->NtfUnicode = (i == NFR_UNICODE) ? 1 : 0; @@ -4473,7 +4472,7 @@ REBAR_WindowPosChanged (REBAR_INFO *infoPtr, WPARAM wParam, LPARAM lParam) /* Save the new origin of this window - used by _ForceResize */ infoPtr->origin.x = lpwp->x; infoPtr->origin.y = lpwp->y; - ret = DefWindowProcA(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED, + ret = DefWindowProcW(infoPtr->hwndSelf, WM_WINDOWPOSCHANGED, wParam, lParam); GetWindowRect(infoPtr->hwndSelf, &rc); TRACE("hwnd %p new pos (%ld,%ld)-(%ld,%ld)\n", @@ -4490,7 +4489,7 @@ REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) TRACE("hwnd=%p msg=%x wparam=%x lparam=%lx\n", hwnd, uMsg, wParam, lParam); if (!infoPtr && (uMsg != WM_NCCREATE)) - return DefWindowProcA (hwnd, uMsg, wParam, lParam); + return DefWindowProcW (hwnd, uMsg, wParam, lParam); switch (uMsg) { /* case RB_BEGINDRAG: */ @@ -4707,7 +4706,7 @@ REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) 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); } } @@ -4715,9 +4714,9 @@ REBAR_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) VOID REBAR_Register (void) { - WNDCLASSA wndClass; + WNDCLASSW wndClass; - ZeroMemory (&wndClass, sizeof(WNDCLASSA)); + ZeroMemory (&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; wndClass.lpfnWndProc = REBAR_WindowProc; wndClass.cbClsExtra = 0; @@ -4727,9 +4726,9 @@ REBAR_Register (void) #if GLATESTING wndClass.hbrBackground = CreateSolidBrush(RGB(0,128,0)); #endif - wndClass.lpszClassName = REBARCLASSNAMEA; + wndClass.lpszClassName = REBARCLASSNAMEW; - RegisterClassA (&wndClass); + RegisterClassW (&wndClass); mindragx = GetSystemMetrics (SM_CXDRAG); mindragy = GetSystemMetrics (SM_CYDRAG); @@ -4740,5 +4739,5 @@ REBAR_Register (void) VOID REBAR_Unregister (void) { - UnregisterClassA (REBARCLASSNAMEA, NULL); + UnregisterClassW (REBARCLASSNAMEW, NULL); } diff --git a/reactos/lib/comctl32/syslink.c b/reactos/lib/comctl32/syslink.c index 34402f3a6f8..e39332d0119 100644 --- a/reactos/lib/comctl32/syslink.c +++ b/reactos/lib/comctl32/syslink.c @@ -17,11 +17,19 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * NOTES + * + * This code was audited for completeness against the documented features + * of Comctl32.dll version 6.0 on Apr. 4, 2005, 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: * - Fix SHIFT+TAB and TAB issue (wrong link is selected when control gets the focus) * - Better string parsing * - Improve word wrapping - * - Control styles?! * */ @@ -33,6 +41,7 @@ #include "winuser.h" #include "winnls.h" #include "commctrl.h" +#include "comctl32.h" #include "wine/unicode.h" #include "wine/debug.h" @@ -40,10 +49,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(progress); INT WINAPI StrCmpNIW(LPCWSTR,LPCWSTR,INT); -#define SYSLINK_Alloc(size) HeapAlloc(GetProcessHeap(), 0, (size)) -#define SYSLINK_Free(ptr) HeapFree(GetProcessHeap(), 0, (ptr)) -#define SYSLINK_ReAlloc(ptr, size) HeapReAlloc(GetProcessHeap(), 0, ptr, (size)) - typedef struct { int nChars; @@ -85,6 +90,8 @@ typedef struct _DOC_ITEM typedef struct { HWND Self; /* The window handle for this control */ + HWND Notify; /* The parent handle to receive notifications */ + DWORD Style; /* Styles for this control */ PDOC_ITEM Items; /* Address to the first document item */ BOOL HasFocus; /* Whether the control has the input focus */ int MouseDownID; /* ID of the link that the mouse button first selected */ @@ -115,8 +122,8 @@ static VOID SYSLINK_FreeDocItem (PDOC_ITEM DocItem) { if(DocItem->Type == slLink) { - SYSLINK_Free(DocItem->u.Link.szID); - SYSLINK_Free(DocItem->u.Link.szUrl); + Free(DocItem->u.Link.szID); + Free(DocItem->u.Link.szUrl); } if(DocItem->Type == slLink && DocItem->u.Link.hRgn != NULL) @@ -127,18 +134,18 @@ static VOID SYSLINK_FreeDocItem (PDOC_ITEM DocItem) /* we don't free Text because it's just a pointer to a character in the entire window text string */ - SYSLINK_Free(DocItem); + Free(DocItem); } /*********************************************************************** * SYSLINK_AppendDocItem * Create and append a new document item. */ -static PDOC_ITEM SYSLINK_AppendDocItem (SYSLINK_INFO *infoPtr, LPWSTR Text, UINT textlen, +static PDOC_ITEM SYSLINK_AppendDocItem (SYSLINK_INFO *infoPtr, LPCWSTR Text, UINT textlen, SL_ITEM_TYPE type, PDOC_ITEM LastItem) { PDOC_ITEM Item; - Item = SYSLINK_Alloc(sizeof(DOC_ITEM) + ((textlen + 1) * sizeof(WCHAR))); + Item = Alloc(sizeof(DOC_ITEM) + ((textlen + 1) * sizeof(WCHAR))); if(Item == NULL) { ERR("Failed to alloc DOC_ITEM structure!\n"); @@ -191,25 +198,16 @@ static VOID SYSLINK_ClearDoc (SYSLINK_INFO *infoPtr) * Parses the window text string and creates a document. Returns the * number of document items created. */ -static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPWSTR Text) +static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPCWSTR Text) { - WCHAR *current, *textstart, *linktext, *firsttag; - int taglen = 0, textlen, linklen, docitems = 0; + LPCWSTR current, textstart = NULL, linktext = NULL, firsttag = NULL; + int taglen = 0, textlen = 0, linklen = 0, docitems = 0; PDOC_ITEM Last = NULL; SL_ITEM_TYPE CurrentType = slText; - DWORD Style; - LPWSTR lpID, lpUrl; + LPCWSTR lpID, lpUrl; UINT lenId, lenUrl; - Style = GetWindowLongW(infoPtr->Self, GWL_STYLE); - - firsttag = NULL; - textstart = NULL; - linktext = NULL; - textlen = 0; - linklen = 0; - - for(current = (WCHAR*)Text; *current != 0;) + for(current = Text; *current != 0;) { if(*current == '<') { @@ -232,9 +230,8 @@ static UINT SYSLINK_ParseText (SYSLINK_INFO *infoPtr, LPWSTR Text) case ' ': { /* we expect parameters, parse them */ - LPWSTR *CurrentParameter = NULL; + LPCWSTR *CurrentParameter = NULL, tmp; UINT *CurrentParameterLen = NULL; - WCHAR *tmp; taglen = 3; tmp = current + taglen; @@ -362,7 +359,7 @@ CheckParameter: { int nc; - if(!(Style & WS_DISABLED)) + if(!(infoPtr->Style & WS_DISABLED)) { Last->u.Link.state |= LIS_ENABLED; } @@ -371,7 +368,7 @@ CheckParameter: { nc = min(lenId, strlenW(lpID)); nc = min(nc, MAX_LINKID_TEXT); - Last->u.Link.szID = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR)); + Last->u.Link.szID = Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR)); if(Last->u.Link.szID != NULL) { lstrcpynW(Last->u.Link.szID, lpID, nc + 1); @@ -384,7 +381,7 @@ CheckParameter: { nc = min(lenUrl, strlenW(lpUrl)); nc = min(nc, L_MAX_URL_LENGTH); - Last->u.Link.szUrl = SYSLINK_Alloc((L_MAX_URL_LENGTH + 1) * sizeof(WCHAR)); + Last->u.Link.szUrl = Alloc((L_MAX_URL_LENGTH + 1) * sizeof(WCHAR)); if(Last->u.Link.szUrl != NULL) { lstrcpynW(Last->u.Link.szUrl, lpUrl, nc + 1); @@ -442,7 +439,7 @@ CheckParameter: { int nc; - if(!(Style & WS_DISABLED)) + if(!(infoPtr->Style & WS_DISABLED)) { Last->u.Link.state |= LIS_ENABLED; } @@ -451,7 +448,7 @@ CheckParameter: { nc = min(lenId, strlenW(lpID)); nc = min(nc, MAX_LINKID_TEXT); - Last->u.Link.szID = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR)); + Last->u.Link.szID = Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR)); if(Last->u.Link.szID != NULL) { lstrcpynW(Last->u.Link.szID, lpID, nc + 1); @@ -464,7 +461,7 @@ CheckParameter: { nc = min(lenUrl, strlenW(lpUrl)); nc = min(nc, L_MAX_URL_LENGTH); - Last->u.Link.szUrl = SYSLINK_Alloc((L_MAX_URL_LENGTH + 1) * sizeof(WCHAR)); + Last->u.Link.szUrl = Alloc((L_MAX_URL_LENGTH + 1) * sizeof(WCHAR)); if(Last->u.Link.szUrl != NULL) { lstrcpynW(Last->u.Link.szUrl, lpUrl, nc + 1); @@ -479,7 +476,7 @@ CheckParameter: if(linktext != NULL && linklen > 0) { - /* we got a unclosed link, just display the text */ + /* we got an unclosed link, just display the text */ Last = SYSLINK_AppendDocItem(infoPtr, linktext, linklen, slText, Last); if(Last == NULL) { @@ -737,11 +734,11 @@ static VOID SYSLINK_Render (SYSLINK_INFO *infoPtr, HDC hdc) if(bl != NULL) { - bl = SYSLINK_ReAlloc(bl, ++nBlocks * sizeof(DOC_TEXTBLOCK)); + bl = ReAlloc(bl, ++nBlocks * sizeof(DOC_TEXTBLOCK)); } else { - bl = SYSLINK_Alloc(++nBlocks * sizeof(DOC_TEXTBLOCK)); + bl = Alloc(++nBlocks * sizeof(DOC_TEXTBLOCK)); } if(bl != NULL) @@ -879,13 +876,14 @@ static LRESULT SYSLINK_Draw (SYSLINK_INFO *infoPtr, HDC hdc) * SYSLINK_Paint * Handles the WM_PAINT message. */ -static LRESULT SYSLINK_Paint (SYSLINK_INFO *infoPtr) +static LRESULT SYSLINK_Paint (SYSLINK_INFO *infoPtr, HDC hdcParam) { HDC hdc; PAINTSTRUCT ps; - hdc = BeginPaint (infoPtr->Self, &ps); + + hdc = hdcParam ? hdcParam : BeginPaint (infoPtr->Self, &ps); SYSLINK_Draw (infoPtr, hdc); - EndPaint (infoPtr->Self, &ps); + if (!hdcParam) EndPaint (infoPtr->Self, &ps); return 0; } @@ -939,7 +937,7 @@ static HFONT SYSLINK_SetFont (SYSLINK_INFO *infoPtr, HFONT hFont, BOOL bRedraw) * SYSLINK_SetText * Set new text for the SysLink control. */ -static LRESULT SYSLINK_SetText (SYSLINK_INFO *infoPtr, LPWSTR Text) +static LRESULT SYSLINK_SetText (SYSLINK_INFO *infoPtr, LPCWSTR Text) { int textlen; @@ -1038,7 +1036,7 @@ static LRESULT SYSLINK_SetItem (SYSLINK_INFO *infoPtr, PLITEM Item) { if(!di->u.Link.szID) { - di->u.Link.szID = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR)); + di->u.Link.szID = Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR)); if(!Item->szID) { ERR("Unable to allocate memory for link id\n"); @@ -1055,7 +1053,7 @@ static LRESULT SYSLINK_SetItem (SYSLINK_INFO *infoPtr, PLITEM Item) { if(!di->u.Link.szUrl) { - di->u.Link.szUrl = SYSLINK_Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR)); + di->u.Link.szUrl = Alloc((MAX_LINKID_TEXT + 1) * sizeof(WCHAR)); if(!Item->szUrl) { ERR("Unable to allocate memory for link url\n"); @@ -1241,7 +1239,7 @@ static LRESULT SYSLINK_SendParentNotify (SYSLINK_INFO *infoPtr, UINT code, PDOC_ nml.item.szUrl[0] = 0; } - return SendMessageW(GetParent(infoPtr->Self), WM_NOTIFY, (WPARAM)nml.hdr.idFrom, (LPARAM)&nml); + return SendMessageW(infoPtr->Notify, WM_NOTIFY, (WPARAM)nml.hdr.idFrom, (LPARAM)&nml); } /*********************************************************************** @@ -1466,7 +1464,7 @@ static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message, switch(message) { case WM_PAINT: - return SYSLINK_Paint (infoPtr); + return SYSLINK_Paint (infoPtr, (HDC)wParam); case WM_SETCURSOR: { @@ -1606,14 +1604,31 @@ static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message, case WM_KILLFOCUS: return SYSLINK_KillFocus(infoPtr, (HWND)wParam); + case WM_ENABLE: + infoPtr->Style &= ~WS_DISABLED; + infoPtr->Style |= (wParam ? 0 : WS_DISABLED); + InvalidateRect (infoPtr->Self, NULL, FALSE); + return 0; + + case WM_STYLECHANGED: + if (wParam == GWL_STYLE) + { + infoPtr->Style = ((LPSTYLESTRUCT)lParam)->styleNew; + + InvalidateRect(infoPtr->Self, NULL, TRUE); + } + return 0; + case WM_CREATE: /* allocate memory for info struct */ - infoPtr = (SYSLINK_INFO *)SYSLINK_Alloc (sizeof(SYSLINK_INFO)); + infoPtr = Alloc (sizeof(SYSLINK_INFO)); if (!infoPtr) return -1; SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); /* initialize the info struct */ infoPtr->Self = hwnd; + infoPtr->Notify = ((LPCREATESTRUCTW)lParam)->hwndParent; + infoPtr->Style = ((LPCREATESTRUCTW)lParam)->style; infoPtr->Font = 0; infoPtr->LinkFont = 0; infoPtr->Items = NULL; @@ -1623,8 +1638,7 @@ static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message, infoPtr->LinkColor = GetSysColor(COLOR_HIGHLIGHT); infoPtr->VisitedColor = GetSysColor(COLOR_HIGHLIGHT); TRACE("SysLink Ctrl creation, hwnd=%p\n", hwnd); - lParam = (LPARAM)(((LPCREATESTRUCTW)lParam)->lpszName); - SYSLINK_SetText(infoPtr, (LPWSTR)lParam); + SYSLINK_SetText(infoPtr, ((LPCREATESTRUCTW)lParam)->lpszName); return 0; case WM_DESTROY: @@ -1632,8 +1646,8 @@ static LRESULT WINAPI SysLinkWindowProc(HWND hwnd, UINT message, SYSLINK_ClearDoc(infoPtr); if(infoPtr->Font != 0) DeleteObject(infoPtr->Font); if(infoPtr->LinkFont != 0) DeleteObject(infoPtr->LinkFont); - SYSLINK_Free (infoPtr); SetWindowLongPtrW(hwnd, 0, 0); + Free (infoPtr); return 0; default: diff --git a/reactos/lib/comctl32/tab.c b/reactos/lib/comctl32/tab.c index 8fb27e89d85..3287b573cb4 100644 --- a/reactos/lib/comctl32/tab.c +++ b/reactos/lib/comctl32/tab.c @@ -21,7 +21,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * TODO: - * Unicode support (under construction) * * Styles: * TCIF_RTLREADING @@ -82,7 +81,7 @@ typedef struct USHORT uVItemPadding_s; /* Set amount of vertical padding, in pixels */ HFONT hFont; /* handle to the current font */ HCURSOR hcurArrow; /* handle to the current cursor */ - HIMAGELIST himl; /* handle to a image list (may be 0) */ + HIMAGELIST himl; /* handle to an image list (may be 0) */ HWND hwndToolTip; /* handle to tab's tooltip */ INT leftmostVisible; /* Used for scrolling, this member contains * the index of the first visible item */ @@ -144,7 +143,7 @@ TAB_SendSimpleNotify (const TAB_INFO *infoPtr, UINT code) (WPARAM) nmhdr.idFrom, (LPARAM) &nmhdr); } -static VOID +static void TAB_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, WPARAM wParam, LPARAM lParam) { @@ -162,25 +161,13 @@ TAB_RelayEvent (HWND hwndTip, HWND hwndMsg, UINT uMsg, } static void -TAB_DumpItemExternalA(TCITEMA *pti, UINT iItem) -{ - if (TRACE_ON(tab)) { - TRACE("external tab %d, mask=0x%08x, dwState=0x%08x, dwStateMask=0x%08x, cchTextMax=0x%08x\n", - iItem, pti->mask, pti->dwState, pti->dwStateMask, pti->cchTextMax); - TRACE("external tab %d, iImage=%d, lParam=0x%08lx, pszTextA=%s\n", - iItem, pti->iImage, pti->lParam, debugstr_a(pti->pszText)); - } -} - - -static void -TAB_DumpItemExternalW(TCITEMW *pti, UINT iItem) +TAB_DumpItemExternalT(TCITEMW *pti, UINT iItem, BOOL isW) { if (TRACE_ON(tab)) { TRACE("external tab %d, mask=0x%08x, dwState=0x%08lx, dwStateMask=0x%08lx, cchTextMax=0x%08x\n", iItem, pti->mask, pti->dwState, pti->dwStateMask, pti->cchTextMax); TRACE("external tab %d, iImage=%d, lParam=0x%08lx, pszTextW=%s\n", - iItem, pti->iImage, pti->lParam, debugstr_w(pti->pszText)); + iItem, pti->iImage, pti->lParam, isW ? debugstr_w(pti->pszText) : debugstr_a((LPSTR)pti->pszText)); } } @@ -246,7 +233,7 @@ static LRESULT TAB_SetCurFocus (TAB_INFO *infoPtr, INT iItem) { if (iItem < 0 || iItem >= infoPtr->uNumItem) return 0; - if (GetWindowLongA(infoPtr->hwnd, GWL_STYLE) & TCS_BUTTONS) { + if (GetWindowLongW(infoPtr->hwnd, GWL_STYLE) & TCS_BUTTONS) { FIXME("Should set input focus\n"); } else { int oldFocus = infoPtr->uFocus; @@ -302,7 +289,7 @@ static BOOL TAB_InternalGetItemRect( RECT* selectedRect) { RECT tmpItemRect,clientRect; - LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); /* Perform a sanity check and a trivial visibility check. */ if ( (infoPtr->uNumItem <= 0) || @@ -417,7 +404,11 @@ static BOOL TAB_InternalGetItemRect( } } - return TRUE; + /* Check for visibility */ + if (lStyle & TCS_VERTICAL) + return (itemRect->top < clientRect.bottom) && (itemRect->bottom > clientRect.top); + else + return (itemRect->left < clientRect.right) && (itemRect->right > clientRect.left); } static inline BOOL @@ -472,7 +463,7 @@ static LRESULT TAB_KeyUp(TAB_INFO* infoPtr, WPARAM keyCode) * This method is called whenever the focus goes in or out of this control * it is used to update the visual state of the control. */ -static VOID TAB_FocusChanging(const TAB_INFO *infoPtr) +static void TAB_FocusChanging(const TAB_INFO *infoPtr) { RECT selectedRect; BOOL isVisible; @@ -566,7 +557,7 @@ TAB_LButtonDown (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam) TAB_RelayEvent (infoPtr->hwndToolTip, infoPtr->hwnd, WM_LBUTTONDOWN, wParam, lParam); - if (GetWindowLongA(infoPtr->hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) { + if (GetWindowLongW(infoPtr->hwnd, GWL_STYLE) & TCS_FOCUSONBUTTONDOWN ) { SetFocus (infoPtr->hwnd); } @@ -648,7 +639,7 @@ TAB_DrawLoneItemInterior(TAB_INFO* infoPtr, int iItem) * we can check if the mouse has left our window. If so, we un-highlight * the hot-tracked tab. */ -static VOID CALLBACK +static void CALLBACK TAB_HotTrackTimerProc ( HWND hwnd, /* handle of window for timer messages */ @@ -717,7 +708,7 @@ TAB_RecalcHotTrack if (out_redrawEnter != NULL) *out_redrawEnter = -1; - if (GetWindowLongA(infoPtr->hwnd, GWL_STYLE) & TCS_HOTTRACK) + if (GetWindowLongW(infoPtr->hwnd, GWL_STYLE) & TCS_HOTTRACK) { POINT pt; UINT flags; @@ -814,7 +805,7 @@ static LRESULT TAB_AdjustRect( WPARAM fLarger, LPRECT prc) { - DWORD lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); + DWORD lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); LONG *iRightBottom, *iLeftTop; TRACE ("hwnd=%p fLarger=%d (%ld,%ld)-(%ld,%ld)\n", infoPtr->hwnd, fLarger, prc->left, prc->top, prc->right, prc->bottom); @@ -903,8 +894,10 @@ static void TAB_SetupScrolling( TAB_INFO* infoPtr, const RECT* clientRect) { + static const WCHAR msctls_updown32W[] = { 'm','s','c','t','l','s','_','u','p','d','o','w','n','3','2',0 }; + static const WCHAR emptyW[] = { 0 }; INT maxRange = 0; - DWORD lStyle = GetWindowLongA(hwnd, GWL_STYLE); + DWORD lStyle = GetWindowLongW(hwnd, GWL_STYLE); if (infoPtr->needsScrolling) { @@ -953,16 +946,12 @@ static void TAB_SetupScrolling( */ if (infoPtr->hwndUpDown==0) { - infoPtr->hwndUpDown = CreateWindowA("msctls_updown32", - "", + infoPtr->hwndUpDown = CreateWindowW(msctls_updown32W, emptyW, WS_VISIBLE | WS_CHILD | UDS_HORZ, controlPos.left, controlPos.top, controlPos.right - controlPos.left, controlPos.bottom - controlPos.top, - hwnd, - NULL, - NULL, - NULL); + hwnd, NULL, NULL, NULL); } else { @@ -1016,8 +1005,8 @@ static void TAB_SetupScrolling( */ static void TAB_SetItemBounds (TAB_INFO *infoPtr) { - LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); - TEXTMETRICA fontMetrics; + LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); + TEXTMETRICW fontMetrics; UINT curItem; INT curItemLeftPos; INT curItemRowCount; @@ -1069,7 +1058,7 @@ static void TAB_SetItemBounds (TAB_INFO *infoPtr) int icon_height = 0; /* Use the current font to determine the height of a tab. */ - GetTextMetricsA(hdc, &fontMetrics); + GetTextMetricsW(hdc, &fontMetrics); /* Get the icon height */ if (infoPtr->himl) @@ -1374,7 +1363,7 @@ TAB_EraseTabInterior RECT* drawRect ) { - LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); HBRUSH hbr = CreateSolidBrush (comctl32_color.clrBtnFace); BOOL deleteBrush = TRUE; RECT rTemp = *drawRect; @@ -1441,7 +1430,7 @@ TAB_DrawItemInterior RECT* drawRect ) { - LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); RECT localRect; @@ -1757,7 +1746,8 @@ TAB_DrawItemInterior /* Draw the text */ if(lStyle & TCS_VERTICAL) /* if we are vertical rotate the text and each character */ { - LOGFONTA logfont; + static const WCHAR ArialW[] = { 'A','r','i','a','l',0 }; + LOGFONTW logfont; HFONT hFont = 0; INT nEscapement = 900; INT nOrientation = 900; @@ -1770,13 +1760,13 @@ TAB_DrawItemInterior /* to get a font with the escapement and orientation we are looking for, we need to */ /* call CreateFontIndirectA, which requires us to set the values of the logfont we pass in */ - if (!GetObjectA((infoPtr->hFont) ? + if (!GetObjectW((infoPtr->hFont) ? infoPtr->hFont : GetStockObject(SYSTEM_FONT), - sizeof(LOGFONTA),&logfont)) + sizeof(LOGFONTW),&logfont)) { INT iPointSize = 9; - lstrcpyA(logfont.lfFaceName, "Arial"); + lstrcpyW(logfont.lfFaceName, ArialW); logfont.lfHeight = -MulDiv(iPointSize, GetDeviceCaps(hdc, LOGPIXELSY), 72); logfont.lfWeight = FW_NORMAL; @@ -1787,7 +1777,7 @@ TAB_DrawItemInterior logfont.lfEscapement = nEscapement; logfont.lfOrientation = nOrientation; - hFont = CreateFontIndirectA(&logfont); + hFont = CreateFontIndirectW(&logfont); SelectObject(hdc, hFont); if (item->pszText) @@ -1845,7 +1835,7 @@ static void TAB_DrawItem( HDC hdc, INT iItem) { - LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); RECT itemRect; RECT selectedRect; BOOL isVisible; @@ -1957,7 +1947,7 @@ static void TAB_DrawItem( /* Clear interior */ SetBkColor(hdc, bkgnd); - ExtTextOutA(hdc, 0, 0, 2, &fillRect, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &fillRect, NULL, 0, 0); /* Draw rectangular edge around tab */ DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_RIGHT|BF_TOP|BF_BOTTOM); @@ -1968,7 +1958,7 @@ static void TAB_DrawItem( r1.top = r.top; r1.right = r.right; r1.bottom = r1.top + ROUND_CORNER_SIZE; - ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &r1, NULL, 0, 0); r1.right--; DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDTOPLEFT); @@ -1977,7 +1967,7 @@ static void TAB_DrawItem( r1.bottom = r.bottom; r1.right = r.right; r1.top = r1.bottom - ROUND_CORNER_SIZE; - ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &r1, NULL, 0, 0); r1.right--; DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDBOTTOMLEFT); @@ -1998,7 +1988,7 @@ static void TAB_DrawItem( /* Clear interior */ SetBkColor(hdc, bkgnd); - ExtTextOutA(hdc, 0, 0, 2, &fillRect, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &fillRect, NULL, 0, 0); /* Draw rectangular edge around tab */ DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_LEFT|BF_TOP|BF_BOTTOM); @@ -2009,7 +1999,7 @@ static void TAB_DrawItem( r1.top = r.top; r1.right = r1.left + ROUND_CORNER_SIZE + 1; r1.bottom = r1.top + ROUND_CORNER_SIZE; - ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &r1, NULL, 0, 0); r1.left++; DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDTOPRIGHT); @@ -2018,7 +2008,7 @@ static void TAB_DrawItem( r1.bottom = r.bottom; r1.right = r1.left + ROUND_CORNER_SIZE + 1; r1.top = r1.bottom - ROUND_CORNER_SIZE; - ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &r1, NULL, 0, 0); r1.left++; DrawEdge(hdc, &r1, EDGE_SUNKEN, BF_DIAGONAL_ENDTOPLEFT); } @@ -2052,7 +2042,7 @@ static void TAB_DrawItem( /* Clear interior */ SetBkColor(hdc, bkgnd); - ExtTextOutA(hdc, 0, 0, 2, &fillRect, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &fillRect, NULL, 0, 0); /* Draw rectangular edge around tab */ DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_LEFT|BF_BOTTOM|BF_RIGHT); @@ -2063,7 +2053,7 @@ static void TAB_DrawItem( r1.bottom = r.bottom; r1.right = r.right; r1.top = r1.bottom - ROUND_CORNER_SIZE - 1; - ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &r1, NULL, 0, 0); r1.bottom--; DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDBOTTOMLEFT); @@ -2072,7 +2062,7 @@ static void TAB_DrawItem( r1.bottom = r.bottom; r1.right = r1.left + ROUND_CORNER_SIZE; r1.top = r1.bottom - ROUND_CORNER_SIZE - 1; - ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &r1, NULL, 0, 0); r1.bottom--; DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDTOPLEFT); @@ -2106,7 +2096,7 @@ static void TAB_DrawItem( /* Clear interior */ SetBkColor(hdc, bkgnd); - ExtTextOutA(hdc, 0, 0, 2, &fillRect, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &fillRect, NULL, 0, 0); /* Draw rectangular edge around tab */ DrawEdge(hdc, &r, EDGE_RAISED, BF_SOFT|BF_LEFT|BF_TOP|BF_RIGHT); @@ -2117,7 +2107,7 @@ static void TAB_DrawItem( r1.top = r.top; r1.right = r.right; r1.bottom = r1.top + ROUND_CORNER_SIZE + 1; - ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &r1, NULL, 0, 0); r1.top++; DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDBOTTOMRIGHT); @@ -2126,7 +2116,7 @@ static void TAB_DrawItem( r1.top = r.top; r1.right = r1.left + ROUND_CORNER_SIZE; r1.bottom = r1.top + ROUND_CORNER_SIZE + 1; - ExtTextOutA(hdc, 0, 0, 2, &r1, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, 2, &r1, NULL, 0, 0); r1.top++; DrawEdge(hdc, &r1, EDGE_RAISED, BF_SOFT|BF_DIAGONAL_ENDTOPRIGHT); } @@ -2149,7 +2139,7 @@ static void TAB_DrawItem( static void TAB_DrawBorder (TAB_INFO *infoPtr, HDC hdc) { RECT rect; - DWORD lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); + DWORD lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); GetClientRect (infoPtr->hwnd, &rect); @@ -2190,7 +2180,7 @@ static void TAB_Refresh (TAB_INFO *infoPtr, HDC hdc) hOldFont = SelectObject (hdc, infoPtr->hFont); - if (GetWindowLongA(infoPtr->hwnd, GWL_STYLE) & TCS_BUTTONS) + if (GetWindowLongW(infoPtr->hwnd, GWL_STYLE) & TCS_BUTTONS) { for (i = 0; i < infoPtr->uNumItem; i++) TAB_DrawItem (infoPtr, hdc, i); @@ -2241,7 +2231,7 @@ static void TAB_EnsureSelectionVisible( TAB_INFO* infoPtr) { INT iSelected = infoPtr->iSelected; - LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); INT iOrigLeftmostVisible = infoPtr->leftmostVisible; /* set the items row to the bottommost row or topmost row depending on @@ -2360,7 +2350,7 @@ static void TAB_EnsureSelectionVisible( static void TAB_InvalidateTabArea(TAB_INFO* infoPtr) { RECT clientRect, rInvalidate, rAdjClient; - DWORD lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); + DWORD lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); INT lastRow = infoPtr->uNumRows - 1; RECT rect; @@ -2439,10 +2429,10 @@ static inline LRESULT TAB_Paint (TAB_INFO *infoPtr, HDC hdcPaint) } static LRESULT -TAB_InsertItemAW (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode) +TAB_InsertItemT (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode) { TAB_ITEM *item; - TCITEMA *pti; + TCITEMW *pti; INT iItem; RECT rect; @@ -2450,17 +2440,14 @@ TAB_InsertItemAW (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode TRACE("Rect: %p T %li, L %li, B %li, R %li\n", infoPtr->hwnd, rect.top, rect.left, rect.bottom, rect.right); - pti = (TCITEMA *)lParam; + pti = (TCITEMW *)lParam; iItem = (INT)wParam; if (iItem < 0) return -1; if (iItem > infoPtr->uNumItem) iItem = infoPtr->uNumItem; - if (bUnicode) - TAB_DumpItemExternalW((TCITEMW*)pti, iItem); - else - TAB_DumpItemExternalA(pti, iItem); + TAB_DumpItemExternalT(pti, iItem, bUnicode); if (infoPtr->uNumItem == 0) { @@ -2502,9 +2489,9 @@ TAB_InsertItemAW (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode if (pti->mask & TCIF_TEXT) { if (bUnicode) - Str_SetPtrW (&item->pszText, (WCHAR*)pti->pszText); + Str_SetPtrW (&item->pszText, pti->pszText); else - Str_SetPtrAtoW (&item->pszText, pti->pszText); + Str_SetPtrAtoW (&item->pszText, (LPSTR)pti->pszText); } if (pti->mask & TCIF_IMAGE) @@ -2532,7 +2519,7 @@ TAB_InsertItemAW (TAB_INFO *infoPtr, WPARAM wParam, LPARAM lParam, BOOL bUnicode static LRESULT TAB_SetItemSize (TAB_INFO *infoPtr, LPARAM lParam) { - LONG lStyle = GetWindowLongA(infoPtr->hwnd, GWL_STYLE); + LONG lStyle = GetWindowLongW(infoPtr->hwnd, GWL_STYLE); LONG lResult = 0; BOOL bNeedPaint = FALSE; @@ -2600,7 +2587,7 @@ TAB_HighlightItem (TAB_INFO *infoPtr, INT iItem, BOOL fHighlight) } static LRESULT -TAB_SetItemAW (TAB_INFO *infoPtr, INT iItem, LPTCITEMA tabItem, BOOL bUnicode) +TAB_SetItemT (TAB_INFO *infoPtr, INT iItem, LPTCITEMW tabItem, BOOL bUnicode) { TAB_ITEM *wineItem; @@ -2609,10 +2596,7 @@ TAB_SetItemAW (TAB_INFO *infoPtr, INT iItem, LPTCITEMA tabItem, BOOL bUnicode) if (iItem < 0 || iItem >= infoPtr->uNumItem) return FALSE; - if (bUnicode) - TAB_DumpItemExternalW((TCITEMW *)tabItem, iItem); - else - TAB_DumpItemExternalA(tabItem, iItem); + TAB_DumpItemExternalT(tabItem, iItem, bUnicode); wineItem = TAB_GetItem(infoPtr, iItem); @@ -2636,9 +2620,9 @@ TAB_SetItemAW (TAB_INFO *infoPtr, INT iItem, LPTCITEMA tabItem, BOOL bUnicode) wineItem->pszText = NULL; } if (bUnicode) - Str_SetPtrW(&wineItem->pszText, (WCHAR*)tabItem->pszText); + Str_SetPtrW(&wineItem->pszText, tabItem->pszText); else - Str_SetPtrAtoW(&wineItem->pszText, tabItem->pszText); + Str_SetPtrAtoW(&wineItem->pszText, (LPSTR)tabItem->pszText); } /* Update and repaint tabs */ @@ -2655,7 +2639,7 @@ static inline LRESULT TAB_GetItemCount (const TAB_INFO *infoPtr) static LRESULT -TAB_GetItemAW (TAB_INFO *infoPtr, INT iItem, LPTCITEMA tabItem, BOOL bUnicode) +TAB_GetItemT (TAB_INFO *infoPtr, INT iItem, LPTCITEMW tabItem, BOOL bUnicode) { TAB_ITEM *wineItem; @@ -2681,15 +2665,12 @@ TAB_GetItemAW (TAB_INFO *infoPtr, INT iItem, LPTCITEMA tabItem, BOOL bUnicode) if (tabItem->mask & TCIF_TEXT) { if (bUnicode) - Str_GetPtrW (wineItem->pszText, (WCHAR*)tabItem->pszText, tabItem->cchTextMax); + Str_GetPtrW (wineItem->pszText, tabItem->pszText, tabItem->cchTextMax); else - Str_GetPtrWtoA (wineItem->pszText, tabItem->pszText, tabItem->cchTextMax); + Str_GetPtrWtoA (wineItem->pszText, (LPSTR)tabItem->pszText, tabItem->cchTextMax); } - if (bUnicode) - TAB_DumpItemExternalW((TCITEMW*)tabItem, iItem); - else - TAB_DumpItemExternalA(tabItem, iItem); + TAB_DumpItemExternalT(tabItem, iItem, bUnicode); return TRUE; } @@ -2835,7 +2816,7 @@ static inline LRESULT TAB_Size (TAB_INFO *infoPtr) GetClientRect(parent, &parent_rect); cx=LOWORD (lParam); cy=HIWORD (lParam); - if (GetWindowLongA(hwnd, GWL_STYLE) & CCS_NORESIZE) + if (GetWindowLongW(hwnd, GWL_STYLE) & CCS_NORESIZE) uPosFlags |= (SWP_NOSIZE | SWP_NOMOVE); SetWindowPos (hwnd, 0, parent_rect.left, parent_rect.top, @@ -2857,14 +2838,14 @@ static inline LRESULT TAB_Size (TAB_INFO *infoPtr) static LRESULT TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) { TAB_INFO *infoPtr; - TEXTMETRICA fontMetrics; + TEXTMETRICW fontMetrics; HDC hdc; HFONT hOldFont; DWORD dwStyle; infoPtr = (TAB_INFO *)Alloc (sizeof(TAB_INFO)); - SetWindowLongA(hwnd, 0, (DWORD)infoPtr); + SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr); infoPtr->hwnd = hwnd; infoPtr->hwndNotify = ((LPCREATESTRUCTW)lParam)->hwndParent; @@ -2876,7 +2857,7 @@ static LRESULT TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) infoPtr->uVItemPadding_s = 3; infoPtr->hFont = 0; infoPtr->items = 0; - infoPtr->hcurArrow = LoadCursorA (0, (LPSTR)IDC_ARROW); + infoPtr->hcurArrow = LoadCursorW (0, (LPWSTR)IDC_ARROW); infoPtr->iSelected = -1; infoPtr->iHotTracked = -1; infoPtr->uFocus = -1; @@ -2894,13 +2875,13 @@ static LRESULT TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) /* The tab control always has the WS_CLIPSIBLINGS style. Even if you don't specify it in CreateWindow. This is necessary in order for paint to work correctly. This follows windows behaviour. */ - dwStyle = GetWindowLongA(hwnd, GWL_STYLE); - SetWindowLongA(hwnd, GWL_STYLE, dwStyle|WS_CLIPSIBLINGS); + dwStyle = GetWindowLongW(hwnd, GWL_STYLE); + SetWindowLongW(hwnd, GWL_STYLE, dwStyle|WS_CLIPSIBLINGS); if (dwStyle & TCS_TOOLTIPS) { /* Create tooltip control */ infoPtr->hwndToolTip = - CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, + CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, 0, 0, 0); @@ -2927,7 +2908,7 @@ static LRESULT TAB_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) hOldFont = SelectObject (hdc, GetStockObject (SYSTEM_FONT)); /* Use the system font to determine the initial height of a tab. */ - GetTextMetricsA(hdc, &fontMetrics); + GetTextMetricsW(hdc, &fontMetrics); /* * Make sure there is enough space for the letters + growing the @@ -2957,6 +2938,8 @@ TAB_Destroy (TAB_INFO *infoPtr) if (!infoPtr) return 0; + SetWindowLongPtrW(infoPtr->hwnd, 0, 0); + if (infoPtr->items) { for (iItem = 0; iItem < infoPtr->uNumItem; iItem++) { if (TAB_GetItem(infoPtr, iItem)->pszText) @@ -2975,7 +2958,6 @@ TAB_Destroy (TAB_INFO *infoPtr) KillTimer(infoPtr->hwnd, TAB_HOTTRACK_TIMER); Free (infoPtr); - SetWindowLongA(infoPtr->hwnd, 0, 0); return 0; } @@ -3017,11 +2999,11 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case TCM_GETITEMA: case TCM_GETITEMW: - return TAB_GetItemAW (infoPtr, (INT)wParam, (LPTCITEMA)lParam, uMsg == TCM_GETITEMW); + return TAB_GetItemT (infoPtr, (INT)wParam, (LPTCITEMW)lParam, uMsg == TCM_GETITEMW); case TCM_SETITEMA: case TCM_SETITEMW: - return TAB_SetItemAW (infoPtr, (INT)wParam, (LPTCITEMA)lParam, uMsg == TCM_SETITEMW); + return TAB_SetItemT (infoPtr, (INT)wParam, (LPTCITEMW)lParam, uMsg == TCM_SETITEMW); case TCM_DELETEITEM: return TAB_DeleteItem (infoPtr, (INT)wParam); @@ -3043,7 +3025,7 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case TCM_INSERTITEMA: case TCM_INSERTITEMW: - return TAB_InsertItemAW (infoPtr, wParam, lParam, uMsg == TCM_INSERTITEMW); + return TAB_InsertItemT (infoPtr, wParam, lParam, uMsg == TCM_INSERTITEMW); case TCM_SETITEMEXTRA: return TAB_SetItemExtra (infoPtr, (int)wParam); @@ -3171,7 +3153,7 @@ TAB_WindowProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) } -VOID +void TAB_Register (void) { WNDCLASSW wndClass; @@ -3189,7 +3171,7 @@ TAB_Register (void) } -VOID +void TAB_Unregister (void) { UnregisterClassW (WC_TABCONTROLW, NULL); diff --git a/reactos/lib/comctl32/toolbar.c b/reactos/lib/comctl32/toolbar.c index 0056c21655c..b11ea510d01 100644 --- a/reactos/lib/comctl32/toolbar.c +++ b/reactos/lib/comctl32/toolbar.c @@ -21,15 +21,6 @@ * * NOTES * - * Differences between MSDN and actual native control operation: - * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text - * to the right of the bitmap. Otherwise, this style is - * identical to TBSTYLE_FLAT." - * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL - * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result - * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does - * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001) - * * This code was audited for completeness against the documented features * of Comctl32.dll version 6.0 on Mar. 14, 2004, by Robert Shearman. * @@ -66,6 +57,16 @@ * setparnt.exe, setrows.exe, toolwnd.exe. * - Microsoft's controlspy examples. * - Charles Petzold's 'Programming Windows': gadgets.exe + * + * Differences between MSDN and actual native control operation: + * 1. MSDN says: "TBSTYLE_LIST: Creates a flat toolbar with button text + * to the right of the bitmap. Otherwise, this style is + * identical to TBSTYLE_FLAT." + * As implemented by both v4.71 and v5.80 of the native COMCTL32.DLL + * you can create a TBSTYLE_LIST without TBSTYLE_FLAT and the result + * is non-flat non-transparent buttons. Therefore TBSTYLE_LIST does + * *not* imply TBSTYLE_FLAT as documented. (GA 8/2001) + * */ #include @@ -116,9 +117,9 @@ typedef struct typedef struct { - DWORD dwStructSize; /* size of TBBUTTON struct */ - INT nHeight; /* height of the toolbar */ - INT nWidth; /* width of the toolbar */ + DWORD dwStructSize; /* size of TBBUTTON struct */ + INT nHeight; /* height of the toolbar */ + INT nWidth; /* width of the toolbar */ RECT client_rect; RECT rcBound; /* bounding rectangle */ INT nButtonHeight; @@ -145,7 +146,7 @@ typedef struct INT iListGap; /* default gap between text and image for toolbar with list style */ HFONT hDefaultFont; HFONT hFont; /* text font */ - HIMAGELIST himlInt; /* image list created internally */ + HIMAGELIST himlInt; /* image list created internally */ PIMLENTRY *himlDef; /* default image list array */ INT cimlDef; /* default image list array count */ PIMLENTRY *himlHot; /* hot image list array */ @@ -162,9 +163,9 @@ typedef struct BOOL bDragOutSent; /* has TBN_DRAGOUT notification been sent for this drag? */ BOOL bUnicode; /* Notifications are ASCII (FALSE) or Unicode (TRUE)? */ BOOL bCaptured; /* mouse captured? */ - DWORD dwStyle; /* regular toolbar style */ - DWORD dwExStyle; /* extended toolbar style */ - DWORD dwDTFlags; /* DrawText flags */ + DWORD dwStyle; /* regular toolbar style */ + DWORD dwExStyle; /* extended toolbar style */ + DWORD dwDTFlags; /* DrawText flags */ COLORREF clrInsertMark; /* insert mark color */ COLORREF clrBtnHighlight; /* color for Flat Separator */ @@ -489,7 +490,7 @@ TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc, TOOLBAR_INFO *infoPtr) newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ? comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow; oldcolor = SetBkColor (hdc, newcolor); - ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); + ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); myrect.left = myrect.right; myrect.right = myrect.left + 1; @@ -497,7 +498,7 @@ TOOLBAR_DrawFlatSeparator (LPRECT lpRect, HDC hdc, TOOLBAR_INFO *infoPtr) newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ? comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight; SetBkColor (hdc, newcolor); - ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); + ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); SetBkColor (hdc, oldcolor); } @@ -533,7 +534,7 @@ TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr, TOOLB newcolor = (infoPtr->clrBtnShadow == CLR_DEFAULT) ? comctl32_color.clrBtnShadow : infoPtr->clrBtnShadow; oldcolor = SetBkColor (hdc, newcolor); - ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); + ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); myrect.top = myrect.bottom; myrect.bottom = myrect.top + 1; @@ -541,7 +542,7 @@ TOOLBAR_DrawDDFlatSeparator (LPRECT lpRect, HDC hdc, TBUTTON_INFO *btnPtr, TOOLB newcolor = (infoPtr->clrBtnHighlight == CLR_DEFAULT) ? comctl32_color.clrBtnHighlight : infoPtr->clrBtnHighlight; SetBkColor (hdc, newcolor); - ExtTextOutA (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); + ExtTextOutW (hdc, 0, 0, ETO_OPAQUE, &myrect, 0, 0, 0); SetBkColor (hdc, oldcolor); } @@ -990,9 +991,9 @@ TOOLBAR_DrawButton (HWND hwnd, TBUTTON_INFO *btnPtr, HDC hdc) COLORREF oldclr; oldclr = SetBkColor(hdc, tbcd.clrHighlightHotTrack); - ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, ETO_OPAQUE, &rc, NULL, 0, 0); if (hasDropDownArrow) - ExtTextOutA(hdc, 0, 0, ETO_OPAQUE, &rcArrow, NULL, 0, 0); + ExtTextOutW(hdc, 0, 0, ETO_OPAQUE, &rcArrow, NULL, 0, 0); SetBkColor(hdc, oldclr); } } @@ -2531,7 +2532,7 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) /* copy the bitmap before adding it so that the user's bitmap * doesn't get modified. */ - GetObjectA ((HBITMAP)lpAddBmp->nID, sizeof(BITMAP), (LPVOID)&bmp); + GetObjectW ((HBITMAP)lpAddBmp->nID, sizeof(BITMAP), (LPVOID)&bmp); hdcImage = CreateCompatibleDC(0); hdcBitmap = CreateCompatibleDC(0); @@ -2559,48 +2560,48 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) switch (lpAddBmp->nID) { case IDB_STD_SMALL_COLOR: - hbmLoad = LoadBitmapA (COMCTL32_hModule, - MAKEINTRESOURCEA(IDB_STD_SMALL)); + hbmLoad = LoadBitmapW (COMCTL32_hModule, + MAKEINTRESOURCEW(IDB_STD_SMALL)); nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace); DeleteObject (hbmLoad); break; case IDB_STD_LARGE_COLOR: - hbmLoad = LoadBitmapA (COMCTL32_hModule, - MAKEINTRESOURCEA(IDB_STD_LARGE)); + hbmLoad = LoadBitmapW (COMCTL32_hModule, + MAKEINTRESOURCEW(IDB_STD_LARGE)); nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace); DeleteObject (hbmLoad); break; case IDB_VIEW_SMALL_COLOR: - hbmLoad = LoadBitmapA (COMCTL32_hModule, - MAKEINTRESOURCEA(IDB_VIEW_SMALL)); + hbmLoad = LoadBitmapW (COMCTL32_hModule, + MAKEINTRESOURCEW(IDB_VIEW_SMALL)); nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace); DeleteObject (hbmLoad); break; case IDB_VIEW_LARGE_COLOR: - hbmLoad = LoadBitmapA (COMCTL32_hModule, - MAKEINTRESOURCEA(IDB_VIEW_LARGE)); + hbmLoad = LoadBitmapW (COMCTL32_hModule, + MAKEINTRESOURCEW(IDB_VIEW_LARGE)); nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace); DeleteObject (hbmLoad); break; case IDB_HIST_SMALL_COLOR: - hbmLoad = LoadBitmapA (COMCTL32_hModule, - MAKEINTRESOURCEA(IDB_HIST_SMALL)); + hbmLoad = LoadBitmapW (COMCTL32_hModule, + MAKEINTRESOURCEW(IDB_HIST_SMALL)); nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace); DeleteObject (hbmLoad); break; case IDB_HIST_LARGE_COLOR: - hbmLoad = LoadBitmapA (COMCTL32_hModule, - MAKEINTRESOURCEA(IDB_HIST_LARGE)); + hbmLoad = LoadBitmapW (COMCTL32_hModule, + MAKEINTRESOURCEW(IDB_HIST_LARGE)); nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace); DeleteObject (hbmLoad); @@ -2614,7 +2615,7 @@ TOOLBAR_AddBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) } else { - hbmLoad = LoadBitmapA (lpAddBmp->hInst, (LPSTR)lpAddBmp->nID); + hbmLoad = LoadBitmapW (lpAddBmp->hInst, (LPWSTR)lpAddBmp->nID); nIndex = ImageList_AddMasked (himlDef, hbmLoad, comctl32_color.clrBtnFace); DeleteObject (hbmLoad); } @@ -2807,8 +2808,7 @@ TOOLBAR_AddStringA (HWND hwnd, WPARAM wParam, LPARAM lParam) INT len; TRACE("adding string from resource!\n"); - len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam, - szString, 256); + len = LoadStringA ((HINSTANCE)wParam, (UINT)lParam, szString, sizeof(szString)); TRACE("len=%d \"%s\"\n", len, szString); nIndex = infoPtr->nNumStrings; @@ -3445,7 +3445,7 @@ TOOLBAR_GetButtonSize (HWND hwnd) return MAKELONG((WORD)infoPtr->nButtonWidth, (WORD)infoPtr->nButtonHeight); else - return MAKELONG(8,7); + return MAKELONG(23,22); } @@ -4331,7 +4331,7 @@ TOOLBAR_ReplaceBitmap (HWND hwnd, WPARAM wParam, LPARAM lParam) /* copy the bitmap before adding it so that the user's bitmap * doesn't get modified. */ - GetObjectA (hBitmap, sizeof(BITMAP), (LPVOID)&bmp); + GetObjectW (hBitmap, sizeof(BITMAP), (LPVOID)&bmp); hdcImage = CreateCompatibleDC(0); hdcBitmap = CreateCompatibleDC(0); @@ -4430,7 +4430,7 @@ TOOLBAR_Restore(TOOLBAR_INFO *infoPtr, LPTBSAVEPARAMSW lpSave) res = ERROR_FILE_NOT_FOUND; if (!res) { - nmtbr.pData = HeapAlloc(GetProcessHeap(), 0, dwSize); + nmtbr.pData = Alloc(dwSize); nmtbr.cbData = (UINT)dwSize; if (!nmtbr.pData) res = ERROR_OUTOFMEMORY; } @@ -4503,7 +4503,7 @@ TOOLBAR_Restore(TOOLBAR_INFO *infoPtr, LPTBSAVEPARAMSW lpSave) if (infoPtr->nNumButtons > 0) ret = TRUE; } } - HeapFree(GetProcessHeap(), 0, nmtbr.pData); + Free (nmtbr.pData); RegCloseKey(hkey); return ret; @@ -4527,22 +4527,33 @@ TOOLBAR_SaveRestoreW (HWND hwnd, WPARAM wParam, LPTBSAVEPARAMSW lpSave) static LRESULT TOOLBAR_SaveRestoreA (HWND hwnd, WPARAM wParam, LPTBSAVEPARAMSA lpSave) { + LPWSTR pszValueName = 0, pszSubKey = 0; TBSAVEPARAMSW SaveW; + LRESULT result = 0; int len; if (lpSave == NULL) return 0; - SaveW.hkr = lpSave->hkr; - 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); + pszSubKey = Alloc(len * sizeof(WCHAR)); + if (pszSubKey) goto exit; + MultiByteToWideChar(CP_ACP, 0, lpSave->pszSubKey, -1, pszSubKey, len); 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); + pszValueName = Alloc(len * sizeof(WCHAR)); + if (!pszValueName) goto exit; + MultiByteToWideChar(CP_ACP, 0, lpSave->pszValueName, -1, pszValueName, len); - return TOOLBAR_SaveRestoreW(hwnd, wParam, &SaveW); + SaveW.pszValueName = pszValueName; + SaveW.pszSubKey = pszSubKey; + SaveW.hkr = lpSave->hkr; + result = TOOLBAR_SaveRestoreW(hwnd, wParam, &SaveW); + +exit: + Free (pszValueName); + Free (pszSubKey); + + return result; } @@ -5442,7 +5453,7 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) { TOOLBAR_INFO *infoPtr = TOOLBAR_GetInfoPtr (hwnd); DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); - LOGFONTA logFont; + LOGFONTW logFont; TRACE("hwnd = %p\n", hwnd); @@ -5483,13 +5494,13 @@ TOOLBAR_Create (HWND hwnd, WPARAM wParam, LPARAM lParam) 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); + SystemParametersInfoW (SPI_GETICONTITLELOGFONT, 0, &logFont, 0); + infoPtr->hFont = infoPtr->hDefaultFont = CreateFontIndirectW (&logFont); if (dwStyle & TBSTYLE_TOOLTIPS) { /* Create tooltip control */ infoPtr->hwndToolTip = - CreateWindowExA (0, TOOLTIPS_CLASSA, NULL, 0, + CreateWindowExW (0, TOOLTIPS_CLASSW, NULL, 0, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, 0, 0, 0); @@ -5523,7 +5534,7 @@ TOOLBAR_Destroy (HWND hwnd, WPARAM wParam, LPARAM lParam) DestroyWindow (infoPtr->hwndToolTip); /* delete temporary buffer for tooltip text */ - HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText); + Free (infoPtr->pszTooltipText); /* delete button data */ if (infoPtr->buttons) @@ -5653,7 +5664,7 @@ TOOLBAR_LButtonDblClk (HWND hwnd, WPARAM wParam, LPARAM lParam) if (nHit >= 0) TOOLBAR_LButtonDown (hwnd, wParam, lParam); - else if (GetWindowLongA (hwnd, GWL_STYLE) & CCS_ADJUSTABLE) + else if (GetWindowLongW (hwnd, GWL_STYLE) & CCS_ADJUSTABLE) TOOLBAR_Customize (hwnd); return 0; @@ -6187,22 +6198,22 @@ TOOLBAR_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) /* native control does: * Get a lot of colors and brushes * WM_NOTIFYFORMAT - * SystemParametersInfoA(0x1f, 0x3c, adr1, 0) - * CreateFontIndirectA(adr1) + * SystemParametersInfoW(0x1f, 0x3c, adr1, 0) + * CreateFontIndirectW(adr1) * CreateBitmap(0x27, 0x24, 1, 1, 0) * hdc = GetDC(toolbar) * GetSystemMetrics(0x48) - * fnt2=CreateFontA(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2, + * fnt2=CreateFontW(0xe, 0, 0, 0, 0x190, 0, 0, 0, 0, 2, * 0, 0, 0, 0, "MARLETT") * oldfnt = SelectObject(hdc, fnt2) - * GetCharWidthA(hdc, 0x36, 0x36, adr2) - * GetTextMetricsA(hdc, adr3) + * GetCharWidthW(hdc, 0x36, 0x36, adr2) + * GetTextMetricsW(hdc, adr3) * SelectObject(hdc, oldfnt) * DeleteObject(fnt2) * ReleaseDC(hdc) * InvalidateRect(toolbar, 0, 1) - * SetWindowLongA(toolbar, 0, addr) - * SetWindowLongA(toolbar, -16, xxx) **sometimes** + * SetWindowLongW(toolbar, 0, addr) + * SetWindowLongW(toolbar, -16, xxx) **sometimes** * WM_STYLECHANGING * CallWinEx old new * ie 1 0x56000a4c 0x46000a4c 0x56008a4d @@ -6277,7 +6288,7 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm TRACE("button index = %d\n", index); - HeapFree(GetProcessHeap(), 0, infoPtr->pszTooltipText); + Free (infoPtr->pszTooltipText); infoPtr->pszTooltipText = NULL; if (index < 0) @@ -6307,7 +6318,7 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm /* need to allocate temporary buffer in infoPtr as there * isn't enough space in buffer passed to us by the * tooltip control */ - infoPtr->pszTooltipText = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR)); + infoPtr->pszTooltipText = Alloc((len+1)*sizeof(WCHAR)); if (infoPtr->pszTooltipText) { memcpy(infoPtr->pszTooltipText, tbgit.pszText, (len+1)*sizeof(WCHAR)); @@ -6345,7 +6356,7 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm /* need to allocate temporary buffer in infoPtr as there * isn't enough space in buffer passed to us by the * tooltip control */ - infoPtr->pszTooltipText = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR)); + infoPtr->pszTooltipText = Alloc((len+1)*sizeof(WCHAR)); if (infoPtr->pszTooltipText) { MultiByteToWideChar(CP_ACP, 0, tbgit.pszText, len+1, infoPtr->pszTooltipText, (len+1)*sizeof(WCHAR)); @@ -6375,7 +6386,7 @@ static LRESULT TOOLBAR_TTGetDispInfo (TOOLBAR_INFO *infoPtr, NMTTDISPINFOW *lpnm /* need to allocate temporary buffer in infoPtr as there * isn't enough space in buffer passed to us by the * tooltip control */ - infoPtr->pszTooltipText = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR)); + infoPtr->pszTooltipText = Alloc((len+1)*sizeof(WCHAR)); if (infoPtr->pszTooltipText) { memcpy(infoPtr->pszTooltipText, pszText, (len+1)*sizeof(WCHAR)); diff --git a/reactos/lib/comctl32/tooltips.c b/reactos/lib/comctl32/tooltips.c index e7499ad7353..7abe894b013 100644 --- a/reactos/lib/comctl32/tooltips.c +++ b/reactos/lib/comctl32/tooltips.c @@ -18,6 +18,8 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * NOTES + * * This code was audited for completeness against the documented features * of Comctl32.dll version 6.0 on Sep. 08, 2004, by Robert Shearman. * @@ -214,7 +216,7 @@ TOOLTIPS_Refresh (HWND hwnd, HDC hdc) if (infoPtr->nMaxTipWidth > -1) uFlags |= DT_WORDBREAK; - if (GetWindowLongA (hwnd, GWL_STYLE) & TTS_NOPREFIX) + if (GetWindowLongW (hwnd, GWL_STYLE) & TTS_NOPREFIX) uFlags |= DT_NOPREFIX; GetClientRect (hwnd, &rc); @@ -385,7 +387,7 @@ static void TOOLTIPS_GetDispInfoW(HWND hwnd, TOOLTIPS_INFO *infoPtr, TTTOOL_INFO else if (ttnmdi.lpszText != LPSTR_TEXTCALLBACKW) { INT max_len = (ttnmdi.lpszText == &ttnmdi.szText[0]) ? sizeof(ttnmdi.szText)/sizeof(ttnmdi.szText[0]) : INFOTIPSIZE-1; - strncpyW(infoPtr->szTipText, ttnmdi.lpszText, max_len); + lstrcpynW(infoPtr->szTipText, ttnmdi.lpszText, max_len); if (ttnmdi.uFlags & TTF_DI_SETITEM) { INT len = max(strlenW(ttnmdi.lpszText), max_len); toolPtr->hinst = 0; @@ -610,8 +612,8 @@ TOOLTIPS_Show (HWND hwnd, TOOLTIPS_INFO *infoPtr) rect.top = rect.bottom - size.cy; } - AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE), - FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE)); + AdjustWindowRectEx (&rect, GetWindowLongW (hwnd, GWL_STYLE), + FALSE, GetWindowLongW (hwnd, GWL_EXSTYLE)); if (style & TTS_BALLOON) { @@ -782,8 +784,8 @@ TOOLTIPS_TrackShow (HWND hwnd, TOOLTIPS_INFO *infoPtr) rect.right = rect.left + size.cx; rect.bottom = rect.top + size.cy; - AdjustWindowRectEx (&rect, GetWindowLongA (hwnd, GWL_STYLE), - FALSE, GetWindowLongA (hwnd, GWL_EXSTYLE)); + AdjustWindowRectEx (&rect, GetWindowLongW (hwnd, GWL_STYLE), + FALSE, GetWindowLongW (hwnd, GWL_EXSTYLE)); if (GetWindowLongW(hwnd, GWL_STYLE) & TTS_BALLOON) { @@ -945,7 +947,7 @@ TOOLTIPS_CheckTool (HWND hwnd, BOOL bShowTest) if (nTool == -1) return -1; - if (!(GetWindowLongA (hwnd, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) { + if (!(GetWindowLongW (hwnd, GWL_STYLE) & TTS_ALWAYSTIP) && bShowTest) { if (!TOOLTIPS_IsWindowActive (GetWindow (hwnd, GW_OWNER))) return -1; } @@ -2395,8 +2397,8 @@ TOOLTIPS_MouseMessage (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) static LRESULT TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) { - DWORD dwStyle = GetWindowLongA (hwnd, GWL_STYLE); - DWORD dwExStyle = GetWindowLongA (hwnd, GWL_EXSTYLE); + DWORD dwStyle = GetWindowLongW (hwnd, GWL_STYLE); + DWORD dwExStyle = GetWindowLongW (hwnd, GWL_EXSTYLE); dwStyle &= 0x0000FFFF; dwStyle |= (WS_POPUP | WS_BORDER | WS_CLIPSIBLINGS); @@ -2405,10 +2407,10 @@ TOOLTIPS_NCCreate (HWND hwnd, WPARAM wParam, LPARAM lParam) * window region, therefore it is useless to us in balloon mode */ if (dwStyle & TTS_BALLOON) dwStyle &= ~WS_BORDER; - SetWindowLongA (hwnd, GWL_STYLE, dwStyle); + SetWindowLongW (hwnd, GWL_STYLE, dwStyle); dwExStyle |= WS_EX_TOOLWINDOW; - SetWindowLongA (hwnd, GWL_EXSTYLE, dwExStyle); + SetWindowLongW (hwnd, GWL_EXSTYLE, dwExStyle); return TRUE; } diff --git a/reactos/lib/comctl32/treeview.c b/reactos/lib/comctl32/treeview.c index 0c4a5cc4e73..0bf386c33d9 100644 --- a/reactos/lib/comctl32/treeview.c +++ b/reactos/lib/comctl32/treeview.c @@ -19,6 +19,8 @@ * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * + * NOTES + * * Note that TREEVIEW_INFO * and HTREEITEM are the same thing. * * Note2: All items always! have valid (allocated) pszText field. @@ -239,6 +241,39 @@ TREEVIEW_GetItemIndex(TREEVIEW_INFO *infoPtr, HTREEITEM handle) return DPA_GetPtrIndex(infoPtr->items, handle); } +/* Checks if item has changed and needs to be redrawn */ +static inline BOOL item_changed (TREEVIEW_ITEM *tiOld, TREEVIEW_ITEM *tiNew, LPTVITEMEXW tvChange) +{ + /* Number of children has changed */ + if ((tvChange->mask & TVIF_CHILDREN) && (tiOld->cChildren != tiNew->cChildren)) + return TRUE; + + /* Image has changed and it's not a callback */ + if ((tvChange->mask & TVIF_IMAGE) && (tiOld->iImage != tiNew->iImage) && + tiNew->iImage != I_IMAGECALLBACK) + return TRUE; + + /* Selected image has changed and it's not a callback */ + if ((tvChange->mask & TVIF_SELECTEDIMAGE) && (tiOld->iSelectedImage != tiNew->iSelectedImage) && + tiNew->iSelectedImage != I_IMAGECALLBACK) + return TRUE; + + /* Text has changed and it's not a callback */ + if ((tvChange->mask & TVIF_TEXT) && (tiOld->pszText != tiNew->pszText) && + tiNew->pszText != LPSTR_TEXTCALLBACKW) + return TRUE; + + /* Indent has changed */ + if ((tvChange->mask & TVIF_INTEGRAL) && (tiOld->iIntegral != tiNew->iIntegral)) + return TRUE; + + /* Item state has changed */ + if ((tvChange->mask & TVIF_STATE) && ((tiOld->state ^ tiNew->state) & tvChange->stateMask )) + return TRUE; + + return FALSE; +} + /*************************************************************************** * This method checks that handle is an item for this tree. */ @@ -489,7 +524,6 @@ TREEVIEW_TVItemFromItem(TREEVIEW_INFO *infoPtr, UINT mask, TVITEMW *tvItem, TREE tvItem->state = item->state; tvItem->stateMask = 0; tvItem->iImage = item->iImage; - tvItem->iImage = item->iImage; tvItem->iSelectedImage = item->iSelectedImage; tvItem->cChildren = item->cChildren; tvItem->lParam = item->lParam; @@ -615,10 +649,10 @@ TREEVIEW_SendCustomDrawNotify(TREEVIEW_INFO *infoPtr, DWORD dwDrawStage, static BOOL TREEVIEW_SendCustomDrawItemNotify(TREEVIEW_INFO *infoPtr, HDC hdc, - TREEVIEW_ITEM *wineItem, UINT uItemDrawState) + TREEVIEW_ITEM *wineItem, UINT uItemDrawState, + NMTVCUSTOMDRAW *nmcdhdr) { HWND hwnd = infoPtr->hwnd; - NMTVCUSTOMDRAW nmcdhdr; LPNMCUSTOMDRAW nmcd; DWORD dwDrawStage, dwItemSpec; UINT uItemState; @@ -634,7 +668,7 @@ TREEVIEW_SendCustomDrawItemNotify(TREEVIEW_INFO *infoPtr, HDC hdc, if (wineItem == infoPtr->hotItem) uItemState |= CDIS_HOT; - nmcd = &nmcdhdr.nmcd; + nmcd = &nmcdhdr->nmcd; nmcd->hdr.hwndFrom = hwnd; nmcd->hdr.idFrom = GetWindowLongPtrW(hwnd, GWLP_ID); nmcd->hdr.code = NM_CUSTOMDRAW; @@ -644,9 +678,7 @@ TREEVIEW_SendCustomDrawItemNotify(TREEVIEW_INFO *infoPtr, HDC hdc, nmcd->dwItemSpec = dwItemSpec; nmcd->uItemState = uItemState; nmcd->lItemlParam = wineItem->lParam; - nmcdhdr.clrText = infoPtr->clrText; - nmcdhdr.clrTextBk = infoPtr->clrBk; - nmcdhdr.iLevel = wineItem->iLevel; + nmcdhdr->iLevel = wineItem->iLevel; TRACE("drawstage:%lx hdc:%p item:%lx, itemstate:%x, lItemlParam:%lx\n", nmcd->dwDrawStage, nmcd->hdc, nmcd->dwItemSpec, @@ -654,10 +686,8 @@ TREEVIEW_SendCustomDrawItemNotify(TREEVIEW_INFO *infoPtr, HDC hdc, retval = TREEVIEW_SendRealNotify(infoPtr, (WPARAM)nmcd->hdr.idFrom, - (LPARAM)&nmcdhdr); + (LPARAM)nmcdhdr); - infoPtr->clrText = nmcdhdr.clrText; - infoPtr->clrBk = nmcdhdr.clrTextBk; return (BOOL)retval; } @@ -974,6 +1004,9 @@ TREEVIEW_AllocateItem(TREEVIEW_INFO *infoPtr) if (!newItem) return NULL; + newItem->iImage = -1; + newItem->iSelectedImage = -1; + if (DPA_InsertPtr(infoPtr->items, INT_MAX, newItem) == -1) { Free(newItem); @@ -2112,9 +2145,8 @@ TREEVIEW_SetItemT(TREEVIEW_INFO *infoPtr, LPTVITEMEXW tvItem, BOOL isW) /* The refresh updates everything, but we can't wait until then. */ TREEVIEW_ComputeItemInternalMetrics(infoPtr, wineItem); - /* if any of the items values changed, redraw the item */ - if(memcmp(&originalItem, wineItem, sizeof(TREEVIEW_ITEM)) || - (tvItem->stateMask & TVIS_BOLD)) + /* if any of the item's values changed and it's not a callback, redraw the item */ + if (item_changed(&originalItem, wineItem, tvItem)) { if (tvItem->mask & TVIF_INTEGRAL) { @@ -2263,10 +2295,14 @@ TREEVIEW_DrawItemLines(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item) BOOL lar = ((infoPtr->dwStyle & (TVS_LINESATROOT|TVS_HASLINES|TVS_HASBUTTONS)) > TVS_LINESATROOT); + HBRUSH hbr, hbrOld; if (!lar && item->iLevel == 0) return; + hbr = CreateSolidBrush(infoPtr->clrBk); + hbrOld = SelectObject(hdc, hbr); + centerx = (item->linesOffset + item->stateOffset) / 2; centery = (item->rect.top + item->rect.bottom) / 2; @@ -2333,15 +2369,10 @@ TREEVIEW_DrawItemLines(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item) HPEN hNewPen = CreatePen(PS_SOLID, 0, infoPtr->clrLine); HPEN hOldPen = SelectObject(hdc, hNewPen); - HBRUSH hbr = CreateSolidBrush(infoPtr->clrBk); - HBRUSH hbrOld = SelectObject(hdc, hbr); Rectangle(hdc, centerx - rectsize - 1, centery - rectsize - 1, centerx + rectsize + 2, centery + rectsize + 2); - SelectObject(hdc, hbrOld); - DeleteObject(hbr); - SelectObject(hdc, hOldPen); DeleteObject(hNewPen); @@ -2371,6 +2402,8 @@ TREEVIEW_DrawItemLines(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *item) } } } + SelectObject(hdc, hbrOld); + DeleteObject(hbr); } static void @@ -2378,12 +2411,50 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem) { INT cditem; HFONT hOldFont; + COLORREF oldTextColor, oldTextBkColor; int centery; - - hOldFont = SelectObject(hdc, TREEVIEW_FontForItem(infoPtr, wineItem)); + BOOL inFocus = (GetFocus() == infoPtr->hwnd); + NMTVCUSTOMDRAW nmcdhdr; TREEVIEW_UpdateDispInfo(infoPtr, wineItem, CALLBACK_MASK_ALL); + /* - If item is drop target or it is selected and window is in focus - + * use blue background (COLOR_HIGHLIGHT). + * - If item is selected, window is not in focus, but it has style + * TVS_SHOWSELALWAYS - use grey background (COLOR_BTNFACE) + * - Otherwise - use background color + */ + if ((wineItem->state & TVIS_DROPHILITED) || ((wineItem == infoPtr->focusedItem) && !(wineItem->state & TVIS_SELECTED)) || + ((wineItem->state & TVIS_SELECTED) && (!infoPtr->focusedItem) && + (inFocus || (infoPtr->dwStyle & TVS_SHOWSELALWAYS)))) + { + if ((wineItem->state & TVIS_DROPHILITED) || inFocus) + { + nmcdhdr.clrTextBk = GetSysColor(COLOR_HIGHLIGHT); + nmcdhdr.clrText = GetSysColor(COLOR_HIGHLIGHTTEXT); + } + else + { + nmcdhdr.clrTextBk = GetSysColor(COLOR_BTNFACE); + if (infoPtr->clrText == -1) + nmcdhdr.clrText = GetSysColor(COLOR_WINDOWTEXT); + else + nmcdhdr.clrText = infoPtr->clrText; + } + } + else + { + nmcdhdr.clrTextBk = infoPtr->clrBk; + if ((infoPtr->dwStyle & TVS_TRACKSELECT) && (wineItem == infoPtr->hotItem)) + nmcdhdr.clrText = comctl32_color.clrHighlight; + else if (infoPtr->clrText == -1) + nmcdhdr.clrText = GetSysColor(COLOR_WINDOWTEXT); + else + nmcdhdr.clrText = infoPtr->clrText; + } + + hOldFont = SelectObject(hdc, TREEVIEW_FontForItem(infoPtr, wineItem)); + /* The custom draw handler can query the text rectangle, * so get ready. */ /* should already be known, set to 0 when changed */ @@ -2395,7 +2466,7 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem) if (infoPtr->cdmode & CDRF_NOTIFYITEMDRAW) { cditem = TREEVIEW_SendCustomDrawItemNotify - (infoPtr, hdc, wineItem, CDDS_ITEMPREPAINT); + (infoPtr, hdc, wineItem, CDDS_ITEMPREPAINT, &nmcdhdr); TRACE("prepaint:cditem-app returns 0x%x\n", cditem); if (cditem & CDRF_SKIPDEFAULT) @@ -2410,6 +2481,10 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem) TREEVIEW_DrawItemLines(infoPtr, hdc, wineItem); + /* Set colors. Custom draw handler can change these so we do this after it. */ + oldTextColor = SetTextColor(hdc, nmcdhdr.clrText); + oldTextBkColor = SetBkColor(hdc, nmcdhdr.clrTextBk); + centery = (wineItem->rect.top + wineItem->rect.bottom) / 2; /* @@ -2435,7 +2510,7 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem) * non-selected image. */ - if ((wineItem->state & TVIS_SELECTED) && (wineItem->iSelectedImage)) + if ((wineItem->state & TVIS_SELECTED) && (wineItem->iSelectedImage >= 0)) { /* The item is currently selected */ imageIndex = wineItem->iSelectedImage; @@ -2467,87 +2542,31 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem) { if (wineItem->pszText) { - COLORREF oldTextColor = 0; - INT oldBkMode; - HBRUSH hbrBk = 0; - BOOL inFocus = (GetFocus() == infoPtr->hwnd); RECT rcText; - oldBkMode = SetBkMode(hdc, TRANSPARENT); - - /* - If item is drop target or it is selected and window is in focus - - * use blue background (COLOR_HIGHLIGHT). - * - If item is selected, window is not in focus, but it has style - * TVS_SHOWSELALWAYS - use grey background (COLOR_BTNFACE) - * - Otherwise - don't fill background - */ - if ((wineItem->state & TVIS_DROPHILITED) || ((wineItem == infoPtr->focusedItem) && !(wineItem->state & TVIS_SELECTED)) || - ((wineItem->state & TVIS_SELECTED) && (!infoPtr->focusedItem) && - (inFocus || (infoPtr->dwStyle & TVS_SHOWSELALWAYS)))) - { - if ((wineItem->state & TVIS_DROPHILITED) || inFocus) - { - hbrBk = CreateSolidBrush(GetSysColor(COLOR_HIGHLIGHT)); - oldTextColor = - SetTextColor(hdc, GetSysColor(COLOR_HIGHLIGHTTEXT)); - } - else - { - hbrBk = CreateSolidBrush(GetSysColor(COLOR_BTNFACE)); - - if (infoPtr->clrText == -1) - oldTextColor = - SetTextColor(hdc, GetSysColor(COLOR_WINDOWTEXT)); - else - oldTextColor = SetTextColor(hdc, infoPtr->clrText); - } - } - else - { - 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 - oldTextColor = SetTextColor(hdc, infoPtr->clrText); - } - rcText.top = wineItem->rect.top; rcText.bottom = wineItem->rect.bottom; rcText.left = wineItem->textOffset; rcText.right = rcText.left + wineItem->textWidth + 4; - if (hbrBk) - { - FillRect(hdc, &rcText, hbrBk); - DeleteObject(hbrBk); - } + TRACE("drawing text %s at (%ld,%ld)-(%ld,%ld)\n", + debugstr_w(wineItem->pszText), + rcText.left, rcText.top, rcText.right, rcText.bottom); + /* Draw it */ + ExtTextOutW(hdc, rcText.left + 2, rcText.top + 1, + ETO_CLIPPED | ETO_OPAQUE, + &rcText, + wineItem->pszText, + lstrlenW(wineItem->pszText), + NULL); + /* Draw the box around the selected item */ if ((wineItem == infoPtr->selectedItem) && inFocus) { DrawFocusRect(hdc,&rcText); } - InflateRect(&rcText, -2, -1); /* allow for the focus rect */ - - TRACE("drawing text %s at (%ld,%ld)-(%ld,%ld)\n", - debugstr_w(wineItem->pszText), - rcText.left, rcText.top, rcText.right, rcText.bottom); - - /* Draw it */ - DrawTextW(hdc, - wineItem->pszText, - lstrlenW(wineItem->pszText), - &rcText, - DT_CENTER | DT_VCENTER | DT_SINGLELINE | DT_NOPREFIX); - - /* Restore the hdc state */ - SetTextColor(hdc, oldTextColor); - - if (oldBkMode != TRANSPARENT) - SetBkMode(hdc, oldBkMode); } } @@ -2591,10 +2610,13 @@ TREEVIEW_DrawItem(TREEVIEW_INFO *infoPtr, HDC hdc, TREEVIEW_ITEM *wineItem) if (cditem & CDRF_NOTIFYPOSTPAINT) { cditem = TREEVIEW_SendCustomDrawItemNotify - (infoPtr, hdc, wineItem, CDDS_ITEMPOSTPAINT); + (infoPtr, hdc, wineItem, CDDS_ITEMPOSTPAINT, &nmcdhdr); TRACE("postpaint:cditem-app returns 0x%x\n", cditem); } + /* Restore the hdc state */ + SetTextColor(hdc, oldTextColor); + SetBkColor(hdc, oldTextBkColor); SelectObject(hdc, hOldFont); } @@ -2814,7 +2836,7 @@ TREEVIEW_Paint(TREEVIEW_INFO *infoPtr, WPARAM wParam) BITMAP bitmap; hbitmap = GetCurrentObject(hdc, OBJ_BITMAP); if (!hbitmap) return 0; - GetObjectA(hbitmap, sizeof(BITMAP), &bitmap); + GetObjectW(hbitmap, sizeof(BITMAP), &bitmap); rc.left = 0; rc.top = 0; rc.right = bitmap.bmWidth; rc.bottom = bitmap.bmHeight; @@ -3807,7 +3829,7 @@ TREEVIEW_TrackMouse(TREEVIEW_INFO *infoPtr, POINT pt) while (1) { - if (PeekMessageA(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) + if (PeekMessageW(&msg, 0, 0, 0, PM_REMOVE | PM_NOYIELD)) { if (msg.message == WM_MOUSEMOVE) { @@ -3829,7 +3851,7 @@ TREEVIEW_TrackMouse(TREEVIEW_INFO *infoPtr, POINT pt) break; } - DispatchMessageA(&msg); + DispatchMessageW(&msg); } if (GetCapture() != infoPtr->hwnd) @@ -4216,14 +4238,17 @@ TREEVIEW_DoSelectItem(TREEVIEW_INFO *infoPtr, INT action, HTREEITEM newSelect, TREEVIEW_EnsureVisible(infoPtr, infoPtr->selectedItem, FALSE); + if (prevSelect) + TREEVIEW_Invalidate(infoPtr, prevSelect); + if (newSelect) + TREEVIEW_Invalidate(infoPtr, newSelect); + TREEVIEW_SendTreeviewNotify(infoPtr, TVN_SELCHANGEDW, cause, TVIF_HANDLE | TVIF_STATE | TVIF_PARAM, prevSelect, newSelect); - TREEVIEW_Invalidate(infoPtr, prevSelect); - TREEVIEW_Invalidate(infoPtr, newSelect); break; case TVGN_DROPHILITE: @@ -4242,9 +4267,12 @@ TREEVIEW_DoSelectItem(TREEVIEW_INFO *infoPtr, INT action, HTREEITEM newSelect, break; case TVGN_FIRSTVISIBLE: - TREEVIEW_EnsureVisible(infoPtr, newSelect, FALSE); - TREEVIEW_SetFirstVisible(infoPtr, newSelect, TRUE); - TREEVIEW_Invalidate(infoPtr, NULL); + if (newSelect != NULL) + { + TREEVIEW_EnsureVisible(infoPtr, newSelect, FALSE); + TREEVIEW_SetFirstVisible(infoPtr, newSelect, TRUE); + TREEVIEW_Invalidate(infoPtr, NULL); + } break; } @@ -4381,10 +4409,18 @@ static INT TREEVIEW_ProcessLetterKeys( idx=infoPtr->root->firstChild; } do { + /* At the end point, sort out wrapping */ if (idx == NULL) { + + /* If endidx is null, stop at the last item (ie top to bottom) */ if (endidx == NULL) break; + + /* Otherwise, start again at the very beginning */ idx=infoPtr->root->firstChild; + + /* But if we are stopping on the first child, end now! */ + if (idx == endidx) break; } /* get item */ @@ -5180,7 +5216,7 @@ TREEVIEW_Notify(TREEVIEW_INFO *infoPtr, WPARAM wParam, LPARAM lParam) } return 0; } - return DefWindowProcA(infoPtr->hwnd, WM_NOTIFY, wParam, lParam); + return DefWindowProcW(infoPtr->hwnd, WM_NOTIFY, wParam, lParam); } static INT TREEVIEW_NotifyFormat (TREEVIEW_INFO *infoPtr, HWND hwndFrom, UINT nCommand) @@ -5289,8 +5325,8 @@ TREEVIEW_SetFocus(TREEVIEW_INFO *infoPtr) TVC_UNKNOWN); } - TREEVIEW_SendSimpleNotify(infoPtr, NM_SETFOCUS); TREEVIEW_Invalidate(infoPtr, infoPtr->selectedItem); + TREEVIEW_SendSimpleNotify(infoPtr, NM_SETFOCUS); return 0; } @@ -5299,8 +5335,9 @@ TREEVIEW_KillFocus(TREEVIEW_INFO *infoPtr) { TRACE("\n"); - TREEVIEW_SendSimpleNotify(infoPtr, NM_KILLFOCUS); TREEVIEW_Invalidate(infoPtr, infoPtr->selectedItem); + UpdateWindow(infoPtr->hwnd); + TREEVIEW_SendSimpleNotify(infoPtr, NM_KILLFOCUS); return 0; } @@ -5567,7 +5604,7 @@ TREEVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) if ((uMsg >= WM_USER) && (uMsg < WM_APP)) TRACE("Unknown msg %04x wp=%08x lp=%08lx\n", uMsg, wParam, lParam); def: - return DefWindowProcA(hwnd, uMsg, wParam, lParam); + return DefWindowProcW(hwnd, uMsg, wParam, lParam); } } @@ -5577,28 +5614,28 @@ def: VOID TREEVIEW_Register(void) { - WNDCLASSA wndClass; + WNDCLASSW wndClass; TRACE("\n"); - ZeroMemory(&wndClass, sizeof(WNDCLASSA)); + ZeroMemory(&wndClass, sizeof(WNDCLASSW)); wndClass.style = CS_GLOBALCLASS | CS_DBLCLKS; wndClass.lpfnWndProc = TREEVIEW_WindowProc; wndClass.cbClsExtra = 0; wndClass.cbWndExtra = sizeof(TREEVIEW_INFO *); - wndClass.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW); + wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW); wndClass.hbrBackground = 0; - wndClass.lpszClassName = WC_TREEVIEWA; + wndClass.lpszClassName = WC_TREEVIEWW; - RegisterClassA(&wndClass); + RegisterClassW(&wndClass); } VOID TREEVIEW_Unregister(void) { - UnregisterClassA(WC_TREEVIEWA, NULL); + UnregisterClassW(WC_TREEVIEWW, NULL); } diff --git a/reactos/lib/comctl32/updown.c b/reactos/lib/comctl32/updown.c index e88ddf69a37..9dc705aad42 100644 --- a/reactos/lib/comctl32/updown.c +++ b/reactos/lib/comctl32/updown.c @@ -49,6 +49,7 @@ typedef struct { HWND Self; /* Handle to this up-down control */ HWND Notify; /* Handle to the parent window */ + DWORD dwStyle; /* The GWL_STYLE for this window */ UINT AccelCount; /* Number of elements in AccelVect */ UDACCEL* AccelVect; /* Vector containing AccelCount elements */ INT AccelIndex; /* Current accel index, -1 if not accel'ing */ @@ -97,7 +98,7 @@ typedef struct 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 }; + 'C', 'l', 'a', 's', 's', 'W', 'n', 'd', 'P', 'r', 'o', 'c', 0 }; static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action); /*********************************************************************** @@ -140,7 +141,7 @@ static BOOL UPDOWN_OffsetVal(UPDOWN_INFO *infoPtr, int delta) { /* check if we can do the modification first */ if(!UPDOWN_InBounds (infoPtr, infoPtr->CurVal+delta)) { - if (GetWindowLongW (infoPtr->Self, GWL_STYLE) & UDS_WRAP) { + if (infoPtr->dwStyle & UDS_WRAP) { delta += (delta < 0 ? -1 : 1) * (infoPtr->MaxVal < infoPtr->MinVal ? -1 : 1) * (infoPtr->MinVal - infoPtr->MaxVal) + @@ -160,9 +161,7 @@ static BOOL UPDOWN_OffsetVal(UPDOWN_INFO *infoPtr, int delta) */ static BOOL UPDOWN_HasBuddyBorder(UPDOWN_INFO* infoPtr) { - DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE); - - return ( ((dwStyle & (UDS_ALIGNLEFT | UDS_ALIGNRIGHT)) != 0) && + return ( ((infoPtr->dwStyle & (UDS_ALIGNLEFT | UDS_ALIGNRIGHT)) != 0) && UPDOWN_IsBuddyEdit(infoPtr) ); } @@ -176,8 +175,6 @@ static BOOL UPDOWN_HasBuddyBorder(UPDOWN_INFO* infoPtr) */ static void UPDOWN_GetArrowRect (UPDOWN_INFO* infoPtr, RECT *rect, int arrow) { - DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE); - GetClientRect (infoPtr->Self, rect); /* @@ -185,7 +182,7 @@ static void UPDOWN_GetArrowRect (UPDOWN_INFO* infoPtr, RECT *rect, int arrow) * border. */ if (UPDOWN_HasBuddyBorder(infoPtr)) { - if (dwStyle & UDS_ALIGNLEFT) + if (infoPtr->dwStyle & UDS_ALIGNLEFT) rect->left += DEFAULT_BUDDYBORDER; else rect->right -= DEFAULT_BUDDYBORDER; @@ -195,7 +192,7 @@ static void UPDOWN_GetArrowRect (UPDOWN_INFO* infoPtr, RECT *rect, int arrow) /* now figure out if we need a space away from the buddy */ if ( IsWindow(infoPtr->Buddy) ) { - if (dwStyle & UDS_ALIGNLEFT) rect->right -= DEFAULT_BUDDYSPACER; + if (infoPtr->dwStyle & UDS_ALIGNLEFT) rect->right -= DEFAULT_BUDDYSPACER; else rect->left += DEFAULT_BUDDYSPACER; } @@ -204,7 +201,7 @@ static void UPDOWN_GetArrowRect (UPDOWN_INFO* infoPtr, RECT *rect, int arrow) * separation between the buttons will lay. We make sure that we * round the uneven numbers by adding 1. */ - if (dwStyle & UDS_HORZ) { + if (infoPtr->dwStyle & UDS_HORZ) { int len = rect->right - rect->left + 1; /* compute the width */ if (arrow & FLAG_INCR) rect->left = rect->left + len/2; @@ -264,7 +261,7 @@ static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr) WCHAR txt[20], sep, *src, *dst; int newVal; - if (!IsWindow(infoPtr->Buddy)) + if (!((infoPtr->dwStyle & UDS_SETBUDDYINT) && IsWindow(infoPtr->Buddy))) return FALSE; /*if the buddy is a list window, we must set curr index */ @@ -273,7 +270,10 @@ static BOOL UPDOWN_GetBuddyInt (UPDOWN_INFO *infoPtr) if(newVal < 0) return FALSE; } else { /* we have a regular window, so will get the text */ - if (!GetWindowTextW(infoPtr->Buddy, txt, COUNT_OF(txt))) return FALSE; + /* note that a zero-length string is a legitimate value for 'txt', + * and ought to result in a successful conversion to '0'. */ + if (GetWindowTextW(infoPtr->Buddy, txt, COUNT_OF(txt)) < 0) + return FALSE; sep = UPDOWN_GetThousandSep(); @@ -306,7 +306,8 @@ static BOOL UPDOWN_SetBuddyInt (UPDOWN_INFO *infoPtr) WCHAR txt[20]; int len; - if (!IsWindow(infoPtr->Buddy)) return FALSE; + if (!((infoPtr->dwStyle & UDS_SETBUDDYINT) && IsWindow(infoPtr->Buddy))) + return FALSE; TRACE("set new value(%d) to buddy.\n", infoPtr->CurVal); @@ -321,7 +322,7 @@ static BOOL UPDOWN_SetBuddyInt (UPDOWN_INFO *infoPtr) /* Do thousands separation if necessary */ - if (!(GetWindowLongW (infoPtr->Self, GWL_STYLE) & UDS_NOTHOUSANDS) && (len > 3)) { + if (!(infoPtr->dwStyle & UDS_NOTHOUSANDS) && (len > 3)) { WCHAR tmp[COUNT_OF(txt)], *src = tmp, *dst = txt; WCHAR sep = UPDOWN_GetThousandSep(); int start = len % 3; @@ -347,7 +348,6 @@ static BOOL UPDOWN_SetBuddyInt (UPDOWN_INFO *infoPtr) */ static LRESULT UPDOWN_Draw (UPDOWN_INFO *infoPtr, HDC hdc) { - DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE); BOOL pressed, hot; RECT rect; @@ -356,7 +356,7 @@ static LRESULT UPDOWN_Draw (UPDOWN_INFO *infoPtr, HDC hdc) GetClientRect(infoPtr->Self, &rect); DrawEdge(hdc, &rect, EDGE_SUNKEN, BF_BOTTOM | BF_TOP | - (dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT)); + (infoPtr->dwStyle & UDS_ALIGNLEFT ? BF_LEFT : BF_RIGHT)); } /* Draw the incr button */ @@ -364,20 +364,20 @@ static LRESULT UPDOWN_Draw (UPDOWN_INFO *infoPtr, HDC hdc) pressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_INCR); hot = (infoPtr->Flags & FLAG_INCR) && (infoPtr->Flags & FLAG_MOUSEIN); DrawFrameControl(hdc, &rect, DFC_SCROLL, - (dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLUP) | - ((dwStyle & UDS_HOTTRACK) && hot ? DFCS_HOT : 0) | + (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLRIGHT : DFCS_SCROLLUP) | + ((infoPtr->dwStyle & UDS_HOTTRACK) && hot ? DFCS_HOT : 0) | (pressed ? DFCS_PUSHED : 0) | - (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); + (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); /* Draw the decr button */ UPDOWN_GetArrowRect(infoPtr, &rect, FLAG_DECR); pressed = (infoPtr->Flags & FLAG_PRESSED) && (infoPtr->Flags & FLAG_DECR); hot = (infoPtr->Flags & FLAG_DECR) && (infoPtr->Flags & FLAG_MOUSEIN); DrawFrameControl(hdc, &rect, DFC_SCROLL, - (dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLDOWN) | - ((dwStyle & UDS_HOTTRACK) && hot ? DFCS_HOT : 0) | + (infoPtr->dwStyle & UDS_HORZ ? DFCS_SCROLLLEFT : DFCS_SCROLLDOWN) | + ((infoPtr->dwStyle & UDS_HOTTRACK) && hot ? DFCS_HOT : 0) | (pressed ? DFCS_PUSHED : 0) | - (dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); + (infoPtr->dwStyle & WS_DISABLED ? DFCS_INACTIVE : 0) ); return 0; } @@ -455,7 +455,6 @@ 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; @@ -489,7 +488,7 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) infoPtr->BuddyType = BUDDY_TYPE_LISTBOX; } - if(dwStyle & UDS_ARROWKEYS){ + if(infoPtr->dwStyle & UDS_ARROWKEYS){ /* 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. */ @@ -504,10 +503,10 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) MapWindowPoints(HWND_DESKTOP, GetParent(infoPtr->Buddy), (POINT *)(&budRect.left), 2); /* now do the positioning */ - if (dwStyle & UDS_ALIGNLEFT) { + if (infoPtr->dwStyle & UDS_ALIGNLEFT) { x = budRect.left; budRect.left += DEFAULT_WIDTH + DEFAULT_XSEP; - } else if (dwStyle & UDS_ALIGNRIGHT) { + } else if (infoPtr->dwStyle & UDS_ALIGNRIGHT) { budRect.right -= DEFAULT_WIDTH + DEFAULT_XSEP; x = budRect.right+DEFAULT_XSEP; } else { @@ -531,7 +530,7 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) * We nudge the control or change its size to overlap. */ if (UPDOWN_HasBuddyBorder(infoPtr)) { - if(dwStyle & UDS_ALIGNLEFT) + if(infoPtr->dwStyle & UDS_ALIGNLEFT) width += DEFAULT_BUDDYBORDER; else x -= DEFAULT_BUDDYBORDER; @@ -563,7 +562,6 @@ static HWND UPDOWN_SetBuddy (UPDOWN_INFO* infoPtr, HWND bud) */ static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action) { - DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE); NM_UPDOWN ni; TRACE("%d by %d\n", action, delta); @@ -588,12 +586,12 @@ static void UPDOWN_DoAction (UPDOWN_INFO *infoPtr, int delta, int action) TRACE("new %d, delta: %d\n", infoPtr->CurVal, ni.iDelta); /* Now take care about our buddy */ - if (dwStyle & UDS_SETBUDDYINT) UPDOWN_SetBuddyInt (infoPtr); + UPDOWN_SetBuddyInt (infoPtr); } } /* Also, notify it. This message is sent in any case. */ - SendMessageW( infoPtr->Notify, dwStyle & UDS_HORZ ? WM_HSCROLL : WM_VSCROLL, + SendMessageW( infoPtr->Notify, (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL, MAKELONG(SB_THUMBPOSITION, infoPtr->CurVal), (LPARAM)infoPtr->Self); } @@ -652,7 +650,6 @@ static BOOL UPDOWN_CancelMode (UPDOWN_INFO *infoPtr) */ static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT y) { - DWORD dwStyle = GetWindowLongW (infoPtr->Self, GWL_STYLE); POINT pt = { x, y }; RECT rect; int temp, arrow; @@ -679,7 +676,7 @@ static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT if (infoPtr->Flags & FLAG_ARROW) { /* Update the CurVal if necessary */ - if (dwStyle & UDS_SETBUDDYINT) UPDOWN_GetBuddyInt (infoPtr); + UPDOWN_GetBuddyInt (infoPtr); /* Set up the correct flags */ infoPtr->Flags |= FLAG_PRESSED; @@ -731,7 +728,6 @@ static void UPDOWN_HandleMouseEvent (UPDOWN_INFO *infoPtr, UINT msg, INT x, INT 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); @@ -742,13 +738,13 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L switch(message) { case WM_CREATE: - SetWindowLongW (hwnd, GWL_STYLE, dwStyle & ~WS_BORDER); infoPtr = (UPDOWN_INFO*)Alloc (sizeof(UPDOWN_INFO)); SetWindowLongPtrW (hwnd, 0, (DWORD_PTR)infoPtr); /* initialize the info struct */ infoPtr->Self = hwnd; - infoPtr->Notify = ((LPCREATESTRUCTA)lParam)->hwndParent; + infoPtr->Notify = ((LPCREATESTRUCTW)lParam)->hwndParent; + infoPtr->dwStyle = ((LPCREATESTRUCTW)lParam)->style; infoPtr->AccelCount = 0; infoPtr->AccelVect = 0; infoPtr->AccelIndex = -1; @@ -759,8 +755,10 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L infoPtr->Buddy = 0; /* No buddy window yet */ infoPtr->Flags = 0; /* And no flags */ + SetWindowLongW (hwnd, GWL_STYLE, infoPtr->dwStyle & ~WS_BORDER); + /* Do we pick the buddy win ourselves? */ - if (dwStyle & UDS_AUTOBUDDY) + if (infoPtr->dwStyle & UDS_AUTOBUDDY) UPDOWN_SetBuddy (infoPtr, GetWindow (hwnd, GW_HWNDPREV)); TRACE("UpDown Ctrl creation, hwnd=%p\n", hwnd); @@ -777,10 +775,19 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L break; case WM_ENABLE: - if (dwStyle & WS_DISABLED) UPDOWN_CancelMode (infoPtr); + infoPtr->dwStyle &= ~WS_DISABLED; + infoPtr->dwStyle |= (wParam ? 0 : WS_DISABLED); + if (infoPtr->dwStyle & WS_DISABLED) UPDOWN_CancelMode (infoPtr); InvalidateRect (infoPtr->Self, NULL, FALSE); break; + case WM_STYLECHANGED: + if (wParam == GWL_STYLE) { + infoPtr->dwStyle = ((LPSTYLESTRUCT)lParam)->styleNew; + InvalidateRect (infoPtr->Self, NULL, FALSE); + } + break; + case WM_TIMER: /* is this the auto-press timer? */ if(wParam == TIMER_AUTOPRESS) { @@ -828,7 +835,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L (infoPtr->Flags & FLAG_ARROW) ) { SendMessageW( infoPtr->Notify, - dwStyle & UDS_HORZ ? WM_HSCROLL : WM_VSCROLL, + (infoPtr->dwStyle & UDS_HORZ) ? WM_HSCROLL : WM_VSCROLL, MAKELONG(SB_ENDSCROLL, infoPtr->CurVal), (LPARAM)hwnd); if (UPDOWN_IsBuddyEdit(infoPtr)) @@ -844,7 +851,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L break; case WM_KEYDOWN: - if((dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr)) + if((infoPtr->dwStyle & UDS_ARROWKEYS) && UPDOWN_IsEnabled(infoPtr)) return UPDOWN_KeyPressed(infoPtr, (int)wParam); break; @@ -910,7 +917,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L } wParam = infoPtr->CurVal; infoPtr->CurVal = temp; - if(dwStyle & UDS_SETBUDDYINT) UPDOWN_SetBuddyInt (infoPtr); + UPDOWN_SetBuddyInt (infoPtr); return wParam; /* return prev value */ case UDM_GETRANGE: @@ -950,7 +957,7 @@ static LRESULT WINAPI UpDownWindowProc(HWND hwnd, UINT message, WPARAM wParam, L } temp = infoPtr->CurVal; /* save prev value */ infoPtr->CurVal = (int)lParam; /* set the new value */ - if(dwStyle & UDS_SETBUDDYINT) UPDOWN_SetBuddyInt (infoPtr); + UPDOWN_SetBuddyInt (infoPtr); return temp; /* return prev value */ case UDM_GETUNICODEFORMAT: diff --git a/reactos/w32api/include/commctrl.h b/reactos/w32api/include/commctrl.h index e75116283b5..c50adfe18d1 100644 --- a/reactos/w32api/include/commctrl.h +++ b/reactos/w32api/include/commctrl.h @@ -2205,6 +2205,17 @@ typedef struct tagNMLVGETINFOTIPW LPARAM lParam; } NMLVGETINFOTIPW, *LPNMLVGETINFOTIPW; #endif /* _WIN32_IE >= 0x0400 */ +typedef struct tagNMLVODSTATECHANGE +{ + NMHDR hdr; + int iFrom; + int iTo; + UINT uNewState; + UINT uOldState; +} NMLVODSTATECHANGE, *LPNMLVODSTATECHANGE; +#define PNM_ODSTATECHANGE LPNMLVODSTATECHANGE +#define LPNM_ODSTATECHANGE LPNMLVODSTATECHANGE +#define NM_ODSTATECHANGE NMLVODSTATECHANGE typedef struct tagNMTVCUSTOMDRAW { NMCUSTOMDRAW nmcd; COLORREF clrText;