Click here to Skip to main content
15,921,113 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionRe: Help needed urgently!! Pin
David Crow9-Nov-06 3:44
David Crow9-Nov-06 3:44 
AnswerRe: Help needed urgently!! Pin
Mark Salsbery9-Nov-06 5:51
Mark Salsbery9-Nov-06 5:51 
GeneralRe: Help needed urgently!! Pin
Hamid_RT9-Nov-06 7:41
Hamid_RT9-Nov-06 7:41 
GeneralRe: Help needed urgently!! Pin
Mark Salsbery9-Nov-06 7:44
Mark Salsbery9-Nov-06 7:44 
GeneralRe: Help needed urgently!! Pin
Hamid_RT9-Nov-06 8:08
Hamid_RT9-Nov-06 8:08 
GeneralRe: Help needed urgently!! Pin
Mark Salsbery9-Nov-06 8:17
Mark Salsbery9-Nov-06 8:17 
GeneralRe: Help needed urgently!! Pin
Hamid_RT9-Nov-06 8:33
Hamid_RT9-Nov-06 8:33 
Questionproblems on CToolTipCtrl with CEdit (tip window pops twice) Pin
cy163@hotmail.com8-Nov-06 18:21
cy163@hotmail.com8-Nov-06 18:21 
Problem Description

My project (Testing) is CFormView based SDI application. On the form view, there is a CEdit control (IDC_EDIT_ExampleText). It is used to display the full path of a selected file. Sometimes, a long path may go beyond the boundary of the CEdit control.

So, I would like to use a Tool tip to display the long path.

I implemented the tool tip functionality for the CEdit control by the following steps. However,
two tip windows poped up one after the other containing the same contents whenever I moved the cursor on to the CEdit control.

another question is when I change

ON_NOTIFY_EX(TTN_NEEDTEXT, 0, SetTipText)

to

ON_NOTIFY_EX(TTN_NEEDTEXT, IDC_EDIT_ExampleText, SetTipText)


the tool tip does not pop up any more. Why, it should be '0'.


--------- Steps --------------

Step 1: declare a CToolTipCtrl member variable for CTestingView

CToolTipCtrl *m_ToolTip

Step 2:

in the OnInitialUpdate(), add the following lines
<br />
	EnableToolTips(TRUE); <br />
	m_ToolTip= new CToolTipCtrl();<br />
	m_ToolTip->Create(this);<br />
<br />
	m_ToolTip->AddTool(&m_EDIT_ExampleText, LPSTR_TEXTCALLBACK);<br />
	m_ToolTip->Activate(TRUE);<br />
<br />


Step 3:
Overload the function PreTranslateMessage by adding a new member function PreTranslateMessage(MSG* pMsg) to CTestingView

<br />
<br />
BOOL CTestingView::PreTranslateMessage(MSG* pMsg)<br />
{<br />
    if(m_ToolTip != NULL)<br />
		m_ToolTip->RelayEvent(pMsg);<br />
	<br />
    return CFormView::PreTranslateMessage(pMsg);<br />
	<br />
<br />
}<br />


Step 4:
Add messae mapping
<br />
ON_NOTIFY_EX(TTN_NEEDTEXT, 0, SetTipText)<br />
<br />



Step 5:
Add new member function SetTipText(UINT id, NMHDR *pTTTStruct, LRESULT *pResult) to CTestingView
<br />
BOOL CTestingView::SetTipText(UINT id, NMHDR *pTTTStruct, LRESULT *pResult)<br />
{<br />
	TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pTTTStruct;<br />
	UINT nID = pTTTStruct->idFrom;<br />
	nID = ::GetDlgCtrlID((HWND)nID);<br />
	char * Content_m_EDIT_ExampleText;<br />
	Content_m_EDIT_ExampleText = (char *)malloc(sizeof(char) * (m_EDIT_ExampleText.LineLength() + 2) );<br />
	m_EDIT_ExampleText.GetLine(0, Content_m_EDIT_ExampleText);<br />
	strcpy(pTTT->lpszText, "ooppp");//(LPTSTR)(LPCTSTR) Content_m_EDIT_ExampleText<br />
<br />
<br />
<br />
	return (FALSE);<br />
}<br />
<br />

AnswerRe: problems on CToolTipCtrl with CEdit (tip window pops twice) Pin
Mark Salsbery9-Nov-06 6:03
Mark Salsbery9-Nov-06 6:03 
AnswerRe: problems on CToolTipCtrl with CEdit (tip window pops twice) Pin
ian_01267-May-11 16:49
ian_01267-May-11 16:49 
QuestionBitmap and Dialogue Interaction Pin
BlitzPackage8-Nov-06 17:56
BlitzPackage8-Nov-06 17:56 
AnswerRe: Bitmap and Dialogue Interaction Pin
Waldermort8-Nov-06 18:17
Waldermort8-Nov-06 18:17 
GeneralRe: Bitmap and Dialogue Interaction Pin
BlitzPackage9-Nov-06 1:27
BlitzPackage9-Nov-06 1:27 
AnswerRe: Bitmap and Dialogue Interaction Pin
Hamid_RT8-Nov-06 18:26
Hamid_RT8-Nov-06 18:26 
GeneralRe: Bitmap and Dialogue Interaction Pin
BlitzPackage9-Nov-06 1:37
BlitzPackage9-Nov-06 1:37 
GeneralRe: Bitmap and Dialogue Interaction Pin
Hamid_RT9-Nov-06 7:38
Hamid_RT9-Nov-06 7:38 
QuestionProblem with Windows Managed C++ Template? Pin
gloriousgopi8-Nov-06 17:39
gloriousgopi8-Nov-06 17:39 
QuestionCEdit selected text Pin
Imtiaz Murtaza8-Nov-06 17:19
Imtiaz Murtaza8-Nov-06 17:19 
AnswerRe: CEdit selected text Pin
Nibu babu thomas8-Nov-06 17:44
Nibu babu thomas8-Nov-06 17:44 
GeneralRe: CEdit selected text Pin
Imtiaz Murtaza8-Nov-06 18:42
Imtiaz Murtaza8-Nov-06 18:42 
GeneralRe: CEdit selected text Pin
David Crow9-Nov-06 3:49
David Crow9-Nov-06 3:49 
AnswerRe: CEdit selected text Pin
Nibu babu thomas8-Nov-06 19:10
Nibu babu thomas8-Nov-06 19:10 
QuestionAbout TreeCtrl Pin
wangpai8-Nov-06 15:55
wangpai8-Nov-06 15:55 
AnswerRe: About TreeCtrl Pin
Christian Graus8-Nov-06 17:09
protectorChristian Graus8-Nov-06 17:09 
GeneralRe: About TreeCtrl Pin
wangpai8-Nov-06 18:46
wangpai8-Nov-06 18:46 

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.