#include <windows.h>
#include <commctrl.h>
#pragma comment(lib, "comctl32.lib")
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM);
//void CreateMyTooltip(HWND);

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow) {
MSG  msg;    
WNDCLASS wc = {0};
wc.lpszClassName = TEXT("Tooltip");
wc.hInstance     = hInstance;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc   = WndProc;
wc.hCursor       = LoadCursor(0, IDC_ARROW);  
RegisterClass(&wc);
CreateWindow(wc.lpszClassName, TEXT("Tooltip"),WS_OVERLAPPEDWINDOW | WS_VISIBLE,100, 100, 200, 150, 0, 0, hInstance, 0);  
while (GetMessage(&msg, NULL, 0, 0)) 
{  
TranslateMessage(&msg);
DispatchMessage(&msg);
}  
return (int) msg.wParam;
}

LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) {

switch(msg) {

case WM_CREATE:
{
// load common control class ICC_WIN95_CLASSES from the dynamic-link library (DLL).
INITCOMMONCONTROLSEX iccex; 
HWND hwndTT; 
iccex.dwICC = ICC_WIN95_CLASSES;
iccex.dwSize = sizeof(INITCOMMONCONTROLSEX);
InitCommonControlsEx(&iccex);

HWND hButton = CreateWindowEx( NULL, TEXT("button"), TEXT("tooltip test"),  WS_CHILD | WS_VISIBLE | WS_BORDER | BS_PUSHBUTTON,10, 10, 150, 25, hwnd, NULL, NULL, NULL);
HWND hwndTip = CreateWindowEx( WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP,CW_USEDEFAULT, CW_USEDEFAULT,CW_USEDEFAULT, CW_USEDEFAULT,hwnd, NULL, NULL, NULL );
// Associate the tooltip with the tool.
TOOLINFO toolInfo = { 0 };
toolInfo.cbSize = sizeof(toolInfo);
toolInfo.hwnd = hwnd;
toolInfo.uFlags = TTF_IDISHWND | TTF_SUBCLASS;
toolInfo.uId = (UINT_PTR)hButton;
toolInfo.lpszText = TEXT("this is a tooltip");
SendMessage( hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo );
}
break;

case WM_DESTROY:
PostQuitMessage(0);
break;
}

return DefWindowProc(hwnd, msg, wParam, lParam);
}