Button with Icon not showing tooltip
-
I have a CButton on which I load an Icon. I set the Icon property of the button to true and load the icon using the LoadImage() function as follows: HANDLE hIconHandle = ::LoadImage( AfxGetResourceHandle(), MAKEINTRESOURCE( IDI_MYICON), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT ); ::SendMessage( m_button.m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) (DWORD) hU ); The tool tips show only if the mouse is on the border of the button and not on the image. The button is placed on a mode less dialog. Any ideas on how can I get the tool tip to show when the mouse is over the button? P.S: I don't want to add a new class to implement this functionality...
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
I have a CButton on which I load an Icon. I set the Icon property of the button to true and load the icon using the LoadImage() function as follows: HANDLE hIconHandle = ::LoadImage( AfxGetResourceHandle(), MAKEINTRESOURCE( IDI_MYICON), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT ); ::SendMessage( m_button.m_hWnd, BM_SETIMAGE, IMAGE_ICON, (LPARAM) (DWORD) hU ); The tool tips show only if the mouse is on the border of the button and not on the image. The button is placed on a mode less dialog. Any ideas on how can I get the tool tip to show when the mouse is over the button? P.S: I don't want to add a new class to implement this functionality...
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
When you run this code what happen?
void CDialogDlg::SetToolTip(LPCTSTR Text,HWND hwnd)
{
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.lpszText = (LPTSTR)Text;
ti.hinst = AfxGetInstanceHandle();
ti.hwnd = hwnd;
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
ti.uId = (UINT) hwnd;
m_tooltip.SendMessage(TTM_ADDTOOL, 0, (LPARAM) &ti);}
void CDialogDlg::OnBnClickedCancel()
{
m_tooltip.Create(this);m\_Button.ModifyStyle(BS\_BITMAP,BS\_ICON);
//HANDLE hIconHandle = ::LoadImage( AfxGetResourceHandle(),
//MAKEINTRESOURCE( IDI_UP), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT );
//m_Button.SetIcon((HICON)hIconHandle );
m_Button.SetIcon(LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDI_UP));
SetToolTip("Test",m_Button.m_hWnd);
}
WhiteSky
-
When you run this code what happen?
void CDialogDlg::SetToolTip(LPCTSTR Text,HWND hwnd)
{
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.lpszText = (LPTSTR)Text;
ti.hinst = AfxGetInstanceHandle();
ti.hwnd = hwnd;
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
ti.uId = (UINT) hwnd;
m_tooltip.SendMessage(TTM_ADDTOOL, 0, (LPARAM) &ti);}
void CDialogDlg::OnBnClickedCancel()
{
m_tooltip.Create(this);m\_Button.ModifyStyle(BS\_BITMAP,BS\_ICON);
//HANDLE hIconHandle = ::LoadImage( AfxGetResourceHandle(),
//MAKEINTRESOURCE( IDI_UP), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT );
//m_Button.SetIcon((HICON)hIconHandle );
m_Button.SetIcon(LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDI_UP));
SetToolTip("Test",m_Button.m_hWnd);
}
WhiteSky
The image on the button disappears when I click on the Cancel button for the first time and is not displayed again. The application crashes when I click on Cancel button for the second time (but this can be handled)
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
When you run this code what happen?
void CDialogDlg::SetToolTip(LPCTSTR Text,HWND hwnd)
{
TOOLINFO ti;
ti.cbSize = sizeof(TOOLINFO);
ti.lpszText = (LPTSTR)Text;
ti.hinst = AfxGetInstanceHandle();
ti.hwnd = hwnd;
ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;
ti.uId = (UINT) hwnd;
m_tooltip.SendMessage(TTM_ADDTOOL, 0, (LPARAM) &ti);}
void CDialogDlg::OnBnClickedCancel()
{
m_tooltip.Create(this);m\_Button.ModifyStyle(BS\_BITMAP,BS\_ICON);
//HANDLE hIconHandle = ::LoadImage( AfxGetResourceHandle(),
//MAKEINTRESOURCE( IDI_UP), IMAGE_ICON, 0, 0, LR_LOADTRANSPARENT );
//m_Button.SetIcon((HICON)hIconHandle );
m_Button.SetIcon(LoadIcon(AfxGetApp()->m_hInstance,(LPCTSTR)IDI_UP));
SetToolTip("Test",m_Button.m_hWnd);
}
WhiteSky
Do we have a substitute for PreTranslateMessage in Modeless dialog. I guess I have figured the problem and now I need a substitute...
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
-
The image on the button disappears when I click on the Cancel button for the first time and is not displayed again. The application crashes when I click on Cancel button for the second time (but this can be handled)
Somethings seem HARD to do, until we know how to do them. ;-)_AnShUmAn_
Yeah you got an error because you have this function on the cancel
m_tooltip.Create(this);
you must remove this function of Oncancel I tried to work with this code and it worked and I could see image on the button before and after click.
WhiteSky