|
v2.0 wrote: where to put what code...
1. Add a member variable in YourDlg.h --> <code>CToolTipCtrl m_ttc</code>;
2. Inside <code>OnInitDialog </code>create your tooltip and tell the tooltip
what are the controls that require a tooltip...
For Eg:
<code>m_ttc.Create(this);
EnableToolTips(true);
m_ttc.AddTool(GetDlgItem(IDC_ABUTTON),_T("A tooltip"));
m_ttc.Activate(true);</code>
3. Override <code>PreTranslateMessage </code>and relay the <code>WM_MOUSEMOVE</code> event to the
tooltip control. For eg:
<code>BOOL CYourDlg::PreTranslateMessage(MSG *pMsg)
{
if(pMsg->message == WM_MOUSEMOVE)
m_ttc.RelayEvent(pMsg);
return CDialog::PreTranslateMessage();
}</code>
This is required coz we must tell the tooltip where the mouse pointer is
and the tooltip control then decides whether the pointer is within the
bounds of a control registered with it.
Hope this should suffice!
Nibu thomas
Software Developer
|
|
|
|
|
|
i don't have a toolbar, only single buttons...
|
|
|
|
|
Hi v2.0,
maybe it is some helpful to you
m_tooltip.Create(this);
SetToolTip("ADAD");
void CAnswerView::SetToolTip(LPCTSTR lpText)
{
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.lpszText = (LPTSTR)lpText;
ti.hinst = AfxGetInstanceHandle();
ti.hwnd = GetDlgItem(IDC_BUTTON1)->m_hWnd;
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
ti.uId = (UINT) GetDlgItem(IDC_BUTTON1)->m_hWnd;
m_tooltip.SendMessage(TTM_ADDTOOL, 0, (LPARAM) &ti);
}
|
|
|
|
|
|
|
thanks Cedric, i'll give it a try.
|
|
|
|
|
I just saw that this is valid only for windows that derives from CFrameWnd, but there is a link here[^] on how to do that for windows that don't derive from CFrameWnd.
|
|
|
|
|
okay, thanks
|
|
|
|
|
|
thanks a bunch... perfect explanation.
i'll tell you if i got it work...
|
|
|
|
|
Here[^] is a well explained link that explains perfectly how to do the tips...
|
|
|
|
|
hello frnds,
I have attach two camera to two different USB port and this both cameras take same driver "Microsoft WDM Video....". want to capture two camera on two different Picturebox. But when i start it show source dialog box and i have to select it from combo box.I want selection throw code.
|
|
|
|
|
hello frnds,
I developed one application of video capturing.I used CCD Camera for this application and it display capturing window.now i want to draw a line on this capturing window but i could not draw line on it.when i run program first time it display line and immediatly disappear.I have attach the capture window on picture box.line show only after when i disconnect capturing(using capDriverDisconnect) from the capture window. if any one have solution plz send me.
|
|
|
|
|
Could you explain your problem a little more clearly? What do you mean when you say the line is drawn on the backsite of the window? Did you open your monitor to see if a line was there?
|
|
|
|
|
I want add buttons to toolbar dynamicly, also delete them dynamicly.
when I added button to toolbar, the button is gray,,
How can i make the newly added buttons active or avalible to the click command, so that i can use the buttons to control something i want.
|
|
|
|
|
Did you set the button state? In the fsState member of TBBUTTON structure, you might need to set the TBSTATE_ENABLED state also.
It also depends on whether you are using MFC or not.
this is this.
|
|
|
|
|
thank you for your reply/
I use the MFC ,and also i set the enabled state ...
how to make the buttons recieve the message which produced by mouse click?
bruspark
|
|
|
|
|
Add a handler function prototype in CMainFrame or the class which will handle the click like:
afx_msg void OnSome();
Also in the .cpp file, add this to the Message map:
ON_COMMAND(ID_SOMETHINGELSE,OnSome)
Also define ID_SOMETHINGELSE to be the same as the command-id of the button for which you want to handle the click.
Then send message:
SendMessage(WM_COMMAND,MAKELPARAM(ID_SOMETHINGELSE,0));
//If sent from the same class as the handler.
Also define the function in the .cpp file:
void CClassname::OnSome()<br />
{<br />
}
this is this.
|
|
|
|
|
khan++,thank you for you reply!
It's a good idea...I will try it.
Thank you!
|
|
|
|
|
The problem is :when i create a button in toolbar,i got the ID of the button,but how can i make the buttons recieve the click event ?
with the classwizard we can map the command to the buttonID,when i click the buttons,handler fuction is called...
however,now ,the buttons is created dynamicly,and we don't know the buttonID in advance.The classwizard can't work in this case.
i can call the PostMessage() fucntion to inform the buttons created dynamicly. the problem is how can the buttons recieved the click event and
where do i place the message handler fuctions?
|
|
|
|
|
Have you add this macro to the map
ON_COMMAND(ID_BUTTON, OnClickButton)
?
or
ON_COMMAND_RANGE
if you have more ID/buttons dynamically created
?
Have a nice code day
|
|
|
|
|
_Russell,I add the ON_COMMAND_RANGE macro ,,it works...
Thanks a lot!
|
|
|
|
|
Have a nice code day
|
|
|
|
|