LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM WPARAM, LPARAM LPARAM) {HDC hdc; Paintstruct PS; Rect rect; StaticHpen Hpen, hOldPen; Switch(message) { CaseWM_PAINT:HDC= BeginPaint (hwnd, &PS); GetClientRect (hwnd,&rect); //The test results: The dotted line interval uses a white fill instead of transparent (the brush's default fill color is white and can be modified SetBkColor)Hpen = CreatePen (Ps_dot,0.1, RGB (255,0,0)); hOldPen=SelectObject (hdc, hpen); //set character, Shadow brush, non-solid line brush background colorSetBkColor (HDC, RGB (0,255,0)); //set character, Shadow brush, non-solid brush background mode (transparent or opaque)//SetBkMode (hdc, OPAQUE); Use the current background color, default white, this can use the SetBkColor settings, not very usefulSetBkMode (hdc, TRANSPARENT);//Transparent, great use//drawing Mode (mixed mode) color or operation (font and window client area color overlay), also known as two-yuan raster operation ROP2SetROP2 (hdc, r2_not);//less useful, more viewing manuals and GETROP2Movetoex (hdc, Rect.left, Rect.bottom/2, NULL); LineTo (hdc, rect.right, Rect.bottom/2); SelectObject (hdc, hOldPen); //first place for destruction//DeleteObject (holdpen);EndPaint (hwnd, &PS); Break; CaseWm_destroy://second place to destroy objectsDeleteObject (hOldPen); PostQuitMessage (0); return 0; } returnDefWindowProc (hwnd, message, WParam, LParam);}
Learn how to set the current background color of Windows programming Day3