【VC开源代码栏目提醒】:本文主要为网学会员提供CDXCSIZINGDIALOG.CPP,希望对需要CDXCSIZINGDIALOG.CPP网友有所帮助,学习一下!
// cdxCSizingDialog.cpp : implementation file
// (c)1998 Hans B黨ler, codex design
// Designed to be used with MS VC++ 5.0
#define OEMRESOURCE
#include <windows.h>
#include "stdafx.h"
#include "cdxCSizingDialog.h"
#ifndef OBM_SIZE
#define OBM_SIZE 32766
// taken from WinresRc.h
// if not used for any reason
#endif
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// Some static variables
/////////////////////////////////////////////////////////////////////////////
static LPCTSTR pfEntry_Left = _T("Left"),
pfEntry_Right = _T("Right"),
pfEntry_Top = _T("Top"),
pfEntry_Bottom = _T("Bottom"),
pfEntry_State = _T("State"),
pfEntry_IsDone = _T("(check)");
#define BAD_ID ((UINT)~0)
static struct cdxCSizingPropSheet::StandardControls psheetCtrls[] =
{
{ ID_WIZNEXT, cdxCSizingDialog::mdRepos,cdxCSizingDialog::mdRepos },
{ ID_WIZFINISH, cdxCSizingDialog::mdRepos,cdxCSizingDialog::mdRepos },
{ ID_WIZBACK, cdxCSizingDialog::mdRepos,cdxCSizingDialog::mdRepos },
{ IDOK, cdxCSizingDialog::mdRepos,cdxCSizingDialog::mdRepos },
{ IDCANCEL, cdxCSizingDialog::mdRepos,cdxCSizingDialog::mdRepos },
{ ID_WIZNEXT, cdxCSizingDialog::mdRepos,cdxCSizingDialog::mdRepos },
{ ID_APPLY_NOW, cdxCSizingDialog::mdRepos,cdxCSizingDialog::mdRepos },
{ IDHELP, cdxCSizingDialog::mdRepos,cdxCSizingDialog::mdRepos },
{ AFX_IDC_TAB_CONTROL, cdxCSizingDialog::mdResize,cdxCSizingDialog::mdResize },
{ ID_WIZFINISH+1,cdxCSizingDialog::mdResize,cdxCSizingDialog::mdRepos}, /* the bevel line; hope that it will keep this id */
{ BAD_ID }
};
/////////////////////////////////////////////////////////////////////////////
// cdxCSizingDialog::ControlInfo::Header
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// Functions for my windowos
/////////////////////////////////////////////////////////////////////////////
/*
* OnInitDialog()
* Gets initial sizes of the window and makes sizing icon
*/
BOOL cdxCSizingDialog::ControlInfo::Header::OnInitDialog(UINT addSzByPcnt)
{
ASSERT(IsValid() && (m_iClientWid == -1));
CRect r;
WINDOWPLACEMENT wpl;
m_pWnd->GetClientRect(&r);
m_iClientWid = r.right - r.left;
m_iClientHi = r.bottom - r.top;
m_pWnd->GetWindowPlacement(&wpl);
m_iMinWid = wpl.rcNormalPosition.right - wpl.rcNormalPosition.left;
m_iMinHi = wpl.rcNormalPosition.bottom - wpl.rcNormalPosition.top;
// set up sizing icon
if(m_bSizeIcon)
{
if(!m_bmSizeIcon.LoadOEMBitmap(OBM_SIZE))
{
TRACE0(_T("*** ERROR[cdxCSizingDialog::ControlInfo::Header::OnInitDialog()]: LoadOEMBitmap() failed.\n"));
m_bSizeIcon = false;
}
else
{
CRect szr(r.Width()-24,r.Height()-24,r.Width(),r.Height());
if(!m_wndSizeIcon.Create(NULL,WS_CHILD|SS_BITMAP,szr,m_pWnd) ||
!m_wndSizeIcon.ModifyStyleEx(0,WS_EX_TRANSPARENT) )
{
TRACE0(_T("*** ERROR[cdxCSizingDialog::ControlInfo::Header::OnInitDialog()]: Can't create static icon control\n"));
m_bSizeIcon = false;
}
else
{
m_wndSizeIcon.SetBitmap(m_bmSizeIcon);
// now the icon has been resized to the real size of the icon
if(!m_wndSizeIcon.GetWindowPlacement(&wpl))
{
TRACE0(_T("*** ERROR[cdxCSizingDialog::ControlInfo::Header::OnInitDialog()]: Can't get windowplacement for sizeicon.\n"));
m_bSizeIcon = false;
}
else
{
wpl.flags = 0;
wpl.rcNormalPosition.left = r.Width() - (wpl.rcNormalPosition.right - wpl.rcNormalPosition.left);
wpl.rcNormalPosition.right = r.Width();
wpl.rcNormalPosition.top = r.Height() - (wpl.rcNormalPosition.bottom - wpl.rcNormalPosition.top);
wpl.rcNormalPosition.bottom= r.Height();
if(!m_wndSizeIcon.SetWindowPlacement(&wpl))
{
TRACE0(_T("*** ERROR[cdxCSizingDialog::ControlInfo::Header::OnInitDialog()]: Can't set windowplacement for sizeicon.\n"));
m_bSizeIcon = false;
}
else
{
AddSzControl(m_wndSizeIcon,mdRepos,mdRepos);
m_wndSizeIcon.ShowWindow(SW_SHOW); // finally - show it
}
}
}
}
}
if(addSzByPcnt)
StretchWindow(addSzByPcnt);
return TRUE;
}
/////////////////////////////////////////////////////////////////////////////
/*
* OnSize() handler
* Call before base classes' handler
*/
void cdxCSizingDialog::ControlInfo::Header::OnSize(UINT nType, int cx, int cy)
{
if((nType != SIZE_MINIMIZED) && (m_iClientWid != -1))
{
ASSERT((m_pWnd != NULL) && ::IsWindow(m_pWnd->m_hWnd));
ChangeSize(cx,cy);
}
}
/*
* tell system what minimum size we have
* call past original function
*/
void cdxCSizingDialog::ControlInfo::Header::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
ASSERT(m_pWnd != NULL);
if(::IsWindow(m_pWnd->m_hWnd) && (m_iClientWid != -1))
{
lpMMI->ptMinTrackSize.x = m_iMinWid;
lpMMI->ptMinTrackSize.y = m_iMinHi;
if(!(m_Freedom & fdVert))
lpMMI->ptMaxTrackSize.y = m_iMinHi;
if(!(m_Freedom & fdHoriz))
lpMMI->ptMaxTrackSize.x = m_iMinWid;
}
}
/////////////////////////////////////////////////////////////////////////////
/*
* this _really_ sizes/positions the controls
* call RedrawWindow() afterwards !
*/
bool cdxCSizingDialog::ControlInfo::Header::ChangeSize(int newWid, int newHi)
{
if(!IsValid() || (m_iClientWid == -1))
return false;
register int deltaX = newWid - m_iClientWid,
deltaY = newHi - m_iClientHi;
bool ok = true;
if(deltaX < 0)
{
ok = false;
deltaX = 0;
}
if(deltaY < 0)
{
deltaY = 0;
ok = false;
}
for(register ControlInfo *ci = m_pFirst; ci; ci = ci->GetNext())
ci->AdaptControlSize(deltaX,deltaY);
m_pWnd->RedrawWindow();
return ok;
}
/*
* force recalculation
*/
bool cdxCSizingDialog::ControlInfo::Header::ReorganizeControls(void)
{
ASSERT(IsValid());
CRect r;
m_pWnd->GetClientRect(&r);
return ChangeSize(r.Width(), r.Height());
}
/*
* resize dialog in all available directions
*/
void cdxCSizingDialog::ControlInfo::Header::StretchWindow(UINT addSzByPcnt)
{
ASSERT(IsValid());
register int delta;
WINDOWPLACEMENT wpl;
if(!m_pWnd->GetWindowPlacement(&wpl))
{
#ifdef
上一篇:
CDSnatchDlg.cpp
下一篇:
多年来只想说一句,我不怪你