Part of Solutions:
1. Kill an InvalidateRect: in mainWindowProc.
2. Kill any other InvalidateRect.
When you Keyup in mainWindowProc only, we can refresh(*1) a screen.
(*1)
refresh = InvalidateRect
Next of Solutions:
1. Call the simple drawing function like Circle.
inside "void wKickEventDisplayThreeD::kickPaintEvent"
At least, we could have problem under the above function.
static LRESULT CALLBACK mainWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) ... switch ( uMsg ){ case WM_PAINT: // event.hDc = BeginPaint( hWnd, &ps); // wmpaint_display_threeD_proc ( hWnd, &hDC, &ps, uMsg, wParam, lParam ); // btc.Process (); printf("WM_PAINT 005: %d *(p_evt->uMsg):%d uMsg: %d \r\n", uMsg, *(p_evt->uMsg), uMsg ); EndPaint(hWnd, &ps); printf("WM_PAINT 006: %d *(p_evt->uMsg):%d uMsg: %d \r\n", uMsg, *(p_evt->uMsg), uMsg ); break; case WM_KEYUP: InvalidateRect( hWnd, NULL, TRUE); break; case WM_CHAR: // ADD: 20200612: //InvalidateRect(hWnd, NULL, TRUE); break; }
file: clibboard.cpp int Paste(HWND hwnd, char *str) { printf("Now we do not use Paste:\r\n"); exit(-1); return ReadClip( hwnd, str ); }
void draw_box(HWND hWnd, HDC hDC, PAINTSTRUCT* ps, UINT uMsg, WPARAM wParam, LPARAM lParam) { if (curtain == nullptr) return; for ( int i=0; i<12; i++ ) { // GamePaint_011( hDC, to_screen_line( curtain->box->line[i] ) ); // already created: GamePaint_011(hDC, to_screen_line(curtain->box->line[i], curtain->box->line_on_screen[i])); // already created: } }
void create_panel_onrails_002 (HWND hWnd, HDC hDC, PAINTSTRUCT* ps, UINT uMsg, WPARAM wParam, LPARAM lParam) { vLine* line = nullptr; vLine* line_1 = nullptr; vLine* line_2 = nullptr; vLine* line_4 = nullptr; printf("void create_panel_onrails_002 (HWND hWnd, HDC hDC, PAINTSTRUCT* ps, UINT uMsg, WPARAM wParam, LPARAM lParam) starts."); // Nove the below to initialization: static POINT points[4]; //ADD: 20191231 for (int i = 0; i < CurveLines->curve_points_num - 2; i += 2) { line = new vLine(); line_1 = new vLine(); line->setLine(CurveLines->curve_points[i], CurveLines_Support->curve_points[i]); line = (vLine*)to_screen_line(line, line_1); line->print(); line_2 = new vLine(); line_4 = new vLine(); line_2->setLine(CurveLines->curve_points[i + 1], CurveLines_Support->curve_points[i + 1]); line_2 = (vLine*)to_screen_line(line_2, line_4); line_2->print(); points[0] = { (int)line_1->p1->x, (int)line_1->p1->y }; points[1] = { (int)line_1->p2->x, (int)line_1->p2->y }; points[2] = { (int)line_4->p2->x, (int)line_4->p2->y }; points[3] = { (int)line_4->p1->x, (int)line_4->p1->y }; GamePaint_012(hDC, (POINT*)points, 4); printf("draw i: %d is painted\r\n", i); } //ADD: 20191231 printf("void create_panel_onrails_002 (HWND hWnd, HDC hDC, PAINTSTRUCT* ps, UINT uMsg, WPARAM wParam, LPARAM lParam) ends."); }
// customized from GamePaint_009 // // // // void GamePaint_011(HDC hDC, vLine* line ) { int scale_2 = 30; static RECT rect_2, rect; if (paintedFlag == 0) return; printf("GamePaint_011: 000\r\n"); MoveToEx(hDC, (int)line->p1->x, (int)line->p1->y, NULL); LineTo(hDC, (int)(line->p2)->x, (int)(line->p2)->y ); printf("GamePaint_011: 001\r\n"); line->print(); if ( line->c1 != nullptr ) { SetRect( &rect, (int)line->p1->x - scale_2, (int)line->p1->y - scale_2, (int)line->p1->x + scale_2, (int)line->p1->y + scale_2 ); //DrawText(hDC, (LPCWSTR)(line->c1), -1, &rect, DT_NOCLIP); //DrawTextA( hdc, this->button_name, array_count(this->button_name), &rect, DT_TOP); DrawTextA( hDC, (line->c1), array_count(line->c1), &rect, DT_TOP); } printf("GamePaint_011: 002\r\n"); if ( line->c2 != nullptr ) { SetRect( &rect_2, (int)line->p2->x - scale_2, (int)line->p2->y - scale_2, (int)line->p2->x + scale_2, (int)line->p2->y + scale_2 ); //DrawText( hDC, (LPCWSTR)(line->c2), -1, &rect_2, DT_NOCLIP ); DrawTextA( hDC, (line->c2), array_count(line->c2), &rect, DT_TOP); } printf("GamePaint_011: 003\r\n"); return; }
// customized from GamePaint_009 // // // // void GamePaint_012( HDC hDC, POINT* points, int num ) { static RECT rect; int retval; if (paintedFlag == 0) return; SelectObject( hDC , CreateSolidBrush(0x88)); retval = SetPolyFillMode( hDC, ALTERNATE); retval = Polygon( hDC, points, num); DeleteObject(SelectObject(hDC , GetStockObject(0x88))); // Polygon( hDC, points, num ); // SetRect( &rect, (int)x1, (int)y1, (int)x2, (int)y2 ); // FillRect(hDC, &rect, (HBRUSH) (COLOR_WINDOW+1)); return; }
// // // // // void wKickEventDisplayThreeD::kickPaintEvent(HWND hWnd, HDC hdc, PAINTSTRUCT* ps, UINT uMsg, WPARAM wParam, LPARAM lParam) { int result_draw = dDisplayControls_wmpaint_display_threeD_proc_OnRails(hWnd, hdc, ps, uMsg, wParam, lParam); return; }