Read-Only Not Set in Release Build 
Author Message
 Read-Only Not Set in Release Build

Hi:

   I have a CLogView view class derived from CEditView.  I have a
CLogDoc document class derived from CDocument.  In CLogDoc, I add text
to the view, then call UpdateAllViews() to finish the display.

   I use the following code in CLogView:

Quote:
> void CLogView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
> {
>    // Make the log read-only
>    CEdit & edit = GetEditCtrl();
>    ASSERT(edit.SetReadOnly(TRUE) != 0);

> if ((edit.GetStyle() & ES_READONLY) == 0)
>    AfxMessageBox("In OnUpdate, Edit control is not read-only");
> else
>    AfxMessageBox("In OnUpdate, Edit control is read-only");
> } // End OnUpdate method

   The problem is that my edit view is not read-only when I do a Release
build.  A Debug build works fine, displaying the view with a read-only
window.

   The message box says "read-only" in Debug and "not read-only" in
Release, so I know my OnUpdate method is getting called in both cases.
Any ideas?  (I'm using VC++ 5.0 in case that matters.)

   Thanks for any help,
   Steve



Sat, 18 Aug 2001 03:00:00 GMT  
 Read-Only Not Set in Release Build
One of the common pitfalls of ASSERT
ASSERT translates to nothing in Release builds.

Move the edit.SetReadonly() outside the assert and all will be fine

bReadOnly = edit.SetReadOnly(TRUE);
ASSERT(bReadOnly);

HTH,
Regards,
Anupama

Quote:

>Hi:

>   I have a CLogView view class derived from CEditView.  I have a
>CLogDoc document class derived from CDocument.  In CLogDoc, I add text
>to the view, then call UpdateAllViews() to finish the display.

>   I use the following code in CLogView:

>> void CLogView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
>> {
>> // Make the log read-only
>> CEdit & edit = GetEditCtrl();
>> ASSERT(edit.SetReadOnly(TRUE) != 0);

>> if ((edit.GetStyle() & ES_READONLY) == 0)
>> AfxMessageBox("In OnUpdate, Edit control is not read-only");
>> else
>> AfxMessageBox("In OnUpdate, Edit control is read-only");
>> } // End OnUpdate method

>   The problem is that my edit view is not read-only when I do a Release
>build.  A Debug build works fine, displaying the view with a read-only
>window.

>   The message box says "read-only" in Debug and "not read-only" in
>Release, so I know my OnUpdate method is getting called in both cases.
>Any ideas?  (I'm using VC++ 5.0 in case that matters.)

>   Thanks for any help,
>   Steve



Sat, 18 Aug 2001 03:00:00 GMT  
 Read-Only Not Set in Release Build
try VERIFY rather than ASSERT

Gordon


Quote:
>Hi:

>   I have a CLogView view class derived from CEditView.  I have a
>CLogDoc document class derived from CDocument.  In CLogDoc, I add text
>to the view, then call UpdateAllViews() to finish the display.

>   I use the following code in CLogView:

>> void CLogView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
>> {
>> // Make the log read-only
>> CEdit & edit = GetEditCtrl();
>> ASSERT(edit.SetReadOnly(TRUE) != 0);

>> if ((edit.GetStyle() & ES_READONLY) == 0)
>> AfxMessageBox("In OnUpdate, Edit control is not read-only");
>> else
>> AfxMessageBox("In OnUpdate, Edit control is read-only");
>> } // End OnUpdate method

>   The problem is that my edit view is not read-only when I do a Release
>build.  A Debug build works fine, displaying the view with a read-only
>window.

>   The message box says "read-only" in Debug and "not read-only" in
>Release, so I know my OnUpdate method is getting called in both cases.
>Any ideas?  (I'm using VC++ 5.0 in case that matters.)

>   Thanks for any help,
>   Steve



Sun, 19 Aug 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Protection Violation in Release Build but not in Debug Build

2. Error in Release build but not Debug build

3. Q: Dialog Tooltips work in DEBUG build but not under RELEASE Build

4. Buffer overrun not being correctly detected in a release build

5. 0x80070005: Access is denied in release build but not in debug

6. Not able to Register release build DLL.

7. STRCPY does not work in debug, Ok in release build

8. Release build runs on 95 but not NT

9. Bitmaps not displayed when using release build

10. Release bulid crashes VB but not debug build

11. _controlfp Not working for me in Release Build

12. Unresolved externals in DEBUG build but not RELEASE

 

 
Powered by phpBB® Forum Software