Comments (4)
I think you can ask the user for filename in console not in your code itself!
from random.
But I can open a open file dialog in just three lines! Haha!
from random.
You can use this
#include "windows.h"
OPENFILENAME ofn;
static TCHAR szFileName[MAX_PATH], szTitleName[MAX_PATH];
static TCHAR szFilter[] = TEXT("PDF Files (.pdf)\0.pdf\0")
TEXT("All Files (.)\0*.*\0\0");
ZeroMemory(&ofn, sizeof(ofn));
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFileTitle = szTitleName;
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrFilter = szFilter;
ofn.lpstrDefExt = TEXT("pdf");
ofn.lpstrTitle = NULL;
ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
ofn.lStructSize = sizeof(OPENFILENAME); // No OFN_ENABLEHOOK
ofn.hwndOwner = m_hWnd;
if (GetOpenFileName(&ofn))
{
MessageBox(szFileName)克雄
首页 » C/C++ » Win32打开文件/保存文件/选择文件夹对话框
Win32打开文件/保存文件/选择文件夹对话框 2
This entry was posted in C/C++ MFC Win32 Windows and tagged C++ MFC VC++ Win32 对话框 on 2016年7月27日 by Next
-
效果图
-
打开文件
OPENFILENAME ofn;
static TCHAR szFileName[MAX_PATH], szTitleName[MAX_PATH];
static TCHAR szFilter[] = TEXT("PDF Files (.pdf)\0.pdf\0")
TEXT("All Files (.)\0*.*\0\0");
ZeroMemory(&ofn, sizeof(ofn));
ofn.lpstrFile = szFileName;
ofn.nMaxFile = MAX_PATH;
ofn.lpstrFileTitle = szTitleName;
ofn.nMaxFileTitle = MAX_PATH;
ofn.lpstrFilter = szFilter;
ofn.lpstrDefExt = TEXT("pdf");
ofn.lpstrTitle = NULL;
ofn.Flags = OFN_HIDEREADONLY | OFN_PATHMUSTEXIST;
ofn.lStructSize = sizeof(OPENFILENAME); // No OFN_ENABLEHOOK
ofn.hwndOwner = m_hWnd;
if (GetOpenFileName(&ofn))
{
freopen(szfilename,"r",stdin);
//Your code here
}
I am too lazy to send a pull request
from random.
filter自己改一下
from random.
Related Issues (4)
- 您可以archive这个repo了 HOT 1
- 您可以在网页上画一个文本框用来输入花名册 HOT 1
- 我觉得用JSON存储设置比用JS好
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from random.