模块的编写及其调用
来源:互联网 发布:相机软件mix 编辑:程序博客网 时间:2024/06/01 08:44
定义接口文件:
//接口文件:#pragma once#ifdef IeWeatherPlug__Exports#defineWeather_Api __declspec(dllexport) #else#define Weather_Api __declspec(dllimport)#endifclass IeWeatherPlug{public:virtual BOOL CreateWeatherWnd(HWND hMainWnd) = 0;virtual void DestroyWeatherWnd() = 0;virtual void ShowWeatherWnd()=0;virtual void HideWeatherWnd()=0;virtual void NetWorkIsConected()=0;virtual void SetCallBack(void * pFun)=0 ;virtual HWND GetWeatherWnd()=0;};extern "C" Weather_Api IeWeatherPlug* GetWeatherPlug();
模块的stdafx文件:
// stdafx.htypedef BOOL (*Fun_CallBack)(CString); extern Fun_CallBack g_CallBackFun;//stdafx.cpp Fun_CallBack g_CallBackFun=NULL;
// 接下来的文件就可以这样调用:
(*g_CallBackFun)(strPic);
定义实现类:
#pragma once
#include "ieweatherplug.h"
#include "DlgWeather.h"
class CWeatherPlug :public IeWeatherPlug{public:CWeatherPlug(void);virtual ~CWeatherPlug(void);virtual BOOL CreateWeatherWnd(HWND hMainWnd);virtual void DestroyWeatherWnd();virtual void ShowWeatherWnd();virtual void HideWeatherWnd();virtual void NetWorkIsConected();virtual void SetCallBack(void * pFun);virtual HWND GetWeatherWnd();CDlgWeather*m_pWeather;};
实现类的cpp文件:
extern "C" Weather_Api IeWeatherPlug* GetWeatherPlug(){static CWeatherPlug Weather;return&Weather;}CWeatherPlug::CWeatherPlug(void){}CWeatherPlug::~CWeatherPlug(void){}BOOL CWeatherPlug::CreateWeatherWnd(HWND hMainWnd){AFX_MANAGE_STATE(AfxGetStaticModuleState());if( m_pWeather == NULL ){m_pWeather = new CDlgWeather();m_pWeather->SetMainHwnd(hMainWnd);if( m_pWeather->Create( CDlgWeather::IDD, CWnd::FromHandle( GetDesktopWindow() ) ) ){return TRUE;}else return FALSE;}return TRUE ;}void CWeatherPlug::ShowWeatherWnd(){AFX_MANAGE_STATE(AfxGetStaticModuleState());if (m_pWeather!=NULL){if (IsWindow(m_pWeather->GetSafeHwnd())){m_pWeather->ShoweWeatherWnd();}}}void CWeatherPlug::DestroyWeatherWnd(){AFX_MANAGE_STATE(AfxGetStaticModuleState());if( m_pWeather != NULL ){if( ::IsWindow( m_pWeather->GetSafeHwnd() ) ){m_pWeather->ShowWindow( SW_HIDE );m_pWeather->DestroyWindow();}deletem_pWeather;m_pWeather = NULL;}}void CWeatherPlug::SetCallBack( void * pFun ){Fun_CallBack CallBack = (Fun_CallBack)pFun ; g_CallBackFun = CallBack ;}HWND CWeatherPlug::GetWeatherWnd(){return m_pWeather->GetSafeHwnd() ;}
// weatherStaticWnd.h#ifdef WXH_NEW_WEATHER #include "..\\..\\include\\IeWeatherPlug.h"#pragma comment(lib,"..\\..\\eWeatherExPlug\\Release\\eWeatherExPlug.lib") #endifclass CWeatherStaticWnd :public CStatic ,public IZxRenderUpdate { public:CWeatherStaticWnd(void);~CWeatherStaticWnd(void);DECLARE_MESSAGE_MAP()public:afx_msg void OnPaint();afx_msg BOOL OnEraseBkgnd(CDC* pDC);protected:virtual void PreSubclassWindow();};
实现文件:
// cpp文件:HWND g_Weather_hwnd=NULL ;CString g_sWeathImgPath;BOOL RenderWeatherCallBack( CString sWeathImgPath ){g_sWeathImgPath=sWeathImgPath ;::PostMessage(g_Weather_hwnd,WM_UPDATE_WEATHER,0,0);return TRUE ;}void CWeatherStaticWnd::PreSubclassWindow(){// TODO: 在此添加专用代码和/或调用基类g_Weather_hwnd=m_hWnd ;#ifdef WXH_NEW_WEATHERGetWeatherPlug()->CreateWeatherWnd(AfxGetMainWnd()->GetSafeHwnd());GetWeatherPlug()->SetCallBack(RenderWeatherCallBack);#endif __super::PreSubclassWindow();}
- 模块的编写及其调用
- 驱动模块及其用户空间的调用
- Python模块的编写和调用
- 用Delphi编写一个Svchost.exe调用的DLL模块
- 用Delphi编写一个Svchost.exe调用的DLL模块
- 用Delphi编写一个Svchost.exe调用的DLL模块
- 驱动模块的编写##向内核添加系统调用函数
- ISE 14.7 Verilog 语言编写的模块调用
- C 模块调用C++ 编写模块
- C 模块调用 C++ 编写模块
- linux下USB驱动及其相关研究(三) --驱动模块的编写
- apache 模块的编写
- 模块的编写
- 内核模块的编写
- VC++2005 编写只有资源文件的DLL及其调用方法
- Python编写自定义模块及调用自定义模块
- 列举系统进程及其所调用的模块文件(Delphi XE2)
- 调用模块的方法
- 翻译:如何提高和优化Lucene索引速度
- JavaWeb Servler respone 返回值的设置
- SCOM 2012 基本管理(二)
- poj 1088 滑雪
- 苹果悄悄进入企业级市场,iOS起飞,Android折翅
- 模块的编写及其调用
- Lucene Similarity (Lucene 文档评分score机制详解)
- eclipse的快捷键
- Java连接Mysql实例
- oracle系统默认用户名以及如何解决scott提示被锁的方法
- MySQL数据库备份恢复及中文乱码问题
- 耐人寻味的几个定律
- C语言嵌入式系统编程注意事项
- Hibernate的三种延迟加载