Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. LV & TV strange behavior

LV & TV strange behavior

Scheduled Pinned Locked Moved C / C++ / MFC
questionhelp
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    GeraldoLuiz
    wrote on last edited by
    #1

    Hi, I've never used label editing in TreeView & ListView before, so I guess it's a simple question. I used the EditLabels property (LVS/TVS_EDITLABELS) and create the controls. But a strange thing happens. I click on the label to edit and it's ok, but when I press any key (in both the TV and LV) the dialog is dismissed. Also, when I press ENTER (without any char has been pressed), they behave differently: the LV accepts it but the TV close the dialog. What is happening ? What is missing here ? I create a very simple test: a new Win32 App,typical HelloWorld, and include this lines in teste.rc: CONTROL "List1",100,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,132,30 CONTROL "Tree1",200,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_EDITLABELS | TVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,7,43,158,24,WS_EX_CLIENTEDGE and include InitCommonControls(); at WinMain and #include "commctrl.h" and put comctl32.lib in the project settings finally I put this on the About function: case WM_INITDIALOG: LVCOLUMN col; col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = _T("Col1"); col.cx = 100; ListView_InsertColumn(GetDlgItem(hDlg, 100), 0, &col); LVITEM lv; lv.mask = LVIF_TEXT; lv.pszText = _T("Txt1"); lv.iItem = 0; lv.iSubItem = 0; ListView_InsertItem(GetDlgItem(hDlg, 100), &lv); TVINSERTSTRUCT tv; tv.hInsertAfter = TVI_LAST; tv.item.mask = TVIF_TEXT; tv.hParent = TVI_ROOT; tv.item.pszText = _T("root"); TreeView_InsertItem(GetDlgItem(hDlg, 200), &tv); return TRUE; and that's it. I didn't include the handlers to LVN/TVN_BEGINLABELEDIT and ENDLABELEDIT , but I think this is not the problem. Why the dialog is dismissed when I press any key ? Why the ENTER key is OK with LV but close the dialog in TV ? Did I forget to handle some message or notification here ? Did they act differently in Windows and Dialogs ?

    G 1 Reply Last reply
    0
    • G GeraldoLuiz

      Hi, I've never used label editing in TreeView & ListView before, so I guess it's a simple question. I used the EditLabels property (LVS/TVS_EDITLABELS) and create the controls. But a strange thing happens. I click on the label to edit and it's ok, but when I press any key (in both the TV and LV) the dialog is dismissed. Also, when I press ENTER (without any char has been pressed), they behave differently: the LV accepts it but the TV close the dialog. What is happening ? What is missing here ? I create a very simple test: a new Win32 App,typical HelloWorld, and include this lines in teste.rc: CONTROL "List1",100,"SysListView32",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_EDITLABELS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,7,132,30 CONTROL "Tree1",200,"SysTreeView32",TVS_HASBUTTONS | TVS_HASLINES | TVS_EDITLABELS | TVS_SHOWSELALWAYS | WS_BORDER | WS_TABSTOP,7,43,158,24,WS_EX_CLIENTEDGE and include InitCommonControls(); at WinMain and #include "commctrl.h" and put comctl32.lib in the project settings finally I put this on the About function: case WM_INITDIALOG: LVCOLUMN col; col.mask = LVCF_TEXT | LVCF_WIDTH; col.pszText = _T("Col1"); col.cx = 100; ListView_InsertColumn(GetDlgItem(hDlg, 100), 0, &col); LVITEM lv; lv.mask = LVIF_TEXT; lv.pszText = _T("Txt1"); lv.iItem = 0; lv.iSubItem = 0; ListView_InsertItem(GetDlgItem(hDlg, 100), &lv); TVINSERTSTRUCT tv; tv.hInsertAfter = TVI_LAST; tv.item.mask = TVIF_TEXT; tv.hParent = TVI_ROOT; tv.item.pszText = _T("root"); TreeView_InsertItem(GetDlgItem(hDlg, 200), &tv); return TRUE; and that's it. I didn't include the handlers to LVN/TVN_BEGINLABELEDIT and ENDLABELEDIT , but I think this is not the problem. Why the dialog is dismissed when I press any key ? Why the ENTER key is OK with LV but close the dialog in TV ? Did I forget to handle some message or notification here ? Did they act differently in Windows and Dialogs ?

      G Offline
      G Offline
      GeraldoLuiz
      wrote on last edited by
      #2

      I think the Edit control of the TreeView (for label editing) on a dialog doesn't handle the ENTER and ESC keys, so they are processed by the system DefDlgProc and directed to DEFPUSHBUTTON. But I think that it's kind of a bug, because the ListView Control does handle the ENTER and ESC keys. I will try to subclass the label edit control of the TreeView and handle the WM_GETDLGCODE message and see if it solves the problem.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups