void KDialogP::SetPopupInfor(TCHAR * pszInfor) { for (size_t i=0;i<(sizeof(m_pTxt_Popup_Infor)/sizeof(m_pTxt_Popup_Infor[0]));i++) { if( NULL != m_pTxt_Popup_Infor[i] ) { m_pTxt_Popup_Infor[i]->SetText(_T("")); } } if( NULL == pszInfor ) return; size_t nFindIndex = 0; size_t nFinded = 0; size_t nFindCount = 0; HINT nHeight = 0; HString strInfo = pszInfor; while( -1 != nFinded ) { nFinded = strInfo.find(_T('\n'),nFindIndex); if( -1 != nFinded ) { if( nFindCount < (sizeof(m_pTxt_Popup_Infor)/sizeof(m_pTxt_Popup_Infor[0])) ) { if( NULL != m_pTxt_Popup_Infor[nFindCount] ) { m_pTxt_Popup_Infor[nFindCount]->SetText(strInfo.substr(nFindIndex,nFinded-nFindIndex).c_str()); } } nFindCount++; nFindIndex = nFinded+1; } else { if( nFindCount < (sizeof(m_pTxt_Popup_Infor)/sizeof(m_pTxt_Popup_Infor[0])) ) { if( NULL != m_pTxt_Popup_Infor[nFindCount] ) { m_pTxt_Popup_Infor[nFindCount]->SetText(strInfo.substr(nFindIndex,strInfo.length()-nFindIndex).c_str()); } } nFindCount++; } } nHeight = (SCREEN_HEIGHT - (nFindCount*40))/2;// 220/*170*/ - (HINT)((nFindCount-1)*20); for (size_t i=0;i<(sizeof(m_pTxt_Popup_Infor)/sizeof(m_pTxt_Popup_Infor[0]));i++) { if( NULL != m_pTxt_Popup_Infor[i] ) { m_pTxt_Popup_Infor[i]->MoveTo(214,(HINT)(nHeight+i*40)); } } }
//主程序 HINT APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, HINT nCmdShow) { DWORD nCostTime = GetTickCount(); CBTCommand *pComand=CBTCommand::Instance(); if(pComand != NULL) { pComand->LowBTPower(); } wprintf(L"[wWinMain] Begin\r\n"); //g_Mutex =::CreateMutex(NULL, TRUE, APP_CLASSNAME_TEST1); INSTANCE_START HINT nParam = 0; _stscanf_s(GetCommandLine(),_T("%d"),&nParam); nCmdShow = PARAM_SHOW_CMD(nParam); s_Show = nCmdShow; BTDEBUGINFO(L"nCmdShow = %d",nCmdShow); HINT nDlg = PARAM_BT_DLG_CMD(nParam); BTDEBUGINFO(L"nDlg = %d",nDlg); s_nDlg = nDlg; // HINT nDlgType = PARAM_BT_DLG_CMD(nParam); // HMI 初始化 if( !UIDevInit( SCREEN_WIDTH, SCREEN_HEIGHT, hInstance, const_cast<HCHAR*>(STR_PROCESSNAME_BT), const_cast<HCHAR*>(STR_PROCESSNAME_BT), 0, g_hBTWnd) ) { return 0; } ::ShowWindow(g_hBTWnd, nCmdShow); SetOwnerProc(MyProc); //注册回调 // 注册IPC //移到后面 CEIPC_Regist(IPC_ID_BT, g_hBTWnd, RecvIPCEvent); // 切换字体 GetRESingleton()->ReLoadFont(FONT_MSYH_TTF); GetRESingleton()->ReLoadFont(FONT_QUARTZ_REGULAR_TTF); InitPopupSurface(GetHMIPath(_T("")).c_str()); KCBTDialogManager* pObj = KCBTDialogManager::Instance(); btSource::Instance()->GetBtSource(GetHMIPath(_T("")).c_str()); if(pComand != NULL) { pComand->SetMyhWnd(g_hBTWnd); pComand->OnInit(1,115200); nCostTime = GetTickCount() - nCostTime; BTDEBUGINFO(L"%s,CostTime1 = %d",__FUNCTIONW__,nCostTime); nCostTime = GetTickCount(); } if(pObj != NULL) { pObj->CreateAllBTDlg(); pComand->SendGetBTInfo(); pObj->ShowDlg(eDIALOGT_BTCONNECTSETTING); nCostTime = GetTickCount() - nCostTime; BTDEBUGINFO(L"%s,CostTime2 = %d",__FUNCTIONW__,nCostTime); nCostTime = GetTickCount(); //pObj->ShowBTHMIDlg(); } // 获取配置信息 if( NULL != KCLastMemory::GetInstance() ) { // 读取SETUP配置文件 KCLastMemory::GetInstance()->GetSetupMemory(g_SetupSetting); } else { KCLastMemory::GetSetupMemoryDefault(g_SetupSetting); } //::ShowWindow(g_hBTWnd, nCmdShow); ::UpdateWindow(g_hBTWnd); //CEIPC_Regist(IPC_ID_BT, g_hBTWnd, RecvIPCEvent); //s_nDlg = 4; if(s_nDlg == 4) { BTDEBUGINFO(L"s_nDlg == 4"); UINT nrett = SetTimer(g_hBTWnd,15,10000,SetDlg); if(nrett == 0) { BTDEBUGINFO(L"SetTimer error: %d",GetLastError()); } } nCostTime = GetTickCount() - nCostTime; BTDEBUGINFO(L"%s,CostTime3 = %d",__FUNCTIONW__,nCostTime); HCHAR szPath[MAX_PATH] = {0}; ::GetModuleFileName(NULL, szPath, MAX_PATH); appPath += szPath; HINT nPos = (HINT)appPath.rfind(_T('\\')); if(nPos == -1) { wprintf(L"[HCSourceBase::GetExePath] exe path error "); return false; } appPath = appPath.substr(0, nPos+1); #if BTLOGSTATE appPath += L"..\\Config\\BTLog.txt"; g_Logfile1.open(appPath.c_str(),ios::app); #else #endif #if TESTRESTARTPROTEM char buffer[256] = {0}; char buffer1[256] = {0}; char Num[20] ={0}; ifstream examplefile1; int i1,j1; i1= j1 = 0; int nn = 0; appPath += L"..\\Config\\BTPro.txt"; examplefile1.open(appPath.c_str()); if(!examplefile1) { printf("File Not Exsit\r\n"); g_nRestTime = 1; } else { while (! examplefile1.eof() ) { memset(buffer,0,sizeof(buffer)); examplefile1.getline(buffer,100); if(buffer[0] == 'T') { memset(buffer1,0,sizeof(buffer1)); memcpy(buffer1,buffer,100); } //nn++; //cout<<"====="<<nn<<endl; } while (buffer1[i1] != '^') { i1++; cout<<"i= "<<i1<<endl; } j1 = i1 + 1; while (buffer1[j1] != '^') { j1++; cout<<"j = "<<j1<<endl; } if(i1 < j1 && i1 > 0 && (j1-i1) < 10) { memcpy(Num,buffer1+i1+1,j1-i1-1); } g_nRestTime = atoi(Num) + 1; cout << "666++++"<<g_nRestTime<<endl; examplefile1.close(); } g_Profile1.open(appPath.c_str(),ios::app); char Temm[200] = {0}; //sprintf(Temm,"Totol^%d^^^^%d\n",g_nRestTime,GetTickCount()); //g_Profile1.write(Temm); g_Profile1<<"Total^"<<g_nRestTime<<"^^^^"<<GetTickCount()<<endl; //g_Profile1<<"Total^"<<g_nRestTime<<"^^^^"<<GetTickCount()<<endl; g_Profile1.close(); #endif //消息循环 MSG msg; UINT nretTime = SetTimer(g_hBTWnd,10,1000,CheckHDMISignal); if(nretTime == 0) { BTDEBUGINFO(L"SetTimer error: %d",GetLastError()); } DWORD dwClickDownTime = GetTickCount(); while(GetMessage(&msg, NULL, 0, 0)) { eDIALOGTYPE eDlgType = KCBTDialogManager::Instance()->GetCurrentDlgType(); if(GetTickCount() - dwClickDownTime >= 800 && msg.message == WM_LBUTTONDOWN && ((eDlgType == eDIALOGT_BTADDRESSBOOK) || (eDlgType == eDIALOGT_BTCALLRECORDS))) { dwClickDownTime = GetTickCount(); } else if(msg.message == WM_LBUTTONDOWN && GetTickCount() - dwClickDownTime < 800 && ((eDlgType == eDIALOGT_BTADDRESSBOOK) || (eDlgType == eDIALOGT_BTCALLRECORDS))) { continue; } TranslateMessage(&msg); DispatchMessage(&msg); } CEIPC_UnRegist(); CBTCommand::DeleteInstance(); KCBTDialogManager::Instance()->DeleteInstance(); btSource::Instance()->DeleteInstance(); //UnInitPopupSurface(); //释放 UIDevRelease(); KillTimer(g_hBTWnd,10); KillTimer(g_hBTWnd,15); HWND hServerWnd = ::FindWindow(STR_PROCESSNAME_MANAGE, STR_PROCESSNAME_MANAGE); HWND hBtUpateWnd = ::FindWindow(L"BTAPP.exe", L"BTAPP.exe"); if(hBtUpateWnd != NULL) { ::PostMessage(hBtUpateWnd, WM_USER + 1000, 0, NULL); } //printf("+++++++++++++VWM_SERVER_SRC_CLOSE+++++IPC_ID_BT++++++\r\n"); if (hServerWnd) { ::PostMessage(hServerWnd, VWM_SERVER_SRC_CLOSE, IPC_ID_BT, NULL); } return 0; }