comctl32: listview: Create the LISTVIEW_INFO in WM_NCCREATE.
This commit is contained in:
parent
30b6f9acd6
commit
3ea059c9d7
|
@ -7673,17 +7673,17 @@ static CALLBACK VOID LISTVIEW_DelayedEditItem(HWND hwnd, UINT uMsg, UINT_PTR idE
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* DESCRIPTION:
|
* DESCRIPTION:
|
||||||
* Creates the listview control.
|
* Creates the listview control - the WM_NCCREATE phase.
|
||||||
*
|
*
|
||||||
* PARAMETER(S):
|
* PARAMETER(S):
|
||||||
* [I] hwnd : window handle
|
* [I] hwnd : window handle
|
||||||
* [I] lpcs : the create parameters
|
* [I] lpcs : the create parameters
|
||||||
*
|
*
|
||||||
* RETURN:
|
* RETURN:
|
||||||
* Success: 0
|
* Success: TRUE
|
||||||
* Failure: -1
|
* Failure: FALSE
|
||||||
*/
|
*/
|
||||||
static LRESULT LISTVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
|
static LRESULT LISTVIEW_NCCreate(HWND hwnd, const CREATESTRUCTW *lpcs)
|
||||||
{
|
{
|
||||||
LISTVIEW_INFO *infoPtr;
|
LISTVIEW_INFO *infoPtr;
|
||||||
UINT uView = lpcs->style & LVS_TYPEMASK;
|
UINT uView = lpcs->style & LVS_TYPEMASK;
|
||||||
|
@ -7693,7 +7693,7 @@ static LRESULT LISTVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
|
||||||
|
|
||||||
/* initialize info pointer */
|
/* initialize info pointer */
|
||||||
infoPtr = Alloc(sizeof(LISTVIEW_INFO));
|
infoPtr = Alloc(sizeof(LISTVIEW_INFO));
|
||||||
if (!infoPtr) return -1;
|
if (!infoPtr) return FALSE;
|
||||||
|
|
||||||
SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
|
SetWindowLongPtrW(hwnd, 0, (DWORD_PTR)infoPtr);
|
||||||
|
|
||||||
|
@ -7701,8 +7701,7 @@ static LRESULT LISTVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
|
||||||
infoPtr->dwStyle = lpcs->style;
|
infoPtr->dwStyle = lpcs->style;
|
||||||
/* determine the type of structures to use */
|
/* determine the type of structures to use */
|
||||||
infoPtr->hwndNotify = lpcs->hwndParent;
|
infoPtr->hwndNotify = lpcs->hwndParent;
|
||||||
infoPtr->notifyFormat = SendMessageW(infoPtr->hwndNotify, WM_NOTIFYFORMAT,
|
/* infoPtr->notifyFormat will be filled in WM_CREATE */
|
||||||
(WPARAM)infoPtr->hwndSelf, (LPARAM)NF_QUERY);
|
|
||||||
|
|
||||||
/* initialize color information */
|
/* initialize color information */
|
||||||
infoPtr->clrBk = CLR_NONE;
|
infoPtr->clrBk = CLR_NONE;
|
||||||
|
@ -7731,19 +7730,6 @@ static LRESULT LISTVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
|
||||||
infoPtr->hFont = infoPtr->hDefaultFont;
|
infoPtr->hFont = infoPtr->hDefaultFont;
|
||||||
LISTVIEW_SaveTextMetrics(infoPtr);
|
LISTVIEW_SaveTextMetrics(infoPtr);
|
||||||
|
|
||||||
/* create header */
|
|
||||||
infoPtr->hwndHeader = CreateWindowW(WC_HEADERW, NULL,
|
|
||||||
WS_CHILD | HDS_HORZ | HDS_FULLDRAG | (DWORD)((LVS_NOSORTHEADER & lpcs->style)?0:HDS_BUTTONS),
|
|
||||||
0, 0, 0, 0, hwnd, NULL,
|
|
||||||
lpcs->hInstance, NULL);
|
|
||||||
if (!infoPtr->hwndHeader) goto fail;
|
|
||||||
|
|
||||||
/* set header unicode format */
|
|
||||||
SendMessageW(infoPtr->hwndHeader, HDM_SETUNICODEFORMAT, (WPARAM)TRUE, (LPARAM)NULL);
|
|
||||||
|
|
||||||
/* set header font */
|
|
||||||
SendMessageW(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)infoPtr->hFont, (LPARAM)TRUE);
|
|
||||||
|
|
||||||
/* allocate memory for the data structure */
|
/* allocate memory for the data structure */
|
||||||
if (!(infoPtr->selectionRanges = ranges_create(10))) goto fail;
|
if (!(infoPtr->selectionRanges = ranges_create(10))) goto fail;
|
||||||
if (!(infoPtr->hdpaItems = DPA_Create(10))) goto fail;
|
if (!(infoPtr->hdpaItems = DPA_Create(10))) goto fail;
|
||||||
|
@ -7754,6 +7740,54 @@ static LRESULT LISTVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
|
||||||
/* initialize the icon sizes */
|
/* initialize the icon sizes */
|
||||||
set_icon_size(&infoPtr->iconSize, infoPtr->himlNormal, uView != LVS_ICON);
|
set_icon_size(&infoPtr->iconSize, infoPtr->himlNormal, uView != LVS_ICON);
|
||||||
set_icon_size(&infoPtr->iconStateSize, infoPtr->himlState, TRUE);
|
set_icon_size(&infoPtr->iconStateSize, infoPtr->himlState, TRUE);
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
fail:
|
||||||
|
DestroyWindow(infoPtr->hwndHeader);
|
||||||
|
ranges_destroy(infoPtr->selectionRanges);
|
||||||
|
DPA_Destroy(infoPtr->hdpaItems);
|
||||||
|
DPA_Destroy(infoPtr->hdpaPosX);
|
||||||
|
DPA_Destroy(infoPtr->hdpaPosY);
|
||||||
|
DPA_Destroy(infoPtr->hdpaColumns);
|
||||||
|
Free(infoPtr);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/***
|
||||||
|
* DESCRIPTION:
|
||||||
|
* Creates the listview control - the WM_CREATE phase. Most of the data is
|
||||||
|
* already set up in LISTVIEW_NCCreate
|
||||||
|
*
|
||||||
|
* PARAMETER(S):
|
||||||
|
* [I] hwnd : window handle
|
||||||
|
* [I] lpcs : the create parameters
|
||||||
|
*
|
||||||
|
* RETURN:
|
||||||
|
* Success: 0
|
||||||
|
* Failure: -1
|
||||||
|
*/
|
||||||
|
static LRESULT LISTVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
|
||||||
|
{
|
||||||
|
LISTVIEW_INFO *infoPtr = (LISTVIEW_INFO *)GetWindowLongPtrW(hwnd, 0);
|
||||||
|
UINT uView = lpcs->style & LVS_TYPEMASK;
|
||||||
|
|
||||||
|
TRACE("(lpcs=%p)\n", lpcs);
|
||||||
|
|
||||||
|
infoPtr->notifyFormat = SendMessageW(infoPtr->hwndNotify, WM_NOTIFYFORMAT,
|
||||||
|
(WPARAM)infoPtr->hwndSelf, (LPARAM)NF_QUERY);
|
||||||
|
|
||||||
|
/* create header */
|
||||||
|
infoPtr->hwndHeader = CreateWindowW(WC_HEADERW, NULL,
|
||||||
|
WS_CHILD | HDS_HORZ | HDS_FULLDRAG | (DWORD)((LVS_NOSORTHEADER & lpcs->style)?0:HDS_BUTTONS),
|
||||||
|
0, 0, 0, 0, hwnd, NULL,
|
||||||
|
lpcs->hInstance, NULL);
|
||||||
|
if (!infoPtr->hwndHeader) return -1;
|
||||||
|
|
||||||
|
/* set header unicode format */
|
||||||
|
SendMessageW(infoPtr->hwndHeader, HDM_SETUNICODEFORMAT, (WPARAM)TRUE, (LPARAM)NULL);
|
||||||
|
|
||||||
|
/* set header font */
|
||||||
|
SendMessageW(infoPtr->hwndHeader, WM_SETFONT, (WPARAM)infoPtr->hFont, (LPARAM)TRUE);
|
||||||
|
|
||||||
/* init item size to avoid division by 0 */
|
/* init item size to avoid division by 0 */
|
||||||
LISTVIEW_UpdateItemSize (infoPtr);
|
LISTVIEW_UpdateItemSize (infoPtr);
|
||||||
|
@ -7775,16 +7809,6 @@ static LRESULT LISTVIEW_Create(HWND hwnd, const CREATESTRUCTW *lpcs)
|
||||||
OpenThemeData(hwnd, themeClass);
|
OpenThemeData(hwnd, themeClass);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
fail:
|
|
||||||
DestroyWindow(infoPtr->hwndHeader);
|
|
||||||
ranges_destroy(infoPtr->selectionRanges);
|
|
||||||
DPA_Destroy(infoPtr->hdpaItems);
|
|
||||||
DPA_Destroy(infoPtr->hdpaPosX);
|
|
||||||
DPA_Destroy(infoPtr->hdpaPosY);
|
|
||||||
DPA_Destroy(infoPtr->hdpaColumns);
|
|
||||||
Free(infoPtr);
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/***
|
/***
|
||||||
|
@ -9246,7 +9270,7 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
|
||||||
TRACE("(uMsg=%x wParam=%x lParam=%lx)\n", uMsg, wParam, lParam);
|
TRACE("(uMsg=%x wParam=%x lParam=%lx)\n", uMsg, wParam, lParam);
|
||||||
|
|
||||||
if (!infoPtr && (uMsg != WM_CREATE))
|
if (!infoPtr && (uMsg != WM_NCCREATE))
|
||||||
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
return DefWindowProcW(hwnd, uMsg, wParam, lParam);
|
||||||
|
|
||||||
switch (uMsg)
|
switch (uMsg)
|
||||||
|
@ -9605,6 +9629,9 @@ LISTVIEW_WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
case WM_COMMAND:
|
case WM_COMMAND:
|
||||||
return LISTVIEW_Command(infoPtr, wParam, lParam);
|
return LISTVIEW_Command(infoPtr, wParam, lParam);
|
||||||
|
|
||||||
|
case WM_NCCREATE:
|
||||||
|
return LISTVIEW_NCCreate(hwnd, (LPCREATESTRUCTW)lParam);
|
||||||
|
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
return LISTVIEW_Create(hwnd, (LPCREATESTRUCTW)lParam);
|
return LISTVIEW_Create(hwnd, (LPCREATESTRUCTW)lParam);
|
||||||
|
|
||||||
|
|
|
@ -343,6 +343,34 @@ static void test_items(void)
|
||||||
DestroyWindow(hwnd);
|
DestroyWindow(hwnd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* test setting imagelist between WM_NCCREATE and WM_CREATE */
|
||||||
|
static WNDPROC listviewWndProc;
|
||||||
|
static HIMAGELIST test_create_imagelist;
|
||||||
|
|
||||||
|
static LRESULT CALLBACK create_test_wndproc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
if (uMsg == WM_CREATE)
|
||||||
|
SendMessage(hwnd, LVM_SETIMAGELIST, 0, (LPARAM)test_create_imagelist);
|
||||||
|
return CallWindowProc(listviewWndProc, hwnd, uMsg, wParam, lParam);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void test_create()
|
||||||
|
{
|
||||||
|
HWND hList;
|
||||||
|
WNDCLASSEX cls;
|
||||||
|
cls.cbSize = sizeof(WNDCLASSEX);
|
||||||
|
ok(GetClassInfoEx(GetModuleHandle(NULL), "SysListView32", &cls), "GetClassInfoEx failed\n");
|
||||||
|
listviewWndProc = cls.lpfnWndProc;
|
||||||
|
cls.lpfnWndProc = create_test_wndproc;
|
||||||
|
cls.lpszClassName = "MyListView32";
|
||||||
|
ok(RegisterClassEx(&cls), "RegisterClassEx failed\n");
|
||||||
|
|
||||||
|
test_create_imagelist = ImageList_Create(16, 16, 0, 5, 10);
|
||||||
|
hList = CreateWindow("MyListView32", "Test", WS_VISIBLE, 0, 0, 100, 100, NULL, NULL, GetModuleHandle(NULL), 0);
|
||||||
|
ok((HIMAGELIST)SendMessage(hList, LVM_GETIMAGELIST, 0, 0) == test_create_imagelist, "Image list not obtained\n");
|
||||||
|
DestroyWindow(hList);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(listview)
|
START_TEST(listview)
|
||||||
{
|
{
|
||||||
INITCOMMONCONTROLSEX icc;
|
INITCOMMONCONTROLSEX icc;
|
||||||
|
@ -354,4 +382,5 @@ START_TEST(listview)
|
||||||
test_images();
|
test_images();
|
||||||
test_checkboxes();
|
test_checkboxes();
|
||||||
test_items();
|
test_items();
|
||||||
|
test_create();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue