comctl32/listview: Position edit box after notification.
This commit is contained in:
parent
c98dc0da71
commit
ae0d363043
|
@ -418,7 +418,7 @@ static BOOL LISTVIEW_SetItemState(LISTVIEW_INFO *, INT, const LVITEMW *);
|
||||||
static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *, INT, INT, HWND);
|
static LRESULT LISTVIEW_VScroll(LISTVIEW_INFO *, INT, INT, HWND);
|
||||||
static LRESULT LISTVIEW_HScroll(LISTVIEW_INFO *, INT, INT, HWND);
|
static LRESULT LISTVIEW_HScroll(LISTVIEW_INFO *, INT, INT, HWND);
|
||||||
static BOOL LISTVIEW_EnsureVisible(LISTVIEW_INFO *, INT, BOOL);
|
static BOOL LISTVIEW_EnsureVisible(LISTVIEW_INFO *, INT, BOOL);
|
||||||
static HWND CreateEditLabelT(LISTVIEW_INFO *, LPCWSTR, DWORD, INT, INT, INT, INT, BOOL);
|
static HWND CreateEditLabelT(LISTVIEW_INFO *, LPCWSTR, DWORD, BOOL);
|
||||||
static HIMAGELIST LISTVIEW_SetImageList(LISTVIEW_INFO *, INT, HIMAGELIST);
|
static HIMAGELIST LISTVIEW_SetImageList(LISTVIEW_INFO *, INT, HIMAGELIST);
|
||||||
static INT LISTVIEW_HitTest(const LISTVIEW_INFO *, LPLVHITTESTINFO, BOOL, BOOL);
|
static INT LISTVIEW_HitTest(const LISTVIEW_INFO *, LPLVHITTESTINFO, BOOL, BOOL);
|
||||||
|
|
||||||
|
@ -5055,7 +5055,11 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW)
|
||||||
WCHAR szDispText[DISP_TEXT_SIZE] = { 0 };
|
WCHAR szDispText[DISP_TEXT_SIZE] = { 0 };
|
||||||
NMLVDISPINFOW dispInfo;
|
NMLVDISPINFOW dispInfo;
|
||||||
RECT rect;
|
RECT rect;
|
||||||
|
SIZE sz;
|
||||||
HWND hwndSelf = infoPtr->hwndSelf;
|
HWND hwndSelf = infoPtr->hwndSelf;
|
||||||
|
HDC hdc;
|
||||||
|
HFONT hOldFont = NULL;
|
||||||
|
TEXTMETRICW textMetric;
|
||||||
|
|
||||||
TRACE("(nItem=%d, isW=%d)\n", nItem, isW);
|
TRACE("(nItem=%d, isW=%d)\n", nItem, isW);
|
||||||
|
|
||||||
|
@ -5088,8 +5092,7 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW)
|
||||||
dispInfo.item.cchTextMax = DISP_TEXT_SIZE;
|
dispInfo.item.cchTextMax = DISP_TEXT_SIZE;
|
||||||
if (!LISTVIEW_GetItemT(infoPtr, &dispInfo.item, isW)) return 0;
|
if (!LISTVIEW_GetItemT(infoPtr, &dispInfo.item, isW)) return 0;
|
||||||
|
|
||||||
infoPtr->hwndEdit = CreateEditLabelT(infoPtr, dispInfo.item.pszText, WS_VISIBLE,
|
infoPtr->hwndEdit = CreateEditLabelT(infoPtr, dispInfo.item.pszText, WS_VISIBLE, isW);
|
||||||
rect.left-2, rect.top-1, 0, rect.bottom - rect.top+2, isW);
|
|
||||||
if (!infoPtr->hwndEdit) return 0;
|
if (!infoPtr->hwndEdit) return 0;
|
||||||
|
|
||||||
if (notify_dispinfoT(infoPtr, LVN_BEGINLABELEDITW, &dispInfo, isW))
|
if (notify_dispinfoT(infoPtr, LVN_BEGINLABELEDITW, &dispInfo, isW))
|
||||||
|
@ -5101,6 +5104,27 @@ static HWND LISTVIEW_EditLabelT(LISTVIEW_INFO *infoPtr, INT nItem, BOOL isW)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Now position and display edit box */
|
||||||
|
hdc = GetDC(infoPtr->hwndSelf);
|
||||||
|
|
||||||
|
/* Select the font to get appropriate metric dimensions */
|
||||||
|
if(infoPtr->hFont != 0)
|
||||||
|
hOldFont = SelectObject(hdc, infoPtr->hFont);
|
||||||
|
|
||||||
|
/* Get String Length in pixels */
|
||||||
|
GetTextExtentPoint32W(hdc, dispInfo.item.pszText, lstrlenW(dispInfo.item.pszText), &sz);
|
||||||
|
|
||||||
|
/* Add Extra spacing for the next character */
|
||||||
|
GetTextMetricsW(hdc, &textMetric);
|
||||||
|
sz.cx += (textMetric.tmMaxCharWidth * 2);
|
||||||
|
|
||||||
|
if(infoPtr->hFont != 0)
|
||||||
|
SelectObject(hdc, hOldFont);
|
||||||
|
|
||||||
|
ReleaseDC(infoPtr->hwndSelf, hdc);
|
||||||
|
|
||||||
|
MoveWindow(infoPtr->hwndEdit, rect.left - 2, rect.top - 1, sz.cx,
|
||||||
|
rect.bottom - rect.top + 2, FALSE);
|
||||||
ShowWindow(infoPtr->hwndEdit, SW_NORMAL);
|
ShowWindow(infoPtr->hwndEdit, SW_NORMAL);
|
||||||
SetFocus(infoPtr->hwndEdit);
|
SetFocus(infoPtr->hwndEdit);
|
||||||
SendMessageW(infoPtr->hwndEdit, EM_SETSEL, 0, -1);
|
SendMessageW(infoPtr->hwndEdit, EM_SETSEL, 0, -1);
|
||||||
|
@ -10735,41 +10759,21 @@ static LRESULT CALLBACK EditLblWndProcA(HWND hwnd, UINT uMsg, WPARAM wParam, LPA
|
||||||
*
|
*
|
||||||
* RETURN:
|
* RETURN:
|
||||||
*/
|
*/
|
||||||
static HWND CreateEditLabelT(LISTVIEW_INFO *infoPtr, LPCWSTR text, DWORD style,
|
static HWND CreateEditLabelT(LISTVIEW_INFO *infoPtr, LPCWSTR text, DWORD style, BOOL isW)
|
||||||
INT x, INT y, INT width, INT height, BOOL isW)
|
|
||||||
{
|
{
|
||||||
WCHAR editName[5] = { 'E', 'd', 'i', 't', '\0' };
|
WCHAR editName[5] = { 'E', 'd', 'i', 't', '\0' };
|
||||||
HWND hedit;
|
HWND hedit;
|
||||||
SIZE sz;
|
|
||||||
HDC hdc;
|
|
||||||
HDC hOldFont=0;
|
|
||||||
TEXTMETRICW textMetric;
|
|
||||||
HINSTANCE hinst = (HINSTANCE)GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_HINSTANCE);
|
HINSTANCE hinst = (HINSTANCE)GetWindowLongPtrW(infoPtr->hwndSelf, GWLP_HINSTANCE);
|
||||||
|
|
||||||
TRACE("(text=%s, ..., isW=%d)\n", debugtext_t(text, isW), isW);
|
TRACE("(text=%s, ..., isW=%d)\n", debugtext_t(text, isW), isW);
|
||||||
|
|
||||||
style |= WS_CHILDWINDOW|WS_CLIPSIBLINGS|ES_LEFT|ES_AUTOHSCROLL|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 */
|
/* Window will be resized and positioned after LVN_BEGINLABELEDIT */
|
||||||
if(infoPtr->hFont != 0)
|
|
||||||
hOldFont = SelectObject(hdc, infoPtr->hFont);
|
|
||||||
|
|
||||||
/*Get String Length in pixels */
|
|
||||||
GetTextExtentPoint32W(hdc, text, lstrlenW(text), &sz);
|
|
||||||
|
|
||||||
/*Add Extra spacing for the next character */
|
|
||||||
GetTextMetricsW(hdc, &textMetric);
|
|
||||||
sz.cx += (textMetric.tmMaxCharWidth * 2);
|
|
||||||
|
|
||||||
if(infoPtr->hFont != 0)
|
|
||||||
SelectObject(hdc, hOldFont);
|
|
||||||
|
|
||||||
ReleaseDC(infoPtr->hwndSelf, hdc);
|
|
||||||
if (isW)
|
if (isW)
|
||||||
hedit = CreateWindowW(editName, text, style, x, y, sz.cx, height, infoPtr->hwndSelf, 0, hinst, 0);
|
hedit = CreateWindowW(editName, text, style, 0, 0, 0, 0, infoPtr->hwndSelf, 0, hinst, 0);
|
||||||
else
|
else
|
||||||
hedit = CreateWindowA("Edit", (LPCSTR)text, style, x, y, sz.cx, height, infoPtr->hwndSelf, 0, hinst, 0);
|
hedit = CreateWindowA("Edit", (LPCSTR)text, style, 0, 0, 0, 0, infoPtr->hwndSelf, 0, hinst, 0);
|
||||||
|
|
||||||
if (!hedit) return 0;
|
if (!hedit) return 0;
|
||||||
|
|
||||||
|
|
|
@ -207,6 +207,7 @@ static const struct message editbox_create_pos[] = {
|
||||||
{ WM_WINDOWPOSCHANGED, sent },
|
{ WM_WINDOWPOSCHANGED, sent },
|
||||||
{ WM_MOVE, sent|defwinproc },
|
{ WM_MOVE, sent|defwinproc },
|
||||||
{ WM_SIZE, sent|defwinproc },
|
{ WM_SIZE, sent|defwinproc },
|
||||||
|
/* the rest is todo */
|
||||||
{ WM_WINDOWPOSCHANGING, sent },
|
{ WM_WINDOWPOSCHANGING, sent },
|
||||||
{ WM_WINDOWPOSCHANGED, sent },
|
{ WM_WINDOWPOSCHANGED, sent },
|
||||||
{ 0 }
|
{ 0 }
|
||||||
|
|
Loading…
Reference in New Issue