Use the program to control the flash control (talk about the self-starting program for CD)

zhaozj2021-02-08  209

The current Flash is very popular, and flash provides IE in the form of controls. Since it is a control, we can control it with VC or other languages. The playback function of the flash control is very good, it has a powerful command fscommand, which can be used to send messages to the application, intercept this message, we can implement a lot of functions. This will combine the power of flash's beautiful interface and VC!

Let's use the flash control to do CD as an example: CD self-starting procedure is generally an interface after running, there is a different installation item, here should first make a flash animation, a beautiful interface, plus a few The button, the point different button, gives different fscommand commands. The fscommand is two strings by the command. Responding to the FSCommand event application may get these two strings, the designs can refer to Flash animation related books, this is not explained to establish a single document without VIEW / DOC, Import the flash control, can be seen from the header file Shockwaveflash.h, we may control a lot of details, here, I only turn over the Create and SetMovie functions

virtual BOOL Create (LPCTSTR lpszClassName, LPCTSTR lpszWindowName, DWORD dwStyle, const RECT & rect, CWnd * pParentWnd, UINT nID, CCreateContext * pContext = NULL) {return CreateControl (GetClsid (), lpszWindowName, dwStyle, rect, pParentWnd, nID);} Void SetMovie (LPCTSTR LPSZNEWVALUE);

Add a Flash control, method, define public: cshockwaveflash m_flash; overcreate over the header file in the header file; overcreate with CchildView

INT cchildview :: oncreate (lpcreatestruct lpcreatestruct) {if (CWnd :: oncreate (lpcreateStruct) == -1) Return -1; m_flash.create (null, null, ws_child | WS_Visible, CRECT (0, 0, 0) , this, flashid; m_flash.setmovie (SzWorkPath "Autorun.swf"); return 0;}

The above setmovie parameters are the full file name of the flash file.

Finally, the fscommand command in response to the animation, that is, in response to Fscommand events in CChildView

Begin_Eventsink_Map (CchildView, CWND) ON_EVENT (CchildView, FlashID, 150 / * fscommand * /, onfscommandflash, vts_bstr vts_bstr) end_eventsink_map ()

afx_msg void CChildView :: OnFSCommandFlash (LPCTSTR command, LPCTSTR args) {if (strcmp (command, "quit") == 0) {m_flash.Stop (); AfxGetMainWnd () -> PostMessage (WM_CLOSE);} else if (strcmp (Command, "SetupPath") == 0) DORUN (ARGS); Else IF (strcmp (strcmp (command, "openpath") == 0) DoExplore (args); else {}} where command and args are fscommand issued two String, because Command, and Args content are determined by the animation file autorun.swf, change Autorun.swf can have different CD self-starting programs. In the above example, there is a button that is {"Quit", ""} to exit another button is {"openpath", ""} to open the current directory there are still {"setuppath" "Soft1 / setup.exe"} To run the setup.exe under Soft1, Soft1 is installed in Soft1. Similarly, the button may also be sent is {"setuppath", "Soft2 / setup.exe"} installed Soft2 {" Setuppath "," Soft3 / Setup.exe "} is not very simple to install Soft3

转载请注明原文地址:https://www.9cbs.com/read-1755.html

New Post(0)