//* 字符转换
#ifndef wchar_to_utf8_ms #define wchar_to_utf8_ms(wstr, str, strlength) WideCharToMultiByte(CP_UTF8, 0, wstr, -1, str, strlength, NULL, NULL) #endif
//* 对话框在初始化中退出:OnInitDialog中直接调用OnCancel()
//* CEdit滚动到最后一行:::PostMessage(GetDlgItem(IDC_EDIT1)->m_hWnd, WM_VSCROLL, SB_BOTTOM, 0);
//* CEdit设置焦点:OnInitDialog中SetFoucs, 返回False。
//* 文件另存为:
CFileDialog saveFile = CFileDialog(FALSE, _T(".txt"), _T("defaultName"), OFN_CREATEPROMPT | OFN_PATHMUSTEXIST , _T("(*.txt)|*.txt|All files (*.*)|*.*||") ); if(IDOK == saveFile.DoModal()) { CString strFile = saveFile.GetPathName(); // do save }
//* 给按钮发送消息:
::PostMessage(m_hWnd,WM_COMMAND,MAKEWPARAM(IDC_BUTTON,BN_CLICKED),0);
//* VC6风格程序转VS2008
Debug目录找到.manifest文件添加
<dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"></assemblyIdentity> </dependentAssembly> </dependency>
编译即可。
//* VC6程序VS2008环境下改Framework至3.5
将.vcproj文件中的 TargetFrameworkVersion="131072" 改为 TargetFrameworkVersion="196613"
//* Combobox SetWindowText不显示是因为需要设置为DropDown风格。