How to solve the version mismatch problem when creating a tooltip using Win32 API

Source: Internet
Author: User

In Visual Studio 2005 or a later version, you can use APIs to create a tootip. After creation, messages such as ttm_addtool will fail to be sent because the loaded commctrl dll version does not match. The solution is as follows:

 

1. Change # DEFINE _ win32_winnt 0x0501 to # DEFINE _ win32_winnt 0x0500 in the stdafx. h file.

 

2. Add the following code before # include "commctrl. H" # pragma comment (Lib, "comctl32.lib:

# If _ win32_winnt> 0x0500

# If defined _ m_ix86
# Pragma comment (linker, "/manifestdependency:/" type = 'win32 'name = 'Microsoft. windows. common-controls 'version = '6. 0.0.0 'processorarchitecture = 'x86 'publickeytoken = '6595b64144ccf1df' Language = '*'/"")
# Elif defined _ m_ia64
# Pragma comment (linker, "/manifestdependency:/" type = 'win32 'name = 'Microsoft. windows. common-controls 'version = '6. 0.0.0 'processorarchitecture = 'ia64' publickeytoken = '6595b64144ccf1df 'Language = '*'/"")
# Elif defined _ m_x64
# Pragma comment (linker, "/manifestdependency:/" type = 'win32 'name = 'Microsoft. windows. common-controls 'version = '6. 0.0.0 'processorarchitecture = 'amd64' publickeytoken = '6595b64144ccf1df 'Language = '*'/"")
# Else
# Pragma comment (linker, "/manifestdependency:/" type = 'win32 'name = 'Microsoft. windows. common-controls 'version = '6. 0.0.0 'processorarchitecture = '*' publickeytoken = '6595b64144ccf1df 'Language = '*'/"")
# Endif

# Endif

 

3. Change the cbsize when filling the toolinfo structure, as shown below:

Toolinfo Ti;
Memset (& Ti, 0, sizeof (toolinfo ));

# If _ win32_winnt> 0x0500
Ti. cbsize = sizeof (toolinfo)-sizeof (void *);
# Else
Ti. cbsize = sizeof (toolinfo );
# Endif

The reason is that when _ win32_winnt is greater than 0x0500, The toolinfo struct has an additional lparam definition, resulting in a mismatch between sizeof (toolinfo) and the old version.

 

We recommend that you use 3rd methods. Because the previous two methods modify the entire commctrl dll version, the system will use a lower version of commctrl DLL.

 

The sample code is as follows:

Hwnd hwindow =: createjavaswex (null, tooltips_class, null, ws_popup | tts_noprefix | average, cw_usedefault, null, (hmenu) 0, null, null );

 

Toolinfo Ti;
Memset (& Ti, 0, sizeof (toolinfo ));

# If _ win32_winnt> 0x0500
Ti. cbsize = sizeof (toolinfo)-sizeof (void *);
# Else
Ti. cbsize = sizeof (toolinfo );
# Endif

... // Other data Filling

: Sendmessage (hwindow, ttm_addtool, 0, & Ti );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.