You need to handle WM_CTLCOLORDLG
. You should return a brush handle. For example, to make the background white:
case WM_CTLCOLORDLG:
return (INT_PTR)GetStockObject(WHITE_BRUSH);
' Not Tested In VBA Just FollowingCode Copied HereHDC hdcMemLPDRAWITEMSTRUCT lpdisSelect Case messagecase WM_INITDIALOG'hbm1 and hbm2 are defined globally.hbm1 = LoadBitmap((HANDLE) hinst, "OwnBit1")hbm2 = LoadBitmap((HANDLE) hinst, "OwnBit2")return TRUEcase WM_DRAWITEMlpdis=(LPDRAWITEMSTRUCT) lParamhdcMem = CreateCompatibleDC(lpdis.hDC)if (lpdis->itemState & ODS_SELECTED)'if selectedSelectObject(hdcMem,hbm2)elseSelectObject(hdcMem,hbm1)'DestinationStretchBlt lpdis.hDC,lpdis.rcItem.left,lpdis.rcItem.top,lpdis.rcItem.right-lpdis.rcItem.left,lpdis.rcItem.bottom-lpdis.rcItem.top,hdcMem,0,0,32,32,SRCCOPYDeleteDC hdcMemreturn TRUEEnd Ifcase WM_COMMANDif (wParam= IDOK Or wParam=IDCANCEL) ThenEndDialog hDlg, TRUEreturn TRUEEnd Ifif (HIWORD(wParam)=BN_CLICKED) ThenSelect Case (LOWORD(wParam))case IDB_OWNERDRAWEnd SelectEnd Ifcase WM_DESTROYDeleteObject hbm1DeleteObject hbm2End Selectreturn FALSE
' Not Tested
case WM_CREATEhdc = GetDC(hwnd)'xPixel = GetDeviceCaps(hdc, ASPECTX) 'yPixel = GetDeviceCaps(hdc, ASPECTY) ReleaseDC hwnd, hdcSetTimer hwnd,ID_TIMER,50,NULL return 0case WM_SIZExCenter=(cxClient=LOWORD(lParam))/2 yCenter=(cyClient=HIWORD(lParam))/2cxRadius=cyRadius=min(cxClient, cyClient)/16cxMove=max(1, cxRadius/2)cyMove = max(1, cyRadius / 2)cxTotal=2 * (cxRadius + cxMove)cyTotal=2 * (cyRadius + cyMove)case WM_TIMERhdc = GetDC(hwnd)hdcMem = CreateCompatibleDC(hdc); SelectObject hdcMem, hBitmap)BitBlt hdc,xCenter-cxTotal/2, yCenter -cyTotal/2,cxTotal,cyTotal,hdcMem,0,0, SRCCOPY)ReleaseDC hwnd, hdcDeleteDC hdcMemTimers and Animation animation
BackGround Color question-146319