static int Main(const Options *options) { if(!CreateWnd(options->showWindow)) return 1; NotifyCtl(NIM_ADD,L"",0); UpdateToolTip(FALSE); if(options->pLayoutToSet) { HKL hkl=FindLayoutHandleForDisplayName(options->pLayoutToSet); SetLayoutByHandle(hkl,FALSE); } for(;;) { int r; MSG msg; r=GetMessage(&msg,NULL,0,0); if(r==0||r==-1) break; TranslateMessage(&msg); DispatchMessage(&msg); } NotifyCtl(NIM_DELETE,NULL,0); return 0; }
CBCGPRadialMenuItem::CBCGPRadialMenuItem(UINT nID) { CommonInit(); m_nID = nID; UpdateToolTip(); }
/* ** Does the initial construction of the ToolTip for the meter */ void Meter::CreateToolTip(Skin* skin) { HWND hSkin = m_Skin->GetWindow(); HINSTANCE hInstance = GetRainmeter().GetModuleInstance(); DWORD style = WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP; if (m_ToolTipType) { style |= TTS_BALLOON; } HWND hwndTT = CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, style, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hSkin, nullptr, hInstance, nullptr); if (hwndTT) { SetWindowPos(hwndTT, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE); TOOLINFO ti = {sizeof(TOOLINFO), TTF_SUBCLASS, hSkin, 0, GetMeterRect(), hInstance}; SendMessage(hwndTT, TTM_ADDTOOL, 0, (LPARAM)&ti); m_ToolTipHandle = hwndTT; UpdateToolTip(); } }
static LRESULT CALLBACK WndProc(HWND hWnd,UINT uMsg,WPARAM wParam,LPARAM lParam) { switch(uMsg) { default: if(uMsg==g_controlMsg) { if(wParam==CONTROL_NEXT_LAYOUT||wParam==CONTROL_PREV_LAYOUT) { Layout *pFirstLayout,*pActiveLayout; pFirstLayout=CreateLayoutsList(); pActiveLayout=FindActiveLayout(pFirstLayout); if(pActiveLayout) { Layout *pNewLayout; LOG("Active layout: \"%S\"\n",pActiveLayout->pDisplayName); LOG("wParam=%d\n",(int)wParam); if(wParam==CONTROL_NEXT_LAYOUT) { pNewLayout=pActiveLayout->pNextLayout; if(!pNewLayout) pNewLayout=pFirstLayout; } else { Layout *pNextLayout; if(pActiveLayout==pFirstLayout) pNextLayout=NULL; else pNextLayout=pActiveLayout; for(pNewLayout=pFirstLayout;pNewLayout;pNewLayout=pNewLayout->pNextLayout) { if(pNewLayout->pNextLayout==pNextLayout) break; } } if(pNewLayout) { LOG("New layout: \"%S\"\n",pNewLayout->pDisplayName); SetLayoutByHandle(pNewLayout->hkl,TRUE); } } DeleteLayoutList(pFirstLayout); pFirstLayout=NULL; } else if(wParam==CONTROL_SET_LAYOUT) { SetLayoutByHandle((HKL)lParam,TRUE); } } break; case WM_PAINT: { RECT client; PAINTSTRUCT ps; HDC dc=BeginPaint(hWnd,&ps); SaveDC(dc); GetClientRect(hWnd,&client); FillRect(dc,&client,GetStockObject(WHITE_BRUSH)); SelectObject(dc,GetStockObject(DEFAULT_GUI_FONT)); SetTextColor(dc,RGB(0,0,0)); SetTextAlign(dc,TA_CENTER|VTA_CENTER); TextOutA(dc,client.right/2,client.bottom/2,RIGHT_CLICK_MESSAGE,RIGHT_CLICK_MESSAGE_LEN); RestoreDC(dc,-1); EndPaint(hWnd,&ps); } return 0; case WM_INPUTLANGCHANGEREQUEST: UpdateToolTip(FALSE); break; case WM_RBUTTONUP: // avoid injecting the DLL into explorer... DoPopupMenu(); return 0; case SHOWTIP_MSG: UpdateToolTip(TRUE); return 0; case NOTIFY_MSG: { switch(lParam) { case WM_RBUTTONDOWN: DoPopupMenu(); return 0; } } break; case WM_CLOSE: PostQuitMessage(0); return 0; } return DefWindowProc(hWnd,uMsg,wParam,lParam); }