From: Joseph M. Newcomer on
See below....
On Sat, 19 Jun 2010 00:32:06 -0500, "JCO" <someone(a)somewhere.com> wrote:

>Error 1:
>Debug Assertion Failed!
>Program: ........ name of program
>File: f:\dd\vcctools\vc7libs\ship\atlmfc\src\mfc\winocc.cpp
>Line: 246
>
>This is line 246:
> ENSURE(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
>
****
So what are the values of m_hWnd and m_pCtrlSite? This is in SetWindowText, so you need
to show us where you are calling it, not just the line, but the context!

Are you calling SetWindowText of a dialog before the DoModal()? This cannot POSSIBLY work
bcause until the DoModal is executed, there IS NO WINDOW to set the text to.

For example

CWhatever dlg;
dlg.m_Name.SetWindowText(s);
dlg.DoModal();

cannot work. In fact, BEFORE the DoModal, there is no dialog (hence no window) and AFTER
the DoModal there is no dialog (hence no window). The ONLY valid place you can do this
SetWindowText is in, or after the execution of, OnInitDialog. Until
CWhatever::OnInitDialog is executed, there is no control (if you don't have an
OnInitDialog, then CDialog::OnInitDialog is going to get called, and the same applies)
joe
*****

>
>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>news:sibi16puh8g12a8scl9naspalcm7lpsfa7(a)4ax.com...
>> There is no such thing as "an" assertion error. Every assertion error
>> tells you precisely
>> which file it occurred in, and precisely what line of that file it
>> occurred on. Coupled
>> with the knowledge of which version of VS you are using, these three
>> pieces of information
>> tell us what went wrong. In the *absence* of these three pieces of
>> information, there is
>> no solution to the problem.
>>
>> Did you enter the debugger? What did the ASSERT line say?
>> joe
>>
>> On Wed, 16 Jun 2010 09:21:25 -0500, "JCO" <someone(a)somewhere.com> wrote:
>>
>>>Yes this is all working now except for the implementation in the actual
>>>About Box. I'm getting the Assertion Error.
>>>For the AboutBox implementation I have the following:
>>>prototypes
>>>void SetVersionString (LPTCSTR sVer);
>>>LPTCSTR GetVersionString (void);
>>>
>>>//m_CtrlStaticVer is the control variable for the CStatic that is to be
>>>set
>>>with the proper value in the dialog
>>>BOOL CAboutDlg::OnInitDialog(void)
>>>{
>>> CString s;
>>> s.Format( _T("AppVersionDynamic, Version %d.%d.%d.%d"), VERMAJ,
>>> VERMIN, VERFIX,
>>>BUILDNUMBER );
>>> SetVersionString( s );
>>>
>>> m_CtrlStaticVer.SetWindowText( GetVersionString() );
>>> return TRUE;
>>>}
>>>
>>>I get 2 Assertion Errors. One deals with the control variable setting the
>>>value. If commented out, I get still get an assertion on the dialog when
>>>you close it out.
>>>
>>>Thanks
>>>
>>>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>>>news:i7jg165ugb9uba3nei7p3tqleka51cvm7v(a)4ax.com...
>>>> If you add a VERSIONINFO to the RC2 file, you must DELETE the EXISTING
>>>> ONE
>>>> from the .rc
>>>> file! Otherwise, guess what, you have a duplicate resource of type
>>>> VERSION, whose name is
>>>> 1, and whose language is 0x0409.
>>>>
>>>> Error 1 leads directly to error 2.
>>>> joe
>>>>
>>>> On Tue, 15 Jun 2010 12:24:05 -0500, "JCO" <someone(a)somewhere.com> wrote:
>>>>
>>>>>When I add this information to the RC2 file, I get these two errors:
>>>>>1 CVT1100: duplicate resource, Type:VERSION, name:1, language:0x0409
>>>>>2 LNK1123: failure during conversion to COFF: file invalid or corrupt
>>>>>
>>>>>"RB" <NoMail(a)NoSpam> wrote in message
>>>>>news:umG$MhIDLHA.4400(a)TK2MSFTNGP05.phx.gbl...
>>>>>> Corrective update, although the paste I gave you does in fact work
>>>>>> in my App currently. You may want to reexamine my use of the
>>>>>> results of #define _STR(x) #x
>>>>>> #define STR(x) _STR(x)
>>>>>> since I am still learning this area, and some reading I did last night
>>>>>> proves to me that I did not fully understand what this macro was
>>>>>> expanding to when I implemented some of the pasted code.
>>>>>>
>>>>>> I really should not be replying to questions since I am not at that
>>>>>> level of competence yet. I only supplied it since I "appeared at the
>>>>>> time" to have a working example of what you asked for, which
>>>>>> the whole idea was given to me ( if you followed the thread )
>>>>>> by David Webber, but the implementation (and any foo bars )
>>>>>> are my doing, not Davids.
>>>>>> So use what you will but be aware.
>>>>>> RB
>>>> Joseph M. Newcomer [MVP]
>>>> email: newcomer(a)flounder.com
>>>> Web: http://www.flounder.com
>>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>> Joseph M. Newcomer [MVP]
>> email: newcomer(a)flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
From: JCO on
m_hWnd and mPCtrlSite are both NULL

Yes that is my mistake which I assumed was the case from the start. I was
calling to make the static control change before I have a window. Yes I
called SetWindowText() in the CAboutDlg::OnInitDialog().

I'm not sure where to call it? It has to be called right after the dialog
is displayed.


"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
news:1jkp16d871giu2smlggvacjsd6mcvbnd23(a)4ax.com...
> See below....
> On Sat, 19 Jun 2010 00:32:06 -0500, "JCO" <someone(a)somewhere.com> wrote:
>
>>Error 1:
>>Debug Assertion Failed!
>>Program: ........ name of program
>>File: f:\dd\vcctools\vc7libs\ship\atlmfc\src\mfc\winocc.cpp
>>Line: 246
>>
>>This is line 246:
>> ENSURE(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
>>
> ****
> So what are the values of m_hWnd and m_pCtrlSite? This is in
> SetWindowText, so you need
> to show us where you are calling it, not just the line, but the context!
>
> Are you calling SetWindowText of a dialog before the DoModal()? This
> cannot POSSIBLY work
> bcause until the DoModal is executed, there IS NO WINDOW to set the text
> to.
>
> For example
>
> CWhatever dlg;
> dlg.m_Name.SetWindowText(s);
> dlg.DoModal();
>
> cannot work. In fact, BEFORE the DoModal, there is no dialog (hence no
> window) and AFTER
> the DoModal there is no dialog (hence no window). The ONLY valid place
> you can do this
> SetWindowText is in, or after the execution of, OnInitDialog. Until
> CWhatever::OnInitDialog is executed, there is no control (if you don't
> have an
> OnInitDialog, then CDialog::OnInitDialog is going to get called, and the
> same applies)
> joe
> *****
>
>>
>>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>>news:sibi16puh8g12a8scl9naspalcm7lpsfa7(a)4ax.com...
>>> There is no such thing as "an" assertion error. Every assertion error
>>> tells you precisely
>>> which file it occurred in, and precisely what line of that file it
>>> occurred on. Coupled
>>> with the knowledge of which version of VS you are using, these three
>>> pieces of information
>>> tell us what went wrong. In the *absence* of these three pieces of
>>> information, there is
>>> no solution to the problem.
>>>
>>> Did you enter the debugger? What did the ASSERT line say?
>>> joe
>>>
>>> On Wed, 16 Jun 2010 09:21:25 -0500, "JCO" <someone(a)somewhere.com> wrote:
>>>
>>>>Yes this is all working now except for the implementation in the actual
>>>>About Box. I'm getting the Assertion Error.
>>>>For the AboutBox implementation I have the following:
>>>>prototypes
>>>>void SetVersionString (LPTCSTR sVer);
>>>>LPTCSTR GetVersionString (void);
>>>>
>>>>//m_CtrlStaticVer is the control variable for the CStatic that is to be
>>>>set
>>>>with the proper value in the dialog
>>>>BOOL CAboutDlg::OnInitDialog(void)
>>>>{
>>>> CString s;
>>>> s.Format( _T("AppVersionDynamic, Version %d.%d.%d.%d"), VERMAJ,
>>>> VERMIN, VERFIX,
>>>>BUILDNUMBER );
>>>> SetVersionString( s );
>>>>
>>>> m_CtrlStaticVer.SetWindowText( GetVersionString() );
>>>> return TRUE;
>>>>}
>>>>
>>>>I get 2 Assertion Errors. One deals with the control variable setting
>>>>the
>>>>value. If commented out, I get still get an assertion on the dialog
>>>>when
>>>>you close it out.
>>>>
>>>>Thanks
>>>>
>>>>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>>>>news:i7jg165ugb9uba3nei7p3tqleka51cvm7v(a)4ax.com...
>>>>> If you add a VERSIONINFO to the RC2 file, you must DELETE the EXISTING
>>>>> ONE
>>>>> from the .rc
>>>>> file! Otherwise, guess what, you have a duplicate resource of type
>>>>> VERSION, whose name is
>>>>> 1, and whose language is 0x0409.
>>>>>
>>>>> Error 1 leads directly to error 2.
>>>>> joe
>>>>>
>>>>> On Tue, 15 Jun 2010 12:24:05 -0500, "JCO" <someone(a)somewhere.com>
>>>>> wrote:
>>>>>
>>>>>>When I add this information to the RC2 file, I get these two errors:
>>>>>>1 CVT1100: duplicate resource, Type:VERSION, name:1, language:0x0409
>>>>>>2 LNK1123: failure during conversion to COFF: file invalid or corrupt
>>>>>>
>>>>>>"RB" <NoMail(a)NoSpam> wrote in message
>>>>>>news:umG$MhIDLHA.4400(a)TK2MSFTNGP05.phx.gbl...
>>>>>>> Corrective update, although the paste I gave you does in fact work
>>>>>>> in my App currently. You may want to reexamine my use of the
>>>>>>> results of #define _STR(x) #x
>>>>>>> #define STR(x) _STR(x)
>>>>>>> since I am still learning this area, and some reading I did last
>>>>>>> night
>>>>>>> proves to me that I did not fully understand what this macro was
>>>>>>> expanding to when I implemented some of the pasted code.
>>>>>>>
>>>>>>> I really should not be replying to questions since I am not at that
>>>>>>> level of competence yet. I only supplied it since I "appeared at the
>>>>>>> time" to have a working example of what you asked for, which
>>>>>>> the whole idea was given to me ( if you followed the thread )
>>>>>>> by David Webber, but the implementation (and any foo bars )
>>>>>>> are my doing, not Davids.
>>>>>>> So use what you will but be aware.
>>>>>>> RB
>>>>> Joseph M. Newcomer [MVP]
>>>>> email: newcomer(a)flounder.com
>>>>> Web: http://www.flounder.com
>>>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>>> Joseph M. Newcomer [MVP]
>>> email: newcomer(a)flounder.com
>>> Web: http://www.flounder.com
>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
> Joseph M. Newcomer [MVP]
> email: newcomer(a)flounder.com
> Web: http://www.flounder.com
> MVP Tips: http://www.flounder.com/mvp_tips.htm

From: Joseph M. Newcomer on
Note that if you added an OnInitDialog handler, you code must follow the
CDialog::OnInitDialog();
call at the front, because until that is executed, there is no control binding. And if
this call is missing, you will have to add it!
joe

On Mon, 21 Jun 2010 16:33:30 -0500, "JCO" <someone(a)somewhere.com> wrote:

>m_hWnd and mPCtrlSite are both NULL
>
>Yes that is my mistake which I assumed was the case from the start. I was
>calling to make the static control change before I have a window. Yes I
>called SetWindowText() in the CAboutDlg::OnInitDialog().
>
>I'm not sure where to call it? It has to be called right after the dialog
>is displayed.
>
>
>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>news:1jkp16d871giu2smlggvacjsd6mcvbnd23(a)4ax.com...
>> See below....
>> On Sat, 19 Jun 2010 00:32:06 -0500, "JCO" <someone(a)somewhere.com> wrote:
>>
>>>Error 1:
>>>Debug Assertion Failed!
>>>Program: ........ name of program
>>>File: f:\dd\vcctools\vc7libs\ship\atlmfc\src\mfc\winocc.cpp
>>>Line: 246
>>>
>>>This is line 246:
>>> ENSURE(::IsWindow(m_hWnd) || (m_pCtrlSite != NULL));
>>>
>> ****
>> So what are the values of m_hWnd and m_pCtrlSite? This is in
>> SetWindowText, so you need
>> to show us where you are calling it, not just the line, but the context!
>>
>> Are you calling SetWindowText of a dialog before the DoModal()? This
>> cannot POSSIBLY work
>> bcause until the DoModal is executed, there IS NO WINDOW to set the text
>> to.
>>
>> For example
>>
>> CWhatever dlg;
>> dlg.m_Name.SetWindowText(s);
>> dlg.DoModal();
>>
>> cannot work. In fact, BEFORE the DoModal, there is no dialog (hence no
>> window) and AFTER
>> the DoModal there is no dialog (hence no window). The ONLY valid place
>> you can do this
>> SetWindowText is in, or after the execution of, OnInitDialog. Until
>> CWhatever::OnInitDialog is executed, there is no control (if you don't
>> have an
>> OnInitDialog, then CDialog::OnInitDialog is going to get called, and the
>> same applies)
>> joe
>> *****
>>
>>>
>>>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>>>news:sibi16puh8g12a8scl9naspalcm7lpsfa7(a)4ax.com...
>>>> There is no such thing as "an" assertion error. Every assertion error
>>>> tells you precisely
>>>> which file it occurred in, and precisely what line of that file it
>>>> occurred on. Coupled
>>>> with the knowledge of which version of VS you are using, these three
>>>> pieces of information
>>>> tell us what went wrong. In the *absence* of these three pieces of
>>>> information, there is
>>>> no solution to the problem.
>>>>
>>>> Did you enter the debugger? What did the ASSERT line say?
>>>> joe
>>>>
>>>> On Wed, 16 Jun 2010 09:21:25 -0500, "JCO" <someone(a)somewhere.com> wrote:
>>>>
>>>>>Yes this is all working now except for the implementation in the actual
>>>>>About Box. I'm getting the Assertion Error.
>>>>>For the AboutBox implementation I have the following:
>>>>>prototypes
>>>>>void SetVersionString (LPTCSTR sVer);
>>>>>LPTCSTR GetVersionString (void);
>>>>>
>>>>>//m_CtrlStaticVer is the control variable for the CStatic that is to be
>>>>>set
>>>>>with the proper value in the dialog
>>>>>BOOL CAboutDlg::OnInitDialog(void)
>>>>>{
>>>>> CString s;
>>>>> s.Format( _T("AppVersionDynamic, Version %d.%d.%d.%d"), VERMAJ,
>>>>> VERMIN, VERFIX,
>>>>>BUILDNUMBER );
>>>>> SetVersionString( s );
>>>>>
>>>>> m_CtrlStaticVer.SetWindowText( GetVersionString() );
>>>>> return TRUE;
>>>>>}
>>>>>
>>>>>I get 2 Assertion Errors. One deals with the control variable setting
>>>>>the
>>>>>value. If commented out, I get still get an assertion on the dialog
>>>>>when
>>>>>you close it out.
>>>>>
>>>>>Thanks
>>>>>
>>>>>"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message
>>>>>news:i7jg165ugb9uba3nei7p3tqleka51cvm7v(a)4ax.com...
>>>>>> If you add a VERSIONINFO to the RC2 file, you must DELETE the EXISTING
>>>>>> ONE
>>>>>> from the .rc
>>>>>> file! Otherwise, guess what, you have a duplicate resource of type
>>>>>> VERSION, whose name is
>>>>>> 1, and whose language is 0x0409.
>>>>>>
>>>>>> Error 1 leads directly to error 2.
>>>>>> joe
>>>>>>
>>>>>> On Tue, 15 Jun 2010 12:24:05 -0500, "JCO" <someone(a)somewhere.com>
>>>>>> wrote:
>>>>>>
>>>>>>>When I add this information to the RC2 file, I get these two errors:
>>>>>>>1 CVT1100: duplicate resource, Type:VERSION, name:1, language:0x0409
>>>>>>>2 LNK1123: failure during conversion to COFF: file invalid or corrupt
>>>>>>>
>>>>>>>"RB" <NoMail(a)NoSpam> wrote in message
>>>>>>>news:umG$MhIDLHA.4400(a)TK2MSFTNGP05.phx.gbl...
>>>>>>>> Corrective update, although the paste I gave you does in fact work
>>>>>>>> in my App currently. You may want to reexamine my use of the
>>>>>>>> results of #define _STR(x) #x
>>>>>>>> #define STR(x) _STR(x)
>>>>>>>> since I am still learning this area, and some reading I did last
>>>>>>>> night
>>>>>>>> proves to me that I did not fully understand what this macro was
>>>>>>>> expanding to when I implemented some of the pasted code.
>>>>>>>>
>>>>>>>> I really should not be replying to questions since I am not at that
>>>>>>>> level of competence yet. I only supplied it since I "appeared at the
>>>>>>>> time" to have a working example of what you asked for, which
>>>>>>>> the whole idea was given to me ( if you followed the thread )
>>>>>>>> by David Webber, but the implementation (and any foo bars )
>>>>>>>> are my doing, not Davids.
>>>>>>>> So use what you will but be aware.
>>>>>>>> RB
>>>>>> Joseph M. Newcomer [MVP]
>>>>>> email: newcomer(a)flounder.com
>>>>>> Web: http://www.flounder.com
>>>>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>>>> Joseph M. Newcomer [MVP]
>>>> email: newcomer(a)flounder.com
>>>> Web: http://www.flounder.com
>>>> MVP Tips: http://www.flounder.com/mvp_tips.htm
>> Joseph M. Newcomer [MVP]
>> email: newcomer(a)flounder.com
>> Web: http://www.flounder.com
>> MVP Tips: http://www.flounder.com/mvp_tips.htm
Joseph M. Newcomer [MVP]
email: newcomer(a)flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm