CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 1999
    Posts
    4

    Re-paint all controls when dialog box is visible

    I'd like to know how to do to re-paint all controls in a dialog box when this one is visible (and when PC is processing) after having been hidden.
    For example, I create a Dialog Box with CStatic, CEdit..... and CProgressCtrl controls and, from this dialog box,Icall a function Process([function parameters],CProgressCtrl* poProgress)
    {
    for(i = 0;i < 10000;i++)
    {
    .
    .
    .
    poProgress->OffsetPos(1);
    }
    }

    When the dialog box is hidden and re-shown, only the progression of the CProgressCtrl is redrawn.
    I'd like all the other controls to be redrawn.
    Thanks.



  2. #2
    Join Date
    May 1999
    Posts
    26

    Re: Re-paint all controls when dialog box is visible

    You have to use multithreading to do processing and having the controls process their messages at the samen time. Use AfxBeginThread(MyProcess, pParams) to create a "worker thread" (that will do the process) instead of call your MyProcess() function. You just have to encapsulate the paramenters you pass to MyProcess in a single class or sctructure. And you have to define your process function like this:

    UINT MyProcess(LPVOID pParam)




    For example:

    Instead of :

    ...
    MyProcess(int a, int b, CSomeClass c);
    ...



    It'll be:

    //Definitions:

    UINT MyProcess(LPVOID pParam);

    structure
    {
    int a;
    int b;
    CSomeclass c;
    }MyParamStructure;



    And when starting the processing:

    ...
    MyParamStructure ps;
    ps.a = a;
    ps.b = b;
    ps.c = c;

    AfxBeginThread(MyProcess,&ps);
    ...







Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured