|
一群垃圾
不会不要瞎叫。。eeworld垃圾越来越多了。。
我给一个调试通过的给你(没有优化版,优化的我写成了一类,东西太多,这个简单,容易看懂)
hwndChild = CreateWindow(
TEXT("Button"),
TEXT("Close"),
BS_PUSHBUTTON | WS_VISIBLE |WS_CHILD|BS_OWNERDRAW,// OWNERDRAW自绘按钮标识
436,
3,
39,
33,
hWnd,
(HMENU)(IDC_CLOSE),
hInst,
NULL);
if(!IsWindow(hwndChild))
{
DestroyWindow(hWnd);
return 0;
}
WM_DRAWITEM消息调下面函数:
LRESULT CALLBACK DoDrawitemMain (HWND hWnd, UINT wMsg, WPARAM wParam,
LPARAM lParam)
{
HBITMAP hBmp;
LPDRAWITEMSTRUCT lpDIS = LPDRAWITEMSTRUCT(lParam);
RECT rectBtn;
rectBtn.bottom = lpDIS->rcItem.bottom;
rectBtn.top = lpDIS->rcItem.top;
rectBtn.left = lpDIS->rcItem.left;
rectBtn.right = lpDIS->rcItem.right;
INT i;
HDC hdcBmp = CreateCompatibleDC(lpDIS->hDC);
if((lpDIS->itemState & ODS_SELECTED ) ||(lpDIS->itemState == (ODS_FOCUS))||(lpDIS->itemState == (ODS_CHECKED)))
switch(lpDIS->CtlID)
{
case IDC_CLOSE:
hBmp = LoadBitmap(hInst,MAKEINTRESOURCE(IDB_CLOSEY));
i = 0;
break;
}
}
//未按下时显示图片
else //if(((lpDIS->itemAction&ODA_DRAWENTIRE)||
//(lpDIS->itemAction == ODA_SELECT))&&!(lpDIS->itemState == ODS_FOCUS))
{
switch(lpDIS->CtlID)
{
case IDC_CLOSE:
hBmp = LoadBitmap(hInst,MAKEINTRESOURCE(IDB_CLOSEN));
i = 0;
break;
}
}
HGDIOBJ hOldSel = SelectObject(hdcBmp,hBmp);
BITMAP bmp;
GetObject(hBmp,sizeof(BITMAP),&bmp);
BitBlt(lpDIS->hDC,rectBtn.left,rectBtn.top,bmp.bmWidth,bmp.bmHeight,hdcBmp,0,0,SRCCOPY);
SelectObject(hdcBmp,hOldSel);
DeleteObject(hBmp);
DeleteDC(hdcBmp);
return 0;
}
|
|