FILE.CPP
资源名称:MSDN_VC98.zip [点击查看]
上传用户:bangxh
上传日期:2007-01-31
资源大小:42235k
文件大小:2k
源码类别:
Windows编程
开发平台:
Visual C++
- /*==========================================================================
- *
- * Copyright (C) 1995, 1996 Microsoft Corporation. All Rights Reserved.
- *
- * File: file.cpp
- *
- ***************************************************************************/
- #include <d3drmwin.h>
- #include "viewer.h"
- #include <windows.h>
- #include <stdio.h>
- #include <string.h>
- #include <commdlg.h>
- char* OpenNewFile( HWND hwnd, const char *wndTitle )
- {
- static char file[256];
- static char fileTitle[256];
- static char filter[] = "X files (*.x) *.x "
- "All Files (*.*) *.* ";
- OPENFILENAME ofn;
- lstrcpy( file, "");
- lstrcpy( fileTitle, "");
- ofn.lStructSize = sizeof(OPENFILENAME);
- ofn.hwndOwner = hwnd;
- #ifdef WIN32
- ofn.hInstance = (HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE);
- #else
- ofn.hInstance = (HINSTANCE) GetWindowWord(hwnd, GWW_HINSTANCE);
- #endif
- ofn.lpstrFilter = filter;
- ofn.lpstrCustomFilter = (LPSTR) 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.lpstrTitle = wndTitle;
- ofn.nFileOffset = 0;
- ofn.nFileExtension = 0;
- ofn.lpstrDefExt = "*.x";
- ofn.lCustData = 0;
- ofn.Flags = OFN_SHOWHELP | OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
- if (GetOpenFileName(&ofn))
- return (char*)ofn.lpstrFile;
- else
- return NULL;
- }