Menu

Windows - Redraw mainwindow and controls

2003-01-30
2012-09-26
  • Nobody/Anonymous

    I am working on making my program fully color customizable through a dialoog where the user can choose color on a ChooseColor common dialog.

    This color scheme is saved on COLORREF vars and later on a ini file.

    Everything is working except for a weird bug: Whenever i set the color for a control, i have to minimize and restore the window in order for the color to show on the control.

    What command do you think i should be using in order to update/fully redraw the window and its controls ?

     
    • Nobody/Anonymous

      erm... did you try UpdateWindow(hwnd);???

      Zero Valintine

      I like the short answers..

       
      • Nobody/Anonymous

        I did it doesnt work.
        Thats weird hun? :(

         
    • Nobody/Anonymous

      Maybe this will work..

      // PAINTSRUCT ps;
      // HDC hdc;

      case WM_PAINT:
      {
          hdc = BeginPaint(hWnd, &ps);
          InvalidateRect(hWnd, NULL, true);
          EndPaint(hWnd, &ps);
          break;
      }

      (in your windproc of course)

      -Jay

       
    • Nobody/Anonymous

      um jay, that can also casue bugs InvalidateRect(hWnd, NULL, TRUE);  is like SendMessage(hWnd, WM_PAINT,0,0);

      try setting the colors in WM_PAINT

      also depending on what control you want to colr you meay need to reference it though WM_CTLCOLORBTN: or WM_CTLCOLOREDIT: or WM_CTLCOLORSTATIC or WM_CTLCOLORDLG NB: wm_ctlcoloredit doesnt work with richedits

       
    • Nobody/Anonymous

      Maybe there some way for me to ask windows to redraw just a specific hwnd and not the entire window and all its controls?

       

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.