mfc >> CEditView character set

by VGhvbWFzIFNlZGxhY3plaw » Tue, 20 Apr 2004 04:41:05 GMT

Hello

I have created MDI (VC7) application, where the view class is based on CEditView class using, the application wizard. If I type or copy text to it, the text is displayed correctly in the view but in the print preview just the first character will be displayed. Same is happened if I save the document to a file. Just the fist character is stored. If I open an existing text file it looks like Chinese character, but in the print preview everything is fine

What can cause this problem? Is there method to set character set for CEditView class? Where I have to look

Thank you for any help

Best regard
Thoma


mfc >> CEditView character set

by Jeff Partch » Tue, 20 Apr 2004 05:00:26 GMT



CEditView class using, the application wizard. If I type or copy text to it,
the text is displayed correctly in the view but in the print preview just
the first character will be displayed. Same is happened if I save the
document to a file. Just the fist character is stored. If I open an existing
text file it looks like Chinese character, but in the print preview
everything is fine.
CEditView class? Where I have to look?

This sounds like the CEditView\UNICODE bug.
--
Jeff Partch [VC++ MVP]

mfc >> CEditView character set

by VGhvbWFzIFNlZGxhY3plaw » Tue, 20 Apr 2004 05:21:03 GMT

Hello Jeff

where can I find informations to work around this bug?

Regard
Thomas

mfc >> CEditView character set

by Jeff Partch » Tue, 20 Apr 2004 05:28:11 GMT


I'll have to consult my notes, but IIRC you need to make sure that you have
a non-themed ANSI app with an ANSI edit. For the UNICODE scenario, I think
you pretty much need to rewrite CEditView.
--
Jeff Partch [VC++ MVP]

mfc >> CEditView character set

by VGhvbWFzIFNlZGxhY3plaw » Tue, 20 Apr 2004 06:01:04 GMT

Sorry

but what is "a non-themed ANSI app with an ANSI edit"?

The problem occurs already if I create a new MDI application with the wizard. I just have changed the base class of the view class to CEditView, all other settings are left to there default. I use VisualStudio .net 2002 (English)

Best regards from good old German
Thoma

mfc >> CEditView character set

by Jeff Partch » Tue, 20 Apr 2004 06:39:27 GMT


wizard. I just have changed the base class of the view class to CEditView,
all other settings are left to there default. I use VisualStudio .net 2002
(English).

Hmm. My recollection is that VS2002 produced a manifest resource by default.
If that's the case, then your app will be themed. The themed edit control
stores its text internally as WCHAR. Anyway, the so-called fix they came up
with for VS2003 was to conditionally include the manifest resource only if
UNICODE is defined, but if I remember right, saving and loading was still
broken for some reason*. So try building without the manifest and see if it
solves the problem -- it may be I'm off on the wrong track.

--
Jeff Partch [VC++ MVP]

*I think what it was is it could read back its own files, but not real
UNICODE files and not regular ANSI text files.

mfc >> CEditView character set

by VGhvbWFzIFNlZGxhY3plaw » Tue, 20 Apr 2004 07:21:02 GMT

Hi Jeff

