Click here to Skip to main content
15,914,416 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralEnvironment macro Pin
Rome Singh12-Sep-04 6:31
Rome Singh12-Sep-04 6:31 
GeneralRe: Environment macro Pin
Andrew Walker12-Sep-04 14:46
Andrew Walker12-Sep-04 14:46 
GeneralRe: Environment macro Pin
Rome Singh13-Sep-04 5:12
Rome Singh13-Sep-04 5:12 
GeneralRe: Environment macro Pin
Andrew Walker13-Sep-04 12:52
Andrew Walker13-Sep-04 12:52 
QuestionWarning: no message line prompt for ID *???? Pin
jettocrack12-Sep-04 6:13
jettocrack12-Sep-04 6:13 
AnswerRe: Warning: no message line prompt for ID *???? Pin
Ravi Bhavnani12-Sep-04 7:13
professionalRavi Bhavnani12-Sep-04 7:13 
GeneralProblem Regarding Tree in DOTNET Pin
eshban28412-Sep-04 6:08
eshban28412-Sep-04 6:08 
GeneralRe: Problem Regarding Tree in DOTNET Pin
Antti Keskinen12-Sep-04 10:12
Antti Keskinen12-Sep-04 10:12 
The message TVN_SELCHANGED is generated when the selection in the tree control is changed. It gives you a pointer to the item structure which the user selected.

To capture the TVN_SELCHANGED message in MFC, write the following code inside the BEGIN_MESSAGE_MAP and END_MESSAGE_MAP macros located in the window class that is the parent for the tree control:
ON_NOTIFY( TVN_SELCHANGED, tree-ctrl-id, OnSelChanged )
Then add a member function to the class like this:
afx_msg void OnSelChanged( NMHDR * pNotifyStruct, LRESULT * result );
Then write the following skeleton for the handler function:
afx_msg void memberFxn( NMHDR * pNotifyStruct, LRESULT * result )
{
    // Cast to correct structure. See TVN_SELCHANGED in Platform SDK for details
    NMTREEVIEW* pTreeView = dynamic_cast<NMTREEVIEW*>( pNotifyStruct );<DIV>

    // Using the new pointer, fetch the name of the newly selected node
    CString strNodeName( pTreeView->itemNew->pszText );

    // Your code here
}
If you need to identify the items based on their ID, you need to originally store this ID as the lParam value in the TVITEM structure. It can be an integer, for example. When you store it there, you can use the itemNew pointer to get it via the lParam member. An example as follows:
// Add a new item. The '1' specifies the ID
pTreeCtrl->InsertItem( TVIF_PARAM | TVIF_TEXT, _T("Child node 1"), 0, 0, 0, 0, 1, hParentNode, NULL );<DIV>

// Later, in the handler function, get the ID
int ID = (int) pTreeView->itemNew->lParam;
I hope this will help you. If you have further questions/problems, post them here.

-Antti Keskinen


----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
GeneralDouble buffering in MFC Pin
amigaguy12-Sep-04 6:07
amigaguy12-Sep-04 6:07 
GeneralRe: Double buffering in MFC Pin
Antti Keskinen12-Sep-04 10:33
Antti Keskinen12-Sep-04 10:33 
GeneralRe: Double buffering in MFC Pin
Anonymous12-Sep-04 11:50
Anonymous12-Sep-04 11:50 
GeneralCDaoDatabase connection string in Windows XP Pin
olis12-Sep-04 5:36
olis12-Sep-04 5:36 
GeneralProcess help Pin
swarup12-Sep-04 4:40
swarup12-Sep-04 4:40 
GeneralToolbar in views Pin
Jens Christiansen12-Sep-04 3:26
Jens Christiansen12-Sep-04 3:26 
QuestionHow can I export my class in &quot;Regular DLL that statically linked MFC&quot;? Pin
Behzad Ebrahimi12-Sep-04 3:20
Behzad Ebrahimi12-Sep-04 3:20 
GeneralDialog in taskbar steals focus from children Pin
PEK12-Sep-04 1:49
PEK12-Sep-04 1:49 
GeneralRe: Dialog in taskbar steals focus from children Pin
Gary R. Wheeler12-Sep-04 2:44
Gary R. Wheeler12-Sep-04 2:44 
GeneralRe: Dialog in taskbar steals focus from children Pin
PEK12-Sep-04 4:55
PEK12-Sep-04 4:55 
Generalbackground color Pin
Joerg Warthemann12-Sep-04 1:42
Joerg Warthemann12-Sep-04 1:42 
GeneralGetting the -REAL- printable area of a page Pin
Ernesto D.11-Sep-04 21:48
Ernesto D.11-Sep-04 21:48 
GeneralRe: Getting the -REAL- printable area of a page Pin
Blake Miller13-Sep-04 6:10
Blake Miller13-Sep-04 6:10 
Questionhow to find which port is active? Pin
anuchelvi11-Sep-04 20:55
anuchelvi11-Sep-04 20:55 
AnswerRe: how to find which port is active? Pin
Mad__13-Sep-04 4:49
Mad__13-Sep-04 4:49 
Generalsearching for Nicholl-Lee- Nicholl C or C++ code Pin
gledaoc11-Sep-04 18:26
gledaoc11-Sep-04 18:26 
GeneralRe: searching for Nicholl-Lee- Nicholl C or C++ code Pin
Ravi Bhavnani12-Sep-04 7:16
professionalRavi Bhavnani12-Sep-04 7:16 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.