Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define WINVER 0x0501
- #define _WIN32_WINNT 0x0501
- #include <tchar.h>
- #include <assert.h>
- #include <windows.h>
- #include <commctrl.h>
- #define ok(cond, fmt) \
- if (!(cond)) \
- { \
- MessageBox(NULL, fmt, _T("Error!"), \
- MB_ICONEXCLAMATION | MB_OK); \
- exit(1); \
- }
- static LRESULT CALLBACK CustomDrawWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
- {
- switch(msg) {
- case WM_DESTROY:
- PostQuitMessage(0);
- break;
- default:
- return DefWindowProc(hWnd, msg, wParam, lParam);
- }
- return 0L;
- }
- int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
- LPSTR lpCmdLine, int nCmdShow)
- {
- WNDCLASS wc;
- LRESULT lResult;
- MSG msg;
- /* Create a class to use the custom draw wndproc */
- wc.style = CS_HREDRAW | CS_VREDRAW;
- wc.cbClsExtra = 0;
- wc.cbWndExtra = 0;
- wc.hInstance = GetModuleHandle(NULL);
- wc.hIcon = NULL;
- wc.hCursor = LoadCursor(NULL, IDC_ARROW);
- wc.hbrBackground = GetSysColorBrush(COLOR_WINDOW);
- wc.lpszMenuName = NULL;
- wc.lpszClassName = _T("CustomDrawClass");
- wc.lpfnWndProc = CustomDrawWndProc;
- RegisterClass(&wc);
- HWND hwndMain, hwndTip;
- TOOLINFO toolInfo = { 0 };
- /* Create a main window */
- hwndMain = CreateWindowEx(0, _T("CustomDrawClass"), NULL,
- WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX |
- WS_MAXIMIZEBOX | WS_VISIBLE,
- 50, 50,
- 300, 300,
- NULL, NULL, NULL, 0);
- ok(hwndMain != NULL, _T("Creation of main window failed\n"));
- /* Make it show */
- ShowWindow(hwndMain, SW_SHOWNORMAL);
- /* Create Tooltip */
- hwndTip = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, NULL,
- TTS_NOPREFIX | TTS_ALWAYSTIP,
- CW_USEDEFAULT, CW_USEDEFAULT,
- CW_USEDEFAULT, CW_USEDEFAULT,
- hwndMain, NULL, GetModuleHandle(NULL), 0);
- ok(hwndTip != NULL, _T("Creation of tooltip window failed\n"));
- /* Make it topmost, as per the MSDN */
- SetWindowPos(hwndTip, HWND_TOPMOST, 0, 0, 0, 0,
- SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
- /* Create a tool */
- toolInfo.cbSize = sizeof(TOOLINFO);
- toolInfo.hwnd = hwndMain;
- toolInfo.hinst = GetModuleHandle(NULL);
- toolInfo.uFlags = TTF_SUBCLASS;
- toolInfo.uId = 0x1234ABCD;
- toolInfo.lpszText = (LPTSTR)_T("This is a test tooltip");
- GetClientRect(hwndMain, &toolInfo.rect);
- lResult = SendMessage(hwndTip, TTM_ADDTOOL, 0, (LPARAM)&toolInfo);
- ok(lResult, _T("Adding the tool to the tooltip failed\n"));
- // Step 3: The Message Loop
- while(GetMessage(&msg, NULL, 0, 0) > 0)
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- return msg.wParam;
- }
Advertisement
Add Comment
Please, Sign In to add comment