Wu.Country@侠缘

勤学似春起之苗,不见其增,日有所长; 辍学如磨刀之石,不见其损,日所有亏!

导航

[导入]How to play a flash with C#

How to play a flash with C#

First of all, you should know flash is a ActiveX controls, so it's has the common interface like other ActiveX controls. But the C#, is running in the protected environment, so you can not use the ActiveX Controls such as COM controls like the way in VC++. But, it's also very easy to use it.

Firt, set a new project, just windows appliction.

Second, you can add the Flash control to your tool bar. Please be sure, your computer must be set up this ActiveX control. You can find the file (Flash.ocx) on your computer in the directory of "C:\WINDOWS\system32\Macromed\Flash\Flash.ocx". Add it.

Then, your can drag the ActriveX controls to your Windows application like other controls. After that, you can set some property for is. You muset set the file path(must be full path) to play the SWF file. You also can add the SWF file into your application, but it will increase the size of you project(maybe very large).

Give another secret, there is a file GetFlash.exe at your computer(if you have set up the Flash Control). The pathe is: "C:\WINDOWS\system32\Macromed\Flash\", you can get update the FlashPlayer by run this file, is can update your FlashPlayer automately.

You can fliter the keyboard message by setting the property of the Form. But I have not find anyway to filter the message which send by right button of mouse in C#, but it is very easily to do this in C++.

Filter the keyboard message.
First, set the property.
this.KeyPreview = true;
This property is false by default, the form will not to filter the keyboard message when this propterty is "false". Then you should wirte a function to filter the message.
  private void Form1_KeyDown(object sender, System.Windows.Forms.KeyEventArgs e)
  {
  
  }

  private void Form1_KeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
  {
  
  }

  private void Form1_KeyUp(object sender, System.Windows.Forms.KeyEventArgs e)
  {
  
  }
This three funcitons should be defined and do something which you whant to filter the message. You can set the "e.Handled = true;", that means, the message have been disposal, then the child Control will nolonger to deal with this message.
For example, you can filter some speciall KeyCode like this:
   if(e.KeyCode==32)
   {
    //to do something
    e.Handled = true;
   }
OK, I will find anyway to filter the


文章来源:http://computer.mblogger.cn/wucountry/posts/45358.aspx

posted on 2005-09-06 01:47  Wu.Country@侠缘  阅读(342)  评论(0编辑  收藏  举报