YOU CAN CODE!

 

With The Case Of UCanCode.net  Release The Power OF  Visual C++ !   HomeProducts | PurchaseSupport | Downloads  
Download Evaluation
Pricing & Purchase?
E-XD++Visual C++/ MFC Products
Overview
Features Tour 
Electronic Form Solution
Visualization & HMI Solution
Power system HMI Solution
CAD Drawing and Printing Solution

Bar code labeling Solution
Workflow Solution

Coal industry HMI Solution
Instrumentation Gauge Solution

Report Printing Solution
Graphical modeling Solution
GIS mapping solution

Visio graphics solution
Industrial control SCADA &HMI Solution
BPM business process Solution

Industrial monitoring Solution
Flowchart and diagramming Solution
Organization Diagram Solution

Graphic editor Source Code
UML drawing editor Source Code
Map Diagramming Solution

Architectural Graphic Drawing Solution
Request Evaluation
Purchase
ActiveX COM Products
Overview
Download
Purchase
Technical Support
  General Q & A
Discussion Board
Contact Us

Links

Get Ready to Unleash the Power of UCanCode .NET


UCanCode Software focuses on general application software development. We provide complete solution for developers. No matter you want to develop a simple database workflow application, or an large flow/diagram based system, our product will provide a complete solution for you. Our product had been used by hundreds of top companies around the world!

"100% source code provided! Free you from not daring to use components because of unable to master the key technology of components!"


Tooltips CToolBar EnableToolTips and CBRS_ALIGN_ANY | CBRS_TOOLTIPS | CBRS_FLYBY with_countof

 
 

Sample Image - ToolTipsInDialog.gif

Introduction

When I posted an article discussing the subject of placing a toolbar right in the middle of elsewhere, Daniel Kaminsky pointed out, that the tool tips were not displayed.

So I sat down, and placed the line EnableToolTips() in my dialogs OnInitDialog function. And what shall I tell you, it did not work. Every dialog and every view showed the toolbar, but no tool tips, or occasionally only very odd ones popped up.

Having a look at the help, there it was stated:

Simply calling EnableToolTips is not enough to display tool tips for your child controls unless the parent window is derived from CFrameWnd.

And because a CDialog or CView is not a descendant of CFrameWnd the tool tips will not get displayed. But a solution was also at the bottom of this article, which I implemented without further thinking. It worked well except to the fact that it showed something like: "Your mouse is hovering over the control with the ID 1234". That was something I never used as tool tip text. Because I wanted the text, stored in the resource of the toolbar being displayed, I looked up the source codes of the MFC itself.

The solution provided here is solely from the people of Microsoft. My only creative part, is finding the places to copy!

Step1

Create a toolbar and attach it to your dialog. Use the normal method of creating a variable of type CToolBar, and ... (or look at the source). In the creation process during OnInit...(), make sure that the bar style flag CBRS_TOOLTIPS is set.

Collapse Copy Code
m_wndToolBar.SetBarStyle(CBRS_ALIGN_ANY | CBRS_TOOLTIPS | CBRS_FLYBY);

Then call EnableToolTips(true);. If you compile now, and run the application, you can see the tool tips not to work.

Step2

Now comes the typing part. Create a message map entry in your CPP-file.

Collapse Copy Code
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTW, 0, 0xFFFF, OnToolTipNotify)
ON_NOTIFY_EX_RANGE(TTN_NEEDTEXTA, 0, 0xFFFF, OnToolTipNotify)

Or copy these two lines just before the END_MESSAGE_MAP() line in your dialogs CPP-file.

According to the documentation, you must create an entry for both TTN_NEEDTEXTW and TTN_NEEDTEXTA notifications.

In your header file declare a function prototype for OnToolTipNotify:

Collapse Copy Code
afx_msg BOOL OnToolTipNotify(UINT id, NMHDR *pNMHDR,LRESULT *pResult);

Or copy this line just before the DECLARE_MESSAGE_MAP() line in your dialogs h-file.

If you compile now, the compiler will tell you, that it needs a function named OnToolTipNotify.

Step 3

Now comes the copy part. Write a new line in your dialogs implementation file (*.cpp):

Collapse Copy Code
BOOL CMyDlgOrView:OnToolTipNotify(UINT, NMHDR* pNMHDR, LRESULT* pResult)

Open WINFRM.CPP in your MFC-source directory. Copy the complete function body of BOOL CFrameWnd::OnToolTipText(UINT, NMHDR* pNMHDR, LRESULT* pResult) and paste it just beneath the new written line in your dialogs/view implementation file. Do not compile!

I told you not to! Add #include <afxpriv.h> either at the beginning of the dialogs header file or elsewhere in stdafx.h. Thus the functions AfxExtractSubString and AfxLoadString are known. Find the following lines in AFXISAPI.H (source directory for MFC->Include)

Collapse Copy Code
#ifndef _countof
#define _countof(array) (sizeof(array)/sizeof(array[0]))
#endif

and paste them into stdafx.h.

Compile, and see the tool tips work.

Extroduction

If you have no access to the sources of the MFC, open the sources of the demo project. I did already copy and paste. If I understand right, what is said in the documentation, this will work for any CWnd - window. Like CDialogs, CViews, CStatics, CTreeCtrl s, just to name a few? Happy copying and pasting.

 

 

 

Copyright ?1998-2009 UCanCode.Net Software , all rights reserved.
Other product and company names herein may be the trademarks of their respective owners.

Please direct your questions or comments to webmaster@ucancode.net