Code for ToolTip Code

G

Guest

Can anybody help me in using the following code in c#. This is used for creating ToolTips

/* CREATE A TOOLTIP CONTROL OVER THE ENTIRE WINDOW AREA */
void CreateMyTooltip (HWND hwnd)
{
// struct specifying control classes to register
INITCOMMONCONTROLSEX iccex;
HWND hwndTT; // handle to the ToolTip control
// struct specifying info about tool in ToolTip control
TOOLINFO ti;
unsigned int uid = 0; // for ti initialization
char strTT[30] = "This is your ToolTip string.";
LPTSTR lptstr = strTT;
RECT rect; // for client area coordinates

/* INITIALIZE COMMON CONTROLS */
iccex.dwICC = ICC_WIN95_CLASSES;
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCommonControlsEx(&iccex);

/* CREATE A TOOLTIP WINDOW */
hwndTT = CreateWindowEx(WS_EX_TOPMOST,
TOOLTIPS_CLASS,
NULL,
WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
hwnd,
NULL,
ghThisInstance,
NULL
);

SetWindowPos(hwndTT,
HWND_TOPMOST,
0,
0,
0,
0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);

/* GET COORDINATES OF THE MAIN CLIENT AREA */
GetClientRect (hwnd, &rect);

/* INITIALIZE MEMBERS OF THE TOOLINFO STRUCTURE */
ti.cbSize = sizeof(TOOLINFO);
ti.uFlags = TTF_SUBCLASS;
ti.hwnd = hwnd;
ti.hinst = ghThisInstance;
ti.uId = uid;
ti.lpszText = lptstr;
// ToolTip control will cover the whole window
ti.rect.left = rect.left;
ti.rect.top = rect.top;
ti.rect.right = rect.right;
ti.rect.bottom = rect.bottom;

/* SEND AN ADDTOOL MESSAGE TO THE TOOLTIP CONTROL WINDOW */
SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM) (LPTOOLINFO) &ti);

}
 
N

Nilesh Rade

Actually I want to make use of this code snippet in C# to deleopm my own
custom tool tip. Can you hel p me please
 
H

Herfried K. Wagner [MVP]

* "=?Utf-8?B?TmlsZXNoIFJhZGU=?= said:
Can anybody help me in using the following code in c#. This is used for creating ToolTips

Why not use .NET's ToolTip component?!
 
N

Nilesh Rade

I can't use that tool tip because It appears from the tail of the
mouse..but in case of the treeView it overlaps the nodes....
Is there a way by which i can set the location of the .net tooltip as to
from where should it appear??then in that case I can use the .net
tooltip...

This is a big drawback of the .net tool tip that i can't set the
location for it......

Please suggest / help
 
N

Nilesh Rade

Hi Steve,
Thanks a lot for the reply.But this site (www.tooltips.net) doesn't
exposed any source code. I am looking out for the develoment help form
the group.Please help and cooperate.

Nilesh
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top