#include "stdafx.h"
#include "WndBase.h"
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CWndBase::CWndBase():
m_hWnd(NULL),
m_hWndParent(NULL),
m_bCreated(FALSE),
m_hEventCreated(NULL),
m_bMsgThrdInside(FALSE),
m_dwStyle(WS_TABSTOP)
{
}
CWndBase::~CWndBase()
{
}
BOOL CWndBase::Create(HWND hWndParent,const TSTRING &strWndClass,const TSTRING &strWndName,BOOL bMsgThrdInside)
{
return CreateEx(hWndParent,strWndClass,strWndName,WS_TABSTOP,bMsgThrdInside);
}
BOOL CWndBase::RegisterClass()
{
WNDCLASS wc;
GetDataForRegistryClass(wc);
return ::RegisterClass(&wc);
}
LRESULT CALLBACK CWndBase::StaticWndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
CWndBase *pObject = reinterpret_cast<CWndBase*>(GetWindowLong(hWnd, GWL_USERDATA));
if(pObject)
{
return pObject->WndProc(hWnd,wMsg,wParam,lParam);
}
else
{
return DefWindowProc(hWnd,wMsg,wParam,lParam);
}
}
LRESULT CWndBase::WndProc(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
switch(wMsg)
{
case WM_DESTROY:
OnDestroy(hWnd,wMsg,wParam,lParam);
break;
}
return DefWindowProc(hWnd,wMsg,wParam,lParam);
}
BOOL CWndBase::ShowWindow(BOOL bShow)
{
if(m_hWnd == NULL)
{
return FALSE;
}
if(bShow == TRUE)
{
SetForegroundWindow(m_hWnd);
SetWindowPos(m_hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW);
}
else
{
::ShowWindow(m_hWnd,SW_HIDE);
}
return TRUE;
}
DWORD WINAPI CWndBase::CreateProc(PVOID pArg)
{
//Get the object instance
CWndBase *pObject = reinterpret_cast<CWndBase *>(pArg);
#ifdef _WIN32_WCE
pObject->m_bCreated = pObject->CreateWnd(pObject->m_dwStyle,0);
#else
//Create the window.You should set the WS_EX_NOPARENTNOTIFY here, or maybe the CreateWindowEx
//never return because it is waiting for the parent window responding when the main message loop doesn't begin working.
pObject->m_bCreated = pObject->CreateWnd(pObject->m_dwStyle,WS_EX_NOPARENTNOTIFY);
#endif //#ifdef _WIN32_WCE
//Set the event
if(pObject->m_hEventCreated != NULL)
{
SetEvent(pObject->m_hEventCreated);
}
if(pObject->m_bCreated == FALSE)
{
//Failed in creating the window, so return and needn't the message loop
return 0x01;
}
//The message loop
MSG msg;
while(GetMessage(&msg,NULL,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
BOOL CWndBase::CreateWnd(DWORD dwStyle,DWORD dwExStyle)
{
if(RegisterClass() == FALSE)
{
return FALSE;
}
RECT rcArea = {0};
SystemParametersInfo(SPI_GETWORKAREA, 0, &rcArea, 0);
m_hWnd = CreateWindowEx(dwExStyle,
m_strWndClass.c_str(),
m_strWndName.c_str(),
dwStyle,
rcArea.left,
rcArea.top,
rcArea.right - rcArea.left,
rcArea.bottom - rcArea.top,
m_hWndParent,
NULL,
GetModuleHandle(NULL),
0);
//ASSERT(m_hWnd != FALSE);
if (IsWindow(m_hWnd) == FALSE)
{
return FALSE;
}
// If the window is created successfully, store this object so the
//static wrapper can pass calls to the real WndProc.
SetWindowLong(m_hWnd, GWL_USERDATA, reinterpret_cast<DWORD>(this));
return TRUE;
}
void CWndBase::OnDestroy(HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam)
{
if(m_bMsgThrdInside == TRUE)
{
//Exit the inside thread
PostQuitMessage(0x00);
}
}
HWND CWndBase::GetWindow(void) const
{
return m_hWnd;
}
HWND CWndBase::GetParentWindow(void) const
{
if(m_hWnd != NULL)
{
m_hWndParent = ::GetParent(m_hWnd);
}
return m_hWndParent;
}
BOOL CWndBase::SetParentWindow(HWND hWndParent)
{
if(m_hWnd == NULL)
{
m_hWndParent = hWndParent;
return TRUE;
}
LONG lStyle = GetWindowLong(m_hWnd,GWL_STYLE);
lStyle &= ~WS_POPUP; //Remove the WS_POPUP flag
lStyle |= WS_CHILD; //Set the WS_CHILD flag
SetWindowLong(m_hWnd,GWL_STYLE,lStyle);
::SetParent(m_hWnd,hWndParent);
m_hWndParent = GetParentWindow();
//ASSERT(m_hWndParent != NULL);
return (m_hWndParent != NULL);
}
BOOL CWndBase::CreateEx(HWND hWndParent,const TSTRING &strWndClass,const TSTRING &strWndName,DWORD dwStyle,BOOL bMsgThrdInside)
{
m_hWndParent = hWndParent;
m_dwStyle = dwStyle;
m_strWndName = strWndName;
m_strWndClass = strWndClass;
//Create the window
if(bMsgThrdInside == TRUE)
{
HANDLE hdThrd = CreateThread(NULL,0,CreateProc,this,0,NULL);
if(hdThrd == NULL )
{
return FALSE;
}
else
{
CloseHandle(hdThrd);
//Create the event and wait
m_hEventCreated = CreateEvent(NULL,FALSE,FALSE,NULL);
if(m_hEventCreated != NULL)
{
WaitForSingleObject(m_hEventCreated,INFINITE);
CloseHandle(m_hEventCreated);
m_hEventCreated = NULL;
return m_bCreated;
}
else
{
return FALSE;
}
}
}
else
{
return CreateWnd(dwStyle,0);
}
}
void CWndBase::GetDataForRegistryClass(WNDCLASS &wc)
{
wc.style = 0;
wc.lpfnWndProc = CWndBase::StaticWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = GetModuleHandle(NULL);
wc.hIcon = NULL;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.lpszMenuName = NULL;
wc.lpszClassName = m_strWndClass.c_str();
wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
}
没有合适的资源?快使用搜索试试~ 我知道了~
Windows CE下模拟IPhone滑动效果的示例代码.rar
共36个文件
suo:6个
h:5个
obj:4个
4星 · 超过85%的资源 需积分: 9 9 下载量 180 浏览量
2012-11-13
16:54:17
上传
评论
收藏 812KB RAR 举报
温馨提示
Windows CE下模拟IPhone滑动效果的示例代码,实现界面滑动效果实现代码。
资源推荐
资源详情
资源评论
收起资源包目录
Windows CE下模拟IPhone滑动效果的示例代码.rar (36个子文件)
2.5 IPhoneEffect
MemDC.h 3KB
IPhoneEffect.suo 22KB
IPhoneEffect.vcproj 30KB
WndBase.cpp 6KB
Main.cpp 683B
CMemDC.suo 13KB
CBaseFunc.suo 17KB
stdafx.h 269B
MemDC.cpp 2KB
MainWnd.cpp 5KB
IPhoneEffect.sln 6KB
Debug
IPhoneEffect.exe.embed.manifest 405B
MainWnd.obj 54KB
IPhoneEffect.pdb 603KB
IPhoneEffect.exe.embed.manifest.res 472B
vc80.idb 579KB
IPhoneEffect.res 765KB
mt.dep 69B
IPhoneEffect.exe 984KB
IPhoneEffect.ilk 462KB
IPhoneEffect.exe.intermediate.manifest 387B
WndBase.obj 58KB
BuildLog.htm 12KB
MemDC.obj 46KB
Main.obj 41KB
vc80.pdb 228KB
CWndBase.suo 13KB
resource.h 500B
WndBase.h 4KB
IPhoneEffect.rc 2KB
MainWnd.h 2KB
vssver2.scc 110B
SysVolume.suo 17KB
Res
B_Wnd_Backlight.bmp 383KB
A_Wnd_Backlight.bmp 383KB
CMedia.suo 18KB
共 36 条
- 1
资源评论
- yangqingleshi2013-01-07实现了滑动效果,呵呵
niechao8635
- 粉丝: 2
- 资源: 13
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功