Yes you are right! When I open Unicode, the view is correct but the print preview is wrong. Okay then I has to write my own load and store function and have to convert the string to Unicode for the view and to reconvert it to ANSI for the print preview and for serialisation. :-( Sorry but it my first MFC application, before I have used VB and I was thinking that such a simple thing can be only a question of a wrong property

Many thanks for your help and have a nice week

Best regard
Thoma

mfc >> CEditView character set

by Martin Nolte [MS] » Mon, 26 Apr 2004 23:33:59 GMT

ello Thomas,

the following article should help you to solve your issue:

FIX: Error in Print Preview for MFC Applications in ANSI Builds

-------------------------------------------------------------------------------
The information in this article applies to:

- Microsoft Visual C++ .NET (2002)
- the operating system: Microsoft Windows XP

-------------------------------------------------------------------------------

SYMPTOMS
========

The Print Preview dialog box in an MFC application displays only the first
character of the document that you want to print.

CAUSE
=====

You experience this behavior when you create an MFC application that is
associated with a common control manifest. Additionally, the MFC application
is built to support the multi-byte character set.

WORKAROUND
==========

To work around the print preview display problem, use
the following methods:

- When you create a new MFC application, turn off the "Common Control
Manifest" feature for the application so that a common control manifest is
not created.

To turn off the "Common Control Manifest" feature for your application,
follow
these steps:

1. Start Microsoft Visual Studio .NET.
2. Click the "File" menu, point to
"New", and then click "Project".
3. In the "New Project" dialog box, under
"Project Types" click to select "Visual C++
Projects". Under "Templates" click to select "MFC
Application".
4. Enter a name for the application, and then click
"OK".
5. In the "MFC Application Wizard" dialog
box, click "Advanced Features", and then click to clear the
"Common Control Manifest" check box.
- If your application uses the side-by-side assembly feature with a manifest
file, edit the manifest file to remove the "assemblyIdentity" section.

To remove the "assemblyIdentity" section from your manifest, follow these
steps:

1. In "Solution Explorer", under
"Resource Files", double-click the manifest file.
2. Remove the "assemblyIdentity" section
with the name attribute that is set as follows from the common
control
manifest:

Microsoft.Windows.Common-Controls
- If your application does not use the side-by-side assembly
feature, you can remove the manifest resource from your
application.

To remove all references to the common control manifest
from your application, follow these steps:

1. In "Resource View", expand
"RT_MANIFEST".
2. Right-click "IDR_MANIFEST", and then
click "Delete".
- The problem only appears for an MFC application that is
built for the multi-byte character set. You can change the character set
of
your application from multi-byte to Unicode.

To change the character set of your application to Unicode, follow these
steps:

1. In "Solution Explorer", right-click the
project folder, and then click "Properties".
2. Expand "Configuration
Properties".
3. Expand "General".
4. In the "Character Set" list box, click
to select "Use Unicode Character Set".


STATUS
======
Microsoft has confirmed that this is a bug in the Microsoft products
that are
listed at the beginning of this article.


This bug was corrected in Microsoft Visual C++ .NET (2003).

Best Regards,

Martin Nolte [MS]

"Thomas Sedlaczek" < XXXX@XXXXX.COM > wrote in message
news: XXXX@XXXXX.COM

mfc >> CEditView character set

by VGhvbWFzIFNlZGxhY3plaw » Tue, 27 Apr 2004 00:01:07 GMT

Hello Martin

thank you very much for your workaround! It works well this way! :O

Have a nice week

Thoma

PS: Alles ist mglich, aber das Dmmste ist am Wahrscheinlichsten..
Everything is possible, but the simplest is most likely...

Similar Threads

1. basic execution character set and basic execution wide-character set

2. basic execution character set and basic execution wide-character set

3. CEditView and wide characters

Hi!

I have been troubleshooting PRs and came across an interesting problem for which I cannot find a solution. The build environment is Studio .NET 2003 and this is a non-_UNICODE build. I am seeing varying behavior between Win2K and WinXP boxes when trying to print or save by sending an ID_FILE_PRINT/SAVE_AS to the view. On WinXP, only the first character prints or saves. Tracing down through MFC, I noticed that there is a LockBuffer() call to retrieve the window text and lstrlen() is used to determine the length. The stack looks like:

CEditView::SerializeRaw()
CEditView::WriteToArchive()
CEditView::GetBufferLength()

LockBuffer() seems to return a buffer of wide char, but in CEditView::GetBufferLength(), lstrlen() returns 1 as if the buffer were multibyte. The data returned from LockBuffer() looks like this:

'P' 0x00 'r' 0x00 'o' 0x00 ... 0x00 0x00

Does anyone have any idea why this is happening? Is the data returned from LockBuffer() supposed to be wide char? If so, what's going on with lstrlen() returning 1 as if this were a multibyte string rather than the length of the wide char array?

Any help would be appreciated!
James

4. Character Set = Multi-Byte / Unicode / Not Set?

5. Regex negative character set

Hi All,

It might be because its the end of a long week, but I can't figure out the 
correct way to write a regular expression to find all matches except a 
specified string.

For example, take the following 3 lines:
  This is OK
  This is Not OK
  Again This is OK

I want to find the first and last line, and not the "This is Not OK" line.

Thanks,
PAGates

6. character set encoding: how to generate errors - CSharp/C#

7. Character Set for TextBox

8. character sets - CSharp/C#