|
CListView is a wrapper over Win32 list control, the control is already subclassed for you by MFC. Just handle the messages in a CListView derived class. You don't need a child CListCtrl, unless you plan to reuse it as a control (not a view) in the future.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Hello,
I have a tree control that I would like to do in-place editing of the labels. But, I only want to be able to edit certain levels. I currently have a context menu that gets enabled when on the appropriate level and calls myTree.EditLabel(sHItem) which is exactly what I want. However, when I check "Edit Labels" on the tree control in the resource tab, everything is editable. If I don't check this, then I crash when I call EditLabel(). Is there a way around this?
Assuming I get everything working, I have a couple more questions. How do I capture once the user is done editing. I may want to prevent them from renaming or provide a warning message if they proceed. The problem I see is each level has different contraints that I have to handle. Do I have to provide all the logic for each level in the OnEndlabeledit() handler?
Thanks in Advance!
Derek
|
|
|
|
|
However, when I check "Edit Labels" on the tree control in the resource tab, everything is editable.
Handle TVN_BEGINLABELEDIT notification. Return TRUE to cancel label editing.
How do I capture once the user is done editing.
TVN_ENDLABELEDIT, wrapped by OnEndlabelEdit handler. Return FALSE to reject the edited text and revert to the original label.
Do I have to provide all the logic for each level in the OnEndlabeledit() handler?
Yes.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
Thanks - I worked through some of that, but you confirmed my suspicions!
I have a new problem related to this. If I only want to allow in-place label editing from a right-click context menu - say "Rename", how do I do this and not allow the tree to do the in-place editing as well. What I'm looking for is the same functionality as in regedit.exe and the right-click "Rename" command on a key, value, etc.
You've helped me in the past and I truly appreciate it!
|
|
|
|
|
how do I do this and not allow the tree to do the in-place editing as well.
Just handle TVN_BEGINLABELEDIT. Check the HTREEITEM and decide if editing is OK - if not, return TRUE to disable it.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I'm already enabling/disabling the appropriate tree levels in the OnBeginlabeledit() method, so what would the HTREEITEM structure give me? I only want the right-click menu to allow the in-place editing.
I'm wondering if I should set a flag (kludge) in my OnRename() method and then check for it in the OnBeginlabeledit() method.
|
|
|
|
|
What is meaning of the "X" in "AFX"?
Thanks.
Maer
|
|
|
|
|
"Application FrameworX" AFAIK
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Thanks my pal.
What I do not understand is the meaning of "X"?
Can you help?
Thanks.
Maer
|
|
|
|
|
Let me look this up in "MFC Internals", but I'm pretty sure that the X doesn't mean anything. It's just a sexy way of pronouncing the last two letters in Frameworks - that's why I wrote "Application FrameworX" (not the capital A, F and X). Anyway, it's just an old name for MFC (actually I don't think MFC was ever called AFX - it was just the name it had during development. That's why you only see it in the source code").
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Thanks for helping me again, my pal.
You help me a lot.
Can you tell me where to look up the "MFC Internals"? Thanks again.
Best regards.
Maer
|
|
|
|
|
You can find it at e.g. bn.com:
http://shop.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=2UPJYZHY8L&mscssid=R1MRPQRSKSG98HC7MAD52TTXG63R2M1F&isbn=0201407213
It's by George Shepherd & Scot Wingo, and it's a must-must for MFC developers. It only covers the MFC that came with VC++ 4.0, but it's still valid. You can also try Mike Blaszczak's "Professional MFC with Visual C++ 6.0":
http://shop.barnesandnoble.com/booksearch/isbnInquiry.asp?userid=2UPJYZHY8L&mscssid=R1MRPQRSKSG98HC7MAD52TTXG63R2M1F&isbn=1861000154
Haven't got it myself (I bought Kruglinski's "Inside Visual C++ version 4" instead, also excellent), but Blaszczak is the MFC Guru of all Guru's (he was once head of the MFC team at MS).
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
What is the following mean?
The thread 0xFFF16C63 has exited with code -858993460 (0xCCCCCCCC).
The program 'C:\testexitcode\Debug\testexitcode.exe' has exited with code -858993460 (0xCCCCCCCC).
Thanks my pal.
Maer
|
|
|
|
|
The exit code is a number the program returns to the calling process. In the ol' DOS days you could access this code throught the enviroment variable ERRORLEVEL. When you terminate a thread (and the program if it's the program's main thread) through a call to exit, _exit, _endthreadex or ExitThread (or a number of other similar functions that I'm not aware of) you can pass an int which will become the exit code (or, at least for exit, the low-order byte will become the exit code.
The meaning of the exit code is entirely up to the terminating thread. Usually zero indicates normal termination.
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Thanks my pal.
You help a lot.
Best regards.
Maer
|
|
|
|
|
I'd like to know how to do an alphabetical sort of the items in a CListCtrl
I use LVS_SORTASCENDING as the window style but the problem I have is when the list has more than one column, the InsertItem function doesn't work for items placed in any column other than the first one.
The code I have is:
CListCtrl* pList = (CListCtrl*) GetDlgItem (IDC_LIST1);
pList->InsertColumn(0, "Column1", LVCFMT_CENTER, 100);
pList->InsertColumn(1, "Column2", LVCFMT_CENTER, 100);
pList->SetRedraw(FALSE);
pList->InsertItem(0, "Item0 Column0", 0);
pList->SetItemText(0, 1, "Item0 Column1", 0);
// Insert more items like the one above
pList->SetRedraw(TRUE);
If I use LVS_SORTASCENDING, the first column shows right (well sorted) but the second column doesn't display any item.
Thanks in advance,
|
|
|
|
|
If you're using LVS_SORTASCENDING style, the list control has to insert new item at appropriate location. You can't use the 0 as 1st parameter passed to SetItemText. Instead, pass the value returned by InsertItem - this is the real item index in the list.
Tomasz Sowinski -- http://www.shooltz.com
|
|
|
|
|
I to all,
does anyone know how to create and subclass a run-time created object?
I must do this without creating a dialog template.
Thanks in advance.
|
|
|
|
|
If you want to create a dialog window "on the fly" use one of the following dialog functions:
DialogBoxIndirect (modal)
DialogBoxIndirectParam (modal)
CreateDialogIndirect (modeless)
CreateDialogIndirectParam (modeless)
See MSDN : Platform SDK \ Windows User Interface "Creating a Template in Memory"
V.B.
|
|
|
|
|
Thank you, but my question is how to create a run-time object (maybe a CStatic object) and subclass them for a more convenient use.
Thanks in advance.
|
|
|
|
|
I think u can do it by SetWindowLong function with GWL_WNDPROC option and setting a new callback fucntion. I suppose this will work for run-time ocreated object.
Ganesh.M.Ramaswamy
|
|
|
|
|
ok i have a dialog as the main window with a combo box on it defined as IDC_COMBO (NOT USING MFC). now i want to see when the user is typing text in the combobox when he presses the enter key somethin has to happen, i'm surprised i dont know how to do it cause i've done it before, lol but anyways, something like this huh:
...
case IDC_COMBO:
switch(HIWORD(wParam))
{
case WM_KEYDOWN:
break;
}
break;
...
it has to see when the ENTER key is pressed, so u'll need the keycode or something right...?
but this doesn't work i was just pointing out what i'm doing erm..ok, an answer would be nice, thank you in advance
Kuniva
|
|
|
|
|
Is this not working with any keydown or only with enter-key, may be enter-key is closing the dialog box and handled as OK.
Ganesh.M.Ramaswamy
|
|
|
|
|
Hi..
I created a simple database application and created a small setup for this application in windows NT. Here I am storing my installtion path under HEY_LOCAL_MACHINE. So this application is running only when i entered as an administrator rights user, otherwise it is NOT able open the HKEY_LOCAL_MACHINE registry entries. Even if I try to use HKEY_CURRENT_USER it will get vary to different users.
How I can solve so that I should use this registry entry for all types of user..
Thanks in advance..
Raja
Raja Rethinam
Chennai.
India.
|
|
|
|
|