49 WNDPROC lpfnWndProc, LPCTSTR lpWndClass)
53 wndclass.cbSize =
sizeof(wndclass);
54 wndclass.style = CS_HREDRAW | CS_VREDRAW;
55 wndclass.lpfnWndProc = lpfnWndProc;
56 wndclass.cbClsExtra = 0;
57 wndclass.cbWndExtra = DLGWINDOWEXTRA;
58 wndclass.hInstance = hInst;
59 wndclass.hIcon = NULL;
60 wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);
61 wndclass.hbrBackground = (HBRUSH)COLOR_WINDOW;
62 wndclass.lpszMenuName = NULL;
63 wndclass.lpszClassName = lpWndClass;
64 wndclass.hIconSm = NULL;
66 RegisterClassEx(&wndclass);
68 l_hWnd = CreateDialog(hInst, MAKEINTRESOURCE(iDlg), hParent, NULL);
76 SendMessage(
l_hWnd, WM_INITDIALOG, (WPARAM)0, (LPARAM)0);
84 HBITMAP hBitmapUp, HBITMAP hBitmapDwn,
102 LPDRAWITEMSTRUCT lpdis)
106 if ((lpdis->itemAction & ODA_DRAWENTIRE) != 0U) {
108 SetClassLongPtr(lpdis->hwndItem,
109 GCLP_HCURSOR, (LONG_PTR)me->
hCursor);
113 lpdis->rcItem.left, lpdis->rcItem.top);
117 else if ((lpdis->itemAction & ODA_SELECT) != 0U) {
118 if ((lpdis->itemState & ODS_SELECTED) != 0U) {
120 lpdis->rcItem.left, lpdis->rcItem.top);
154 UINT width, UINT height,
155 UINT itemID, BYTE
const bgColor[3])
157 BITMAPINFO bi24BitInfo;
165 GetWindowRect(me->
hItem, &rect);
173 bi24BitInfo.bmiHeader.biBitCount = 3U*8U;
174 bi24BitInfo.bmiHeader.biCompression = BI_RGB;
175 bi24BitInfo.bmiHeader.biPlanes = 1U;
176 bi24BitInfo.bmiHeader.biSize =
sizeof(bi24BitInfo.bmiHeader);
177 bi24BitInfo.bmiHeader.biWidth = me->
src_width;
178 bi24BitInfo.bmiHeader.biHeight = me->
src_height;
181 me->
hBitmap = CreateDIBSection(me->
src_hDC, &bi24BitInfo, DIB_RGB_COLORS,
182 (
void **)&me->
bits, 0, 0);
192 OutputDebugString(
"GraphicDisplay_xtor\n");
200 BYTE *bits = me->
bits;
216 UINT segmentNum, UINT bitmapNum)
220 me->
hSegment = (HWND *)calloc(segmentNum,
sizeof(HWND));
222 for (n = 0U; n < segmentNum; ++n) {
225 me->
hBitmap = (HBITMAP *)calloc(bitmapNum,
sizeof(HBITMAP));
227 for (n = 0U; n < bitmapNum; ++n) {
247 UINT segmentNum, UINT segmentID)
249 if (segmentNum < me->segmentNum) {
251 return me->
hSegment[segmentNum] != NULL;
259 UINT bitmapNum, HBITMAP hBitmap)
261 if ((bitmapNum < me->bitmapNum) && (hBitmap != NULL)) {
262 me->
hBitmap[bitmapNum] = hBitmap;
271 UINT segmentNum, UINT bitmapNum)
273 if ((segmentNum < me->segmentNum) && (bitmapNum < me->bitmapNum)) {
274 SendMessage(me->
hSegment[segmentNum], STM_SETIMAGE,
276 (LPARAM)me->
hBitmap[bitmapNum]);
289 int xStart,
int yStart)
293 HDC hdcMem = CreateCompatibleDC(hdc);
295 SelectObject(hdcMem, hBitmap);
296 SetMapMode(hdcMem, GetMapMode(hdc));
298 GetObject(hBitmap,
sizeof(BITMAP), (LPVOID)&bm);
299 ptSize.x = bm.bmWidth;
300 ptSize.y = bm.bmHeight;
301 DPtoLP(hdc, &ptSize, 1);
305 DPtoLP(hdcMem, &ptOrg, 1);
307 BitBlt(hdc, xStart, yStart, ptSize.x, ptSize.y,
308 hdcMem, ptOrg.x, ptOrg.y, SRCCOPY);
void SegmentDisplay_init(SegmentDisplay *const me, UINT segmentNum, UINT bitmapNum)
void OwnerDrawnButton_xtor(OwnerDrawnButton *const me)
void OwnerDrawnButton_set(OwnerDrawnButton *const me, int isDepressed)
enum OwnerDrawnButtonAction OwnerDrawnButton_draw(OwnerDrawnButton *const me, LPDRAWITEMSTRUCT lpdis)
void DrawBitmap(HDC hdc, HBITMAP hBitmap, int xStart, int yStart)
void OwnerDrawnButton_init(OwnerDrawnButton *const me, UINT itemID, HBITMAP hBitmapUp, HBITMAP hBitmapDwn, HCURSOR hCursor)
void GraphicDisplay_redraw(GraphicDisplay *const me)
void SegmentDisplay_xtor(SegmentDisplay *const me)
void GraphicDisplay_xtor(GraphicDisplay *const me)
BOOL SegmentDisplay_initBitmap(SegmentDisplay *const me, UINT bitmapNum, HBITMAP hBitmap)
BOOL SegmentDisplay_initSegment(SegmentDisplay *const me, UINT segmentNum, UINT segmentID)
BOOL OwnerDrawnButton_isDepressed(OwnerDrawnButton const *const me)
void GraphicDisplay_clear(GraphicDisplay *const me)
void GraphicDisplay_init(GraphicDisplay *const me, UINT width, UINT height, UINT itemID, BYTE const bgColor[3])
BOOL SegmentDisplay_setSegment(SegmentDisplay *const me, UINT segmentNum, UINT bitmapNum)
HWND CreateCustDialog(HINSTANCE hInst, int iDlg, HWND hParent, WNDPROC lpfnWndProc, LPCTSTR lpWndClass)
QWIN GUI facilities for building realistic embedded front panels.