如何扩展Win 32编辑框控件的Unicode支持 [英] How to extend Unicode Support for Win 32 Edit Box Control

查看:107
本文介绍了如何扩展Win 32编辑框控件的Unicode支持的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我在Win 32中创建了一个对话框(有编辑控件)。我从CDialogImpl类派生了对话框。



我在编辑框控件上输入Unicode字符时遇到问题。



在设计师中,当我输入字符时在Unicode(比如印地语)中,它显示正确。



但是当我运行程序时,同一个编辑框显示?。



对话框的代码如下所示:



标题(.h)文件:



Hi All,

I created a dialog (which has Edit Control) on it in Win 32. I derived the dialog from CDialogImpl class.

I am facing a problem in entering Unicode characters on the Edit box control.

In designer, when i enter characters in Unicode (say Hindi Language), it is showing correctly.

But when i run the program, the same edit box shows "?".

The code for the Dialog Box looks something like below :

The Header (.h) file :

#pragma once
    #include "resource.h"

    // CEnterPasswordDlg dialog
    class CEnterPasswordDlg : public CDialogImpl<CEnterPasswordDlg>
    {

    public:
    	CEnterPasswordDlg();   // standard constructor
    	virtual ~CEnterPasswordDlg();

    	// Dialog Data
    	enum { IDD = IDD_DIALOG_ENTER_PASSWORD };

    	WTL::CString GetEnteredPassword() { return m_strPasswordEntered; };

    	LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    	LRESULT OnCancelCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
    	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);

    protected:

    	BEGIN_MSG_MAP(CEnterPasswordDlg)
    		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
    		COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
    		COMMAND_ID_HANDLER(IDCANCEL, OnCancelCmd)
    	END_MSG_MAP()

    private:

    	WTL::CString m_strPasswordEntered;
    };



实施文件(CPP文件):




The Implementation File (CPP File) :

// EnterPasswordDlg.cpp : implementation file
    //

    #include "stdafx.h"
    #include "EnterPasswordDlg.h"

    // CEnterPasswordDlg dialog
    //class CFullSr
    CEnterPasswordDlg::CEnterPasswordDlg()
    	: m_strPasswordEntered(_T(""))
    {
    }

    CEnterPasswordDlg::~CEnterPasswordDlg()
    {
    }

    // CEnterPasswordDlg message handlers

    LRESULT CEnterPasswordDlg::OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    {
    	char cPassword[MAX_PATH];
    	GetDlgItemText(IDC_EDIT_PASSWORD, cPassword, MAX_PATH);

    	m_strPasswordEntered = cPassword;	

    	EndDialog(wID);
    		
    	return 0;
    }

    LRESULT CEnterPasswordDlg::OnCancelCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
    {
    	EndDialog(wID);
    	return 0;
    }

    LRESULT CEnterPasswordDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
    {
    	CenterWindow();

    	return TRUE;
    }







有人能告诉我可能出错的吗?



如何才能看到我在对话框中输入的Unicode字符。



我的项目不是Unicode项目。我没有添加宏_UNICODE。



是否可以不将宏添加到项目属性中?

没关系对我来说,如果我可以只在这个对话框中添加Unicode属性。



任何帮助将不胜感激



谢谢和问候,



Kishor Reddy




Could anyone tell me what could be wrong ?

How can i see the Unicode characters that i actually enter in the dialog.

My project is not an Unicode project. I didn't add the Macro "_UNICODE".

Is it possible without adding that Macro to the project properties ?
It is fine for me if i could just add Unicode properties to this dialog alone.

Any help will be greatly appreciated

Thanks and Regards,

Kishor Reddy

推荐答案

对于Unicode,你必须使用unicode函数和类型。 Microsft标准是他们最后还有一个额外的W.

For Unicode you MUST use the unicode functions and types. Microsft standard is that they have an additional W on the end.
wchar_t cPassword[MAX_PATH];
GetDlgItemTextW(IDC_EDIT_PASSWORD, cPassword, MAX_PATH);



我的建议是将项目转换为unicode以摆脱这些东西。它是在几个小时内完成的令人烦恼的代码更改,但是:那你就完成了; - )


My advice is to transform your project to unicode to get rid of this stuff. It is done in some hours of annoying code changes like about, but: THEN YOU ARE DONE ;-)


这篇关于如何扩展Win 32编辑框控件的Unicode支持的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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