IPB SourceForge.net Logo

Welcome Guest ( Log In | Register )

[ Outline ] · Standard · Linear+

> Is this a bug?

Kevin Yuan
post Nov 4 2005, 02:21 AM
Post #1


Member
**

Group: Members
Posts: 21
Joined: 4-November 05
Member No.: 182



I am new here and this is my first post smile.gif

I found VCF yesterday very accidentally, but I am loving it now! It is GREAT!
I have seen several frameworks, but this one is the most comfortable to me.

<I am using VCF-0.6.8 on Window XP(Chinese version) sp2, Visual Studio.NET 2003>
After trying some hello-wolds I found a problem: When I adding DefaultMenuItems to MenuBar on the MainWindow using some MBCS characters(such as Chinese, Japanese) as captions, the strings on menu items appear incompletely.

I tried to read the source and found sth suspicious:
CODE

// \src\vcf\ApplicationKit\Win32MenuItem.cpp
// line 117 ~ 127
// function Win32MenuItem::insertSimpleMenuItem

       info.cch = itemName.size();//!! size of the string is calc unicode way
#if defined(VCF_CW) && defined(UNICODE)
wchar_t* tmpName = new wchar_t[info.cch+1];
memset( tmpName, 0, (info.cch+1)*sizeof(wchar_t) );
itemName.copy( tmpName, info.cch );//OK
#else
char* tmpName = new char[info.cch+1];
memset( tmpName, 0, (info.cch+1)*sizeof(char) );
itemName.copy( tmpName, info.cch );//Buggy!!
#endif
info.dwTypeData = tmpName;
 
      if ( InsertMenuItem( menu, child->getIndex()/*info.wID*/, TRUE, &info ) )

Here they use #if...#else...#endif to deal with unicode and ansi which is not OK I think. As we know, the pre-compile directives are solved at compile time rather than at run time, so the menu item string pointed by info.dwTypeData is unicode or ansi is fixed when the library is built. This is not what we desired.
BTW, the size of item string(info.cch) is calculated always unicode way, this is buggy when UNICODE is not defined(the info.cch may be shorter than the actual size in case MBCS characters). I also find other code this style in VCF source .
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
 
Reply to this topicStart new topicStart Poll
Replies
ddiego
post Nov 4 2005, 06:00 PM
Post #2


VCF Lead Developer
***

Group: Lead Developer
Posts: 2834
Joined: 2-August 03
Member No.: 2



QUOTE(Kevin Yuan @ Nov 3 2005, 10:21 PM)
I am new here and this is my first post smile.gif


By the way, welcome! smile.gif

OK I just checked in some fixes that address all the various VCF_CW && UNICODE issues. If you'd like, feel free to grab this from the current CVS development branch like so:

CODE

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/vcf login

(hit enter when prompted)

cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/vcf co -r devmain-0-6-9 vcf


This should get the code and then you can build it.

Cheers

Jim
User is offlineProfile CardPM
Go to the top of the page
+Quote Post
Kevin Yuan
post Nov 6 2005, 07:33 AM
Post #3


Member
**

Group: Members
Posts: 21
Joined: 4-November 05
Member No.: 182



QUOTE(ddiego @ Nov 5 2005, 02:00 AM)
QUOTE(Kevin Yuan @ Nov 3 2005, 10:21 PM)
I am new here and this is my first post smile.gif


By the way, welcome! smile.gif

OK I just checked in some fixes that address all the various VCF_CW && UNICODE issues. If you'd like, feel free to grab this from the current CVS development branch like so:

CODE

cvs -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/vcf login

(hit enter when prompted)

cvs -z3 -d:pserver:anonymous@cvs.sourceforge.net:/cvsroot/vcf co -r devmain-0-6-9 vcf


This should get the code and then you can build it.

Cheers

Jim
*




Thank you!!
But I am still trying to learn the CVS things sad.gif
To tell the truth I do not know how to use CVS and I have to download the entire package tongue.gif
User is offlineProfile CardPM
Go to the top of the page
+Quote Post

Posts in this topic


Reply to this topicTopic OptionsStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
 

Lo-fi Version : 19th May 2013 - 05:22 AM