Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

DirectUI Window as in XP system folders

, 1 Aug 2004 CPOL
A control to show a list of possible tasks just as in XP.
// todowinView.cpp : Implementierung der Klasse CTodowinView
//

#include "stdafx.h"
#include "todowin.h"

#include "todowinDoc.h"
#include "todowinView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif


/////////////////////////////////////////////////////////////////////////////
// CTodowinView

IMPLEMENT_DYNCREATE(CTodowinView, CView)

BEGIN_MESSAGE_MAP(CTodowinView, CView)
	//{{AFX_MSG_MAP(CTodowinView)
	ON_WM_CREATE()
	ON_WM_SIZE()
	ON_WM_ERASEBKGND()
	ON_COMMAND(ID_NUMBER1, OnNumber1)
	ON_COMMAND(ID_NUMBER2, OnNumber2)
	ON_COMMAND(IDS_SETJOB1, OnSetjob1)
	ON_COMMAND(IDS_SETJOB2, OnSetjob2)
	ON_COMMAND(IDS_SETJOB3, OnSetjob3)
	ON_COMMAND(ID_JOBWND_MANUALLIST, OnJobwndManuallist)
	ON_COMMAND(ID_JOBWND_STYLEXP, OnJobwndStylexp)
	ON_UPDATE_COMMAND_UI(ID_JOBWND_STYLEXP, OnUpdateJobwndStylexp)
	ON_COMMAND(ID_JOBWND_STYLEOFFICE, OnJobwndStyleoffice)
	ON_UPDATE_COMMAND_UI(ID_JOBWND_STYLEOFFICE, OnUpdateJobwndStyleoffice)
	ON_COMMAND(ID_JOBWND_STYLEXPCLASSIC, OnJobwndStylexpclassic)
	ON_UPDATE_COMMAND_UI(ID_JOBWND_STYLEXPCLASSIC, OnUpdateJobwndStylexpclassic)
	ON_COMMAND(ID_JOBWND_EXPANDGROUP1, OnJobwndExpandgroup1)
	ON_COMMAND(ID_JOBWND_COLLAPSEGROUP1, OnJobwndCollapsegroup1)
	ON_UPDATE_COMMAND_UI(ID_NUMBER1, OnUpdateNumber1)
	ON_COMMAND(ID_JOBWND_STYLETHEMED, OnJobwndStylethemed)
	ON_UPDATE_COMMAND_UI(ID_JOBWND_STYLETHEMED, OnUpdateJobwndStylethemed)
	//}}AFX_MSG_MAP
	// Standard-Druckbefehle
	ON_COMMAND(ID_FILE_PRINT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_DIRECT, CView::OnFilePrint)
	ON_COMMAND(ID_FILE_PRINT_PREVIEW, CView::OnFilePrintPreview)
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CTodowinView Konstruktion/Destruktion

CTodowinView::CTodowinView()
{
	// ZU ERLEDIGEN: Hier Code zur Konstruktion einf�gen,

}

CTodowinView::~CTodowinView()
{
}

BOOL CTodowinView::PreCreateWindow(CREATESTRUCT& cs)
{
	// ZU ERLEDIGEN: �ndern Sie hier die Fensterklasse oder das Erscheinungsbild, indem Sie
	//  CREATESTRUCT cs modifizieren.

	return CView::PreCreateWindow(cs);
}

/////////////////////////////////////////////////////////////////////////////
// CTodowinView Zeichnen

void CTodowinView::OnDraw(CDC* pDC)
{
	CTodowinDoc* pDoc = GetDocument();
	ASSERT_VALID(pDoc);
	// ZU ERLEDIGEN: Hier Code zum Zeichnen der urspr�nglichen Daten hinzuf�gen
}

/////////////////////////////////////////////////////////////////////////////
// CTodowinView Drucken

BOOL CTodowinView::OnPreparePrinting(CPrintInfo* pInfo)
{
	// Standardvorbereitung
	return DoPreparePrinting(pInfo);
}

void CTodowinView::OnBeginPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// ZU ERLEDIGEN: Zus�tzliche Initialisierung vor dem Drucken hier einf�gen
}

