Skip to content

Commit

Permalink
Fix #70
Browse files Browse the repository at this point in the history
  • Loading branch information
katahiromz committed Apr 3, 2024
1 parent c895636 commit 8c64886
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions XgDictList.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,48 @@
// イメージリストを作成する。
HIMAGELIST XgDictList_CreateRadioButtonImageList(HWND hwnd)
{
HIMAGELIST himl;
HDC hdc_wnd, hdc;
HBITMAP hbm_im, hbm_mask;
HGDIOBJ hbm_orig;
HBRUSH hbr_white = GetStockBrush(WHITE_BRUSH);
HBRUSH hbr_black = GetStockBrush(BLACK_BRUSH);
RECT rc;

himl = ImageList_Create(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON),
ILC_COLOR | ILC_MASK, 2, 2);
hdc_wnd = GetDC(hwnd);
hdc = CreateCompatibleDC(hdc_wnd);
hbm_im = CreateCompatibleBitmap(hdc_wnd, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
hbm_mask = CreateBitmap(GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), 1, 1, NULL);
ReleaseDC(hwnd, hdc_wnd);

SetRect(&rc, 0, 0, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON));
hbm_orig = SelectObject(hdc, hbm_mask);
FillRect(hdc, &rc, hbr_white);
InflateRect(&rc, -1, -1);
SelectObject(hdc, hbr_black);
Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom);

SelectObject(hdc, hbm_im);
SelectObject(hdc, GetSysColorBrush(COLOR_WINDOW));
Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom);
SelectObject(hdc, hbm_orig);
ImageList_Add(himl, hbm_im, hbm_mask);

SelectObject(hdc, hbm_im);
SelectObject(hdc, GetSysColorBrush(COLOR_WINDOWTEXT));
Ellipse(hdc, rc.left, rc.top, rc.right, rc.bottom);
SelectObject(hdc, hbm_orig);
ImageList_Add(himl, hbm_im, hbm_mask);

DeleteObject(hbm_mask);
DeleteObject(hbm_im);
DeleteDC(hdc);

return himl;
}

// リストを再読み込みする。
void XgDictList_ReloadList(HWND hwnd)
{
Expand Down Expand Up @@ -101,6 +146,10 @@ XgDictListDlgProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
column.cx = 250;
ListView_InsertColumn(hwndLst1, 1, &column);

// イメージリストを設定。
HIMAGELIST himl = XgDictList_CreateRadioButtonImageList(hwnd);
ListView_SetImageList(hwndLst1, himl, LVSIL_STATE);

// リストを再読み込みする。
++m_bUpdating;
XgDictList_ReloadList(hwnd);
Expand Down

0 comments on commit 8c64886

Please sign in to comment.