当前位置: 首页>>代码示例>>C++>>正文


C++ GetOpenFileName函数代码示例

本文整理汇总了C++中GetOpenFileName函数的典型用法代码示例。如果您正苦于以下问题:C++ GetOpenFileName函数的具体用法?C++ GetOpenFileName怎么用?C++ GetOpenFileName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了GetOpenFileName函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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,代码来源:main.cpp

示例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,代码来源:QIFileDialog.cpp

示例3: GbaSlotCFlash

INT_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,代码来源:gbaslot_config.cpp

示例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,代码来源:optimizedmesh.cpp

示例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,代码来源:FileSelector.cpp

示例6: ConfigureBitmapTransitionProc

INT_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,代码来源:BitmapTransitionSource.cpp

示例7: InitializepreVentrilo

// do all the important initialization stuffz
bool 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,代码来源:preVentrilo.cpp

示例8: menu

void 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,代码来源:pluginmain.cpp

示例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,代码来源:mktyplib.c

示例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,代码来源:skinnedmesh.cpp

示例11: WMCommandProc

LRESULT 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,代码来源:InstallerOptions.cpp

示例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,代码来源:LuaOpenDialog.cpp

示例13: __declspec

void __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,代码来源:browse.c

示例14: IFR

HRESULT 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,代码来源:TestDirectWriteDlg.cpp

示例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,代码来源:MissingFileDialog.cpp


注:本文中的GetOpenFileName函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。