Re: CStatic Text Stops Updating
- From: "SBC News" <wbowling@xxxxxxxxxxx>
- Date: Sat, 10 Dec 2005 08:34:48 GMT
Hi Scott,
I apologize for not having clearly described the problem. Please consider
the following:
// myCString is mapped to static text displayed on the dialog box
char Logentry [ 255 ];
FILE *fh;
strcpy(Logentry,"Something happened");
// Actually, the Logentry variable is passed to the function as an argument
that is part of a
// data structure pointer. There are tests for successful file handle
allocation, string buffer
// content size and everything else one does to bulletproof code used by
others.
fh = fopen("name","w");
fprintf(fh,"%s\n",Logentry);
fclose(fh);
myCString = (LPCTSTR)Logentry;
myCString.UpdateData(FALSE);
This snippet writes to the file every time it is called without fail. The
static text will update for about five seconds and then it quits. Once the
dialog text stops updating, one can select within the dialog box and the
'Not Responding' message goes to the window title bar even though the code
is chugging away like mad. The file is written probably about two times per
second. The code can run for a couple of hours or more and the text file
continues to update properly. Why doesn't the static text in the dialog box
get updated as well? What can I do to make the static string update with
each change to the text?
Regards,
WC (Bill) Bowling
MEBBS E&S
Simi Valley, CA
"Scott McPhillips [MVP]" <org-dot-mvps-at-scottmcp> wrote in message
news:ucH65XC%23FHA.4004@xxxxxxxxxxxxxxxxxxxxxxx
> SBC News wrote:
>> I have a dialog-based application that does some very heavy database
>> activity through an API that is linked with the MFC application. Using
>> ClassWizard (VC6.0) I have a static text that is mapped to a CString
>> variable. As the software loops through its tasks the CString content is
>> modified (CString = (LPCTSTR)myCharBuff) and then updated with
>> CString.UpdateData(FALSE).
>>
>> The text updates for awhile but then stops. I also have a log file being
>> written at the same point as the CString and it's working just fine.
>>
>> The text update stoppage seems to occur at the same time as the dialog
>> reports that the application is "Not Responding" while I click in the
>> dialog box.
>>
>> What do I need to do to make the text string continue to update?
>
> Painting of controls is done in the same thread as your main processing.
> So it can't paint while you are executing lengthy code, such as your heavy
> database activity. You can force an immediate paint of the control by
> calling the control's UpdateWindow method right after you change it.
>
> There will be other problems, such as failing to repaint the window when
> it is uncovered by some other window, and "Not Responding", as long as you
> execute lengthy code in your main thread. The preferred solution is to do
> such lengthy processing in a separate thread. (But this is not easy if
> multithreading in MFC is new to you.)
>
> --
> Scott McPhillips [VC++ MVP]
>
.
- Follow-Ups:
- Re: CStatic Text Stops Updating
- From: Scott McPhillips [MVP]
- Re: CStatic Text Stops Updating
- References:
- CStatic Text Stops Updating
- From: SBC News
- Re: CStatic Text Stops Updating
- From: Scott McPhillips [MVP]
- CStatic Text Stops Updating
- Prev by Date: Re: Sendmessage to combobox of other application- macrokernelexce
- Next by Date: RE: How to Hightlight text in CRichEditCtrl
- Previous by thread: Re: CStatic Text Stops Updating
- Next by thread: Re: CStatic Text Stops Updating
- Index(es):
Relevant Pages
|