Hi,
ich bin gerade dabei einen BS_OWNERDRAW Button zu erstellen.
Nun habe ich folgende Routinen in mein Programm eingebaut:
...
static HBITMAP hbm1,hbm2;
HDC hdcMem1,hdcMem2;
...
hwndStart=CreateWindow("BUTTON", "Start",
WS_VISIBLE|WS_CHILD|BS_OWNERDRAW ,
10, 80, 89, 33, // Positionen auf dem Elternfenster
hwnd, (HMENU)ID_START, hInstance, 0);
hwndExit=CreateWindow("BUTTON", "Exit",
WS_VISIBLE|WS_CHILD|BS_OWNERDRAW ,
10, 180, 89, 33, // Positionen auf dem Elternfenster
hwnd, (HMENU)ID_EXIT, hInstance, 0);
...
case WM_DRAWITEM:
hdcMem2 = BeginPaint(hwnd,&ps);
hdcMem1 = CreateCompatibleDC(hdcMem2);
SelectObject(hdcMem1, hbm1);
StretchBlt(hdcMem2,
0,
0,
89,
33,
hdcMem1, // source device context
0, 0, // x and y upper left
89, // source bitmap width
33, // source bitmap height
SRCCOPY); // raster operation
EndPaint(hwnd,&ps);
DeleteDC(hdcMem1);
DeleteDC(hdcMem2);
return TRUE;
Aber irgendwie klappt es nicht den Buttons verschiedene Bilder zuzuweisen.
Was mache ich falsch?
ich bin gerade dabei einen BS_OWNERDRAW Button zu erstellen.
Nun habe ich folgende Routinen in mein Programm eingebaut:
...
static HBITMAP hbm1,hbm2;
HDC hdcMem1,hdcMem2;
...
hwndStart=CreateWindow("BUTTON", "Start",
WS_VISIBLE|WS_CHILD|BS_OWNERDRAW ,
10, 80, 89, 33, // Positionen auf dem Elternfenster
hwnd, (HMENU)ID_START, hInstance, 0);
hwndExit=CreateWindow("BUTTON", "Exit",
WS_VISIBLE|WS_CHILD|BS_OWNERDRAW ,
10, 180, 89, 33, // Positionen auf dem Elternfenster
hwnd, (HMENU)ID_EXIT, hInstance, 0);
...
case WM_DRAWITEM:
hdcMem2 = BeginPaint(hwnd,&ps);
hdcMem1 = CreateCompatibleDC(hdcMem2);
SelectObject(hdcMem1, hbm1);
StretchBlt(hdcMem2,
0,
0,
89,
33,
hdcMem1, // source device context
0, 0, // x and y upper left
89, // source bitmap width
33, // source bitmap height
SRCCOPY); // raster operation
EndPaint(hwnd,&ps);
DeleteDC(hdcMem1);
DeleteDC(hdcMem2);
return TRUE;
Aber irgendwie klappt es nicht den Buttons verschiedene Bilder zuzuweisen.
Was mache ich falsch?
Comment