您好,登錄后才能下訂單哦!
一、窗口全屏顯示,去掉任務(wù)欄
//全屏顯示 //隱藏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);
二、獲取當(dāng)前程序路徑
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; }
三、加載字庫(kù)
//加載字體 CString strFontPath = GetAppllicationPath()+_T("msyh.ttf"); if (NULL != AddFontResource(strFontPath)) { ::SendMessage( HWND_BROADCAST, WM_FONTCHANGE, 0, 0); } else { AfxMessageBox(L"字體加載失敗"); }
程序退出時(shí),卸載字庫(kù)
CString strFontPath = GetApplicationPath()+_T("msyh.ttf"); if(RemoveFontResource(strFontPath)) { ::SendMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0); } else AfxMessageBox(L"Failed to UNLOAD font!");
四、加載位圖用LoadImage無(wú)效
HBITMAP hBitmap = (HBITMAP)::SHLoadDIBitmap(szBitmapFile);
五、要以共享MFC的DLL庫(kù)的方式發(fā)布程序,須將如下目錄中DLL全部復(fù)制到目標(biāo)機(jī)器上。
C:\Program Files (x86)\Microsoft Visual Studio 8\VC\ce\Dll\armv4i
六、wchar_t*轉(zhuǎn)char*
如,sCaption為 LPCTSTR類型字符串,要轉(zhuǎn)成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);
七、字體平滑,需要修改注冊(cè)表
HKEY_LOCAL_MACHINE\\System\\GDI\\ClearType Default=2
八、不關(guān)閉屏幕,常期顯示工作界面
//電源參數(shù)請(qǐng)求更新 HANDLE hevReloadActivityTimeouts = OpenEvent(EVENT_ALL_ACCESS, FALSE, _T("PowerManager/ReloadActivityTimeouts")); if (hevReloadActivityTimeouts) { SetEvent(hevReloadActivityTimeouts); CloseHandle(hevReloadActivityTimeouts); }
同時(shí),在注冊(cè)表中也要修改超時(shí)設(shè)置。
九、Sqlite數(shù)據(jù)庫(kù)讀寫
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); }
十一、字符串轉(zhuǎn)浮點(diǎn)數(shù)
_tstof在WinCE中未實(shí)現(xiàn),需要自己實(shí)現(xiàn)。如果轉(zhuǎn)成double型可以如下:
double StringToDouble(LPCTSTR lpszSrc) { TCHAR * endptr; return _tcstod(lpszSrc, &endptr); }
免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如果涉及侵權(quán)請(qǐng)聯(lián)系站長(zhǎng)郵箱:is@yisu.com進(jìn)行舉報(bào),并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。