/********************************************************************
This dialog will be inserted as a child into the outbar control.
It uses Marc Richarme 's Easysize classes to keep the controls in the proper
position during resizing (very nice work Mark!, easy to use and works just great)
The test dialogs contails a list box, a button, a static label and an edit box.
With button you can add the text in the edit into the list box.
The dialog will be transparent, showing the background of the outbar control.
See CMainFrame::OnCreate() for how to insert this into the control itself.
*********************************************************************/
#include "stdafx.h"
#include "Outbar2_demo.h"
#include "DlgTest1.h"
// CDlgTest1 dialog
//EASYSIZE(control,left,top,right,bottom,options)
BEGIN_EASYSIZE_MAP(CDlgTest1)
EASYSIZE(IDC_EDIT1,ES_BORDER,ES_BORDER,ES_BORDER,ES_KEEPSIZE,0)
EASYSIZE(IDC_BUTTON1,ES_KEEPSIZE,ES_BORDER,ES_BORDER,ES_KEEPSIZE,0)
EASYSIZE(IDC_LIST1,ES_BORDER,ES_BORDER,ES_BORDER,ES_BORDER,0)
END_EASYSIZE_MAP
IMPLEMENT_DYNAMIC(CDlgTest1, CDialog)
CDlgTest1::CDlgTest1(CWnd* pParent /*=NULL*/)
: CDialog(CDlgTest1::IDD, pParent)
{
}
CDlgTest1::~CDlgTest1()
{
}
void CDlgTest1::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Text(pDX, IDC_EDIT1, csFind);
DDX_Control(pDX, IDC_LIST1, wndList);
}
BEGIN_MESSAGE_MAP(CDlgTest1, CDialog)
ON_BN_CLICKED(IDOK, OnBnClickedOk)
ON_BN_CLICKED(IDCANCEL, OnBnClickedCancel)
ON_WM_SIZE()
ON_WM_ERASEBKGND()
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_BUTTON1, OnBnClickedButton1)
END_MESSAGE_MAP()
// CDlgTest1 message handlers
// Those 2 needs to be overridden to avoid the child window go poof on enter/esc key
void CDlgTest1::OnBnClickedOk()
{
}
void CDlgTest1::OnBnClickedCancel()
{
}
BOOL CDlgTest1::OnInitDialog()
{
CDialog::OnInitDialog();
INIT_EASYSIZE; // this is for the auto-resizing of controls
wndList.InsertColumn(0,"Topic",LVCFMT_LEFT,80);
wndList.InsertColumn(1,"Title",LVCFMT_LEFT,280);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CDlgTest1::OnSize(UINT nType, int cx, int cy)
{
CDialog::OnSize(nType, cx, cy);
UPDATE_EASYSIZE; // this is for the auto-resizing of controls
Invalidate(); // at least on win2k seems that glitches may happen during resize, so let's invalidate
}
BOOL CDlgTest1::OnEraseBkgnd(CDC* pDC)
{
// let's have the control background show through
return TRUE;
}
HBRUSH CDlgTest1::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
// also let's have the static labels with an invisible background and
// proper color for the text
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
if (nCtlColor == CTLCOLOR_STATIC)
{
pDC->SetBkMode(TRANSPARENT);
pDC->SetTextColor(GetSysColor(COLOR_WINDOW));
return (HBRUSH) GetStockObject(NULL_BRUSH);
}
return hbr;
}
void CDlgTest1::OnBnClickedButton1()
{
// and at end let's have the controls do something
UpdateData();
int idx = wndList.InsertItem(wndList.GetItemCount(), "*");
wndList.SetItemText(idx,1,csFind);
GetDlgItem(IDC_EDIT1)->SetFocus();
}