您好,登錄后才能下訂單哦!
一、窗口全屏顯示,去掉任務欄
//全屏顯示 //隱藏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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。