我有一个现成的OCX控件(不是自己做的)由于提供的方法有限,我想再做一个OCX
控件,包含该OCX控件,以提供更多的方法和属性给VB程序使用,具体怎样实现OCX的
嵌套
控件,包含该OCX控件,以提供更多的方法和属性给VB程序使用,具体怎样实现OCX的
嵌套
解决方案 »
- 编辑框背景颜色的问题
- 安装VC6.0++ 提示:检测到潜在的冲突?
- ping的问题
- 如何制作浏览器插件?就是工具条那种
- 寻觅基于 Class 的 Windows SDK 程序框架,高手请进!!
- 【求助】MsgWaitForMultipleObjects 函数的问题
- mfc 连接MSSQL服务器 SA登录失败
- 在我们学校我们系的网络断了,但是,我的 可以上网,我是不是可以,通过我的电脑,来让所有的机器上网,是不是要装两个网卡,我现在已经安装了REDHAT LINUX,
- 解密ZIP文件的密码Advanced ZIP Password Recovery软件真的好用,只可惜未注册最长只能解五位密码!!!
- ActiveX.dll和Active.exe有什么区别?
- 关于MFC,提问,希望老鸟帮助.谢谢
- 郁闷死了,在用VC6的时候(其它时候没有)机子自动重启,平均3~6次每天,又不像是中毒..
#include "stdafx.h"
#define MAX_LOADSTRING 100
#include <atlbase.h>
CComModule _Module;
#include <atlcom.h>
#include <atlwin.h>
#pragma comment(lib,"atl")
#import "c:\winnt\system32\macromed\flash\swflash.ocx"
using namespace ShockwaveFlashObjects;// 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;// 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;
}
// Main message loop:
while (GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
CoUninitialize();
return msg.wParam;
}
//
// FUNCTION: MyRegisterClass()
//
// PURPOSE: Registers the window class.
//
// COMMENTS:
//
// This function and its usage is only necessary if you want this code
// to be compatible with Win32 systems prior to the 'RegisterClassEx'
// function that was added to Windows 95. It is important to call this function
// so that the application will get 'well formed' small icons associated
// with it.
//
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
//
// COMMENTS:
//
// In this function, we save the instance handle in a global variable and
// create and display the main program 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;
}//
// FUNCTION: WndProc(HWND, unsigned, WORD, LONG)
//
// PURPOSE: Processes messages for the main window.
//
// WM_COMMAND - process the application menu
// WM_PAINT - Paint the main window
// WM_DESTROY - post a quit message and return
//
//
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");
IShockwaveFlash* shwaveflash;
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);
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:
m_container.QueryControl( __uuidof(IShockwaveFlash), reinterpret_cast<void**>(&shwaveflash) );
shwaveflash->put_Movie(_bstr_t("c:\\downloads\\radin\\flash\\2.1.swf")); // 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);
// TODO: Add any drawing code here...
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;
}