void CTodowinView::OnEndPrinting(CDC* /*pDC*/, CPrintInfo* /*pInfo*/)
{
	// ZU ERLEDIGEN: Hier Bereinigungsarbeiten nach dem Drucken einf�gen
}

/////////////////////////////////////////////////////////////////////////////
// CTodowinView Diagnose

#ifdef _DEBUG
void CTodowinView::AssertValid() const
{
	CView::AssertValid();
}

void CTodowinView::Dump(CDumpContext& dc) const
{
	CView::Dump(dc);
}

CTodowinDoc* CTodowinView::GetDocument() // Die endg�ltige (nicht zur Fehlersuche kompilierte) Version ist Inline
{
	ASSERT(m_pDocument->IsKindOf(RUNTIME_CLASS(CTodowinDoc)));
	return (CTodowinDoc*)m_pDocument;
}
#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CTodowinView Nachrichten-Handler

int CTodowinView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CView::OnCreate(lpCreateStruct) == -1)
		return -1;
	if (!m_wndDirectUI.Create(CRect(0,0,300,0), this, 1000))
		return -1;
	
//	OnSetjob1();
	OnJobwndManuallist();
#ifdef USE_THEMES
	OnJobwndStylethemed();
#else
	OnJobwndStylexp();
#endif

	
	if (!m_wndLeft.Create(WS_CHILD|WS_VISIBLE|ES_MULTILINE|ES_AUTOHSCROLL|ES_AUTOVSCROLL|WS_VSCROLL|WS_HSCROLL , 
		CRect(0,0,0,0), this, 1001))
		return -1;

	return 0;
}

void CTodowinView::OnSize(UINT nType, int cx, int cy) 
{
	CView::OnSize(nType, cx, cy);
	
	CRect rcJobs;
	m_wndDirectUI.GetWindowRect(&rcJobs);
	ScreenToClient(rcJobs);
	rcJobs.left = cx - rcJobs.Width();
	rcJobs.right= cx;
	rcJobs.bottom = rcJobs.top+cy;
	m_wndDirectUI.MoveWindow(rcJobs);
	
	m_wndLeft.MoveWindow(0,0, cx-rcJobs.Width(), cy, TRUE);
}

BOOL CTodowinView::OnEraseBkgnd(CDC* pDC) 
{
	return TRUE;
}

void CTodowinView::OnNumber1() 
{
	AfxMessageBox("OnNumber1");
}

void CTodowinView::OnNumber2() 
{
	AfxMessageBox("OnNumber2");
}

void CTodowinView::OnSetjob1() 
{
	m_wndDirectUI.InitFromMenu(IDR_JOB1);
	m_wndDirectUI.SetToolbarImages(IDR_MAINFRAME, IDB_BITMAP1);
	m_wndDirectUI.EnableItem(ID_BILDERBEARBEITEN_PEREMAILSENDEN, FALSE);
}

void CTodowinView::OnSetjob2() 
{
	m_wndDirectUI.InitFromMenu(IDR_JOB2);
	m_wndDirectUI.SetToolbarImages(IDR_MAINFRAME, IDB_BITMAP1);
}

void CTodowinView::OnSetjob3() 
{
	m_wndDirectUI.InitFromMenu(IDR_JOB3);
	m_wndDirectUI.SetToolbarImages(IDR_MAINFRAME, IDB_BITMAP1);
}

void CTodowinView::OnJobwndManuallist() 
{
	m_wndDirectUI.RemoveAll();

	int nGroup;
	nGroup = m_wndDirectUI.AddGroup("Test group");

	m_wndDirectUI.AddItem(nGroup, new CDirectUIItemStatic(_T("This is\na multiline\ntest text")));
	m_wndDirectUI.AddItem(nGroup, new CDirectUIItemEdit(_T("Edit this!"), &m_wndDirectUI));
	m_wndDirectUI.AddItemCommand(nGroup, "item 1", ID_NUMBER1);
	m_wndDirectUI.AddItemCommand(nGroup, "item 2", ID_NUMBER2);
	m_wndDirectUI.AddItemCommand(nGroup, "item 1", ID_NUMBER1);
	m_wndDirectUI.AddItemCommand(nGroup, "item 2", ID_NUMBER2);
	m_wndDirectUI.AddItemCommand(nGroup, "item 1", ID_NUMBER1);
	m_wndDirectUI.AddItemCommand(nGroup, "item 2", ID_NUMBER2);
	m_wndDirectUI.AddItemCommand(nGroup, "item 1", ID_NUMBER1);
	m_wndDirectUI.AddItemCommand(nGroup, "item 2", ID_NUMBER2);

	nGroup = m_wndDirectUI.AddGroup("Test group 2");

	m_wndDirectUI.AddItemCommand(nGroup, "item 1", ID_NUMBER1);
	m_wndDirectUI.AddItemCommand(nGroup, "item 2", ID_NUMBER2);
	m_wndDirectUI.AddItemCommand(nGroup, "item 1", ID_NUMBER1);

	nGroup = m_wndDirectUI.AddGroup("And an empty group");

	m_wndDirectUI.SetToolbarImages(IDR_MAINFRAME);
}

void CTodowinView::OnJobwndStylexp() 
{
	m_wndDirectUI.SetStyle(CWndDirectUI::styleXP);
}

void CTodowinView::OnUpdateJobwndStylexp(CCmdUI* pCmdUI) 
{
	pCmdUI->SetRadio(m_wndDirectUI.GetStyle() == CWndDirectUI::styleXP);
}

void CTodowinView::OnJobwndStyleoffice() 
{
	m_wndDirectUI.SetStyle(CWndDirectUI::styleOffice);
}

void CTodowinView::OnUpdateJobwndStyleoffice(CCmdUI* pCmdUI) 
{
	pCmdUI->SetRadio(m_wndDirectUI.GetStyle() == CWndDirectUI::styleOffice);
}

void CTodowinView::OnJobwndStylexpclassic() 
{
	m_wndDirectUI.SetStyle(CWndDirectUI::styleXPclassic);
}

void CTodowinView::OnUpdateJobwndStylexpclassic(CCmdUI* pCmdUI) 
{
	pCmdUI->SetRadio(m_wndDirectUI.GetStyle() == CWndDirectUI::styleXPclassic);
}

void CTodowinView::OnJobwndExpandgroup1() 
{
	m_wndDirectUI.ExpandGroup(0, TRUE);
}

void CTodowinView::OnJobwndCollapsegroup1() 
{
	m_wndDirectUI.ExpandGroup(0, FALSE);
}

void CTodowinView::OnUpdateNumber1(CCmdUI* pCmdUI) 
{
	// TODO: Code f�r die Befehlsbehandlungsroutine zum Aktualisieren der Benutzeroberfl�che hier einf�gen
	
}

BOOL CTodowinView::OnCmdMsg(UINT nID, int nCode, void* pExtra, AFX_CMDHANDLERINFO* pHandlerInfo) 
{
	if ((nID == ID_NUMBER1) & (nCode > 0))
		Beep(200, 50);
	
	return CView::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}

void CTodowinView::OnJobwndStylethemed() 
{
	m_wndDirectUI.SetStyle(CWndDirectUI::styleThemed);
}

void CTodowinView::OnUpdateJobwndStylethemed(CCmdUI* pCmdUI) 
{
	pCmdUI->SetRadio(m_wndDirectUI.GetStyle() == CWndDirectUI::styleThemed);
}

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.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Alexander Bischofberger
Web Developer
Germany Germany
Ok, a few words about me:
 
I started programming on the C64 by the "trial and error" method. Years later my parents got their first PC (Atari PC4, AT 8 MHz) where I started with Turbo Pascal. The next steps led to Turbo Pascal for Windows, Visual C++ 1.52c, and finally Visual C++ 6.
 
I had several chances to code larger projects, e.g.
* stand-alone disc copy station software (Win 3.1) with automatic reboot, disc encryption, ...
* government-used strategic decision system
* MLM marketing tool (www.upline.de)
* maintenance for show planning system and other TV software (www.hse24.de)
 
A lot of code, tipps and help came from this site for my later projects. Thanks again to all who helped me, even if they don't know it. I'm trying to share code (which is worth sharing) so others can get the help I got (and still need) for everyday problems.
 
Well, I think that's enough.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.141216.1 | Last Updated 2 Aug 2004
Article Copyright 2002 by Alexander Bischofberger
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid