c++操作falsh,忘了原文在哪了,自己尝试了,直接贴代码

 // 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_8_800_94.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, _T("use flash control in sdk exe"));
wsprintf(szWindowClass, _T("flashinsdk"));
MyRegisterClass(hInstance);
CoInitialize(NULL);
// Perform application initialization:
if (!InitInstance (hInstance, nCmdShow))
return FALSE;
while (GetMessage(&msg, NULL, , ))
{
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 = ;
wcex.cbWndExtra = ;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+);
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, , CW_USEDEFAULT, , 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, _T("use flash control in sdk"));
HWND hbtnstart;
RECT rc;
switch (message)
{
case WM_CREATE:
GetClientRect(hWnd, &rc );
rc.top = ;
m_container.Create( hWnd, rc, _T("{D27CDB6E-AE6D-11cf-96B8-444553540000}"),WS_CHILD |WS_VISIBLE |WS_HSCROLL |WS_VSCROLL );//create a browser control
hbtnstart=CreateWindow(_T("BUTTON"), _T("play"), WS_CHILD|WS_VISIBLE,,,,,hWnd,(HMENU)0x100,hInst,);
heditfilepath=CreateWindow(_T("EDIT"), _T("filepath"),WS_CHILD |WS_VISIBLE |WS_BORDER,,,,,hWnd,(HMENU)0x101,hInst,);
SetWindowText(heditfilepath, _T("E:\\test\\c++\\flashocx\\Debug\\loginui.swf"));
m_container.QueryControl( __uuidof(IShockwaveFlash), reinterpret_cast<void**>(&shwaveflash) );
break;
case WM_SIZING:
GetClientRect(hWnd, &rc );
rc.top = ;
m_container.MoveWindow(&rc,true);
shwaveflash->SetZoomRect( , , rc.right - rc.left, rc.bottom - rc.top );
break;
case WM_COMMAND:
wmId = LOWORD(wParam);
wmEvent = HIWORD(wParam);
// Parse the menu selections:
switch (wmId)
{
case 0x100:
{
ODS(_T("0x100"));
wchar_t buf[];
GetWindowText(heditfilepath, (LPWSTR)buf,);
_bstr_t bstr((wchar_t*)buf);
//ODS(buf);
//bstr=_bstr_t(_T("c:\\2.1.swf"));
//bstr=_bstr_t(_T("E:\\test\\c++\\flashocx\\Debug\\loginui.swf"));
if(shwaveflash->put_Movie(bstr)!=S_OK){// you have to change the path here
ODS(_T("load movie error"));
}else{
shwaveflash->Play();
shwaveflash->SetVariable(_bstr_t(_T("user")), _bstr_t(_T("testuser")));
shwaveflash->SetVariable(_bstr_t(_T("password")), _bstr_t(_T("password")));
GetClientRect(hWnd, &rc );
shwaveflash->SetZoomRect( , , rc.right - rc.left, rc.bottom - rc.top );
shwaveflash->PutMenu( false );
}
}
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((const char*)szHello), &rt, DT_CENTER);
EndPaint(hWnd, &ps);
break;
case WM_DESTROY:
PostQuitMessage();
break;
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
return ; }

下面是尝试的swf

http://files.cnblogs.com/marcher/loginui.swf

