Mình làm 1 cửa số win32 đơn giản và viết thông tin lên đó,
Nhưng vấn đề mình gặp đó là khi thông tin được cập nhập thì bị nháy do cơ chế của thằng nvalidateRect , nó xóa màn hình , flush, rồi vẽ lại flush , do có 2 cái flush đó nên sẽ có cảm giác nháy nháy.
Đây là code của mình, bạn có thể chỉ mình có cách nào để loại bỏ tình trạng này ko?

Mã:
#include <windows.h>#include <vmlog.h>#include <stdio.h>static VMINT   xdebug; //x      //for debug solutionstatic VMINT   ydebug; //y      //for debug solutionstatic VMUINT16   cdebug; //color     //for debug solutionstatic VMINT   pdebug; //pen     //for debug solutionstatic VMINT   kedebug;//key event    //for debug solutionstatic VMINT   kcdebug;//key code    //for debug solutionstatic VMINT   pgfdebug;//pointer game frame //for debug solutionstatic VMINT   pmmdebug;//pointer main menu //for debug solutionstatic VMINT   phodebug;//pointer hold on  //for debug solutionstatic VMWCHAR   debugbuff[200];     //for debug solutionstatic HWND    hwnd;       //for debug solutionstatic HWND    hw_pgf;static struct _debugnode{ WCHAR name[30]; void *data; int  type;} dnode[20];LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam){ PAINTSTRUCT ps; HDC hdc; RECT rt; static WCHAR xau[100]; HFONT font; PLOGFONT plf; int y; static WCHAR peneventxt[][30]={  L"0",  L"Tap",  L"Release",  L"Move",  L"Long",  L"Double",  L"Repeat", }; static WCHAR keyeventtxt[][30]={  L"0",  L"E.Up",  L"E.Down",  L"E.Long",  L"E.Repeat", };  switch (message)  { case WM_COMMAND:  break; case WM_TIMER:  {   //HANDLE h=FindWindowA("V","V");  // if (h==NULL) WndProc(hWnd,WM_DESTROY,0,0);  }  InvalidateRect(hwnd,NULL,TRUE);  //SendMessage(hwnd,WM_NCPAINT,1,0);  break; case WM_PAINT:    hdc = BeginPaint(hWnd, &ps);  GetClientRect(hWnd, &rt);  SetBkMode(hdc,TRANSPARENT);   plf=(PLOGFONT)LocalAlloc(LPTR, sizeof(LOGFONT));   lstrcpyA(plf->lfFaceName, "Arial");   plf->lfWeight = FW_NORMAL;   plf->lfHeight=26;  font = CreateFontIndirect(plf);   SelectObject(hdc,font);  //title  wcscpy(xau,L"Th\xF4ng tin g\x1EE1 r\x1ED1i");  SetTextColor(hdc,RGB(255,0,0));  ExtTextOutW(hdc,(rt.right-rt.left-150)/2,10,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);   //line under title  MoveToEx(hdc, 0, 40, NULL);  LineTo(hdc, rt.right-rt.left, 40);   //reset font  plf=(PLOGFONT)LocalAlloc(LPTR, sizeof(LOGFONT));   lstrcpyA(plf->lfFaceName, "Arial");   plf->lfWeight = FW_BOLD;   plf->lfHeight=16;  font = CreateFontIndirect(plf);   SelectObject(hdc,font);  SetTextColor(hdc,RGB(166,42,44));  //Ve trai  y=50;  wcscpy(xau,L"Pointer game frame");  ExtTextOutW(hdc,rt.left+5,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wcscpy(xau,L":");  ExtTextOutW(hdc,rt.left+135,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wsprintfW(xau,L"%d",pgfdebug);  ExtTextOutW(hdc,rt.left+145,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  y+=20;  wcscpy(xau,L"Pointer main menu");  ExtTextOutW(hdc,rt.left+5,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wcscpy(xau,L":");  ExtTextOutW(hdc,rt.left+135,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wsprintfW(xau,L"%d",pmmdebug);  ExtTextOutW(hdc,rt.left+145,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  y+=20;  wcscpy(xau,L"Pointer hold on");  ExtTextOutW(hdc,rt.left+5,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wcscpy(xau,L":");  ExtTextOutW(hdc,rt.left+135,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wsprintfW(xau,L"%d",phodebug);  ExtTextOutW(hdc,rt.left+145,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  y+=20;  wcscpy(xau,L"Key event/Key code");  ExtTextOutW(hdc,rt.left+5,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wcscpy(xau,L":");  ExtTextOutW(hdc,rt.left+135,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wsprintfW(xau,L"%s/%d",keyeventtxt[kedebug],kcdebug);  ExtTextOutW(hdc,rt.left+145,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  y+=20;   //ve phai  y=50;  wcscpy(xau,L"Pen");  ExtTextOutW(hdc,rt.right-100,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wcscpy(xau,L":");  ExtTextOutW(hdc,rt.right-60,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);   wsprintfW(xau,L"%s",peneventxt[pdebug]);  ExtTextOutW(hdc,rt.right-50,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  y+=20;   wcscpy(xau,L"X");  ExtTextOutW(hdc,rt.right-100,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wcscpy(xau,L":");  ExtTextOutW(hdc,rt.right-60,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wsprintfW(xau,L"%d",xdebug);  ExtTextOutW(hdc,rt.right-50,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  y+=20;  wcscpy(xau,L"Y");  ExtTextOutW(hdc,rt.right-100,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wcscpy(xau,L":");  ExtTextOutW(hdc,rt.right-60,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wsprintfW(xau,L"%d",ydebug);  ExtTextOutW(hdc,rt.right-50,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  y+=20;  wcscpy(xau,L"Color");  ExtTextOutW(hdc,rt.right-100,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wcscpy(xau,L":");  ExtTextOutW(hdc,rt.right-60,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  wsprintfW(xau,L"0x%X",cdebug);  ExtTextOutW(hdc,rt.right-50,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);  y+=20;  MoveToEx(hdc,rt.right-105, 40, NULL);  LineTo(hdc, rt.right-105, y);  //line under  MoveToEx(hdc, 0, y, NULL);  LineTo(hdc, rt.right-rt.left, y);   {   int i;      for (i=0,y=140;i<20;i++,y+=20)   {    switch(dnode[i].type)    {    case DEBUG_CARE_INT:     wsprintfW(xau,L"%d. %s %d",i+1,dnode[i].name,*((int *)dnode[i].data));     break;    case DEBUG_CARE_CHAR:     wsprintfW(xau,L"%d. %s %d",i+1,dnode[i].name,*((char *)dnode[i].data));     break;    case DEBUG_CARE_WCHAR:     wsprintfW(xau,L"%d. %s %d",i+1,dnode[i].name,*((WCHAR *)dnode[i].data));     break;    case DEBUG_CARE_FLOAT:     wsprintfW(xau,L"%d. %s %f",i+1,dnode[i].name,*((float *)dnode[i].data));     break;    case DEBUG_CARE_DOUBLE:     wsprintfW(xau,L"%d. %s %lf",i+1,dnode[i].name,*((double *)dnode[i].data));     break;    case DEBUG_CARE_STR:     wsprintfW(xau,L"%d. %s %s",i+1,dnode[i].name,(char *)dnode[i].data);     break;    case DEBUG_CARE_WSTR:     wsprintfW(xau,L"%d. %s %s",i+1,dnode[i].name,(WCHAR *)dnode[i].data);     break;    default:     wsprintfW(xau,L"%d.",i+1);     break;    }    ExtTextOutW(hdc,rt.left+5,y,ETO_CLIPPED,&rt,xau,wcslen(xau),NULL);   }  }    EndPaint(hWnd, &ps);  break; case WM_DESTROY:  {   DWORD pid;   HANDLE hdl;   GetWindowThreadProcessId(hwnd, &pid);   hdl=OpenProcess(PROCESS_TERMINATE,FALSE,pid);   TerminateProcess(hdl, 0);    CloseHandle(hdl);  }  vm_exit_app();  PostQuitMessage(0);  break; default:  return DefWindowProc(hWnd, message, wParam, lParam); } return 0;}void StartDebugScreen(void){ if (hwnd==NULL) {  MSG msg;  WNDCLASSA wcex;  HINSTANCE hInstance=0;    wcex.style   = CS_HREDRAW | CS_VREDRAW;  wcex.lpfnWndProc = (WNDPROC)WndProc;  wcex.cbClsExtra  = 0;  wcex.cbWndExtra  = 0;  wcex.hInstance  = hInstance;  wcex.hIcon   = LoadIcon(hInstance, (LPCTSTR)IDI_APPLICATION);  wcex.hCursor  = LoadCursor(NULL, IDC_ARROW);  wcex.hbrBackground = (HBRUSH)(COLOR_APPWORKSPACE);  wcex.lpszMenuName = NULL;  wcex.lpszClassName = "Debug Screen by QuangBT";  RegisterClassA(&wcex);  hwnd = CreateWindow("Debug Screen by QuangBT", "Debug Screen by QuangBT", WS_OVERLAPPEDWINDOW,   800, 100, 400, 600, NULL, NULL, hInstance, NULL);  if (!hwnd)  {   return ;  }  ShowWindow(hwnd, SW_SHOWDEFAULT);  UpdateWindow(hwnd);  SetTimer(hwnd,1,20,NULL);  while (GetMessage(&msg, NULL, 0, 0))   {   TranslateMessage(&msg);   DispatchMessage(&msg);  } }}