c++播放Flash文件 (三)

2014-11-24 00:33:25 · 作者: · 浏览: 18

DispatchMessage(&msg);
}
}
CoUninitialize();
return (int) msg.wParam;
}



//
// 函数: MyRegisterClass()
//
// 目的: 注册窗口类。
//
ATOM MyRegisterClass(HINSTANCE hInstance)
{
WNDCLASSEX wcex;

wcex.cbSize = sizeof(WNDCLASSEX);

wcex.style = CS_HREDRAW | CS_VREDRAW;
wcex.lpfnWndProc = WndProc;
wcex.cbClsExtra = 0;
wcex.cbWndExtra = 0;
wcex.hInstance = hInstance;
wcex.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_WIN32PROJECT7));
wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
wcex.lpszMenuName = MAKEINTRESOURCE(IDC_WIN32PROJECT7);
wcex.lpszClassName = szWindowClass;
wcex.hIconSm = LoadIcon(wcex.hInstance, MAKEINTRESOURCE(IDI_SMALL));

return RegisterClassEx(&wcex);
}

//
// 函数: InitInstance(HINSTANCE, int)
//
// 目的: 保存实例句柄并创建主窗口
//
// 注释:
//
// 在此函数中,我们在全局变量中保存实例句柄并
// 创建和显示主程序窗口。
//
BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
{
HWND hWnd;

hInst = hInstance; // 将实例句柄存储在全局变量中


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;
}

//
// 函数: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// 目的: 处理主窗口的消息。
//
// WM_COMMAND - 处理应用程序菜单
// WM_PAINT - 绘制主窗口
// WM_DESTROY - 发送退出消息并返回
//
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
int wmId, wmEvent;
PAINTSTRUCT ps;
HDC hdc;

RECT rc = {0, 0, 300, 300 };
RECT rc1 = {0, 0, 600, 300 };
HWND hwnd_tmp= NULL;
HWND hwnd_tmp1= NULL;
CAxWindow m_pWinContainer;
static CComPtr pFlash;
static FlashSink flashSink;

CAxWindow m_pWinContainer1;
static CComPtr pFlash1;
static FlashSink flashSink1;


switch (message)
{
case WM_CREATE:
AllocConsole();
freopen("CONOUT$","w+t", stdout);
SetWindowPos(hWnd,NULL,0,0,1024,768,SWP_NOMOVE);
GetClientRect(hWnd,&rc);
GetWindowRect(hWnd,&rc1);
POINT tmpPoint;
tmpPoint.x = rc1.left;
tmpPoint.y = rc1.top;
ScreenToClient(hWnd,&tmpPoint);

rc1.left -= tmpPoint.x;
rc1.top -= tmpPoint.y;

tmpPoint.x = rc.right;
tmpPoint.y = rc.bottom;
ClientToScreen(hWnd,&tmpPoint);

rc1.right = tmpPoint.x;
rc1.bottom = tmpPoint.y;

hwnd_tmp=m_pWinContainer.Create(hWnd,rc,TEXT("ShockwaveFlash.ShockwaveFlash"),WS_CHILD|WS_VISIBLE);
hwnd_tmp1=m_pWinContainer1.Create(hWnd,rc1,TEXT("ShockwaveFlash.ShockwaveFlash"),WS_POPUPWINDOW|WS_VISIBLE,WS_EX_LAYERED);
SetLayeredWindowAttributes(hwnd_tmp1, 0, 123, LWA_ALPHA);
printf("%d",GetLastError());

if (NULL == hwnd_tmp)
{
printf("%s","句柄为空");
}
if (NULL == hwnd_tmp1)
{
printf("%s","窗