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. Gentoo:startx出现Failed to load module问题

    安装完xorg-server后,startx启动桌面环境,出现缺少模块错误. 查看log: cat /var/log/Xorg.0.log | grep EE [75.403] (EE) Failed ...

  2. running android lint has encountered a

    近期写学习android编程的的时候,每次保存.java文件的时候,总会跳出例如以下错误 这个错误不是属于程序错误,把它关掉对于编程没有不论什么影响,但每次见到这个就是不爽,希望大神可以解决一下,谢谢 ...

  3. hibernate学习系列-----(5)hibernate基本查询下篇:hibernate聚合函数、分组查询及命名查询

    在上一篇中,大致学习了hibernate的基本查询:HQL基本查询,今天,继续昨天的步伐,继续学习hibernate的基本查询..... 1.hql聚合函数,先大致列一下hql的聚合函数有哪些吧: 在 ...

  4. gitlab创建项目代码:

    cd (当前工程文件夹目录) git init     //初始化git git remote add origin http://worker.njbandou.com/KLElevator/kle ...

  5. P-Called-Party-ID 头域的应用说明

    P-Called-Party-ID 头域的适用场景 P-Called-Party-ID 适用于 UAS 须要知道在代理将目标改写为Contact 地址之前请求中Request-URI的目的AOR的情况 ...

  6. STL学习笔记(序列式容器)

    Vector Vector是一个动态数组. 1.Vector的操作函数 构造.拷贝和析构 vector<Elem> c //产生一个空vector ,其中没有任何元素 vector< ...

  7. java 字符深入知识,待整理

    '编',"编",  为什么获取到的字节数组长度不一样 http://www.cnblogs.com/yongdaimi/p/5899328.html Unicode 官网 http ...

  8. iOS将数组中的内容分拼接成字符串

    NSString *string = [array componentsJoinedByString:@","];--分隔符

  9. css进阶读书笔记

    说明:努力在十一左右,最迟双11之前掌握所有css知识要点 一.摘自<写给大家看的CSS书(第2版)>(虽然书比较旧,09年版的,但对于我这种刚入门的小菜鸟 来说,能学到的还是挺多的) 1 ...

  10. bios文字解释

    很多笔记本电脑用户由于不熟悉bios,导致在需要设置bios时不知如何下手,其实bios基本大同小异,熟悉了以后再遇到bios设置就手到擒来了. 今天我们以笔记本电脑为例,进行bios界面的解读. 1 ...