Click here to Skip to main content
15,886,664 members
Articles / Desktop Programming / MFC

MFC Snapping Windows

Rate me:
Please Sign up or sign in to vote.
4.68/5 (17 votes)
27 May 2014GPL34 min read 44.6K   2.7K   56  
Easily create windows that snap to each other.
#pragma once

#include "CExtWS.h"

#define WM_DESTROY_CHILD	WM_USER+0x110

// CChildSnapper dialog

class CChildSnapper : public CExtCS < CDialogEx >
{
	DECLARE_DYNAMIC(CChildSnapper)

public:
	CChildSnapper(CWnd* pParent = NULL);   // standard constructor
	virtual ~CChildSnapper();

// Dialog Data
	enum { IDD = IDD_DIALOG1 };

protected:
	//HWND m_hwndParent;

	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

	DECLARE_MESSAGE_MAP()
	virtual void OnCancel();
	virtual void OnOK();
public:
	virtual BOOL DestroyWindow();
	void SetParentHwnd(HWND hwndParent);
};

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 GNU General Public License (GPLv3)


Written By
Systems / Hardware Administrator
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions