質問

in my windows form project, in C++ , visual 2010, I'm using this line with this purpose that user just select this types of files:

openFileDialog1->Filter =  "Image Files(*.png, *.jpg)|*.png;*.jpg";

this line is written before openfiledialog1->ShowDialog();

but when I run the project and open the OpenFileDialog, I can see files in other format, such as *.txt.

where is my fault?

thank you so much ...

役に立ちましたか?

解決

The documentation for what you are trying to do is here: http://msdn.microsoft.com/en-us/library/ms646839(v=vs.85).aspx

The string needs to be formatted using nulls as delimiters for the different sections of a filter. So, your string should be formatted as follows:

openFileDialog1->Filter =  "Image Files (*.png, *.jpg)\0*.png;*.jpg\0";

他のヒント

Probably the comma should be a semicolon. Maybe the space (after that comma) is not allowed either.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top