2)如何用VC显示gb18030的4字节编码所表示的汉字?
1)为什么发贴不让给分呢?只能加0分先给0分,等我有权利了补上。
1)为什么发贴不让给分呢?只能加0分先给0分,等我有权利了补上。
解决方案 »
- VC 生成的txt文件不能换行
- 请问各位高手,DLL报"i386\chkdsp.c line:42"错误,怎么解决?急等!
- 怎样在界面上写一个红色的文字,而且不带着白色的背景颜色。dc.DrawText会有白色背景问题。
- MSComm使用时,在线程中如何响应OnComm事件?顶者有分!
- 急、急,求助
- 请教:VC做短信开发需要哪些方面知识???
- 怪问题!同一个id的函数居然会有不同的反应!!
- 如何显示出电脑内已经注册的dll文件列表?
- 如何是一个窗口在失去焦点时处于最前端
- 推荐几本winsock和directX编程的书好么?(VC的)
- 请教下怎么在两组各2个 Radio Button中,通过第一组的Radio Button的按钮事件来控制第二组的Radio button按钮单击事件?
- 24位jpg图形如何添加水印?
寒号鸟我已经下载了支持包,并使用最新的ExtTextoutL函数进行输出,但是还是出现乱码。
typedef BOOL (__stdcall * MyExtTextOutL)(HDC hdc, int x, int y, UINT fuOptions, CONST RECT *lprc, LPCSTR lpString, UINT cbCount, CONST INT *lpDx );typedef int ( __stdcall * MyMessageBoxL)(
HWND hWnd, // handle to owner window
LPCSTR lpText, // text in message box
LPCSTR lpCaption, // message box title
UINT uType // message box style
);/*
BOOL ExtTextOutL(
HDC hdc, // handle to DC
int X, // x-coordinate of reference point
int Y, // y-coordinate of reference point
UINT fuOptions, // text-output options
CONST RECT* lprc, // optional dimensions
LPCSTR lpString, // string
UINT cbCount, // number of characters in string
CONST INT* lpDx // array of spacing values
);
BOOL GetTextExtentExPointL(
HDC hdc, // handle to DC
LPCSTR lpszStr, // character string
int cchString, // number of characters
int nMaxExtent, // maximum width of formatted string
LPINT lpnFit, // maximum number of characters
LPINT alpDx, // array of partial string widths
LPSIZE lpSize // string dimensions
);
BOOL GetTextExtentPoint32L(
HDC hdc, // handle to DC
LPCSTR lpString, // text string
int cbString, // characters in string
LPSIZE lpSize // string size
);
Int MessageBoxL(
HWND hWnd, // handle to owner window
LPCSTR lpText, // text in message box
LPCSTR lpCaption, // message box title
UINT uType // message box style
);
Int MessageBoxExL(
HWND hWnd, // handle to owner window
LPCSTR lpText, // text in message box
LPCSTR lpCaption, // message box title
UINT uType, // message box style
WORD wLanguageId // language identifier
);
BOOL TextOutL(
HDC hdc, // handle to DC
int nXStart, // x-coordinate of starting position
int nYStart, // y-coordinate of starting position
LPCSTR lpString, // character string
int cbString // number of characters
);*/
void CGB18030Dlg::OnButton1()
{
if( IsValidCodePage( GB18030_CP ) )
{
CPINFO cpinfo;
if( GetCPInfo( GB18030_CP, &cpinfo ) )
{
CClientDC dc( this );
CFont font;
font.CreateFont( 12, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T( "宋体") );
CFont *p = dc.SelectObject( &font ); unsigned char aa[ 10 ] = { 0x81, 0x32, 0xe8, 0x36, 0 };
WCHAR wstr[ 100 ] = L"";
char bb[ 100 ] = ""; MultiByteToWideChar( GB18030_CP, 0, ( char * )aa, 4, wstr, 100 );
WideCharToMultiByte( CP_OEMCP, 0, wstr, 2, bb, 100, NULL, NULL ); HMODULE h;
h = LoadLibrary( "ms4bsp.dll" );
if( !h )
{
AfxMessageBox( "no dll" );
}
else
{
MyExtTextOutL t = (MyExtTextOutL)GetProcAddress( h, "ExtTextOutL" );
if( !t )
{
AfxMessageBox( "no ExtTextOutL" );
FreeLibrary( h );
return;
}
MyMessageBoxL l = (MyMessageBoxL)GetProcAddress( h, "MessageBoxL" );
if( !l )
{
AfxMessageBox( "no MessageBoxL" );
FreeLibrary( h );
return;
}
l( NULL, ( LPCSTR )aa, NULL, 0 );
l( NULL, ( LPCSTR )bb, NULL, 0 );
l( NULL, ( LPCSTR )wstr, NULL, 0 );
t( dc.GetSafeHdc(), 200, 100, 0, NULL, ( char * )bb, 1, NULL );
FreeLibrary( h );
}
dc.SelectObject( p );
}
else
{
AfxMessageBox( "GetCPInfo( GB18030_CP, &cpinfo )" );
}
}
else
{
AfxMessageBox( "IsValidCodePage( GB18030_CP )" );
}
}这是我的测试程序,工程是vc6的,没有unicode选项。
2、设置下dc的font
void CTtDlg::OnButton1()
{
//{0x4db5} = {0x82, 0x35, 0x87, 0x38} char bufA[] = {0x82, 0x35, 0x87, 0x38, 0, 0, 0, 0};
wchar_t bufW[2] = {0};
MultiByteToWideChar(GB18030_CP, 0, bufA, -1, bufW, 1); //error
//MessageBox(bufA);
//MessageBoxW(0, bufW, 0, 0); CClientDC dc(this);
CFont font;
font.CreateFont( 20, 0, 0, 0, FW_NORMAL, FALSE, FALSE, 0, ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_SWISS, _T( "宋体-18030") );
CFont* ofont = dc.SelectObject(&font); CRect rcA(50, 50, 300, 100);
CRect rcW(50, 100, 300, 150); ::DrawTextA(dc.m_hDC, bufA, -1, &rcA, DT_SINGLELINE);//error
::DrawTextW(dc.m_hDC, bufW, -1, &rcW, DT_SINGLELINE);//ok HMODULE h = LoadLibrary(_T("ms4bsp.dll"));
if (h)
{
MyExtTextOutL t = (MyExtTextOutL)GetProcAddress(h, _T("ExtTextOutL"));
if(t)
{
t(dc.m_hDC, 50, 150, 0, NULL, bufA, 4, NULL);//ok
}
MyMessageBoxL m = (MyMessageBoxL)GetProcAddress(h, _T("MessageBoxL"));
if(m)
{
m(NULL, bufA, bufA, 0);//error
} FreeLibrary(h);
} dc.SelectObject(ofont);
}
-----------------------------------------
我测试的结果:所有的对话框都是乱码,设置好字体和转码正确后,文本输出正确