MCPcopy Create free account
hub / github.com/0x7c13/UnityEditor-DarkMode / PaintODTBUTTON

Function PaintODTBUTTON

UnityEditorDarkMode.cpp:320–357  ·  view source on GitHub ↗

https://stackoverflow.com/questions/16313333/drawing-rounded-and-colored-owner-draw-buttons

Source from the content-addressed store, hash-verified

318
319// https://stackoverflow.com/questions/16313333/drawing-rounded-and-colored-owner-draw-buttons
320void PaintODTBUTTON(const DRAWITEMSTRUCT& dis) {
321 HWND hwnd = dis.hwndItem;
322
323 RECT rc;
324 GetClientRect(hwnd, &rc);
325
326 auto hdc = dis.hDC;
327 auto bkcolor = LoadThemeConfig()->menubar_bgcolor;
328 auto brush = CreateSolidBrush(bkcolor);
329 auto pen = CreatePen(PS_SOLID, 1, LoadThemeConfig()->menubar_textcolor);
330 auto oldbrush = SelectObject(hdc, brush);
331 auto oldpen = SelectObject(hdc, pen);
332
333 SelectObject(hdc, (HFONT)SendMessage(hwnd, WM_GETFONT, 0, 0));
334 SetBkColor(hdc, bkcolor);
335 SetTextColor(hdc, LoadThemeConfig()->menubar_textcolor);
336
337 HBRUSH tmp = CreateSolidBrush(RGB(127, 192, 127));
338 FillRect(hdc, &rc, tmp);
339
340 Rectangle(hdc, 0, 0, rc.right, rc.bottom);
341
342 if (GetFocus() == hwnd)
343 {
344 RECT temp = rc;
345 InflateRect(&temp, -2, -2);
346 DrawFocusRect(hdc, &temp);
347 }
348
349 TCHAR buf[128];
350 GetWindowText(hwnd, buf, 128);
351 DrawText(hdc, buf, -1, &rc, DT_EDITCONTROL | DT_CENTER | DT_VCENTER | DT_SINGLELINE);
352
353 SelectObject(hdc, oldpen);
354 SelectObject(hdc, oldbrush);
355 DeleteObject(brush);
356 DeleteObject(pen);
357}
358
359LRESULT CALLBACK CallWndSubClassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uIdSubclass, DWORD_PTR dwRefData) {
360 switch (uMsg) {

Callers 1

CallWndSubClassProcFunction · 0.85

Calls 1

LoadThemeConfigFunction · 0.85

Tested by

no test coverage detected