这篇教程C++ GetOpenFileName函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetOpenFileName函数的典型用法代码示例。如果您正苦于以下问题:C++ GetOpenFileName函数的具体用法?C++ GetOpenFileName怎么用?C++ GetOpenFileName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetOpenFileName函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: DlgProc//.........这里部分代码省略......... { TCHAR dropped_file[MAX_PATH]=_T(""); if (DragQueryFile((HDROP)wParam,(UINT)-1,NULL,0)==1) { DragQueryFile((HDROP)wParam,0,dropped_file,MAX_PATH); if (lstrlen(dropped_file)>0) { SetZip(hwndDlg,dropped_file); } } else { MessageBox(hwndDlg,_T("Dropping more than one zip file at a time is not supported"),g_errcaption,MB_OK|MB_ICONSTOP); } DragFinish((HDROP)wParam); return TRUE; } case WM_COMMAND: switch (LOWORD(wParam)) { case IDC_BROWSE: if (!g_extracting) { OPENFILENAME l={sizeof(l),}; TCHAR buf[1024]; l.hwndOwner = hwndDlg; l.lpstrFilter = _T("ZIP Files/0*.zip/0All Files/0*.*/0"); l.lpstrFile = buf; l.nMaxFile = 1023; l.lpstrTitle = _T("Open ZIP File"); l.lpstrDefExt = _T("zip"); l.lpstrInitialDir = NULL; l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER|OFN_PATHMUSTEXIST; buf[0]=0; if (GetOpenFileName(&l)) { SetZip(hwndDlg,buf); } } break; case IDC_BROWSE2: { OPENFILENAME l={sizeof(l),}; TCHAR buf[1024]; l.hwndOwner = hwndDlg; l.lpstrFilter = _T("Executables/0*.exe/0All Files/0*.*/0"); l.lpstrFile = buf; l.nMaxFile = 1023; l.lpstrTitle = _T("Select Output EXE File"); l.lpstrDefExt = _T("exe"); l.lpstrInitialDir = NULL; l.Flags = OFN_HIDEREADONLY|OFN_EXPLORER; GetDlgItemText(hwndDlg,IDC_OUTFILE,buf,sizeof(buf)); if (GetSaveFileName(&l)) { SetDlgItemText(hwndDlg,IDC_OUTFILE,buf); } } break; case IDC_BACK: if (!g_hThread) { g_made=false; ShowWindow(GetDlgItem(hwndDlg,IDC_BACK),SW_HIDE); ShowWindow(GetDlgItem(hwndDlg,IDC_TEST),SW_HIDE); ShowWindow(GetDlgItem(hwndDlg,IDC_OUTPUTTEXT),SW_HIDE); {
开发者ID:abcsds,项目名称:pinguino-installers,代码行数:67,
示例2: run virtual void run() { QString result; QString workDir; QString initSel; QFileInfo fi (mStartWith); if (fi.isDir()) workDir = mStartWith; else { workDir = fi.absolutePath(); initSel = fi.fileName(); } workDir = QDir::toNativeSeparators (workDir); if (!workDir.endsWith ("//")) workDir += "//"; QString title = mCaption.isNull() ? tr ("Select a file") : mCaption; QWidget *topParent = windowManager().realParentWindow(mParent ? mParent : windowManager().mainWindowShown()); QString winFilters = winFilter (mFilters); AssertCompile (sizeof (TCHAR) == sizeof (QChar)); TCHAR buf [1024]; if (initSel.length() > 0 && initSel.length() < sizeof (buf)) memcpy (buf, initSel.isNull() ? 0 : initSel.utf16(), (initSel.length() + 1) * sizeof (TCHAR)); else buf [0] = 0; OPENFILENAME ofn; memset (&ofn, 0, sizeof (OPENFILENAME)); ofn.lStructSize = sizeof (OPENFILENAME); ofn.hwndOwner = topParent ? topParent->winId() : 0; ofn.lpstrFilter = (TCHAR *) winFilters.isNull() ? 0 : winFilters.utf16(); ofn.lpstrFile = buf; ofn.nMaxFile = sizeof (buf) - 1; ofn.lpstrInitialDir = (TCHAR *) workDir.isNull() ? 0 : workDir.utf16(); ofn.lpstrTitle = (TCHAR *) title.isNull() ? 0 : title.utf16(); ofn.Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_ENABLEHOOK | OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST); ofn.lpfnHook = OFNHookProc; if (GetOpenFileName (&ofn)) { result = QString::fromUtf16 ((ushort *) ofn.lpstrFile); } // qt_win_eatMouseMove(); MSG msg = {0, 0, 0, 0, 0, 0, 0}; while (PeekMessage (&msg, 0, WM_MOUSEMOVE, WM_MOUSEMOVE, PM_REMOVE)); if (msg.message == WM_MOUSEMOVE) PostMessage (msg.hwnd, msg.message, 0, msg.lParam); result = result.isEmpty() ? result : QFileInfo (result).absoluteFilePath(); QApplication::postEvent (mTarget, new GetOpenFileNameEvent (result)); }
开发者ID:eaas-framework,项目名称:virtualbox,代码行数:62,
示例3: GbaSlotCFlashINT_PTR CALLBACK GbaSlotCFlash(HWND dialog, UINT msg,WPARAM wparam,LPARAM lparam){ switch(msg) { case WM_INITDIALOG: { switch (tmp_CFlashMode) { case ADDON_CFLASH_MODE_Path: SetFocus(GetDlgItem(dialog,IDC_RFOLDER)); CheckDlgButton(dialog, IDC_RFOLDER, BST_CHECKED); EnableWindow(GetDlgItem(dialog, IDC_PATH), TRUE); EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), TRUE); EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); if (strlen(tmp_cflash_path)) _OKbutton = TRUE; break; case ADDON_CFLASH_MODE_File: SetFocus(GetDlgItem(dialog,IDC_RFILE)); CheckDlgButton(dialog, IDC_RFILE, BST_CHECKED); EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), TRUE); EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), TRUE); EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); if (strlen(tmp_cflash_filename)) _OKbutton = TRUE; break; case ADDON_CFLASH_MODE_RomPath: SetFocus(GetDlgItem(dialog,IDC_PATHDESMUME)); CheckDlgButton(dialog, IDC_PATHDESMUME, BST_CHECKED); EnableWindow(GetDlgItem(dialog, IDC_PATH), FALSE); EnableWindow(GetDlgItem(dialog, IDC_BBROWSE2), FALSE); EnableWindow(GetDlgItem(dialog, IDC_PATHIMG), FALSE); EnableWindow(GetDlgItem(dialog, IDC_BBROWSE), FALSE); _OKbutton = TRUE; break; } SetWindowText(GetDlgItem(dialog, IDC_PATHIMG), tmp_cflash_filename); SetWindowText(GetDlgItem(dialog, IDC_PATH), tmp_cflash_path); return FALSE; } case WM_COMMAND: { switch (LOWORD(wparam)) { case IDC_BBROWSE: { int filterSize = 0, i = 0; OPENFILENAME ofn; char filename[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = dialog; const char *fileFilter = "FAT image (*.img)/0*.img/0Any file (*.*)/0*.*/0"; ofn.lpstrFilter = fileFilter; ofn.nFilterIndex = 1; ofn.lpstrFile = filename; ofn.nMaxFile = MAX_PATH; ofn.lpstrDefExt = "img"; ofn.Flags = OFN_NOCHANGEDIR | OFN_CREATEPROMPT | OFN_PATHMUSTEXIST; if(!GetOpenFileName(&ofn)) return FALSE; SetWindowText(GetDlgItem(dialog, IDC_PATHIMG), filename); strcpy(tmp_cflash_filename, filename); if (!strlen(tmp_cflash_filename)) EnableWindow(OKbutton, FALSE); else EnableWindow(OKbutton, TRUE); return FALSE; } case IDC_BBROWSE2: { BROWSEINFO bp={0}; bp.hwndOwner=dialog; bp.pidlRoot=NULL; bp.pszDisplayName=NULL; bp.lpszTitle="Select directory for FAT image building"; bp.ulFlags=BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE | BIF_USENEWUI; bp.lpfn=NULL; LPITEMIDLIST tmp = SHBrowseForFolder((LPBROWSEINFO)&bp); if (tmp!=NULL) { memset(tmp_cflash_path, 0, sizeof(tmp_cflash_path)); SHGetPathFromIDList(tmp, tmp_cflash_path); if (tmp_cflash_path[strlen(tmp_cflash_path)-1] != '//') tmp_cflash_path[strlen(tmp_cflash_path)] = '//'; SetWindowText(GetDlgItem(dialog, IDC_PATH), tmp_cflash_path); } if (strlen(tmp_cflash_path)) EnableWindow(OKbutton, TRUE);//.........这里部分代码省略.........
开发者ID:MoochMcGee,项目名称:desmume-plus,代码行数:101,
示例4: CheckMenuItem//.........这里部分代码省略......... // Toggle strips else if( LOWORD(wParam) == IDM_SHOWTRILIST ) { m_bShowStrips = FALSE; m_bShowSingleStrip = FALSE; CheckMenuItem( GetMenu(hWnd), IDM_SHOWTRILIST, MF_CHECKED ); CheckMenuItem( GetMenu(hWnd), IDM_SHOWONESTRIP, MF_UNCHECKED ); CheckMenuItem( GetMenu(hWnd), IDM_SHOWMANYSTRIPS, MF_UNCHECKED ); } else if( LOWORD(wParam) == IDM_SHOWONESTRIP ) { m_bShowStrips = FALSE; m_bShowSingleStrip = TRUE; CheckMenuItem( GetMenu(hWnd), IDM_SHOWTRILIST, MF_UNCHECKED ); CheckMenuItem( GetMenu(hWnd), IDM_SHOWONESTRIP, MF_CHECKED ); CheckMenuItem( GetMenu(hWnd), IDM_SHOWMANYSTRIPS, MF_UNCHECKED ); } else if( LOWORD(wParam) == IDM_SHOWMANYSTRIPS ) { m_bShowStrips = TRUE; m_bShowSingleStrip = FALSE; CheckMenuItem( GetMenu(hWnd), IDM_SHOWTRILIST, MF_UNCHECKED ); CheckMenuItem( GetMenu(hWnd), IDM_SHOWONESTRIP, MF_UNCHECKED ); CheckMenuItem( GetMenu(hWnd), IDM_SHOWMANYSTRIPS, MF_CHECKED ); } // Toggle vertex buffer mode else if( LOWORD(wParam) == IDM_DYNAMICVB ) { if (m_dwMemoryOptions == D3DXMESH_DYNAMIC) { m_dwMemoryOptions = D3DXMESH_MANAGED; CheckMenuItem( GetMenu(hWnd), IDM_DYNAMICVB, MF_UNCHECKED ); } else { m_dwMemoryOptions = D3DXMESH_DYNAMIC; CheckMenuItem( GetMenu(hWnd), IDM_DYNAMICVB, MF_CHECKED ); } // Destroy and recreate everything InvalidateDeviceObjects(); RestoreDeviceObjects(); } else if( LOWORD(wParam) == IDM_FORCE32BYTEVERTEX ) { m_bForce32ByteFVF = !m_bForce32ByteFVF; CheckMenuItem( GetMenu(hWnd), IDM_FORCE32BYTEVERTEX, m_bForce32ByteFVF ? MF_CHECKED : MF_UNCHECKED ); // Destroy and recreate everything InvalidateDeviceObjects(); DeleteDeviceObjects(); InitDeviceObjects(); RestoreDeviceObjects(); } // Handle the open file command else if( LOWORD(wParam) == IDM_OPENFILE ) { TCHAR g_strFilename[512] = _T(""); // Display the OpenFileName dialog. Then, try to load the specified file OPENFILENAME ofn = { sizeof(OPENFILENAME), NULL, NULL, _T(".X Files (.x)/0*.x/0/0"), NULL, 0, 1, m_strMeshFilename, 512, g_strFilename, 512, m_strInitialDir, _T("Open Mesh File"), OFN_FILEMUSTEXIST, 0, 1, NULL, 0, NULL, NULL }; if( TRUE == GetOpenFileName( &ofn ) ) { _tcscpy( m_strInitialDir, m_strMeshFilename ); TCHAR* pLastSlash = _tcsrchr( m_strInitialDir, _T('//') ); if( pLastSlash ) *pLastSlash = 0; SetCurrentDirectory( m_strInitialDir ); // Destroy and recreate everything InvalidateDeviceObjects(); DeleteDeviceObjects(); InitDeviceObjects(); RestoreDeviceObjects(); } } else if ((LOWORD(wParam) >= ID_OPTIONS_DISPLAY1) && (LOWORD(wParam) <= ID_OPTIONS_DISPLAY36)) { // uncheck old item CheckMenuItem( GetMenu(hWnd), ID_OPTIONS_DISPLAY1 + (m_cObjectsPerSide-1), MF_UNCHECKED ); // calc new item m_cObjectsPerSide = LOWORD(wParam) - ID_OPTIONS_DISPLAY1 + 1; // check new item CheckMenuItem( GetMenu(hWnd), ID_OPTIONS_DISPLAY1 + (m_cObjectsPerSide-1), MF_CHECKED ); } } return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );}
开发者ID:grakidov,项目名称:Render3D,代码行数:101,
示例5: TVPSelectFile//.........这里部分代码省略......... &val, params))) { ttstr lname(val); if(!lname.IsEmpty()) { lname = TVPNormalizeStorageName(lname); TVPGetLocalName(lname); initialdir = lname.AsAnsiString(); ofn.lpstrInitialDir = initialdir.c_str(); } } // title if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("title"), 0, &val, params))) { title = ttstr(val).AsAnsiString(); ofn.lpstrTitle = title.c_str(); } else { ofn.lpstrTitle = NULL; } // flags bool issave = false; if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("save"), 0, &val, params))) issave = val.operator bool(); ofn.Flags = OFN_ENABLEHOOK|OFN_EXPLORER|OFN_NOCHANGEDIR| OFN_PATHMUSTEXIST|OFN_HIDEREADONLY|OFN_ENABLESIZING; if(!issave) ofn.Flags |= OFN_FILEMUSTEXIST; else ofn.Flags |= OFN_OVERWRITEPROMPT; // default extension if(TJS_SUCCEEDED(params->PropGet(TJS_MEMBERMUSTEXIST, TJS_W("defaultExt"), 0, &val, params))) { defaultext = ttstr(val).AsAnsiString(); ofn.lpstrDefExt = defaultext.c_str(); } else { ofn.lpstrDefExt = NULL; } // hook proc ofn.lpfnHook = TVPOFNHookProc; // show dialog box if(!issave) result = GetOpenFileName(&ofn); else result = GetSaveFileName(&ofn); if(!result && CommDlgExtendedError() == CDERR_STRUCTSIZE) { // for old windows // set lStructSize to old Windows' structure size ofn.lStructSize = TVP_OLD_OFN_STRUCT_SIZE; if(!issave) result = GetOpenFileName(&ofn); else result = GetSaveFileName(&ofn); } if(result) { // returns some informations // filter index val = (tjs_int)ofn.nFilterIndex; params->PropSet(TJS_MEMBERENSURE, TJS_W("filterIndex"), 0, &val, params); // file name val = TVPNormalizeStorageName(ttstr(filename)); params->PropSet(TJS_MEMBERENSURE, TJS_W("name"), 0, &val, params); } } catch(...) { if(filter) delete [] filter; if(filename) delete [] filename; throw; } delete [] filter; delete [] filename; return (bool)result;}
开发者ID:xmoeproject,项目名称:X-moe,代码行数:101,
示例6: ConfigureBitmapTransitionProcINT_PTR CALLBACK ConfigureBitmapTransitionProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ switch(message) { case WM_INITDIALOG: { ConfigBitmapInfo *configInfo = (ConfigBitmapInfo*)lParam; SetWindowLongPtr(hwnd, DWLP_USER, (LONG_PTR)configInfo); LocalizeWindow(hwnd); //-------------------------- HWND hwndTemp = GetDlgItem(hwnd, IDC_BITMAPS); StringList bitmapList; configInfo->data->GetStringList(TEXT("bitmap"), bitmapList); for(UINT i=0; i<bitmapList.Num(); i++) { CTSTR lpBitmap = bitmapList[i]; if(OSFileExists(lpBitmap)) SendMessage(hwndTemp, LB_ADDSTRING, 0, (LPARAM)lpBitmap); } //-------------------------- hwndTemp = GetDlgItem(hwnd, IDC_TRANSITIONTIME); UINT transitionTime = configInfo->data->GetInt(TEXT("transitionTime")); SendMessage(hwndTemp, UDM_SETRANGE32, MIN_TRANSITION_TIME, MAX_TRANSITION_TIME); if(!transitionTime) transitionTime = 10; SendMessage(hwndTemp, UDM_SETPOS32, 0, transitionTime); EnableWindow(GetDlgItem(hwnd, IDC_REPLACE), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_REMOVE), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_MOVEUPWARD), FALSE); EnableWindow(GetDlgItem(hwnd, IDC_MOVEDOWNWARD), FALSE); //-------------------------- BOOL bFadeInOnly = configInfo->data->GetInt(TEXT("fadeInOnly")); BOOL bDisableFading = configInfo->data->GetInt(TEXT("disableFading")); BOOL bRandomize = configInfo->data->GetInt(TEXT("randomize")); SendMessage(GetDlgItem(hwnd, IDC_FADEINONLY), BM_SETCHECK, bFadeInOnly ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hwnd, IDC_DISABLEFADING), BM_SETCHECK, bDisableFading ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hwnd, IDC_RANDOMIZE), BM_SETCHECK, bRandomize ? BST_CHECKED : BST_UNCHECKED, 0); EnableWindow(GetDlgItem(hwnd, IDC_FADEINONLY), !bDisableFading); return TRUE; } case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_ADD: { TSTR lpFile = (TSTR)Allocate(32*1024*sizeof(TCHAR)); zero(lpFile, 32*1024*sizeof(TCHAR)); OPENFILENAME ofn; zero(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.lpstrFile = lpFile; ofn.hwndOwner = hwnd; ofn.nMaxFile = 32*1024*sizeof(TCHAR); ofn.lpstrFilter = TEXT("All Formats (*.bmp;*.dds;*.jpg;*.png;*.gif)/0*.bmp;*.dds;*.jpg;*.png;*.gif/0"); ofn.nFilterIndex = 1; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_ALLOWMULTISELECT | OFN_EXPLORER; TCHAR curDirectory[MAX_PATH+1]; GetCurrentDirectory(MAX_PATH, curDirectory); BOOL bOpenFile = GetOpenFileName(&ofn); TCHAR newDirectory[MAX_PATH+1]; GetCurrentDirectory(MAX_PATH, newDirectory); SetCurrentDirectory(curDirectory); if(bOpenFile) { TSTR lpCurFile = lpFile+ofn.nFileOffset; while(lpCurFile && *lpCurFile) { String strPath; strPath << newDirectory << TEXT("//") << lpCurFile; UINT idExisting = (UINT)SendMessage(GetDlgItem(hwnd, IDC_BITMAPS), LB_FINDSTRINGEXACT, -1, (LPARAM)strPath.Array()); if(idExisting == LB_ERR) SendMessage(GetDlgItem(hwnd, IDC_BITMAPS), LB_ADDSTRING, 0, (LPARAM)strPath.Array()); lpCurFile += slen(lpCurFile)+1; } }//.........这里部分代码省略.........
开发者ID:magicpriest,项目名称:OBS,代码行数:101,
示例7: InitializepreVentrilo// do all the important initialization stuffzbool InitializepreVentrilo(){ std::ifstream fin(strSettingsFile.c_str()); std::string line; if(!std::getline(fin, line)) { char *pProg; size_t len; errno_t err = _dupenv_s( &pProg, &len, "PROGRAMFILES" ); if(!err) { settings.ventPath = pProg; settings.ventPath += "//Ventrilo//Ventrilo.exe"; free( pProg ); } else settings.ventPath = ""; } else settings.ventPath = line; if(!(fin >> settings.pauseType)) settings.pauseType = (PAUSE_TYPE_OTHERS | PAUSE_TYPE_SELF); if(!(fin >> settings.mediaPlayer)) settings.mediaPlayer = MEDIA_PLAYER_WINAMP; if(!(fin >> settings.bAdjustVolume)) settings.bAdjustVolume = true; if(!(fin >> settings.nAdjustedVolume)) settings.nAdjustedVolume = 29; fin.close(); SaveSettings(); hinstDLL = LoadLibrary("prevent.dll"); if(hinstDLL == NULL) { MessageBox(NULL, "Unable to load prevent.dll", NULL, NULL); return false; } pSetVentHook = (LPSetVentHook)GetProcAddress(hinstDLL, "SetVentHook"); pKillVentHook = GetProcAddress(hinstDLL, "KillVentHook"); pSetMediaPlayer = (LPdwhwnd)GetProcAddress(hinstDLL, "SetMediaPlayer"); pSetMuteType = (LPSetMuteType)GetProcAddress(hinstDLL, "SetMuteType"); if(pSetVentHook == NULL || pKillVentHook == NULL || pSetMediaPlayer == NULL || pSetMuteType == NULL) { MessageBox(NULL, "Unable to load DLL functions", NULL, NULL); return false; } hWndVent = FindWindow( NULL, "Ventrilo"); if(hWndVent == NULL) { if((int)ShellExecute(NULL, "open", settings.ventPath.c_str(), "", NULL, SW_SHOWNORMAL) <= 32) { MessageBox(NULL, "Please select the Ventrilo executable.", NULL, NULL); OPENFILENAME ofn; char szFileName[MAX_PATH] = ""; ZeroMemory(&ofn, sizeof(ofn)); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = NULL; ofn.lpstrFilter = "Ventrilo.exe/0Ventrilo.exe/0All Files (*.*)/0*.*/0"; ofn.lpstrFile = szFileName; ofn.nMaxFile = MAX_PATH; ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_NOCHANGEDIR; ofn.lpstrDefExt = "exe"; if(GetOpenFileName(&ofn)) { settings.ventPath = szFileName; ShellExecute(NULL, "open", settings.ventPath.c_str(), "", NULL, SW_SHOWNORMAL); } } } hThreadVent = CreateThread( NULL, // default security attributes 0, // use default stack size ThreadVentProc, // thread function NULL, // argument to thread function 0, // use default creation flags &dwThreadVentId); // returns the thread identifier if(hThreadVent == NULL) { MessageBox(NULL, "Error.", NULL, NULL); return false; } OnMediaPlayer(); return true;}
开发者ID:lloydpick,项目名称:preVentrilo,代码行数:95,
示例8: menuvoid menu(CBTYPE cbType, void* arg1){ PLUG_CB_MENUENTRY* info = (PLUG_CB_MENUENTRY*)arg1; if(info->hEntry == 1) { // get patch information size_t buffersize; size_t numPatches; std::unique_ptr<DBGPATCHINFO> patchList(nullptr); if(!(patchList = EnumPatches(buffersize, numPatches))) return; // browse OPENFILENAME browse; memset(&browse, 0, sizeof(browse)); browse.lStructSize = sizeof(browse); browse.hwndOwner = hwndDlg; browse.hInstance = hModule; wchar_t filter[512]; memset(filter, 0, sizeof(filter)); memset(templatename, 0, sizeof(templatename)); memset(exportedname, 0, sizeof(exportedname)); LoadString(hModule, IDS_FILTER, filter, 512); for(size_t i = 0; i < _countof(filter); i++) { if(filter[i] == '|') filter[i] = '/0'; } browse.lpstrFilter = filter; browse.nFilterIndex = 1; browse.lpstrFile = templatename; browse.lpstrFileTitle = nullptr; browse.nMaxFile = 512; browse.Flags = OFN_FILEMUSTEXIST; if(GetOpenFileName(&browse) == 0) return; std::wstring templateContent = LoadFile(templatename); std::wstring filterString = getTemplateFilter(templateContent); browse.lpstrFile = exportedname; browse.lpstrFilter = filterString.c_str(); browse.Flags = OFN_OVERWRITEPROMPT; if(GetSaveFileName(&browse) == 0) return; // export patches ExportPatch(templateContent, patchList.get(), numPatches); } else if(info->hEntry == 2) { // get patch information size_t buffersize; size_t numPatches; std::unique_ptr<DBGPATCHINFO> patchList(nullptr); if(!(patchList = EnumPatches(buffersize, numPatches))) return; // check last template if(wcslen(templatename) == 0) { MessageBox(hwndDlg, LoadWideString(IDS_NOLASTTEMPLATE).c_str(), LoadWideString(IDS_PLUGNAME).c_str(), MB_ICONERROR); return; } std::wstring templateContent = LoadFile(templatename); // browse OPENFILENAME browse; memset(&browse, 0, sizeof(browse)); browse.lStructSize = sizeof(browse); browse.hwndOwner = hwndDlg; browse.hInstance = hModule; wchar_t filter[512]; memset(filter, 0, sizeof(filter)); memset(exportedname, 0, sizeof(exportedname)); LoadString(hModule, IDS_FILTER, filter, 512); for(size_t i = 0; i < _countof(filter); i++) { if(filter[i] == '|') filter[i] = '/0'; } std::wstring filterString = getTemplateFilter(templateContent); browse.lpstrFile = exportedname; browse.lpstrFilter = filterString.c_str(); browse.nFilterIndex = 1; browse.lpstrFileTitle = nullptr; browse.nMaxFile = 512; browse.lpstrFile = exportedname; browse.Flags = OFN_OVERWRITEPROMPT; if(GetSaveFileName(&browse) == 0) return; // export patches ExportPatch(templateContent, patchList.get(), numPatches); } else if(info->hEntry == 3) { std::wstring text = LoadWideString(IDS_ABOUT); std::wstring compiledate; std::string compiledateASCII(__DATE__); utf8::utf8to16(compiledateASCII.begin(), compiledateASCII.end(), std::back_inserter(compiledate)); ReplaceWString(text, L"$compiledate", compiledate); MessageBox(hwndDlg, text.c_str(), LoadWideString(IDS_PLUGNAME).c_str(), MB_OK); } else { __debugbreak();//.........这里部分代码省略.........
开发者ID:blaquee,项目名称:x64dbgpatchexporter,代码行数:101,
示例9: GetWinDebugInfo//.........这里部分代码省略.........#ifndef WIN16#ifndef NO_MPW else printf("/n");#endif //NO_MPW#endif //!WIN16 } if (fArgErr || fGiveUsage) {GiveUsage: DisplayLine(szUsage); ErrorExit(); // clean up and exit(1) }#ifndef MAC // use common dialog to get input filename if user didn't specify one if (szInputFile == NULL) { szInputFile = malloc(CB_MAX_PATHNAME+1); memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME);// ofn.hwndOwner = g_hwndMain; ofn.hwndOwner = NULL; ofn.lpstrFile = szInputFile; ofn.nMaxFile = CB_MAX_PATHNAME+1; *szInputFile = '/0'; ofn.lpstrFilter = "Object Description Lang./0*.odl/0/0"; ofn.nFilterIndex = 1; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST; // if anything went wrong -- just give the usage message if (GetOpenFileName(&ofn) == 0) goto GiveUsage; }#endif //!MAC Assert(szInputFile);// now compute filenames based off the input filename if (szTypeLibFile == NULL) // if output file not specified { // use input filename with ".tlb" extension szTypeLibFile = CloneNameAddExt(szInputFile, ".tlb"); } if (fHFile && szHFile == NULL) // if header filename not specified { // use input filename with ".h" extension szHFile = CloneNameAddExt(szInputFile, ".h"); } // If output file ends up with the same name as the input file, then // the user is screwed. Just give the usage message. if (!strcmp(szInputFile, szTypeLibFile)) goto GiveUsage; // If .h file ends up with the same name as either the input file or output // file, then the user is screwed. Just give the usage message. if (szHFile && (!strcmp(szInputFile, szHFile) || !strcmp(szTypeLibFile, szHFile))) goto GiveUsage;#ifdef USE_DIMALLOC // Use the dimalloc implementation, since the default implementation
开发者ID:mingpen,项目名称:OpenNT,代码行数:67,
示例10: switch//-----------------------------------------------------------------------------// Name: MsgProc()// Desc: Message proc function to handle key and menu input//-----------------------------------------------------------------------------LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam ){ // Pass mouse messages to the ArcBall so it can build internal matrices m_ArcBall.HandleMouseMessages( hWnd, uMsg, wParam, lParam ); switch( uMsg ) { case WM_COMMAND: if ( 0 == HIWORD(wParam) ) { switch ( LOWORD(wParam) ) { case ID_FILE_OPENMESHHEIRARCHY: { OPENFILENAME ofn; memset( &ofn, 0, sizeof(ofn) ); static TCHAR file[256]; static TCHAR szFilepath[256]; static TCHAR fileTitle[256]; static TCHAR filter[] = TEXT("X files (*.x)/0*.x/0") TEXT("All Files (*.*)/0*.*/0"); _tcscpy( file, TEXT("")); _tcscpy( fileTitle, TEXT("")); ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = m_hWnd; ofn.hInstance = NULL;//m_hInstance; ofn.lpstrFilter = filter; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0L; ofn.nFilterIndex = 1L; ofn.lpstrFile = file; ofn.nMaxFile = sizeof(file); ofn.lpstrFileTitle = fileTitle; ofn.nMaxFileTitle = sizeof(fileTitle); ofn.lpstrInitialDir = NULL; ofn.nFileOffset = 0; ofn.nFileExtension = 0; ofn.lpstrDefExt = TEXT("*.x"); ofn.lCustData = 0; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY; if ( ! GetOpenFileName( &ofn) ) { TCHAR s[40]; DWORD dwErr = CommDlgExtendedError(); if ( 0 != dwErr ) { wsprintf( s, "GetOpenFileName failed with %x", dwErr ); MessageBox( m_hWnd, s, "TexWin", MB_OK | MB_SYSTEMMODAL ); } return 0; } lstrcpy(m_szPath, ofn.lpstrFile); HRESULT hr = LoadMeshHierarchy(); if (FAILED(hr)) MessageBox(NULL, "Could not open file or incorrect file type", "Error loading file", MB_OK); return 0; } case ID_OPTIONS_D3DINDEXED: { CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXED, MF_CHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DNONINDEXED, MF_UNCHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_SOFTWARESKINNING, MF_UNCHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXEDVS, MF_UNCHECKED); m_method = D3DINDEXED; break; } case ID_OPTIONS_D3DINDEXEDVS: { CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXED, MF_UNCHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DNONINDEXED, MF_UNCHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_SOFTWARESKINNING, MF_UNCHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXEDVS, MF_CHECKED); m_method = D3DINDEXEDVS; break; } case ID_OPTIONS_D3DNONINDEXED: { CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXED, MF_UNCHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DNONINDEXED, MF_CHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_SOFTWARESKINNING, MF_UNCHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXEDVS, MF_UNCHECKED); m_method = D3DNONINDEXED; break; } case ID_OPTIONS_SOFTWARESKINNING: { CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXED, MF_UNCHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DNONINDEXED, MF_UNCHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_SOFTWARESKINNING, MF_CHECKED); CheckMenuItem(GetMenu(hWnd), ID_OPTIONS_D3DINDEXEDVS, MF_UNCHECKED); m_method = SOFTWARE;//.........这里部分代码省略.........
开发者ID:grakidov,项目名称:Render3D,代码行数:101,
示例11: WMCommandProcLRESULT WINAPI WMCommandProc(HWND hWnd, UINT id, HWND hwndCtl, UINT codeNotify) { switch (codeNotify) { case BN_CLICKED: // The user pressed a button case LBN_SELCHANGE: // The user changed the selection in a ListBox control// case CBN_SELCHANGE: // The user changed the selection in a DropList control (same value as LBN_SELCHANGE) { char szBrowsePath[MAX_PATH]; int nIdx = FindControlIdx(id); // Ignore if the dialog is in the process of being created if (g_done || nIdx < 0) break; if (pFields[nIdx].nType == FIELD_BROWSEBUTTON) --nIdx; FieldType *pField = pFields + nIdx; switch (pField->nType) { case FIELD_FILEREQUEST: { OPENFILENAME ofn={0,}; ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hConfigWindow; ofn.lpstrFilter = pField->pszFilter; ofn.lpstrFile = szBrowsePath; ofn.nMaxFile = sizeof(szBrowsePath); ofn.Flags = pField->nFlags & (OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_CREATEPROMPT | OFN_EXPLORER); GetWindowText(pField->hwnd, szBrowsePath, sizeof(szBrowsePath)); tryagain: if ((pField->nFlags & FLAG_SAVEAS) ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn)) { mySetWindowText(pField->hwnd, szBrowsePath); break; } else if (szBrowsePath[0] && CommDlgExtendedError() == FNERR_INVALIDFILENAME) { szBrowsePath[0] = '/0'; goto tryagain; } break; } case FIELD_DIRREQUEST: { BROWSEINFO bi; bi.hwndOwner = hConfigWindow; bi.pidlRoot = NULL; bi.pszDisplayName = szBrowsePath; bi.lpszTitle = pField->pszText;#ifndef BIF_NEWDIALOGSTYLE#define BIF_NEWDIALOGSTYLE 0x0040#endif bi.ulFlags = BIF_STATUSTEXT | BIF_RETURNONLYFSDIRS | BIF_NEWDIALOGSTYLE; bi.lpfn = BrowseCallbackProc; bi.lParam = nIdx; bi.iImage = 0; if (pField->pszRoot) { LPSHELLFOLDER sf; ULONG eaten; LPITEMIDLIST root; int ccRoot = (lstrlen(pField->pszRoot) * 2) + 2; LPWSTR pwszRoot = (LPWSTR) MALLOC(ccRoot); MultiByteToWideChar(CP_ACP, 0, pField->pszRoot, -1, pwszRoot, ccRoot); SHGetDesktopFolder(&sf); sf->ParseDisplayName(hConfigWindow, NULL, pwszRoot, &eaten, &root, NULL); bi.pidlRoot = root; sf->Release(); FREE(pwszRoot); }// CoInitializeEx(NULL, COINIT_APARTMENTTHREADED); LPITEMIDLIST pResult = SHBrowseForFolder(&bi); if (!pResult) break; if (SHGetPathFromIDList(pResult, szBrowsePath)) { mySetWindowText(pField->hwnd, szBrowsePath); } LPMALLOC pMalloc; if (!SHGetMalloc(&pMalloc)) { pMalloc->Free(pResult); } break; } case FIELD_LINK: case FIELD_BUTTON: // Allow the state to be empty - this might be useful in conjunction // with the NOTIFY flag if (*pField->pszState) ShellExecute(hMainWindow, NULL, pField->pszState, NULL, NULL, SW_SHOWDEFAULT); break; } if (pField->nFlags & LBS_NOTIFY) { // Remember which control was activated then pretend the user clicked Next g_NotifyField = nIdx + 1; // the next button must be enabled or nsis will ignore WM_COMMAND BOOL bWasDisabled = EnableWindow(hNextButton, TRUE); FORWARD_WM_COMMAND(hMainWindow, IDOK, hNextButton, BN_CLICKED, mySendMessage);//.........这里部分代码省略.........
开发者ID:kichik,项目名称:nsis-1,代码行数:101,
示例12: DlgLuaScriptDialog//.........这里部分代码省略......... // without blocking on it or leaving a command window open. if((int)ShellExecute(NULL, "edit", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC) if((int)ShellExecute(NULL, "open", Str_Tmp, NULL, NULL, SW_SHOWNORMAL) == SE_ERR_NOASSOC) ShellExecute(NULL, NULL, "notepad", Str_Tmp, NULL, SW_SHOWNORMAL); } break; case IDC_BUTTON_LUABROWSE: { systemSoundClearBuffer(); CString filter = winResLoadFilter(IDS_FILTER_LUA); CString title = winResLoadString(IDS_SELECT_LUA_NAME); CString luaName = winGetDestFilename(theApp.gameFilename, IDS_LUA_DIR, ".lua"); CString luaDir = winGetDestDir(IDS_LUA_DIR); filter.Replace('|', '/000');// char *p = filter.GetBuffer(0);// while ((p = strchr(p, '|')) != NULL)// *p++ = 0; OPENFILENAME ofn; ZeroMemory( (LPVOID)&ofn, sizeof(OPENFILENAME) ); ofn.lpstrFile = luaName.GetBuffer(MAX_PATH); ofn.nMaxFile = MAX_PATH; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hDlg; ofn.lpstrFilter = filter; ofn.nFilterIndex = 0; ofn.lpstrInitialDir = luaDir; ofn.lpstrTitle = title; ofn.lpstrDefExt = "lua"; ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ENABLESIZING | OFN_EXPLORER; // hide previously-ignored read-only checkbox (the real read-only box is in the open-movie dialog itself) if(GetOpenFileName( &ofn )) { SetWindowText(GetDlgItem(hDlg, IDC_EDIT_LUAPATH), luaName); } return true; } break; case IDC_EDIT_LUAPATH: { char filename[MAX_PATH]; GetDlgItemText(hDlg, IDC_EDIT_LUAPATH, filename, MAX_PATH); FILE* file = fopen(filename, "rb"); EnableWindow(GetDlgItem(hDlg, IDC_BUTTON_LUAEDIT), file != NULL); if(file) fclose(file); } break; case IDC_LUACONSOLE_CHOOSEFONT: { CHOOSEFONT cf; ZeroMemory(&cf, sizeof(cf)); cf.lStructSize = sizeof(CHOOSEFONT); cf.hwndOwner = hDlg; cf.lpLogFont = &LuaConsoleLogFont; cf.Flags = CF_SCREENFONTS | CF_INITTOLOGFONTSTRUCT; if (ChooseFont(&cf)) { if (hFont) { DeleteObject(hFont); hFont = NULL; } hFont = CreateFontIndirect(&LuaConsoleLogFont); if (hFont)
开发者ID:AlcatrazTr,项目名称:vba-rerecording,代码行数:67,
示例13: __declspecvoid __declspec(dllexport) SelectFileDialog(HWND hwndParent, int string_size, TCHAR *variables, stack_t **stacktop, extra_parameters *extra){ OPENFILENAME ofn={0,}; // XXX WTF int save; TCHAR type[5]; static TCHAR path[1024]; static TCHAR filter[1024]; static TCHAR currentDirectory[1024]; static TCHAR initialDir[1024]; DWORD gfa; EXDLL_INIT(); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwndParent; ofn.lpstrFilter = filter; ofn.lpstrFile = path; ofn.nMaxFile = sizeof(path); //ofn.Flags = pField->nFlags & (OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_CREATEPROMPT | OFN_EXPLORER); ofn.Flags = OFN_CREATEPROMPT | OFN_EXPLORER; popstringn(type, sizeof(type)); popstringn(path, sizeof(path)); popstringn(filter, sizeof(filter)); save = !lstrcmpi(type, _T("save")); // Check if the path given is a folder. If it is we initialize the // ofn.lpstrInitialDir parameter gfa = GetFileAttributes(path); if ((gfa != INVALID_FILE_ATTRIBUTES) && (gfa & FILE_ATTRIBUTE_DIRECTORY)) { lstrcpy(initialDir, path); ofn.lpstrInitialDir = initialDir; path[0] = _T('/0'); // disable initial file selection as path is actually a directory } if (!filter[0]) { lstrcpy(filter, _T("All Files|*.*")); } { // Convert the filter to the format required by Windows: NULL after each // item followed by a terminating NULL TCHAR *p = filter; while (*p) // XXX take care for 1024 { if (*p == _T('|')) { *p++ = 0; } else { p = CharNext(p); } } p++; *p = 0; } GetCurrentDirectory(sizeof(currentDirectory), currentDirectory); // save working dir if ((save ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn))) { pushstring(path); } else if (CommDlgExtendedError() == FNERR_INVALIDFILENAME) { *path = _T('/0'); if ((save ? GetSaveFileName(&ofn) : GetOpenFileName(&ofn))) { pushstring(path); } else { pushstring(_T("")); } } else { pushstring(_T("")); } // restore working dir // OFN_NOCHANGEDIR doesn't always work (see MSDN) SetCurrentDirectory(currentDirectory);}
开发者ID:kichik,项目名称:nsis-1,代码行数:88,
示例14: IFRHRESULT CTestDirectWriteDlg::CreateDevInDependentResources(){ HRESULT hr = S_OK; IFR(D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, &m_pD2DFactory)); IFR(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory), reinterpret_cast<IUnknown**>(&m_pDWriteFactory))); IDWriteFontFacePtr pFontFace = NULL; IDWriteFontFilePtr pFontFiles = NULL; if (SUCCEEDED(hr)) { CString strPath; // open a file name ZeroMemory( &ofn , sizeof( ofn)); ofn.lStructSize = sizeof ( ofn ); ofn.hwndOwner = NULL ; ofn.lpstrFile = szFile ; ofn.lpstrFile[0] = '/0'; ofn.nMaxFile = sizeof( szFile ); ofn.lpstrFilter = L"All/0*.*/0Text/0*.TTF/0"; ofn.nFilterIndex =1; ofn.lpstrFileTitle = NULL ; ofn.nMaxFileTitle = 0 ; ofn.lpstrInitialDir=NULL ; ofn.Flags = OFN_PATHMUSTEXIST|OFN_FILEMUSTEXIST ; GetOpenFileName( &ofn ); // Now simpley display the file name MessageBox (ofn.lpstrFile , L"File Name" , MB_OK); strPath.ReleaseBuffer (); strPath += szFile; hr = m_pDWriteFactory->CreateFontFileReference( strPath, NULL, &pFontFiles); } IDWriteFontFile* fontFileArray[] = {pFontFiles}; if(pFontFiles==NULL) { MessageBox(L"No font file is found at executable folder", L"Error"); return E_FAIL; } IFR(m_pDWriteFactory->CreateFontFace( DWRITE_FONT_FACE_TYPE_TRUETYPE, 1, // file count fontFileArray, 0, DWRITE_FONT_SIMULATIONS_NONE, &pFontFace )); //CString szOutline = m_szOutline; CString szOutline(L"Hello!"); UINT* pCodePoints = new UINT[szOutline.GetLength()]; UINT16* pGlyphIndices = new UINT16[szOutline.GetLength()]; ZeroMemory(pCodePoints, sizeof(UINT) * szOutline.GetLength()); ZeroMemory(pGlyphIndices, sizeof(UINT16) * szOutline.GetLength()); for(int i=0; i<szOutline.GetLength(); ++i) { pCodePoints[i] = szOutline.GetAt(i); } pFontFace->GetGlyphIndicesW(pCodePoints, szOutline.GetLength(), pGlyphIndices); //Create the path geometry IFR(m_pD2DFactory->CreatePathGeometry(&m_pPathGeometry)); IFR(m_pPathGeometry->Open((ID2D1GeometrySink**)&m_pGeometrySink)); IFR(pFontFace->GetGlyphRunOutline( ConvertPointSizeToDIP(48.0f), pGlyphIndices, NULL, NULL, szOutline.GetLength(), FALSE, FALSE, m_pGeometrySink)); IFR(m_pGeometrySink->Close()); if(pCodePoints) { delete [] pCodePoints; pCodePoints = NULL; } if(pGlyphIndices) { delete [] pGlyphIndices; pGlyphIndices = NULL; }//.........这里部分代码省略.........
开发者ID:pierrejoye,项目名称:directwriteusingcustomfont,代码行数:101,
示例15: switch//.........这里部分代码省略......... HWND hwndBrowse = GetDlgItem(hwnd, IDC_BROWSE); BOOL enable = (LOWORD(wParam) == IDC_REMOVE ? FALSE : TRUE); EnableWindow(hwndPath, enable); EnableWindow(hwndBrowse, enable); break; } case IDC_BROWSE: { OPENFILENAME ofn; char initialDir[MAX_PATH] = {0x00}; uint32 size = sizeof(initialDir); char file[MAX_PATH] = {0x00}; strcpy(file, m_path); char filter[] = "MPEG Audio Streams (.mp1;.mp2;.mp3;.mpp)/0" "*.mp1;*.mp2;*.mp3;*.mpp/0" "Ogg/Vorbis Files (*.ogg)/0" "*.ogg/0" "All Files (*.*)/0" "*.*/0" "/0"; m_context->prefs->GetPrefString(kSaveMusicDirPref, initialDir, &size); // Setup open file dialog box structure ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = hwnd; ofn.hInstance = (HINSTANCE)GetWindowLong(hwnd, GWL_HINSTANCE); ofn.lpstrFilter = filter; ofn.lpstrCustomFilter = NULL; ofn.nMaxCustFilter = 0; ofn.nFilterIndex = 1; ofn.lpstrFile = file; ofn.nMaxFile = sizeof(file); ofn.lpstrFileTitle = NULL; ofn.nMaxFileTitle = 0; ofn.lpstrInitialDir = initialDir; ofn.lpstrTitle = "Locate Missing Track"; ofn.Flags = OFN_FILEMUSTEXIST | OFN_PATHMUSTEXIST | OFN_HIDEREADONLY | OFN_EXPLORER; ofn.nFileOffset = 0; ofn.nFileExtension = 0; ofn.lpstrDefExt = "MP3"; if(GetOpenFileName(&ofn)) { HWND hwndPath = GetDlgItem(hwnd, IDC_PATH); SetWindowText(hwndPath, file); strcpy(m_path, file); } break; } case IDCANCEL: { m_context->plm->RemoveItem(m_item); m_context->target->AcceptEvent(new Event(CMD_Stop)); EndDialog(hwnd, FALSE); break; } case IDOK: { HWND hwndRemove = GetDlgItem(hwnd, IDC_REMOVE); BOOL remove = Button_GetCheck(hwndRemove); if(remove) { m_context->plm->RemoveItem(m_item); } else { MissingFile mf(m_context); char url[MAX_PATH + 7]; uint32 size = sizeof(url); FilePathToURL(m_path, url, &size); mf.AcceptLocation(m_item, url); } EndDialog(hwnd, TRUE); break; } } break; } } return result;}
开发者ID:pontocom,项目名称:opensdrm,代码行数:101,
示例16: path/* XOPOpenFileDialog(prompt, fileFilterStr, fileIndexPtr, initialDir, filePath) Displays the open file dialog. Returns 0 if the user chooses a file or -1 if the user cancels or another non-zero number in the event of an error. Returns the full path to the file via filePath. In the event of a cancel, filePath is unmodified. filePath is a native path (using colons on Macintosh, backslashes on Windows). prompt sets the dialog window title. If fileFilterStr is "", then the open file dialog displays all types of files, both on Macintosh and Windows. If fileFilterStr is not "", it identifies the type of files to display. fileFilterStr provides control over the Enable popup menu which the Macintosh Navigation Manager displays in the Open File dialog. For example, the string "Text Files:TEXT,IGTX:.txt,.itx;All Files:****:;" results in two items in the Enable popup menu. The first says "Text Files" and displays any file whose Macintosh file type is TEXT or IGTX as well as any file whose file name extension is ".txt" or ".itx". The second item says "All Files" and displays all files. For further details on the fileFilterStr on Macintosh, see the comments in XOPNavOpenFileDialog. On Windows, fileFilterStr is constructed as for the lpstrFilter field of the OPENFILENAME structure for the Windows GetOpenFileName routine. For example, to allow the user to select text files and Igor Text files, use "Text Files (*.txt)/0*.txt/0Igor Text Files (*.itx)/0*.itx/0All Files (*.*)/0*.*/0/0". Note that the string ends with two null characters (/0/0). On Windows you can specify multiple extensions for a single type of file by listing the extensions with a semicolon between them. For example: "Excel Files (*.xls,*.xlsx)/0*.xls;*.xlsx/0All Files (*.*)/0*.*/0/0"); fileIndexPtr is ignored if it is NULL. If it is not NULL, then *fileIndexPtr is the one-based index of the file type filter to be initially selected. In the example given above, setting *fileIndexPtr to 2 would select the Igor Text file filter on entry to the dialog. On exit from the dialog, *fileIndexPtr is set to the index of the file filter string that the user last selected. initialDir can be "" or it can point to a full path to a directory. It determines the directory that will be initially displayed in the open file dialog. If "", the directory will be the last directory that was seen in the open or save file dialogs. If initialDir points to a valid path to a directory, then this directory will be initially displayed in the dialog. On Macintosh, initialDir is a Macintosh HFS path. On Windows, it is a Windows path. Returns via filePath the full path to the file that the user chose. filePath is unchanged if the user cancels. filePath is a Macintosh HFS path on Macintosh and a Windows path on Windows. filePath must point to a buffer of at least MAX_PATH_LEN+1 bytes. On Windows, the initial value of filePath sets the initial contents of the File Name edit control in the open file dialog. The following values are valid: "" If there is no initial file name a file name a full Mac or Win path to a file Allowed as of XOP Toolkit 5.04 On Macintosh, the initial value of filePath is not currently used. It should be set the same as for Windows because it may be used in the future. In the event of an error other than a cancel, XOPOpenFileDialog displays an error dialog. This should never or rarely happen. WINDOWS NOTES The dialog will appear in the upper left corner of the screen. This is because Windows provides no straight-forward way to set the position of the dialog. Thread Safety: XOPOpenFileDialog is not thread-safe.*/intXOPOpenFileDialog( const char* prompt, const char* fileFilterStr, int* fileIndexPtr, const char* initialDir, char filePath[MAX_PATH_LEN+1]){ OPENFILENAME ofn; char filePath2[MAX_PATH_LEN+1]; char initialDir2[MAX_PATH_LEN+1]; if (!CheckRunningInMainThread("XOPOpenFileDialog")) return NOT_IN_THREADSAFE; if (*fileFilterStr == 0) fileFilterStr = "All Files (*.*)/0*.*/0/0"; if (*initialDir == 0) { GetStandardFileWinPath(initialDir2); // Get Igor's open file dialog directory. } else { strcpy(initialDir2, initialDir); SetStandardFileWinPath(initialDir); // Sets initial directory for next open file dialog. This will be overridden below, but not if the user cancels. } //.........这里部分代码省略.........
开发者ID:jgreenb2,项目名称:DFMLoadWave,代码行数:101,
示例17: EngineDlgProcstatic INT_PTR CALLBACK EngineDlgProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam){ WORD param; BOOL bTranslated = FALSE; static bool loading = true; static int changeCount = 0; switch (uMsg) { case WM_INITDIALOG: loading = true; TranslateDialogDefault(hwndDlg); CheckDlgButton(hwndDlg, IDC_ENGINE_SILENT, Config.EngineStaySilent ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ENGINE_LOWERCASE, Config.EngineMakeLowerCase ? BST_CHECKED : BST_UNCHECKED); CheckDlgButton(hwndDlg, IDC_ENGINE_UNDERSTAND_ALWAYS, Config.EngineUnderstandAlways ? BST_CHECKED : BST_UNCHECKED); SetDlgItemText(hwndDlg, IDC_MINDFILE, Config.MindFileName); EnableWindow(GetDlgItem(hwndDlg, IDC_BTNSAVE), blInit); UpdateUnderstandAlwaysCheckbox(hwndDlg); loading = false; return TRUE; case WM_COMMAND: param = LOWORD(wParam); if (param == IDC_ENGINE_SILENT && HIWORD(wParam) == BN_CLICKED) UpdateUnderstandAlwaysCheckbox(hwndDlg); switch (param) { case IDC_BTNPATH: { const size_t fileNameSize = 5000; TCHAR *filename = new TCHAR[fileNameSize]; TCHAR *fullname = GetFullName(Config.MindFileName); mir_tstrcpy(filename, fullname); if (fullname != Config.MindFileName) delete[] fullname; OPENFILENAME ofn = { 0 }; ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = GetParent(hwndDlg); TCHAR *mind = TranslateTS(MIND_FILE_DESC); TCHAR *anyfile = TranslateTS(ALL_FILES_DESC); CMString filt(FORMAT, MIND_DIALOG_FILTER, mind, anyfile); filt.Replace('/1', '/0'); ofn.lpstrFilter = filt; ofn.lpstrFile = filename; ofn.nMaxFile = fileNameSize; ofn.Flags = OFN_FILEMUSTEXIST; ofn.lpstrInitialDir = tszPath; if (!GetOpenFileName(&ofn)) { delete[] filename; break; } TCHAR *origf = filename; TCHAR *f = filename; TCHAR *p = tszPath; while (*p && *f) { TCHAR p1 = (TCHAR)CharLower((TCHAR*)(long)*p++); TCHAR f1 = (TCHAR)CharLower((TCHAR*)(long)*f++); if (p1 != f1) break; } if (!*p) filename = f; Config.MindFileName = filename; SetDlgItemText(hwndDlg, IDC_MINDFILE, filename); delete[] origf; } case IDC_BTNRELOAD: { const TCHAR *c = Config.MindFileName; int line; bTranslated = blInit = LoadMind(c, line); if (!bTranslated) { TCHAR message[5000]; mir_sntprintf(message, TranslateTS(FAILED_TO_LOAD_BASE), line, c); MessageBox(NULL, message, TranslateTS(BOLTUN_ERROR), MB_ICONERROR | MB_TASKMODAL | MB_OK); } } break; default: if (!loading) { if (param == IDC_MINDFILE/* && HIWORD(wParam) != EN_CHANGE*/) break; SendMessage(GetParent(hwndDlg), PSM_CHANGED, 0, 0); } } break; case WM_NOTIFY: NMHDR *nmhdr = (NMHDR*)lParam; switch (nmhdr->code) { case PSN_APPLY: case PSN_KILLACTIVE: Config.EngineStaySilent = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_SILENT) == BST_CHECKED ? TRUE : FALSE; Config.EngineMakeLowerCase = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_LOWERCASE) == BST_CHECKED ? TRUE : FALSE; Config.EngineUnderstandAlways = IsDlgButtonChecked(hwndDlg, IDC_ENGINE_UNDERSTAND_ALWAYS) == BST_CHECKED ? TRUE : FALSE; UpdateEngine();//.........这里部分代码省略.........
开发者ID:Seldom,项目名称:miranda-ng,代码行数:101,
示例18: GUIGetFileNameint GUIGetFileName( gui_window *wnd, open_file_name *ofn ){ OPENFILENAME wofn; bool issave; int rc; unsigned drive;#if defined(HAVE_DRIVES) unsigned old_drive; unsigned drives;#endif LastPath = NULL; if( ofn->initial_dir != NULL && ofn->initial_dir[0] != '/0' && ofn->initial_dir[1] == ':' ) { drive = ofn->initial_dir[0]; memmove( ofn->initial_dir, ofn->initial_dir+2, strlen( ofn->initial_dir+2 ) + 1 ); } else { drive = 0; } memset( &wofn, 0 , sizeof( wofn ) ); if( ofn->flags & OFN_ISSAVE ) { issave = true; } else { issave = false; } wofn.Flags = 0; if( hookFileDlg ) { wofn.Flags |= OFN_ENABLEHOOK; } if( !(ofn->flags & OFN_CHANGEDIR) ) { wofn.Flags |= OFN_NOCHANGEDIR; } if( ofn->flags & OFN_OVERWRITEPROMPT ) { wofn.Flags |= OFN_OVERWRITEPROMPT; } if( ofn->flags & OFN_HIDEREADONLY ) { wofn.Flags |= OFN_HIDEREADONLY; } if( ofn->flags & OFN_FILEMUSTEXIST ) { wofn.Flags |= OFN_FILEMUSTEXIST; } if( ofn->flags & OFN_PATHMUSTEXIST ) { wofn.Flags |= OFN_PATHMUSTEXIST; } if( ofn->flags & OFN_ALLOWMULTISELECT ) { wofn.Flags |= OFN_ALLOWMULTISELECT; } wofn.hwndOwner = GUIGetParentFrameHWND( wnd ); wofn.hInstance = GUIMainHInst; wofn.lStructSize = sizeof( wofn ); wofn.lpstrFilter = ofn->filter_list; wofn.nFilterIndex = ofn->filter_index; wofn.lpstrFile = ofn->file_name; wofn.nMaxFile = ofn->max_file_name; wofn.lpstrFileTitle = ofn->base_file_name; wofn.nMaxFileTitle = ofn->max_base_file_name; wofn.lpstrTitle = ofn->title; wofn.lpstrInitialDir = ofn->initial_dir; wofn.lpfnHook = (LPOFNHOOKPROC)NULL; if( hookFileDlg ) { wofn.lpfnHook = (LPOFNHOOKPROC)MakeOpenFileHookProcInstance( OpenHook, GUIMainHInst ); }#if defined( HAVE_DRIVES ) if( drive ) { _dos_getdrive( &old_drive ); _dos_setdrive( tolower( drive ) - 'a' + 1, &drives ); }#endif if( issave ) { rc = GetSaveFileName( &wofn ); } else { rc = GetOpenFileName( &wofn ); } if( hookFileDlg ) { (void)FreeProcInstance( (FARPROC)wofn.lpfnHook ); } if( LastPath && ( !rc || !( ofn->flags & OFN_WANT_LAST_PATH ) ) ) { GUIMemFree( LastPath ); LastPath = NULL; } ofn->last_path = LastPath;#if defined( HAVE_DRIVES ) if( drive ) { _dos_setdrive( old_drive, &drives ); }#endif if( rc ) { return( OFN_RC_FILE_SELECTED ); } if( !CommDlgExtendedError() ) { return( OFN_RC_NO_FILE_SELECTED ); } return( OFN_RC_FAILED_TO_INITIALIZE );} /* _GUIGetFileName */
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:100,
示例19: DlgProcstatic BOOL CALLBACK DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lP) { FILE *fp; int i; const char *name, *value, **options = mg_get_valid_option_names(); switch (msg) { case WM_CLOSE: DestroyWindow(hDlg); break; case WM_COMMAND: switch (LOWORD(wParam)) { case ID_SAVE: EnableWindow(GetDlgItem(hDlg, ID_SAVE), FALSE); if ((fp = fopen(config_file, "w+")) != NULL) { save_config(hDlg, fp); fclose(fp); mg_stop(ctx); start_civetweb(__argc, __argv); } EnableWindow(GetDlgItem(hDlg, ID_SAVE), TRUE); break; case ID_RESET_DEFAULTS: for (i = 0; options[i * 2] != NULL; i++) { name = options[i * 2]; value = options[i * 2 + 1] == NULL ? "" : options[i * 2 + 1]; if (is_boolean_option(name)) { CheckDlgButton(hDlg, ID_CONTROLS + i, !strcmp(value, "yes") ? BST_CHECKED : BST_UNCHECKED); } else { SetWindowText(GetDlgItem(hDlg, ID_CONTROLS + i), value); } } break; } for (i = 0; options[i * 2] != NULL; i++) { name = options[i * 2]; if ((is_filename_option(name) || is_directory_option(name)) && LOWORD(wParam) == ID_CONTROLS + i + ID_FILE_BUTTONS_DELTA) { OPENFILENAME of; BROWSEINFO bi; char path[PATH_MAX] = ""; memset(&of, 0, sizeof(of)); of.lStructSize = sizeof(of); of.hwndOwner = (HWND) hDlg; of.lpstrFile = path; of.nMaxFile = sizeof(path); of.lpstrInitialDir = mg_get_option(ctx, "document_root"); of.Flags = OFN_CREATEPROMPT | OFN_NOCHANGEDIR; memset(&bi, 0, sizeof(bi)); bi.hwndOwner = (HWND) hDlg; bi.lpszTitle = "Choose WWW root directory:"; bi.ulFlags = BIF_RETURNONLYFSDIRS; if (is_directory_option(name)) { SHGetPathFromIDList(SHBrowseForFolder(&bi), path); } else { GetOpenFileName(&of); } if (path[0] != '/0') { SetWindowText(GetDlgItem(hDlg, ID_CONTROLS + i), path); } } } break; case WM_INITDIALOG: SendMessage(hDlg, WM_SETICON,(WPARAM) ICON_SMALL, (LPARAM) hIcon); SendMessage(hDlg, WM_SETICON,(WPARAM) ICON_BIG, (LPARAM) hIcon); SetWindowText(hDlg, "Civetweb settings"); SetFocus(GetDlgItem(hDlg, ID_SAVE)); for (i = 0; options[i * 2] != NULL; i++) { name = options[i * 2]; value = mg_get_option(ctx, name); if (is_boolean_option(name)) { CheckDlgButton(hDlg, ID_CONTROLS + i, !strcmp(value, "yes") ? BST_CHECKED : BST_UNCHECKED); } else { SetDlgItemText(hDlg, ID_CONTROLS + i, value == NULL ? "" : value); } } break; default: break; } return FALSE;}
开发者ID:DIVYPRAKASH,项目名称:civetweb,代码行数:93,
示例20: strcpyvoid IGraphicsWin::PromptForFile(WDL_String* pFilename, int action, char* dir, char* extensions){ pFilename->Set(""); if (!WindowIsOpen()) { return; } WDL_String pathStr; char fnCStr[MAX_PATH_LEN], dirCStr[MAX_PATH_LEN]; fnCStr[0] = '/0'; dirCStr[0] = '/0'; if (CSTR_NOT_EMPTY(dir)) { pathStr.Set(dir); strcpy(dirCStr, dir); } else { HostPath(&pathStr); } OPENFILENAME ofn; memset(&ofn, 0, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = mPlugWnd; ofn.lpstrFile = fnCStr; ofn.nMaxFile = MAX_PATH_LEN - 1; ofn.lpstrInitialDir = dirCStr; ofn.Flags = OFN_PATHMUSTEXIST; //if (!extensions.empty()) { //static char extStr[256]; //static char defExtStr[16]; //int i, j, p; //for (j = 0, p = 0; j < extensions.size(); ++j) { // extStr[p++] = extensions[j++]; //} //extStr[p++] = '/0'; //StrVector exts = SplitStr(extensions); //for (i = 0, p = 0; i < exts.size(); ++i) { // const std::string& ext = exts[i]; // if (i) { // extStr[p++] = ';'; // } // extStr[p++] = '*'; // extStr[p++] = '.'; // for (j = 0; j < ext.size(); ++j) { // extStr[p++] = ext[j]; // } //} //extStr[p++] = '/0'; //extStr[p++] = '/0'; //ofn.lpstrFilter = extStr; // //strcpy(defExtStr, exts.front().c_str()); //ofn.lpstrDefExt = defExtStr; //} bool rc = false; switch (action) { case kFileSave: ofn.Flags |= OFN_OVERWRITEPROMPT; rc = GetSaveFileName(&ofn); break; case kFileOpen: default: ofn.Flags |= OFN_FILEMUSTEXIST; rc = GetOpenFileName(&ofn); break; } if (rc) { pFilename->Set(ofn.lpstrFile); }}
开发者ID:tappleby,项目名称:hush-vst,代码行数:77,
示例21: WinMainint WINAPI WinMain(HINSTANCE hinstExe, HINSTANCE hinstPrev, LPSTR lpszCmdLine, int nCmdShow){ int result; TCHAR filename[MAX_PATH]; { OPENFILENAME ofn; // Pick out where our DLL is located. We need to know its location in // order to register it as a COM component lstrcpy(&filename[0], &OurDllName[0]); ZeroMemory(&ofn, sizeof(OPENFILENAME)); ofn.lStructSize = sizeof(OPENFILENAME); ofn.lpstrFilter = &FileDlgExt[0]; ofn.lpstrFile = &filename[0]; ofn.nMaxFile = MAX_PATH; ofn.lpstrTitle = &FileDlgTitle[0]; ofn.Flags = OFN_FILEMUSTEXIST|OFN_EXPLORER|OFN_PATHMUSTEXIST; result = GetOpenFileName(&ofn); } if (result > 0) { HKEY rootKey; HKEY hKey; HKEY hKey2; HKEY hkExtra; TCHAR buffer[39]; DWORD disposition; // Assume an error result = 1; // Open "HKEY_LOCAL_MACHINE/Software/Classes" if (!RegOpenKeyEx(HKEY_LOCAL_MACHINE, &ClassKeyName[0], 0, KEY_WRITE, &rootKey)) { // For a script engine to call the OLE function CLSIDFromProgID() (passing // our registered ProgID in order to get our IExample2 object's GUID), then // we need to create a subkey named with our IExample2 ProgID string. We've // decided to use the ProgID "IExample2.object" if (!RegCreateKeyEx(rootKey, &OurProgID[0], 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &hKey, &disposition)) { // Set its default value to some "friendly" string that helps // a user identify what this COM DLL is for. Setting this value // is optional. You don't need to do it RegSetValueEx(hKey, 0, 0, REG_SZ, (const BYTE *)&ObjectDescription[0], sizeof(ObjectDescription)); // Create a "CLSID" subkey whose default value is our IExample2 object's GUID (in ascii string format) if (!(disposition = RegCreateKeyEx(hKey, &CLSID_Str[0], 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &hKey2, &disposition))) { stringFromCLSID(&buffer[0], (REFCLSID)(&CLSID_IExample3)); disposition = RegSetValueEx(hKey2, 0, 0, REG_SZ, (const BYTE *)&buffer[0], lstrlen(&buffer[0]) + 1); RegCloseKey(hKey2); } RegCloseKey(hKey); if (!disposition) { // Open "HKEY_LOCAL_MACHINE/Software/Classes/CLSID" if (!RegOpenKeyEx(rootKey, &CLSID_Str[0], 0, KEY_ALL_ACCESS, &hKey)) { // Create a subkey whose name is the ascii string that represents // our IExample2 object's GUID if (!RegCreateKeyEx(hKey, &buffer[0], 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &hKey2, &disposition)) { // Set its default value to some "friendly" string that helps // a user identify what this COM DLL is for. Setting this value // is optional. You don't need to do it RegSetValueEx(hKey2, 0, 0, REG_SZ, (const BYTE *)&ObjectDescription[0], sizeof(ObjectDescription)); // Create an "InprocServer32" key whose default value is the path of this DLL if (!RegCreateKeyEx(hKey2, &InprocServer32Name[0], 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &hkExtra, &disposition)) { disposition = 1; if (!RegSetValueEx(hkExtra, 0, 0, REG_SZ, (const BYTE *)&filename[0], lstrlen(&filename[0]) + 1)) { // Create a "ThreadingModel" value set to the string "both" (ie, we don't need to restrict an // application to calling this DLL's functions only from a single thread. We don't use global // data in our IExample2 functions, so we're thread-safe) disposition = RegSetValueEx(hkExtra, &ThreadingModel[0], 0, REG_SZ, (const BYTE *)&BothStr[0], sizeof(BothStr)); } RegCloseKey(hkExtra); // Create a "ProgID" subkey whose default value is our ProgID. This allows the app to call ProgIDFromCLSID() if (!disposition && !(disposition = RegCreateKeyEx(hKey2, &ProgIDName[0], 0, 0, REG_OPTION_NON_VOLATILE, KEY_WRITE, 0, &hkExtra, &disposition))) { disposition = RegSetValueEx(hkExtra, 0, 0, REG_SZ, (const BYTE *)&OurProgID[0], sizeof(OurProgID)); RegCloseKey(hkExtra); if (!disposition) result = 0; } } RegCloseKey(hKey2); } RegCloseKey(hKey); } // Register the type lib (which is assumed to be a .TLB file in the same dir as this DLL)//.........这里部分代码省略.........
开发者ID:Budskii,项目名称:ulib-win,代码行数:101,
示例22: qt_win_get_open_file_nameQString qt_win_get_open_file_name(const QFileDialogArgs &args, QString *initialDirectory, QString *selectedFilter){ QString result; QString isel = args.selection; if (initialDirectory && initialDirectory->left(5) == QLatin1String("file:")) initialDirectory->remove(0, 5); QFileInfo fi(*initialDirectory); if (initialDirectory && !fi.isDir()) { *initialDirectory = fi.absolutePath(); if (isel.isEmpty()) isel = fi.fileName(); } if (!fi.exists()) *initialDirectory = QDir::homePath(); DWORD selFilIdx = 0; int idx = 0; if (selectedFilter) { QStringList filterLst = qt_win_make_filters_list(args.filter); idx = filterLst.indexOf(*selectedFilter); } QDialog modal_widget; modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true); modal_widget.setParent(args.parent, Qt::Window); QApplicationPrivate::enterModal(&modal_widget); bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails; OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection, args.directory, args.caption, qt_win_filter(args.filter, hideFiltersDetails), QFileDialog::ExistingFile, args.options); if (idx) ofn->nFilterIndex = idx + 1; if (GetOpenFileName(ofn)) { result = QString::fromWCharArray(ofn->lpstrFile); selFilIdx = ofn->nFilterIndex; } qt_win_clean_up_OFN(&ofn); QApplicationPrivate::leaveModal(&modal_widget); qt_win_eatMouseMove(); if (result.isEmpty()) return result; fi = result; *initialDirectory = fi.path(); if (selectedFilter) *selectedFilter = qt_win_selected_filter(args.filter, selFilIdx); return fi.absoluteFilePath();}
开发者ID:phen89,项目名称:rtqt,代码行数:61,
示例23: dlg//.........这里部分代码省略......... fileNameBuffer[ wxMAXPATH-1 ] = wxT('/0'); of.lpstrFile = fileNameBuffer; // holds returned filename of.nMaxFile = wxMAXPATH; // we must set the default extension because otherwise Windows would check // for the existing of a wrong file with wxOVERWRITE_PROMPT (i.e. if the // user types "foo" and the default extension is ".bar" we should force it // to check for "foo.bar" existence and not "foo") wxString defextBuffer; // we need it to be alive until GetSaveFileName()! if (m_dialogStyle & wxSAVE && m_dialogStyle & wxOVERWRITE_PROMPT) { const wxChar* extension = filterBuffer; int maxFilter = (int)(of.nFilterIndex*2L) - 1; for( int i = 0; i < maxFilter; i++ ) // get extension extension = extension + wxStrlen( extension ) + 1; // use dummy name a to avoid assert in AppendExtension defextBuffer = AppendExtension(wxT("a"), extension); if (defextBuffer.StartsWith(wxT("a."))) { defextBuffer.Mid(2); of.lpstrDefExt = defextBuffer.c_str(); } } // store off before the standard windows dialog can possibly change it const wxString cwdOrig = wxGetCwd(); //== Execute FileDialog >>================================================= bool success = (m_dialogStyle & wxSAVE ? GetSaveFileName(&of) : GetOpenFileName(&of)) != 0; #ifdef __WXWINCE__ DWORD errCode = GetLastError();#else DWORD errCode = CommDlgExtendedError(); // GetOpenFileName will always change the current working directory on // (according to MSDN) "Windows NT 4.0/2000/XP" because the flag // OFN_NOCHANGEDIR has no effect. If the user did not specify wxCHANGE_DIR // let's restore the current working directory to what it was before the // dialog was shown (assuming this behavior extends to Windows Server 2003 // seems safe). if ( success && (msw_flags & OFN_NOCHANGEDIR) && wxGetOsVersion() == wxWINDOWS_NT ) { wxSetWorkingDirectory(cwdOrig); } #ifdef __WIN32__ if (!success && (errCode == CDERR_STRUCTSIZE)) { // The struct size has changed so try a smaller or bigger size int oldStructSize = of.lStructSize; of.lStructSize = oldStructSize - (sizeof(void *) + 2*sizeof(DWORD)); success = (m_dialogStyle & wxSAVE) ? (GetSaveFileName(&of) != 0) : (GetOpenFileName(&of) != 0); errCode = CommDlgExtendedError(); if (!success && (errCode == CDERR_STRUCTSIZE)) {
开发者ID:ruthmagnus,项目名称:audacity,代码行数:67,
示例24: qt_win_get_open_file_namesQStringList qt_win_get_open_file_names(const QFileDialogArgs &args, QString *initialDirectory, QString *selectedFilter){ QFileInfo fi; QDir dir; if (initialDirectory && initialDirectory->left(5) == QLatin1String("file:")) initialDirectory->remove(0, 5); fi = QFileInfo(*initialDirectory); if (initialDirectory && !fi.isDir()) { *initialDirectory = fi.absolutePath(); } if (!fi.exists()) *initialDirectory = QDir::homePath(); DWORD selFilIdx = 0; QStringList filterLst = qt_win_make_filters_list(args.filter); int idx = 0; if (selectedFilter) { idx = filterLst.indexOf(*selectedFilter); } // Windows Vista (& above) allows users to search from file dialogs. If user selects // multiple files belonging to different folders from these search results, the // GetOpenFileName() will return only one folder name for all the files. To retrieve // the correct path for all selected files, we have to use Common Item Dialog interfaces.#ifndef Q_WS_WINCE if (QSysInfo::WindowsVersion >= QSysInfo::WV_VISTA && (QSysInfo::WindowsVersion & QSysInfo::WV_NT_based)) return qt_win_CID_get_open_file_names(args, initialDirectory, filterLst, selectedFilter, idx);#endif QStringList result; QDialog modal_widget; modal_widget.setAttribute(Qt::WA_NoChildEventsForParent, true); modal_widget.setParent(args.parent, Qt::Window); QApplicationPrivate::enterModal(&modal_widget); bool hideFiltersDetails = args.options & QFileDialog::HideNameFilterDetails; OPENFILENAME* ofn = qt_win_make_OFN(args.parent, args.selection, args.directory, args.caption, qt_win_filter(args.filter, hideFiltersDetails), QFileDialog::ExistingFiles, args.options); if (idx) ofn->nFilterIndex = idx + 1; if (GetOpenFileName(ofn)) { QString fileOrDir = QString::fromWCharArray(ofn->lpstrFile); selFilIdx = ofn->nFilterIndex; int offset = fileOrDir.length() + 1; if (ofn->lpstrFile[offset] == 0) { // Only one file selected; has full path fi.setFile(fileOrDir); QString res = fi.absoluteFilePath(); if (!res.isEmpty()) result.append(res); } else { // Several files selected; first string is path dir.setPath(fileOrDir); QString f; while(!(f = QString::fromWCharArray(ofn->lpstrFile + offset)).isEmpty()) { fi.setFile(dir, f); QString res = fi.absoluteFilePath(); if (!res.isEmpty()) result.append(res); offset += f.length() + 1; } } } qt_win_clean_up_OFN(&ofn); QApplicationPrivate::leaveModal(&modal_widget); qt_win_eatMouseMove(); if (!result.isEmpty()) { *initialDirectory = fi.path(); // only save the path if there is a result if (selectedFilter) *selectedFilter = qt_win_selected_filter(args.filter, selFilIdx); } return result;}
开发者ID:phen89,项目名称:rtqt,代码行数:85,
示例25: switchLRESULT CMainWindow::OnCommand(UINT nMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled){ switch (LOWORD(wParam)) { case IDM_HELPINFO: { HICON paintIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON)); TCHAR infotitle[100]; TCHAR infotext[200]; LoadString(hProgInstance, IDS_INFOTITLE, infotitle, SIZEOF(infotitle)); LoadString(hProgInstance, IDS_INFOTEXT, infotext, SIZEOF(infotext)); ShellAbout(m_hWnd, infotitle, infotext, paintIcon); DeleteObject(paintIcon); break; } case IDM_HELPHELPTOPICS: HtmlHelp(m_hWnd, _T("help//Paint.chm"), 0, 0); break; case IDM_FILEEXIT: SendMessage(WM_CLOSE, wParam, lParam); break; case IDM_FILENEW: { BOOL reset = TRUE; if (!imageModel.IsImageSaved()) { TCHAR programname[20]; TCHAR saveprompttext[100]; TCHAR temptext[500]; LoadString(hProgInstance, IDS_PROGRAMNAME, programname, SIZEOF(programname)); LoadString(hProgInstance, IDS_SAVEPROMPTTEXT, saveprompttext, SIZEOF(saveprompttext)); _stprintf(temptext, saveprompttext, filename); switch (MessageBox(temptext, programname, MB_YESNOCANCEL | MB_ICONQUESTION)) { case IDNO: imageModel.imageSaved = TRUE; //TODO: move to ImageModel break; case IDYES: saveImage(FALSE); break; case IDCANCEL: reset = FALSE; break; } } if (reset && imageModel.IsImageSaved()) //TODO: move to ImageModel { imageModel.Clear(); imageModel.ClearHistory(); } break; } case IDM_FILEOPEN: if (GetOpenFileName(&ofn) != 0) { HBITMAP bmNew = NULL; LoadDIBFromFile(&bmNew, ofn.lpstrFile, &fileTime, &fileSize, &fileHPPM, &fileVPPM); if (bmNew != NULL) { UpdateApplicationProperties(bmNew, ofn.lpstrFileTitle, ofn.lpstrFileTitle); } } break; case IDM_FILESAVE: saveImage(TRUE); break; case IDM_FILESAVEAS: saveImage(FALSE); break; case IDM_FILEPAGESETUP: // DUMMY: Shows the dialog only, no functionality PAGESETUPDLG psd; ZeroMemory(&psd, sizeof(psd)); psd.lStructSize = sizeof(psd); psd.hwndOwner = m_hWnd; PageSetupDlg(&psd); break; case IDM_FILEPRINT: // TODO: Test whether it actually works PRINTDLG pd; ZeroMemory(&pd, sizeof(pd)); pd.lStructSize = sizeof(pd); pd.hwndOwner = m_hWnd; pd.hDevMode = NULL; // freed by user pd.hDevNames = NULL; // freed by user pd.Flags = PD_USEDEVMODECOPIESANDCOLLATE | PD_RETURNDC; pd.nCopies = 1; pd.nFromPage = 0xffff; pd.nToPage = 0xffff; pd.nMinPage = 1; pd.nMaxPage = 0xffff; if (PrintDlg(&pd) == TRUE) { BitBlt(pd.hDC, 0, 0, imageModel.GetWidth(), imageModel.GetHeight(), imageModel.GetDC(), 0, 0, SRCCOPY); DeleteDC(pd.hDC); } if (pd.hDevMode) GlobalFree(pd.hDevMode); if (pd.hDevNames) GlobalFree(pd.hDevNames);//.........这里部分代码省略.........
开发者ID:GYGit,项目名称:reactos,代码行数:101,
示例26: OpenFilesXPPrevBOOL OpenFilesXPPrev(HWND hwnd, lFILEINFO *pFInfoList){ OPENFILENAME ofn; TCHAR * szBuffer, * szBufferPart; size_t stStringLength; FILEINFO fileinfoTmp = {0}; szBuffer = (TCHAR *) malloc(MAX_BUFFER_SIZE_OFN * sizeof(TCHAR)); if(szBuffer == NULL){ MessageBox(hwnd, TEXT("Error allocating buffer"), TEXT("Buffer error"), MB_OK); return FALSE; } StringCchCopy(szBuffer, MAX_BUFFER_SIZE_OFN, TEXT("")); ZeroMemory(& ofn, sizeof (OPENFILENAME)); ofn.lStructSize = sizeof (OPENFILENAME) ; ofn.hwndOwner = hwnd ; ofn.lpstrFilter = TEXT("All files/0*.*/0/0") ; ofn.lpstrFile = szBuffer ; ofn.nMaxFile = MAX_BUFFER_SIZE_OFN ; ofn.Flags = OFN_ALLOWMULTISELECT | OFN_EXPLORER | OFN_ENABLESIZING | OFN_ENABLEHOOK | OFN_NOCHANGEDIR; ofn.lpfnHook = OFNHookProc; if(!GetOpenFileName( & ofn )){ if(CommDlgExtendedError() == FNERR_BUFFERTOOSMALL){ MessageBox(hwnd, TEXT("You selected too many files. The buffers was too small. You can select as many files as you want if you use the rightclick shell extension of RapidCRC!"), TEXT("Buffer too small error"), MB_OK); } free(szBuffer); return FALSE; } fileinfoTmp.parentList = pFInfoList; // if first part of szBuffer is a directory the user selected multiple files // otherwise szBuffer is filename + path if(IsThisADirectory(szBuffer)){ // the first part in szBuffer is the path; // the other parts are filenames without path szBufferPart = szBuffer; StringCchCopy(pFInfoList->g_szBasePath, MAX_PATH_EX, szBufferPart); StringCchLength(szBufferPart, MAX_PATH_EX, & stStringLength); szBufferPart += stStringLength + 1; //pFileinfo = g_fileinfo_list_first_item; while(szBufferPart[0]!= TEXT('/0')){ fileinfoTmp.szFilename.Format(TEXT("%s//%s"), pFInfoList->g_szBasePath, szBufferPart); pFInfoList->fInfos.push_back(fileinfoTmp); // go to the next part the buffer StringCchLength(szBufferPart, MAX_PATH_EX, & stStringLength); szBufferPart += stStringLength + 1; } } else{ // only one file is selected fileinfoTmp.szFilename = szBuffer; pFInfoList->fInfos.push_back(fileinfoTmp); } if(ofn.Flags & OFN_READONLY) { pFInfoList->uiCmdOpts = CMD_REPARENT; } // we don't need the buffer anymore free(szBuffer); return true;}
开发者ID:andrew-tpfc,项目名称:RapidCRC-Unicode,代码行数:68,
示例27: FileOpenBOOL FileOpen (HWND hWndParent, int nStringResourceID, LPTSTR lpInputFileName) { OPENFILENAME ofn ; TCHAR szFileSpec [256] ; TCHAR szFileTitle [80] ; TCHAR szDialogTitle [80] ; HANDLE hFile ; PERFFILEHEADER FileHeader ; TCHAR aszOpenFilter[LongTextLen] ; int StringLength ; BOOL retCode ; LPTSTR pFileName = NULL ; if (strempty(lpInputFileName)) { dwCurrentDlgID = HC_PM_idDlgFileOpen ; // get the file extension strings LoadString (hInstance, nStringResourceID, aszOpenFilter, sizeof(aszOpenFilter) / sizeof(TCHAR)) ; StringLength = lstrlen (aszOpenFilter) + 1 ; LoadString (hInstance, nStringResourceID+1, &aszOpenFilter[StringLength], sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ; StringLength += lstrlen (&aszOpenFilter[StringLength]) + 1 ;#ifdef ADVANCED_PERFMON // get workspace file extension strings LoadString (hInstance, IDS_WORKSPACEFILE, &aszOpenFilter[StringLength], sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ; StringLength += lstrlen (&aszOpenFilter[StringLength]) + 1 ; LoadString (hInstance, IDS_WORKSPACEFILEEXT, &aszOpenFilter[StringLength], sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ; StringLength += lstrlen (&aszOpenFilter[StringLength]) + 1;#endif // get all file extension strings LoadString (hInstance, IDS_ALLFILES, &aszOpenFilter[StringLength], sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ; StringLength += lstrlen (&aszOpenFilter[StringLength]) + 1 ; LoadString (hInstance, IDS_ALLFILESEXT, &aszOpenFilter[StringLength], sizeof(aszOpenFilter) / sizeof(TCHAR) - StringLength) ; StringLength += lstrlen (&aszOpenFilter[StringLength]) ; // setup the end strings aszOpenFilter[StringLength+1] = aszOpenFilter[StringLength+2] = TEXT('/0') ; strclr (szFileSpec) ; strclr (szFileTitle) ; StringLoad (IDS_FILEOPEN_TITLE, szDialogTitle) ; memset (&ofn, 0, sizeof(OPENFILENAME)) ; ofn.lStructSize = sizeof(OPENFILENAME) ; ofn.hwndOwner = hWndParent ; ofn.hInstance = hInstance; ofn.lpstrTitle = szDialogTitle ; ofn.lpstrFilter = aszOpenFilter ; ofn.nFilterIndex = 1L ; ofn.lpstrFile = szFileSpec; ofn.nMaxFile = sizeof(szFileSpec); ofn.lpstrFileTitle = szFileTitle; ofn.nMaxFileTitle = sizeof(szFileTitle); ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_ENABLEHOOK ; ofn.lpfnHook = (LPOFNHOOKPROC) FileOpenHookProc ; if (!GetOpenFileName(&ofn)) { dwCurrentDlgID = 0 ; return (FALSE) ; } dwCurrentDlgID = 0 ; hFile = FileHandleOpen (szFileSpec) ; pFileName = szFileSpec ; } // NULL lpFileName else { // open the input file hFile = FileHandleOpen (lpInputFileName) ; if (hFile && hFile != INVALID_HANDLE_VALUE && SearchPath (NULL, lpInputFileName, NULL, sizeof(szFileSpec)/sizeof(TCHAR) - 1, szFileSpec, &pFileName)) { pFileName = szFileSpec ; } else { pFileName = NULL ; }//.........这里部分代码省略.........
开发者ID:mingpen,项目名称:OpenNT,代码行数:101,
示例28: VcdPlayerOpenCmd/******************************Public*Routine******************************/* VcdPlayerOpenCmd*/**************************************************************************/BOOLVcdPlayerOpenCmd( void ){ static OPENFILENAME ofn; static BOOL fFirstTime = TRUE; BOOL fRet = FALSE; TCHAR achFileName[MAXSTREAMS][MAX_PATH]; TCHAR achFilter[MAX_PATH]; LPTSTR lp; DWORD dwNumFiles = 0; if(fFirstTime) { ofn.lStructSize = sizeof(ofn); ofn.hwndOwner = hwndApp; ofn.Flags = OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_SHAREAWARE | OFN_PATHMUSTEXIST; } lstrcpy(achFilter, IdStr(STR_FILE_FILTER)); ofn.lpstrFilter = achFilter; /* ** Convert the resource string into to something suitable for ** GetOpenFileName ie. replace '#' characters with '/0' characters. */ for(lp = achFilter; *lp; lp++) { if(*lp == TEXT('#')) { *lp = TEXT('/0'); } } for (DWORD i = 0; i < MAXSTREAMS; i++) { ofn.lpstrFile = achFileName[i]; ofn.nMaxFile = sizeof(achFileName[i]) / sizeof(TCHAR); ZeroMemory(achFileName[i], sizeof(achFileName[i])); switch (i) { case 0: // load first file ofn.lpstrTitle = TEXT("Select First Media File"); break; case 1: // load first file ofn.lpstrTitle = TEXT("Select Second Media File"); break; case 2: // load first file ofn.lpstrTitle = TEXT("Select Third Media File"); break; } fRet = GetOpenFileName(&ofn); if(!fRet) { break; } dwNumFiles++; } // for i fFirstTime = FALSE; if (0 == dwNumFiles) { return fRet; } ProcessOpen(achFileName, dwNumFiles); return fRet;}
开发者ID:grakidov,项目名称:Render3D,代码行数:80,
注:本文中的GetOpenFileName函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetOpenFileNameA函数代码示例 C++ GetOpenFile函数代码示例 |