您好,登录后才能下订单哦!
密码登录
登录注册
点击 登录注册 即表示同意《亿速云用户服务条款》
一、窗口全屏显示,去掉任务栏
//全屏显示 //隐藏HHTaskBar窗口代码如下: HWND hTaskBar = ::FindWindow(TEXT("HHTaskBar"), NULL); if (hTaskBar != NULL) { ::EnableWindow(hTaskBar, FALSE); ::ShowWindow(hTaskBar, SW_HIDE); } int iFullWidth = GetSystemMetrics(SM_CXSCREEN); int iFullHeight = GetSystemMetrics(SM_CYSCREEN); ::SetWindowPos(this->m_hWnd, HWND_TOPMOST, 0, 0, iFullWidth, iFullHeight, SWP_NOOWNERZORDER|SWP_SHOWWINDOW);
二、获取当前程序路径
CString CscaleweightDlg::GetAppllicationPath() { WCHAR buff[255]={0}; ::GetModuleFileName(0,buff,255); CString strAppFullName; strAppFullName.Format(_T("%s"),buff); CString strAppPath = _T(""); strAppPath = strAppFullName.Left(strAppFullName.ReverseFind('\\')+1); return strAppPath; }
三、加载字库
//加载字体 CString strFontPath = GetAppllicationPath()+_T("msyh.ttf"); if (NULL != AddFontResource(strFontPath)) { ::SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0); } else { AfxMessageBox(L"字体加载失败"); }
程序退出时,卸载字库
CString strFontPath = GetApplicationPath()+_T("msyh.ttf"); if(RemoveFontResource(strFontPath)) { ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); } else AfxMessageBox(L"Failed to UNLOAD font!");
四、加载位图用LoadImage无效
HBITMAP hBitmap = (HBITMAP)::SHLoadDIBitmap(szBitmapFile);
五、要以共享MFC的DLL库的方式发布程序,须将如下目录中DLL全部复制到目标机器上。
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\ce\Dll\armv4i
六、wchar_t*转char*
如,sCaption为 LPCTSTR类型字符串,要转成char *字符串,如下:
int num = WideCharToMultiByte(CP_OEMCP, NULL, sCaption, -1, NULL, 0, NULL, FALSE); char *pChar = new char[num]; WideCharToMultiByte(CP_OEMCP, NULL, sCaption, -1, pChar, num, NULL, FALSE);
七、字体平滑,需要修改注册表
HKEY_LOCAL_MACHINE\\System\\GDI\\ClearType Default=2
八、不关闭屏幕,常期显示工作界面
//电源参数请求更新 HANDLE hevReloadActivityTimeouts = OpenEvent(EVENT_ALL_ACCESS, FALSE, _T("PowerManager/ReloadActivityTimeouts")); if (hevReloadActivityTimeouts) { SetEvent(hevReloadActivityTimeouts); CloseHandle(hevReloadActivityTimeouts); }
同时,在注册表中也要修改超时设置。
九、Sqlite数据库读写
void CSimpleModeData::TempTableWrite(CString CarNo,CString strWeight,CString GoodsName, CString Time) { CString str ; str.Format(_T("insert into SimpleModeTempTable(CarNo,GoodsName,Weight,Time)\ values('%s','%s','%s','%s')"),CarNo,strWeight,GoodsName, Time); TRACE(str); m_sqliteDB.execQuery(str); } BOOL CSimpleModeData::TempTableRead(CString strCarNo) { CString str ; str.Format(_T("select * from SimpleModeTempTable where CarNo = '%s'")); TRACE(str); CppSQLite3Query query = m_sqliteDB.execQuery(str); if(!query.eof()) { wcscpy_s(CGlobal::g_TempTable.CarNo,20,query.fieldValue(1)); wcscpy_s(CGlobal::g_TempTable.GoodsName,20 ,query.fieldValue(2)); wcscpy_s(CGlobal::g_TempTable.Weight,20,query.fieldValue(3)); return TRUE; } query.finalize(); return FALSE; }
十、软件重启
#include "windows.h" #include "winioctl.h" #define POWER_STATE_RESET (DWORD)(0x00800000) #define POWER_FORCE (DWORD)(0x00001000) extern "C" __declspec(dllimport) DWORD SetSystemPowerState(LPCWSTR pwsSystemState, DWORD StateFlags,DWORD Options); void CtestDlg::OnBnClickedButton2() { SetSystemPowerState(NULL, POWER_STATE_RESET, POWER_FORCE); }
十一、字符串转浮点数
_tstof在WinCE中未实现,需要自己实现。如果转成double型可以如下:
double StringToDouble(LPCTSTR lpszSrc) { TCHAR * endptr; return _tcstod(lpszSrc, &endptr); }
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。