c++操作flash的更多相关文章

  1. C#操作Flash动画

    对于在C#开发的过程中没有接触过Flash相关开发的人员来说,没有系统的资料进行学习,那么这篇文档针对于初学者来说是很好的学习DEMO. 本文章中的DEMO实现了C#的COM控件库中本来就带有对fla ...

  2. STM32F10X SPI操作flash MX25L64读写数据(转)

    源:STM32F10X SPI操作flash MX25L64读写数据 前一段时间在弄SPI,之前没接触过嵌入式外围应用,就是单片机也只接触过串口通信,且也是在学校的时候了.从离开手机硬件测试岗位后,自 ...

  3. selenium自动化过程中如何操作Flash动画

    最近在看python的爬虫框架(scrapy),一个词概括就是:"酸爽"!等把selenium自动化版块讲完后,打算写一写关于scrapy相关的知识,打算从源码角度解析下scrap ...

  4. SPI操作flash MX25L64读写数据

    STM32F10X SPI操作flash MX25L64读写数据 简单的一种应用,ARM芯片作为master,flash为slaver,实现单对单通信.ARM主控芯片STM32F103,flash芯片 ...

  5. Selenium+Java - 结合sikuliX操作Flash网页

    前言 前天被一个Flash的轮播图,给玩坏了,无法操作,后来请教了下crazy总拿到思路,今天实践了下,果然可以了,非常感谢! 模拟场景 打开百度地图 切换城市到北京 使用测距工具 测量 奥林匹克森林 ...

  6. Delphi 操作Flash D7~XE10都有 导入Activex控件 shockwave

    http://www.cnblogs.com/devcjq/articles/2906224.html Flash是Macromedia公司出品的,用在互联网上动态的.可互动的shockwave.它的 ...

  7. STM32的SPI2操作Flash

    关于STM32F107的SPI标志 SPI_I2S_FLAG_BSY和SPI_I2S_FLAG_TXE的疑问  http://www.openedv.com/posts/list/23579.htm ...

  8. selenium结合sikuliX操作Flash网页

    sikuli的官网地址:http://www.sikuli.org 首先下载sikuliX的jar包:https://launchpad.net/sikuli/sikulix/1.1.0 java-d ...

  9. MSP430 flash的操作

    今天顺便研究了一下msp430的flash操作,很多人也许看了我的博客,会发现网站上有很多的人总结得比我要好,这点我承认,因为自己能力有限,但是,从这篇博客起,我会参照以前大神们写的博客,添加大神们写 ...

随机推荐

  1. POJ 1040 Transportation

    链接:http://poj.org/problem?id=1040 Transportation Time Limit: 1000MS Memory Limit: 10000K Total Submi ...

  2. 学习Opencv 2.4.9(二) ---操作像素

    作者:咕唧咕唧liukun321 来自:http://blog.csdn.net/liukun321 本质上说一张图像就是由数值组成的矩阵.Opencv 2.x由 cv::Mat 这个数据结构来表示一 ...

  3. apache环境下禁止某文件夹内运行PHP脚本、禁止访问文件或目录执行权限的设置方法

    apache环境下禁止某文件夹内运行PHP脚本.禁止访问文件或目录执行权限的设置方法   首先我们来看两段对上传目录设置无权限的列子,配置如下: <Directory "要去掉PHP执 ...

  4. html头部转码

    学习html是件比较容易的事情,但单单学html语言肯定是不够用的,所以大多数人并没有拿html作为学习核心,而是将html作为javascript.动态语言或者css学习的必经之路.于是很多人并不关 ...

  5. C#常见的概念阐述

    在上篇文章中,你跟着我写了一个HelloWorld,本篇中,我们来谈谈一些C#程序中的小概念 1.C# 程序结构 一个 C# 程序主要包括以下部分: 命名空间声明(Namespace declarat ...

  6. C#IAsyncResult异步回调函数的解释

    问题:IAsyncResult ar 是如何通过ar.AsyncState强制转换成TCPClientState类型 答:实例中使用的方法如下 我给IAsyncResult ar传入了TCPClien ...

  7. Iocomp控件教程之LinearGauge--线性刻度尺控件

    线性刻度尺-线性刻度尺控件(LinearGauge)是一个具有线性表达式刻度的图像控件.支持多达5种颜色断面和4种指示器样式,相同功能,查看线性对数刻度尺(Linear Log Gauge)控件内容 ...

  8. MapReduce小文件处理之CombineFileInputFormat实现

    在MapReduce使用过程中.一般会遇到输入文件特别小(几百KB.几十MB).而Hadoop默认会为每一个文件向yarn申请一个container启动map,container的启动关闭是很耗时的. ...

  9. Python学习笔记(一)三步走安装pip

    pip是用来方便地管理Python的第三方包的,由于此前玩Python仅仅是浅尝辄止,用的是python(x,y),但是这里并不代表你想用什么包都能从里面找到的,所以我把python(x,y)卸了,然 ...

  10. 李洪强经典面试题40-可能碰到的iOS笔试面试题-C语言

    可能碰到的iOS笔试面试题(4)--C语言 可能碰到的iOS笔试面试题(4)--C语言 C语言,开发的基础功底,iOS很多高级应用都要和C语言打交道,所以,C语言在iOS开发中的重要性,你懂的.里面的 ...