}
default:
break;
}
/* pass the message on to the original window procedure */
return CallWindowProc(origLVWndProc, hWnd, mMsg, wParam, lParam);
}
LRESULT CALLBACK EditWndProc(HWND hWnd, UINT mMsg, WPARAM wParam, LPARAM lParam)
{
switch (mMsg)
{
case WM_CHAR:
switch(wParam) {
case 27: /* ESC */
{
/* edit is cancelled, so no LVN_ENDLABELEDIT is sent */
DestroyWindow(hWnd);
break;
}
break;
}
case WM_KEYDOWN:
{
switch (wParam)
{
case VK_RETURN:
{
HWND hParent = GetParent(hWnd);
LVWnd_t * wnd = (LVWnd_t*) GetWindowLong (hParent, GWL_USERDATA);
if (wnd == 0)
break;
/* get current text */
int textLength = (int)SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0) + 1;
char *newText = (char*)malloc(sizeof(char)*textLength);
SendMessage(hWnd, WM_GETTEXT, (WPARAM)textLength, (LPARAM)newText);
/* send LVN_ENDLABELEDIT via WM_NOTIFY to the main window */
LV_DISPINFO dispInfo;
dispInfo.hdr.hwndFrom = hParent;
dispInfo.hdr.idFrom = 0; /* listview has no ID since it's manually created */
dispInfo.hdr.code = LVN_ENDLABELEDIT;
dispInfo.item.mask = LVIF_TEXT;
dispInfo.item.iItem = wnd->editRow;
dispInfo.item.iSubItem = wnd->editCol;
dispInfo.item.pszText = newText;
dispInfo.item.cchTextMax = (int)strlen(newText);
SendMessage(wnd->hTable, WM_NOTIFY, (WPARAM)0, (LPARAM)&dispInfo);
update_item (wnd, newText);
free(newText);
DestroyWindow(hWnd);
break;
}
}
break;
}
case WM_KILLFOCUS:
{
HWND hParent = GetParent(hWnd);
LVWnd_t * wnd = (LVWnd_t*) GetWindowLong (hParent, GWL_USERDATA);
if (wnd == 0)
break;
ListView_SetItemState (hParent, wnd->editRow, LVIS_SELECTED, LVIS_SELECTED);
/* return focus to the parent */
SetFocus(hParent);
DestroyWindow(hWnd);
break;
}
}
return CallWindowProc(origEditWndProc, hWnd, mMsg, wParam, lParam);
}
LRESULT CALLBACK ComboWndProc(HWND hWnd, UINT mMsg, WPARAM wParam, LPARAM lParam)
{
switch (mMsg)
{
case WM_CHAR:
switch(wParam) {
case 27: /* ESC */
{
/* edit is cancelled, so no LVN_ENDLABELEDIT is sent */
DestroyWindow(hWnd);
break;
}
break;
}
case WM_COMMAND:
if (HIWORD(wParam) != CBN_SELCHANGE)
break;
else goto On_WM_KEYDOWN;
case WM_KEYDOWN:
{
switch (wParam)
{
case VK_RETURN:
{
On_WM_KEYDOWN:
HWND hParent = GetParent(hWnd);
LVWnd_t * wnd = (LVWnd_t*) GetWindowLong (hParent, GWL_USERDATA);
if (wnd == 0)
break;
/* get current text */
int textLength = (int)SendMessage(hWnd, WM_GETTEXTLENGTH, 0, 0) + 1;
char *newText = (char*)malloc(sizeof(char)*textLength);
SendMessage(hWnd, WM_GETTEXT, (WPARAM)textLength, (LPARAM)newText);
/* send LVN_ENDLABELEDIT via WM_NOTIFY to the main window */
LV_DISPINFO dispInfo;
dispInfo.hdr.hwndFrom = hParent;
dispInfo.hdr.idFrom = 0; /* listview has no ID since it's manually created */
dispInfo.hdr.code = LVN_ENDLABELEDIT;
Уважаемый посетитель!
Чтобы распечатать файл, скачайте его (в формате Word).
Ссылка на скачивание - внизу страницы.