Click here to Skip to main content
15,895,606 members
Articles / Desktop Programming / ATL

Sharp Layout

Rate me:
Please Sign up or sign in to vote.
4.80/5 (11 votes)
31 Jan 20052 min read 42.6K   1.3K   33  
Sharp Layout manager for ATL/WTL.
// SharpLayoutSampleView.h : interface of the CSharpLayoutSampleView class
//
/////////////////////////////////////////////////////////////////////////////

#pragma once
#include "sharplayout.h"

class CSharpLayoutSampleView : public CDialogImpl<CSharpLayoutSampleView>,
	public CSharpLayoutImpl<CSharpLayoutSampleView>
{
public:
	enum { IDD = IDD_SHARPLAYOUTSAMPLE_FORM };

	BOOL PreTranslateMessage(MSG* pMsg)
	{
		return CWindow::IsDialogMessage(pMsg);
	}

	BEGIN_MSG_MAP(CSharpLayoutSampleView)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_CONTEXTMENU, OnContextMenu)
		MESSAGE_HANDLER(WM_INITMENUPOPUP, OnInitMenuPopup)
		MESSAGE_HANDLER(WM_DESTROY, OnDestroy)
		COMMAND_ID_HANDLER(ID_1_SHOWTOPDOCKBAR, OnShowTop)
		COMMAND_ID_HANDLER(ID_1_SHOWLEFTDOCKBAR, OnShowLeft)
		CHAIN_MSG_MAP(CSharpLayoutImpl<CSharpLayoutSampleView>)
	END_MSG_MAP()

	LRESULT OnShowTop(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
	{
		CWindow wnd = GetDlgItem(IDC_EDIT1);
		wnd.ShowWindow(wnd.IsWindowVisible() ? SW_HIDE : SW_SHOW);
		RecalcLayout();
		return 0;
	}
	LRESULT OnShowLeft(WORD wNotifyCode, WORD wID, HWND hWndCtl, BOOL& bHandled)
	{
		CWindow wnd = GetDlgItem(IDC_LIST1);
		wnd.ShowWindow(wnd.IsWindowVisible() ? SW_HIDE : SW_SHOW);
		RecalcLayout();
		return 0;
	}

	LRESULT OnContextMenu(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		CMenu menu;
		menu.LoadMenu(IDR_CONTEXTMENU);
		menu.GetSubMenu(0).TrackPopupMenu(
			0, GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam), m_hWnd);
		return 0;
	}
	LRESULT OnInitMenuPopup(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		CMenuHandle menu((HMENU)wParam);
		menu.CheckMenuItem(ID_1_SHOWTOPDOCKBAR, 
			GetDlgItem(IDC_EDIT1).IsWindowVisible() ? MF_CHECKED : MF_UNCHECKED);
		menu.CheckMenuItem(ID_1_SHOWLEFTDOCKBAR, 
			GetDlgItem(IDC_LIST1).IsWindowVisible() ? MF_CHECKED : MF_UNCHECKED);
		return 0;
	}
	LRESULT OnDestroy(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		SaveLayout(HKEY_CURRENT_USER, _T("Software\\wtlsplit\\Layout"));
		return 0;
	}
	LRESULT OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
	{
		SetPaneStyle(GetDlgItem(IDC_EDIT1), 
			SSP_DOCKTOP|SSP_SPLITTER, false);
		SetPaneStyle(GetDlgItem(IDC_LIST1), 
			SSP_DOCKLEFT|SSP_SPLITTER|SSP_INTERACTIVE|SSP_PROPORTIONAL, false);
		SetPaneStyle(GetDlgItem(IDC_BUTTON1), 
			SSP_ALIGNRIGHT|SSP_ALIGNTOP, false);
		SetPaneStyle(GetDlgItem(IDC_BUTTON2), 
			SSP_ALIGNRIGHT|SSP_ALIGNTOP, false);
		SetPaneStyle(GetDlgItem(IDC_BUTTON3), 
			SSP_ALIGNRIGHT|SSP_ALIGNBOTTOM, false);
		SetPaneStyle(GetDlgItem(IDC_EDIT2), 
			SSP_ALIGNRIGHT|SSP_ALIGNLEFT|SSP_ALIGNBOTTOM|SSP_ALIGNTOP, false);
		LoadLayout(HKEY_CURRENT_USER, _T("Software\\wtlsplit\\Layout"), true);
		return 0;
	}

// Handler prototypes (uncomment arguments if needed):
//	LRESULT MessageHandler(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
//	LRESULT CommandHandler(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
//	LRESULT NotifyHandler(int /*idCtrl*/, LPNMHDR /*pnmh*/, BOOL& /*bHandled*/)
};

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
Russian Federation Russian Federation
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions