I created an MFC Pocket PC 2003 application with Visual Studio 2005.

1) I put a button on my dialog box whose caption was set to "Open"
on the propertied page.

2) After the user pushes the button I issue
SetDlgItemText(IDC_OpenClose,_T("Close"));

3) When the user pushes again I issue
SetDlgItemText(IDC_OpenClose,_T("Open"));

4) This toggling works fine.

5) If I issue the AfxMessageBox("Display Error") (or MessageBox()) from
some other event, the above mentioned button reverts back to "Open".
Note that "Open" was the original caption when the DialogBox was
created. I placed a breakpoint in the above mentioned button's
event handler to ensure that the application did not reset the caption.

It seems like the original caption is stored somewhere and repainted when
the AfxMessageBox() dialog closes. How do I solve? I am not an MFC expert.


--
WCSC (Willies Computer Software Co)
http://www.wcscnet.com

Re: Setting button caption with SetDlgItemText() is not permanent? by r_z_aret

r_z_aret
Thu Oct 19 14:27:51 CDT 2006

On Wed, 18 Oct 2006 15:53:02 -0700, ThinkRS232
<ThinkRS232@discussions.microsoft.com> wrote:

>I created an MFC Pocket PC 2003 application with Visual Studio 2005.
>
>1) I put a button on my dialog box whose caption was set to "Open"
> on the propertied page.
>
>2) After the user pushes the button I issue
> SetDlgItemText(IDC_OpenClose,_T("Close"));
>
>3) When the user pushes again I issue
> SetDlgItemText(IDC_OpenClose,_T("Open"));
>
>4) This toggling works fine.
>
>5) If I issue the AfxMessageBox("Display Error") (or MessageBox()) from
> some other event, the above mentioned button reverts back to "Open".
> Note that "Open" was the original caption when the DialogBox was
> created. I placed a breakpoint in the above mentioned button's
> event handler to ensure that the application did not reset the caption.
>
>It seems like the original caption is stored somewhere and repainted when
>the AfxMessageBox() dialog closes. How do I solve? I am not an MFC expert.

Sure doesn't work that way for straight Win32. I have several buttons
with changeable text, and the text stays until my program changes it.
Could be something in MFC. But I suggest checking whether the button
is being recreated and/or your code to change the text is run when you
don't expect.


-----------------------------------------
To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message).

Robert E. Zaret, eMVP
PenFact, Inc.
20 Park Plaza, Suite 478
Boston, MA 02116
www.penfact.com