Thread: Re: [GD-Windows] TreeView label editing
Brought to you by:
vexxed72
From: Andrew G. <ag...@cl...> - 2007-07-06 09:24:35
|
What do you return from TVN_BEGINLABELEDIT? Is your TreeView part of a dialog form, or created dynamically on another Window? A. -----Original Message----- From: gam...@li... [mailto:gam...@li...] On Behalf Of Pierre Terdiman Sent: Thursday, July 05, 2007 7:47 AM To: Game Development for MS Windows Subject: [GD-Windows] TreeView label editing Ok, I have another treeview question, about label editing. So I'm trying to let the user change the label of a treeview item by double-clicking on it. My problem is that no edit box ever shows up, even though I receive the expected messages. So it's like this: - the treeview is created with TVS_EDITLABELS - when user double-click on an item I call TreeView_EditLabel - then I correctly receive the TVN_BEGINLABELEDIT and TVN_ENDLABELEDIT. In the first one I can catch the edit control handle using TreeView_GetEditControl, which returns a valid handle. Yet no edition ever happens. I receive the TVN_ENDLABELEDIT notification immediately after the TVN_BEGINLABELEDIT one, and the text in the associated structure is null. What did I miss? I browsed the net in vain. I can't find a single example clearly showing me how to do that. The MSDN didn't help much either. Thanks, - Pierre ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ Gamedevlists-windows mailing list Gam...@li... https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows Archives: http://sourceforge.net/mailarchive/forum.php?forum_id=555 No virus found in this incoming message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.0/887 - Release Date: 7/5/2007 1:55 PM No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.5.476 / Virus Database: 269.10.0/887 - Release Date: 7/5/2007 1:55 PM |
From: Pierre T. <pte...@ag...> - 2007-07-06 09:30:50
|
> What do you return from TVN_BEGINLABELEDIT? FALSE, but I tried TRUE just in case and it didn't help. > Is your TreeView part of a dialog form, or created dynamically on another > Window? Created dynamically. - Pierre |
From: Sander v. R. <san...@gm...> - 2007-07-06 10:48:28
|
So i guess you still haven't gotten it to work :( Have you tried it on another pc? I suppose editing labels in a treeview works in other applications on your pc? Have you looked for label-editing source code on the web and tried to run it? On 7/6/07, Pierre Terdiman <pte...@ag...> wrote: > > What do you return from TVN_BEGINLABELEDIT? > > FALSE, but I tried TRUE just in case and it didn't help. > > > Is your TreeView part of a dialog form, or created dynamically on another > > Window? > > Created dynamically. > > - Pierre > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |
From: Pierre T. <pte...@ag...> - 2007-07-06 13:13:21
|
> So i guess you still haven't gotten it to work :( > Have you tried it on another pc? > I suppose editing labels in a treeview works in other applications on your pc? > Have you looked for label-editing source code on the web and tried to run it? I created a small repro case with the bare minimum, and of course it does work in the repro case.......... I guess there is something wrong in my wndproc, preventing the edit-box from opening. Oh well, now at least I have it working somewhere, and I can investigate more. I'll handle it from here :) Thanks, - Pierre |
From: Sander v. R. <san...@gm...> - 2007-07-06 13:18:31
|
Ok, good luck.. Be sure to post what was causing your problems if you figure it out, it could help someone out in the future.. you never know On 7/6/07, Pierre Terdiman <pte...@ag...> wrote: > > So i guess you still haven't gotten it to work :( > > Have you tried it on another pc? > > I suppose editing labels in a treeview works in other applications on your > pc? > > Have you looked for label-editing source code on the web and tried to run > it? > > I created a small repro case with the bare minimum, and of course it does > work in the repro case.......... > > I guess there is something wrong in my wndproc, preventing the edit-box from > opening. Oh well, now at least I have it working somewhere, and I can > investigate more. I'll handle it from here :) > > Thanks, > - Pierre > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by DB2 Express > Download DB2 Express C - the FREE version of DB2 express and take > control of your XML. No limits. Just data. Click to get it now. > http://sourceforge.net/powerbar/db2/ > _______________________________________________ > Gamedevlists-windows mailing list > Gam...@li... > https://lists.sourceforge.net/lists/listinfo/gamedevlists-windows > Archives: > http://sourceforge.net/mailarchive/forum.php?forum_id=555 > |
From: Pierre T. <pte...@ag...> - 2007-07-06 16:06:11
|
> > Be sure to post what was causing your problems if you figure it out, > > it could help someone out in the future.. you never know > > Yep, will do. I'll try to check this out this week-end. Apparently it's because of a SetFocus() call while processing the WM_ACTIVATE message. I added this like 3 years ago to solve some problem. It comes with this comment: // Make sure that last activated window gets the focus. This fixes the missing mouse wheel events // in render window. It also makes sure selecting another control removes the focus from render window. window->SetFocus(); Hmmm. In any case removing this line fixing the treeview issue. I'll have to revisit this one a bit.... - Pierre |
From: Pierre T. <pte...@ag...> - 2007-07-06 14:23:54
|
> Be sure to post what was causing your problems if you figure it out, > it could help someone out in the future.. you never know Yep, will do. I'll try to check this out this week-end. Meanwhile I have another issue with a group box not being repainted correctly... sounds familiar? I found this problem mentioned in the MSDN but the provided solution is less than satisfying, as it produces a really nasty flickering instead. I'm not sure if there is a known standard solution to this? The bug is demonstrated in the code below (creating a group box around a treeview - whose label edition does work :)). The bug is simply that the group box is not repainted correctly when you move another window in front of it. The bug disappears when the parent window is not created with WS_CLIPCHILDREN, but not using this flag is not really an option..... - Pierre #include <windows.h> #include <commctrl.h> #define null 0 static LRESULT CALLBACK WndProc(HWND hwnd, UINT uMessage, WPARAM wParam, LPARAM lParam) { switch(uMessage) { case WM_SYSKEYUP: case WM_SYSKEYDOWN: return 0; case WM_NOTIFY: { const NMHDR* nmhdr = (NMHDR*)lParam; if(nmhdr->code == TVN_BEGINLABELEDIT) { LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam; return 0; } if(nmhdr->code == TVN_ENDLABELEDIT) { LPNMTVDISPINFO ptvdi = (LPNMTVDISPINFO)lParam; return TRUE; } } break; case WM_CLOSE: case WM_DESTROY: ::PostQuitMessage(0); return 0; } return ::DefWindowProc(hwnd, uMessage, wParam, lParam); } static void* AddItem(HWND hwnd, void* parent, const char* item) { TV_ITEM tvItem; tvItem.mask = TVIF_TEXT; tvItem.pszText = (LPSTR)item; tvItem.cchTextMax = 256; HTREEITEM hParent; if(!parent) hParent = TVI_ROOT; else hParent = (HTREEITEM)parent; TV_INSERTSTRUCT tvInsert; tvInsert.hParent = hParent; tvInsert.hInsertAfter = TVI_LAST; tvInsert.item = tvItem; return TreeView_InsertItem(hwnd, &tvInsert); } static void CreateGroupBox(int x, int y, int w, int h, HWND parent) { HWND handle = ::CreateWindowEx( 0, "BUTTON", "Group box", WS_VISIBLE | WS_CHILD | BS_GROUPBOX, x, y, w, h, parent, (HMENU)null, (HINSTANCE)GetModuleHandle(null), null ); ::SendMessage(handle, WM_SETFONT, (WPARAM) (HFONT) ::GetStockObject(ANSI_VAR_FONT), MAKELPARAM (TRUE, 0)); } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { WNDCLASSEX WndClass; WndClass.cbSize = sizeof(WNDCLASSEX); WndClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC | CS_DBLCLKS; WndClass.lpfnWndProc = WndProc; WndClass.cbClsExtra = 0; WndClass.cbWndExtra = 0; WndClass.hInstance = (HINSTANCE)GetModuleHandle(null); WndClass.hIcon = null; WndClass.hCursor = ::LoadCursor(null, IDC_ARROW); WndClass.hbrBackground = (HBRUSH)COLOR_WINDOW; WndClass.lpszMenuName = null; WndClass.lpszClassName = "IceGUIClass"; WndClass.hIconSm = null; if(!::RegisterClassEx(&WndClass)) return false; ::InitCommonControls(); ////////// DWORD Style = WS_OVERLAPPEDWINDOW|WS_CLIPCHILDREN; HWND handle = ::CreateWindowEx( 0, "IceGUIClass", "Label", Style, 10, 10, 640, 480, null, (HMENU)null, (HINSTANCE)GetModuleHandle(null), null ); ::ShowWindow(handle, SW_SHOW); ////////// DWORD TVStyle = TVS_HASBUTTONS | TVS_HASLINES | TVS_LINESATROOT | TVS_SHOWSELALWAYS | WS_VISIBLE | WS_CHILD; TVStyle |= TVS_EDITLABELS; HWND TVHandle = ::CreateWindowEx( WS_EX_CLIENTEDGE, WC_TREEVIEW, "", TVStyle, 30, 30, 100, 100, handle, (HMENU)0, (HINSTANCE)GetModuleHandle(null), null ); ::SendMessage(TVHandle, WM_SETFONT, (WPARAM) (HFONT) ::GetStockObject (ANSI_VAR_FONT), MAKELPARAM (TRUE, 0)); ::ShowWindow(TVHandle, SW_SHOW); AddItem(TVHandle, null, "Item1"); AddItem(TVHandle, null, "Item2"); AddItem(TVHandle, null, "Item3"); //////////////////////// CreateGroupBox(10, 10, 140, 140, handle); //////////////////////// MSG msg; while (1) { if(::PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE)) { if(!::GetMessage (&msg, NULL, 0, 0)) { break; } ::TranslateMessage (&msg); ::DispatchMessage (&msg); } } return 0; } |