强制程序使用LoadStringA而不是LoadStringW? [英] Force a program to use LoadStringA instead of LoadStringW ?

查看:188
本文介绍了强制程序使用LoadStringA而不是LoadStringW?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨!我正在改造一个旧项目(不是由我开始)。我正在用一个框架替换旧的对话框,这样我就可以放一个功能区而不是菜单栏(这就是任务)。所以...原始项目不适用于Unicode,但在框架的OnCreate方法中,我需要widechar字符串才能使此片段正常工作:

Hi! I'm reworking on an old project(not started by me). I'm replacing the old dialog with a frame, so that I can put a ribbon instead of the menubar(that's the task). So... The original project doesn't work with Unicode, but in the frame's OnCreate method I need widechar strings for this fragment to work correctly:

    CString strTitlePane1;
CString strTitlePane2;
bNameValid = strTitlePane1.LoadString(IDS_STATUS_PANE1);
ASSERT(bNameValid); //here I get a runtime error
bNameValid = strTitlePane2.LoadString(IDS_STATUS_PANE2);
ASSERT(bNameValid);





LoadString定义为LoadStringA,因为该项目使用ANSI,不得全局更改。有人? :/



P.S.我还不太确定这是不是问题:/



LoadString is defined as LoadStringA since the project works with ANSI and this mustn't be changed globally. Somebody? :/

P.S. I'm still not quite sure if this is exactly the problem :/

推荐答案

我建​​议您将目前无效的部分转换为Unicode工作。



我们差不多在2014年,所以你将应用程序转换为Unicode已经晚了10多年。在2000年代,已经可以在Windows 95/98 / ME系统上使用Microsoft Layer for Unicode在Win 9x上编写Unicode程序。



我猜它是一个非常古老的应用程序作为2000年左右创建的应用程序基本上没有理由用ANSI创建。



在我看来,要么你只修复错误(所以没有新的功能区)并保留ANSI代码或您使应用程序现代化并将其转换为Unicode。



如果应用程序使用文件,那么它应该将旧的ANSI文件转换为Unicode在开幕时或需要时。使用UTF-8进行文件编码可能是有意义的,因为它通常较小。
I would suggest that you convert the part that does not works presently to works in Unicode.

We are almost in 2014 so you are more than 10 years late to convert your application to Unicode. In 2000's, it was already possible to write Unicode program on Win 9x using Microsoft Layer for Unicode on Windows 95/98/ME Systems.

I guess that it is a very old application as application created after around year 2000 has essentially not reason to have been created in ANSI.

In my opinion, either you only make bug fixes (thus no new ribbon) and keep ANSI code or you make the application modern and convert it to Unicode.

If the application uses file then it should convert old ANSI file to Unicode either at opening or when required. It might make sense to use UTF-8 for file encoding as it is typically smaller.


我只是忘记描述.rc文件中所需的项目:D
I simply had forgotten to describe the needed items in the .rc file :D


我这样做:



CStringW strTitlePane2;

bNameValid = strTitlePane1.LoadStringW(IDS_STATUS_PANE1)



在代码中注意两个W:-O



或者问题是无效的strind id为IDS_STATUS_PANE1 ???
i do that this way:

CStringW strTitlePane2;
bNameValid = strTitlePane1.LoadStringW(IDS_STATUS_PANE1)

look out for the two "W" in the code :-O

or is the problem an invalid strind id of IDS_STATUS_PANE1 ???


这篇关于强制程序使用LoadStringA而不是LoadStringW?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