BOOL CDlgOpentools::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) { // TODO: 在此添加消息处理程序代码和/或调用默认值 if (pCopyDataStruct->dwData == COPY_DATA_COMPONENT_FINISH) { FINISH_COPYDATA* pCdFinish = (FINISH_COPYDATA*)pCopyDataStruct->lpData; CStringW strw = (WCHAR *)pCdFinish->flag; CString strFlag; strFlag = strw; //ZTools::WriteZToolsLog(ZTools::FormatString("收到封装环境发来完成消息--%s", strFlag)); if (strFlag.CompareNoCase("save") == 0) { MyClose(IDOK); //ZTools::WriteZToolsLog("MyClose(IDOK);"); } else if (strFlag.CompareNoCase("apply")==0) { m_bApplied = TRUE; } else { MyClose(IDCANCEL); //ZTools::WriteZToolsLog("MyClose(IDCANCEL);"); } } //ZTools::WriteZToolsLog("--return CDialog::OnCopyData(pWnd, pCopyDataStruct);"); return CDialog::OnCopyData(pWnd, pCopyDataStruct); }
PATCH_RET_CODE OpenOld( foff len, int prompt, foff new_size, foff new_sum ) { int handle; foff actual_len; prompt=prompt; _splitpath( NewName, NULL, NULL, new_fname, new_ext ); _splitpath( path, drive, dir, fname, ext ); _makepath( new_path, drive, dir, new_fname, new_ext ); NewName = new_path; #if !defined( INSTALL_PROGRAM ) { char temp[_MAX_PATH]; char msgbuf[MAX_RESOURCE_SIZE]; if( prompt && DoPrompt ) { for( ;; ) { GetMsg( msgbuf, MSG_MODIFY ); cprintf( msgbuf, path ); while( kbhit() ) getch(); gets( temp ); if( tolower( temp[0] ) == 'n' ) { PatchError( ERR_PATCH_ABORTED ); } if( tolower( temp[0] ) == 'y' ) break; } } } #endif handle = open( path, O_RDONLY+O_BINARY, 0 ); FileCheck( handle, path ); MyOpen( &OldFile, handle, path ); actual_len = lseek( handle, 0, SEEK_END ); SeekCheck( actual_len, path ); if( actual_len != len && (actual_len + sizeof( PATCH_LEVEL )) != len && (actual_len - sizeof( PATCH_LEVEL )) != len ) { if( actual_len >= new_size ) { if( CheckSumOld( new_size ) == new_sum ) { MyClose( &OldFile ); return( PATCH_ALREADY_PATCHED ); } } PatchError( ERR_WRONG_SIZE, path, actual_len, len ); MyClose( &OldFile ); return( PATCH_BAD_LENGTH ); } SeekCheck( lseek( handle, 0, SEEK_SET ), path ); return( PATCH_RET_OKAY ); }
void CDlgOpentools::SendMession() { if (m_sOpenFlag.CompareNoCase("CreateComponent") == 0 || m_sOpenFlag.CompareNoCase("CreateForm") == 0) { m_sLocalPath.TrimRight('\\'); CREATE_COPYDATA cdCreate; cdCreate.clear(); strcpy_s(cdCreate.componentName, m_sComponentName); strcpy_s(cdCreate.baseType, m_sBaseType); strcpy_s(cdCreate.localPath, m_sLocalPath); strcpy_s(cdCreate.paramsFilePath, m_sParamsFilePath); cdCreate.hwndDlg = m_hWnd; COPYDATASTRUCT cpd; memset(&cpd, NULL, sizeof(COPYDATASTRUCT)); cpd.cbData = sizeof(CREATE_COPYDATA); cpd.dwData = COPY_DATA_CREATE_COMPONENT; cpd.lpData = &cdCreate; ZTools::WriteZToolsFormatLog("SendMessage Create\n%s\n%s\n%s\n%s", m_sComponentName, m_sBaseType, m_sLocalPath, m_sParamsFilePath); ::SendMessage(m_hWndOpentools, WM_COPYDATA, NULL, (LPARAM)&cpd); } else if (m_sOpenFlag.CompareNoCase("EditComponent") == 0 || m_sOpenFlag.CompareNoCase("EditForm") == 0) { EDIT_COPYDATA cdEdit; cdEdit.clear(); strcpy_s(cdEdit.robotPath, m_sLocalRobotPath); strcpy_s(cdEdit.paramsFilePath, m_sParamsFilePath); cdEdit.hwndDlg = m_hWnd; COPYDATASTRUCT cpd; memset(&cpd, NULL, sizeof(COPYDATASTRUCT)); cpd.cbData = sizeof(EDIT_COPYDATA); cpd.dwData = COPY_DATA_EDIT_COMPONENT; cpd.lpData = &cdEdit; ZTools::WriteZToolsFormatLog("SendMessage Edit\n%s\n%s", m_sLocalRobotPath, m_sParamsFilePath); ::SendMessage(m_hWndOpentools, WM_COPYDATA, NULL, (LPARAM)&cpd); } else { MyClose(IDCANCEL); return; } }
void CDlgOpentools::OnCancel() { if (m_hWndOpentools && IsWindow(m_hWndOpentools)) { ::PostMessage(m_hWndOpentools, WM_KEYDOWN, VK_ESCAPE, 0); ::PostMessage(m_hWndOpentools, WM_KEYUP, VK_ESCAPE, 0); Sleep(1); } // TODO: 在此添加专用代码和/或调用基类 //封装环境有弹出窗口时不允许关闭 if (m_dProcessId) { HWND hwnd = GetOpentoolsPopupWindow(m_dProcessId); if (hwnd != 0 && IsWindow(hwnd)) { ::BringWindowToTop(hwnd); return; } } //int ret = MessageBox("确定未保存直接退出在线封装环境吗?", "在线编辑", MB_OKCANCEL); //if (IDOK != ret) //{ // return; //} if (m_hWndOpentools && IsWindow(m_hWndOpentools)) { CString sFlag = "cancel"; CLOSE_COPYDATA cdClose; cdClose.clear(); strcpy_s(cdClose.flag, sFlag); COPYDATASTRUCT cpd; memset(&cpd, NULL, sizeof(COPYDATASTRUCT)); cpd.cbData = sizeof(CLOSE_COPYDATA); cpd.dwData = COPY_DATA_CLOSE_COMPONENT; cpd.lpData = &cdClose; ::SendMessage(m_hWndOpentools, WM_COPYDATA, NULL, (LPARAM)&cpd); } MyClose(IDCANCEL); //CDialog::OnCancel(); }
PATCH_RET_CODE CloseOld( int havenew, int dobackup ) { char bak[_MAX_PATH]; MyClose( &OldFile ); if( havenew ) { _makepath( bak, drive, dir, fname, "bak" ); remove( bak ); if( rename( path, bak ) != 0 ) { FilePatchError( ERR_CANT_RENAME, path, bak ); return( PATCH_CANT_RENAME ); } if( rename( NewName, path ) != 0 ) { FilePatchError( ERR_CANT_RENAME, NewName, bak ); return( PATCH_CANT_RENAME ); } if( !dobackup ) remove( bak ); } return( PATCH_RET_OKAY ); }
void * ThreadDBAccess(void * arg) { printf("ThreadDBAccess, tid=%u \n",(unsigned)(pthread_self())); pthread_t tid =pthread_self(); MYSQL mysql; int rt =MyConnect(mysql,host.c_str(),user.c_str(),passwd.c_str(),database.c_str(),port); if(0!=rt) ERR("MyConnect"); while(1) { QueueElement qe =g_inQueue[g_tid_pipe[tid]].Get(); // db.Query() int rt =MyQuery(mysql, qe.pack.c_str(), qe.pack.size()); T_TABLES v_tables; rt =MyGetResults(mysql,v_tables); if(0!=rt) { printf("Failed MyGetResults, tid=%u \n",(unsigned)(pthread_self())); continue; } std::string output_data; VectorSerialize::Serialize(v_tables,output_data); QueueElement qeOut; qeOut.fd =qe.fd; qeOut.pack =output_data; g_outQueue[g_tid_pipe[tid]].Put(qeOut); int notifyfd =g_tid_fd[tid]; printf("tid=%u, notifyfd=%d \n",(cf_uint32)tid,notifyfd); std::string tmp("a"); send(notifyfd,tmp.c_str(),1,0); } MyClose(mysql); return NULL; }
BOOL CDlgOpentools::OnInitDialog() { CDialog::OnInitDialog(); SetWindowText("组件编辑 - 类型:" + m_sBaseType + " 名称:" + m_sNodeName); HICON hIcon=AfxGetApp()->LoadIcon(IDI_ICON_OPENTOOLS); //SetIcon(hIcon, FALSE); SetIcon(hIcon, TRUE); // TODO: 在此添加额外的初始化 CRect rcArce; SystemParametersInfo(SPI_GETWORKAREA,0,&rcArce,SPIF_SENDCHANGE); int nWorkHeight = rcArce.Height(); int nWorkWidth = rcArce.Width(); // int x = 1120; // int y = 630; // int xStart = (nWorkWidth - x) / 2; // int yStart = (nWorkHeight - y) / 2; // ::SetWindowPos(m_hWnd, NULL, xStart, yStart, x, y, SWP_NOZORDER); // ::SetWindowPos(m_hWnd, NULL, 0, 0, nWorkWidth, nWorkHeight, SWP_NOZORDER); SetWndPos();//设置窗口大小 ////////////////////////////////////////////////////////////////////////// //取窗口句柄 DWORD dwPid = 0; HWND hWnd = 0; m_pSharedMemoryOnlineEdit->GetInfo(&dwPid, &hWnd); //窗口句柄有效,直接返回 if (hWnd != 0 && IsWindow(hWnd)) { m_hWndOpentools = hWnd; m_dProcessId = dwPid; //ShowWindow(SW_SHOWMAXIMIZED); BindWindow(); //发送任务指令 SetTimer(TIMER_SEND_MISSON, 1, NULL); } else { //窗口句柄无效时,从进程中查 HANDLE hProcess = NULL; if (dwPid != 0) { hProcess = OpenProcess(PROCESS_TERMINATE, FALSE, dwPid); } //若进程无效,重新启动封装环境 if (hProcess == NULL || hProcess == INVALID_HANDLE_VALUE) { m_dProcessId = m_pSharedMemoryOnlineEdit->StartOpenTools(); if (m_dProcessId == 0) { MyClose(IDCANCEL); return TRUE; } InitPaint(); SetTimer(TIMER_FIND_WINDOW, 500, NULL); } else { m_dProcessId = dwPid; CloseHandle(hProcess); HWND hWndFindOpentools = SharedMemoryOnlineEdit::GetMainWindow(m_dProcessId, "组件封装", "HwndWrapper[PeraComponentEditor.exe"); if (hWndFindOpentools && IsWindow(hWndFindOpentools)) { m_hWndOpentools = hWndFindOpentools; //更新共享内存 m_pSharedMemoryOnlineEdit->SetInfo(m_dProcessId, m_hWndOpentools); BindWindow(); //发送任务指令 SetTimer(TIMER_SEND_MISSON, 1, NULL); } else { InitPaint(); SetTimer(TIMER_FIND_WINDOW, 500, NULL); } } } ShowWindow(SW_SHOWMAXIMIZED); return TRUE; // return TRUE unless you set the focus to a control // 异常: OCX 属性页应返回 FALSE }