Use swflash.ocx to play flash

26 篇文章 0 订阅
4 篇文章 0 订阅

// SDK版本
 
// Use swflash.ocx to play flash 
// if it works, it is written by masterz, otherwise I don't know who writes it(*_*) 
 
//#include "stdafx.h" 
//#import "c:\windows\system32\macromed\flash\swflash.ocx" 
#import "C:\WINDOWS\system32\Macromed\Flash\Flash32_11_5_502_110.ocx" 
#include <atlbase.h> 
CComModule _Module; 
#include <atlwin.h> 
#include <windows.h>
#include "stdio.h"
#pragma comment(lib,"atl") 
#define ODS(x) OutputDebugString(x) 
#define MAX_LOADSTRING 100

// Global Variables: 

HINSTANCE hInst; // current instance 
TCHAR szTitle[MAX_LOADSTRING]; // The title bar text 
TCHAR szWindowClass[MAX_LOADSTRING]; // The title bar text 
CAxWindow m_container; 
using namespace ShockwaveFlashObjects; 
IShockwaveFlash* shwaveflash; 

HWND heditfilepath; 

// Foward declarations of functions included in this code module: 
ATOM MyRegisterClass(HINSTANCE hInstance); 
BOOL InitInstance(HINSTANCE, int); 
LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); 

int APIENTRY WinMain(HINSTANCE hInstance, 
					 HINSTANCE hPrevInstance, 
					 LPSTR lpCmdLine, 
					 int nCmdShow) 
{ 
	MSG msg; 
	// Initialize global strings 
	wsprintf(szTitle,"use flash control in sdk exe"); 
	wsprintf(szWindowClass,"flashinsdk"); 
	MyRegisterClass(hInstance); 
	CoInitialize(NULL); 
	// Perform application initialization: 
	if (!InitInstance (hInstance, nCmdShow)) 
		return FALSE; 
	while (GetMessage(&msg, NULL, 0, 0)) 
	{ 
		TranslateMessage(&msg); 
		DispatchMessage(&msg); 
	} 
	CoUninitialize(); 
	return msg.wParam; 
} 

// FUNCTION: MyRegisterClass() 
// PURPOSE: Registers the window class. 
ATOM MyRegisterClass(HINSTANCE hInstance) 
{ 
	WNDCLASSEX wcex; 
	wcex.cbSize = sizeof(WNDCLASSEX); 
	wcex.style = CS_HREDRAW | CS_VREDRAW; 
	wcex.lpfnWndProc = (WNDPROC)WndProc; 
	wcex.cbClsExtra = 0; 
	wcex.cbWndExtra = 0; 
	wcex.hInstance = hInstance; 
	wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION); 
	wcex.hCursor = LoadCursor(NULL, IDC_ARROW); 
	wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); 
	wcex.lpszMenuName = NULL;//(LPCSTR)IDC_FLSH; 
	wcex.lpszClassName = szWindowClass; 
	wcex.hIconSm = LoadIcon(NULL, IDI_APPLICATION); 
	return RegisterClassEx(&wcex); 
} 

// FUNCTION: InitInstance(HANDLE, int) 
// PURPOSE: Saves instance handle and creates main window 
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow) 
{ 
	HWND hWnd; 
	hInst = hInstance; // Store instance handle in our global variable 
	AtlAxWinInit(); 
	hWnd = CreateWindow(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW, 
		CW_USEDEFAULT, 0, CW_USEDEFAULT, 0, NULL, NULL, hInstance, NULL); 
	if (!hWnd) 
		return FALSE; 
	ShowWindow(hWnd, nCmdShow); 
	UpdateWindow(hWnd); 
	return TRUE; 
} 

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) 
{ 
	int wmId, wmEvent; 
	PAINTSTRUCT ps; 
	HDC hdc; 
	TCHAR szHello[MAX_LOADSTRING]; 
	wsprintf(szHello,"use flash control in sdk"); 
	HWND hbtnstart; 
	RECT rc; 
	switch (message) 
	{ 
	case WM_CREATE: 
		GetClientRect(hWnd, &rc ); 
		rc.top = (rc.bottom+rc.top)/2; 
		m_container.Create( hWnd, rc, LPCTSTR                                 ("ShockwaveFlash.ShockwaveFlash.1"),WS_CHILD |WS_VISIBLE |WS_HSCROLL |WS_VSCROLL );//create a browser control 
		hbtnstart=CreateWindow("BUTTON","play",WS_CHILD     |WS_VISIBLE,0,0,120,30,hWnd,(HMENU)0x100,hInst,0); 
		heditfilepath=CreateWindow("EDIT","filepath",WS_CHILD |WS_VISIBLE |WS_BORDER,0,40,420,30,hWnd,(HMENU)0x101,hInst,0); 
		SetWindowText(heditfilepath,"e:\\\\demo.swf"); 
		m_container.QueryControl( __uuidof(IShockwaveFlash), reinterpret_cast<void**>(&shwaveflash) ); 
		break; 
	case WM_SIZING: 
		GetClientRect(hWnd, &rc ); 
		rc.top = (rc.bottom+rc.top)/2; 
		m_container.MoveWindow(&rc,true); 
		break; 
	case WM_COMMAND: 
		wmId = LOWORD(wParam); 
		wmEvent = HIWORD(wParam); 
		// Parse the menu selections: 
		switch (wmId) 
		{ 
		case 0x100: 
			{ 
				ODS("0x100"); 
				char buf[256]; 
				GetWindowText(heditfilepath,buf,255); 
				_bstr_t bstr((char*)buf); 
				ODS(buf); 
				//bstr=_bstr_t("c:\\2.1.swf"); 
				shwaveflash->put_Movie(bstr); // you have to change the path here 
				shwaveflash->Play(); 
			} 
			break; 
		default: 
			return DefWindowProc(hWnd, message, wParam, lParam); 
		} 
		break; 
	case WM_PAINT: 
		hdc = BeginPaint(hWnd, &ps); 
		RECT rt; 
		GetClientRect(hWnd, &rt); 
		DrawText(hdc, szHello, strlen(szHello), &rt, DT_CENTER); 
		EndPaint(hWnd, &ps); 
		break; 
	case WM_DESTROY: 
		PostQuitMessage(0); 
		break; 
	default: 
		return DefWindowProc(hWnd, message, wParam, lParam); 
	} 
	return 0; 

}

新建window 应用程序空项目,添加一cpp文件,只为兴趣,暂时还没有深入应用

参考:http://bbs.csdn.net/topics/70132056


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值