|
// GroupControlDemoDlg.cpp : implementation file
//
#include "stdafx.h"
#include "GroupControlDemo.h"
#include "GroupControlDemoDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGroupControlDemoDlg dialog
CGroupControlDemoDlg::CGroupControlDemoDlg(CWnd* pParent /*=NULL*/)
: CDialog(CGroupControlDemoDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CGroupControlDemoDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CGroupControlDemoDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CGroupControlDemoDlg)
DDX_Control(pDX, IDC_BTN_SHOW_2, m_btnShow2);
DDX_Control(pDX, IDC_BTN_SHOW_1, m_btnShow1);
DDX_Control(pDX, IDC_BTN_ENABLE_2, m_btnEnable2);
DDX_Control(pDX, IDC_BTN_ENABLE_1, m_btnEnable1);
DDX_Control(pDX, IDC_GROUP_2, m_grp2);
DDX_Control(pDX, IDC_GROUP_1, m_grp1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CGroupControlDemoDlg, CDialog)
//{{AFX_MSG_MAP(CGroupControlDemoDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BTN_ENABLE_1, OnBtnEnable1)
ON_BN_CLICKED(IDC_BTN_ENABLE_2, OnBtnEnable2)
ON_BN_CLICKED(IDC_BTN_SHOW_1, OnBtnShow1)
ON_BN_CLICKED(IDC_BTN_SHOW_2, OnBtnShow2)
ON_BN_CLICKED(ID_BTN_MOVE_GRP_2, OnBtnMoveGrp2)
ON_BN_CLICKED(ID_BTN_MOVE_GRP_1, OnBtnMoveGrp1)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CGroupControlDemoDlg message handlers
BOOL CGroupControlDemoDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
// TODO: Add extra initialization here
m_btnEnable1.SetCheck(TRUE);
m_btnEnable2.SetCheck(TRUE);
m_btnShow1.SetCheck(TRUE);
m_btnShow2.SetCheck(TRUE);
return TRUE; // return TRUE unless you set the focus to a control
}
void CGroupControlDemoDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CGroupControlDemoDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CDialog::OnPaint();
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CGroupControlDemoDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CGroupControlDemoDlg::OnBtnEnable1()
{
m_grp1.EnableWindow(m_btnEnable1.GetCheck());
}
void CGroupControlDemoDlg::OnBtnEnable2()
{
m_grp2.EnableWindow(m_btnEnable2.GetCheck());
}
void CGroupControlDemoDlg::OnBtnShow1()
{
m_grp1.ShowWindow(m_btnShow1.GetCheck() ? SW_SHOW : SW_HIDE);
}
void CGroupControlDemoDlg::OnBtnShow2()
{
m_grp2.ShowWindow(m_btnShow2.GetCheck() ? SW_SHOW : SW_HIDE);
}
void CGroupControlDemoDlg::OnBtnMoveGrp2()
{
GetDlgItem(IDC_NUDGE_LABEL)->ShowWindow(SW_HIDE);
CRect rc, rcDlg;
GetWindowRect(rcDlg);
m_grp2.GetWindowRect(&rc);
if ((rc.right + 12) >= rcDlg.right)
rc.OffsetRect(-((rc.left - rcDlg.left) - 12), 0);
else
rc.OffsetRect(20, 0);
ScreenToClient(&rc);
m_grp2.MoveWindow(&rc);
}
void CGroupControlDemoDlg::OnBtnMoveGrp1()
{
GetDlgItem(IDC_NUDGE_LABEL)->ShowWindow(SW_HIDE);
CRect rc, rcDlg;
GetWindowRect(rcDlg);
m_grp1.GetWindowRect(&rc);
if ((rc.right + 12) >= rcDlg.right)
rc.OffsetRect(-((rc.left - rcDlg.left) - 12), 0);
else
rc.OffsetRect(20, 0);
ScreenToClient(&rc);
m_grp1.MoveWindow(&rc);
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Originally from an electronics background, I moved into software in 1996, partly as a result of being made redundant, and partly because I was very much enjoying the small amount of coding (in-at-the-deep-end-C) that I had been doing!
I swiftly moved from C to C++, and learned MFC, and then went on to real-time C on Unix. After this I moved to the company for which I currently work, which specialises in Configuration Management software, and currently program mainly in C/C++, for Windows. I have been gradually moving their legacy C code over to use C++ (with STL, MFC, ATL, and WTL). I have pulled in other technologies (Java, C#, VB, COM, SOAP) where appropriate, especially when integrating with third-party products.
In addition to that, I have overseen the technical side of the company website (ASP, VBScript, JavaScript, HTML, CSS), and have also worked closely with colleagues working on other products (Web-based, C#, ASP.NET, SQL, etc).
For developing, I mainly use Visual Studio 2010, along with an in-house-designed editor based on Andrei Stcherbatchenko's
syntax parsing classes, and various (mostly freeware) tools. For website design, I use Dreaweaver CS3.
When not developing software, I enjoy listening to and playing music, playing electric and acoustic guitars and mandolin.