139 lines
2.7 KiB
C++
139 lines
2.7 KiB
C++
#include "stdafx.h"
|
|
#include "GlwCAcUiDialog.h"
|
|
#include "GlwSkin.h"
|
|
#include "Uxtheme.h"
|
|
|
|
#pragma comment (lib, "UxTheme.lib")
|
|
|
|
#ifndef ZWCAD
|
|
#ifdef CAcUiDialog
|
|
#undef CAcUiDialog
|
|
#endif
|
|
#endif
|
|
|
|
static bool g_bDoModal = false;
|
|
|
|
namespace
|
|
{
|
|
bool OsIsXP()
|
|
{
|
|
OSVERSIONINFOEX info;
|
|
info.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
|
|
::GetVersionEx((OSVERSIONINFO*)&info);
|
|
if (info.dwMajorVersion < 5)
|
|
return false;
|
|
else if (info.dwMajorVersion == 5)
|
|
return true;
|
|
else if (info.dwMajorVersion >= 6)
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
IMPLEMENT_DYNAMIC(GlwCAcUiDialog, CAcUiDialog)
|
|
BEGIN_MESSAGE_MAP(GlwCAcUiDialog, CAcUiDialog)
|
|
ON_WM_CTLCOLOR()
|
|
ON_MESSAGE(WM_ACAD_KEEPFOCUS, &GlwCAcUiDialog::OnAcadKeepFocus)
|
|
ON_WM_LBUTTONDOWN()
|
|
END_MESSAGE_MAP()
|
|
GlwCAcUiDialog::GlwCAcUiDialog(UINT resId,CWnd* pParent)
|
|
: CAcUiDialog(resId, pParent), m_bDragTransparent(true), m_sTitle(_T("")), m_bCadStyle(false), m_pSkin(new GlwSkin)
|
|
{
|
|
m_pSkin->SetDragTransparent(m_bDragTransparent);
|
|
}
|
|
|
|
|
|
GlwCAcUiDialog::~GlwCAcUiDialog(void)
|
|
{
|
|
if(m_pSkin)
|
|
delete m_pSkin;
|
|
}
|
|
|
|
void GlwCAcUiDialog::PreInitDialog()
|
|
{
|
|
m_pSkin->Hook(this);
|
|
GetWindowText(m_sTitle);
|
|
if (!m_sTitle.IsEmpty())
|
|
{
|
|
SetWindowText(m_sTitle);
|
|
m_pSkin->SetLabel(true);
|
|
}
|
|
}
|
|
|
|
BOOL GlwCAcUiDialog:: OnInitDialog()
|
|
{
|
|
CRect rect;
|
|
GetClientRect(rect);
|
|
CRect rectRC, reNc;
|
|
if (m_pSkin->HasCaption())
|
|
{
|
|
reNc = m_pSkin->GetNoClientArea();
|
|
rectRC.SetRect(rect.left, rect.top,
|
|
rect.right+reNc.left+reNc.right, rect.bottom+reNc.top+reNc.bottom);
|
|
CAcUiDialog::MoveWindow(rectRC, true);
|
|
}
|
|
if (g_bDoModal)
|
|
{
|
|
g_bDoModal = false;
|
|
CenterWindow();
|
|
}
|
|
return CAcUiDialog::OnInitDialog();
|
|
}
|
|
|
|
LRESULT GlwCAcUiDialog::OnAcadKeepFocus( WPARAM wp, LPARAM lp )
|
|
{
|
|
if (m_bCadStyle)
|
|
{
|
|
CPoint pt;
|
|
GetCursorPos(&pt);
|
|
CRect rect;
|
|
GetWindowRect(rect);
|
|
if (rect.PtInRect(pt))
|
|
return TRUE;
|
|
return FALSE;
|
|
}
|
|
return TRUE;
|
|
}
|
|
|
|
bool GlwCAcUiDialog::IsCaptionLButtonDown()
|
|
{
|
|
return m_pSkin->IsCaptionLButtonDown();
|
|
}
|
|
|
|
|
|
bool GlwCAcUiDialog::IsBorderLButtonDown()
|
|
{
|
|
return m_pSkin->IsBorderLButtonDown();
|
|
}
|
|
|
|
void GlwCAcUiDialog::SetDragTransparent( bool bValue )
|
|
{
|
|
m_bDragTransparent = bValue;
|
|
m_pSkin->SetDragTransparent(m_bDragTransparent);
|
|
}
|
|
|
|
void GlwCAcUiDialog::SetDlgBkColor(const DWORD & dw)
|
|
{
|
|
m_pSkin->SerColorDlg(dw);
|
|
}
|
|
|
|
void GlwCAcUiDialog::MoveWindow(LPCRECT lpRect, BOOL bRepaint /*= TRUE*/)
|
|
{
|
|
CRect re(*lpRect);
|
|
CAcUiDialog::MoveWindow(CRect(re.TopLeft(), CSize(re.Width(), re.Height())), bRepaint);
|
|
}
|
|
|
|
void GlwCAcUiDialog::MoveWindow(int x, int y, int nW, int nH, BOOL bRepaint /*= TRUE*/)
|
|
{
|
|
CRect re(CPoint(x, y), CSize(nW, nH));
|
|
MoveWindow(&re, bRepaint);
|
|
}
|
|
|
|
INT_PTR GlwCAcUiDialog::DoModal()
|
|
{
|
|
g_bDoModal = true;
|
|
return CAcUiDialog::DoModal();
|
|
}
|
|
|
|
|