bool ClientVersion::loadValidPaths() { while(hasValidPaths() == false) { gui.PopupDialog( wxT("Error"), wxT("Could not locate Tibia.dat and/or Tibia.spr, please navigate to your Tibia ") + name + wxT(" installation folder."), wxOK); wxString dirHelpText(wxT("Select Tibia ")); dirHelpText << name << " directory."; wxDirDialog file_dlg(nullptr, dirHelpText, wxT(""), wxDD_DIR_MUST_EXIST); int ok = file_dlg.ShowModal(); if(ok == wxID_CANCEL) return false; client_path.Assign(file_dlg.GetPath() + FileName::GetPathSeparator()); } ClientVersion::saveVersions(); return true; }
void CTrajecory_combine::OnBnClickedButtonTrackFile() { //创建一个可以选择多个文件的对话框 "gz"参数表示默认文件后缀名 CFileDialog file_dlg(TRUE, "gz", NULL, OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_ALLOWMULTISELECT); file_dlg.m_ofn.lpstrFilter = "gz or bin files(*.gz)|*.gz||"; file_dlg.m_ofn.lpstrTitle = "选择轨迹文件"; //做多可以打开500个文件 file_dlg.m_ofn.nMaxFile = 500 * MAX_PATH; char *ch = new TCHAR[file_dlg.m_ofn.nMaxFile]; file_dlg.m_ofn.lpstrFile = ch; // 内存块清零 ZeroMemory(file_dlg.m_ofn.lpstrFile, sizeof(TCHAR) * file_dlg.m_ofn.nMaxFile); if (file_name_list.GetItemCount() != 0) //列表不为空则先清空 { file_name_list.DeleteAllItems(); array_filename.RemoveAll(); } if (file_dlg.DoModal() == IDOK) { POSITION file_pos = file_dlg.GetStartPosition(); CString list_item(""); while (file_pos != NULL) { list_item = file_dlg.GetNextPathName(file_pos); array_filename.Add(list_item); } } int total_file = array_filename.GetSize(); if (total_file == 0) { AfxMessageBox("没有选择要处理的文件!"); return; } for (int i = 0; i < total_file; i++) { file_name_list.SetItemColor(i, RGB(167, 253, 255)); file_name_list.InsertItem(i, array_filename.GetAt(i)); file_name_list.SetItemText(i, 1, "待处理......"); } delete [] ch; }
static gint glspi_pickfile(lua_State* L) { gboolean save = FALSE; gchar *path = NULL; const gchar *mask = NULL; gchar *name = NULL; gchar*result; gint argc=lua_gettop(L); if (argc >= 1) { if (lua_isstring(L,1)) { const gchar*tmp=lua_tostring(L,1); if (strcasecmp(tmp,"save")==0) { save=TRUE; } else if ( (*tmp != '\0') && (strcasecmp(tmp,"open")!=0) ) { lua_pushfstring(L, _("Error in module \"%s\" at function %s():\n" "expected string \"open\" or \"save\" for argument #1.\n"), LUA_MODULE_NAME, &__FUNCTION__[6]); lua_error(L); return 0; } } else if (!lua_isnil(L,1)) { FAIL_STRING_ARG(1); return 0; } } if (argc >= 2) { if (lua_isstring(L,2)) { path=g_strdup(lua_tostring(L,2)); } else if (!lua_isnil(L,2)) { FAIL_STRING_ARG(2); return 0; } } if (argc >= 3 ) { if (lua_isstring(L,3)) { mask=lua_tostring(L,3); } else if (!lua_isnil(L,3)) { FAIL_STRING_ARG(3); return 0; } } if (path && *path && !g_file_test(path,G_FILE_TEST_IS_DIR) ){ gchar*sep=strrchr(path, G_DIR_SEPARATOR); if (sep) { name=sep+1; *sep='\0'; } else { name=path; path=NULL; } } result=file_dlg(L,save,path,mask,name); if (path) { g_free(path); } else if ( name ) { g_free(name); }; if (result) { lua_pushstring(L,result); g_free(result); } else { lua_pushnil(L); } return 1; }