C ++/CLI中的Media Player,OpenDialog框问题 [英] Media Player in C++/CLI, OpenDialog box question

查看:56
本文介绍了C ++/CLI中的Media Player,OpenDialog框问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,人民,

我正在编写一个媒体播放器,并且停留在打开的对话框代码中.

我已经制作好了媒体播放器,并且可以正常工作,这只是我无法继续查找可以在其中播放的文件的问题.当我单击打开"时,下拉菜单消失了.

希望有人能帮忙

谢谢!!

Hey peoples,

I''m writing up a media player and I''m stuck at the open dialog box code.

I''ve made the media player, and it works without errors, only problem I cant go on to find a file that can be played in it. All it does when I click on open is the drop down menu disappears.

Hope someone can help

Thanks!!

// openToolStripMenuItem
        //
        this->openToolStripMenuItem->Name = L"openToolStripMenuItem";
        this->openToolStripMenuItem->Size = System::Drawing::Size(152, 22);
        this->openToolStripMenuItem->Text = L"Open";
        this->openToolStripMenuItem->Click += gcnew System::EventHandler(this, &Form1::openToolStripMenuItem_Click);



抱歉,我还没有那么出色,只是刚开始不得不再次使用C ++进行编程.



Sorry I''m not that great with all this, only just started having to program in C++ again

推荐答案

代码并不是魔术.仅仅因为某些东西被命名为open,它不会自动弹出一个加载对话框.
您需要提供代码以显示对话框.有一些方法可以从设计器生成打开和保存对话框,但是我一年多没有接触托管代码了,所以我不记得了.
这是我最新的C ++/CLI作业中的代码,进行了一些更改以适合您的解决方案.

Code isn''t magic. It wont automatically bring up a load dialog just because something is named open.
You need to provide code to show the dialog. There is some way of generating the open and save dialogs from the designer, but I havn''t touched managed code in over a year now so I don''t remember.
This is the code from my latest C++/CLI assignment with a few changes to fit your solution.

namespace MoviePlayer { //Your namespace name
	public ref class Player : public System::Windows::Forms::Form { //Your class name
		//With all the other variable declarations
		private: System::Windows::Forms::OpenFileDialog^ FileLoadDialog;
		void InitializeComponent(void) {
			//All the other generated component inits
			this->FileLoadDialog = (gcnew System::Windows::Forms::OpenFileDialog());
			this->FileLoadDialog->Title = L"Load File";
		}
		private: System::Void openToolStripMenuItem_Click(System::Object^ sender, System::EventArgs^ e) {
			FileLoadDialog->DefaultExt = "avi";
			FileLoadDialog->Filter = 
				"All Video Files (*.avi;*.mkv)|*.avi;*.mkv|"
				"AVI Files (*.avi)|*.avi|"
				"Matroska Files (*.mkv)|*.mkv|"
				"All Files (*.*)|*";
			if (FileLoadDialog->ShowDialog() == ::DialogResult::OK) {
				OpenMovie(FileLoadDialog->FileName); //Or whatever
			}
		}
	}
}


这篇关于C ++/CLI中的Media Player,OpenDialog框问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