본문 바로가기
VisualStudio.C++.C#/코딩팁,함수활용,단편

MFC. 대화상자에 분할 윈도우 구현.

by i.got.it 2020. 12. 5.

 

 

 

 

// 헤더파일. 

class CDlgSplitDlg : public CDialogEx
{
// Construction
public:
	CDlgSplitDlg(CWnd* pParent = nullptr);	// standard constructor
	CFrameWnd* m_pMyFrame; 
	CSplitterWnd m_cSplitter;

....
}

// cpp 파일.

int CDlgSplitDlg::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CDialogEx::OnCreate(lpCreateStruct) == -1)
		return -1;

	// TODO:  Add your specialized creation code here

	// Initialize a context for the view. CDialog1 is my view and
	// is defined as :  class CDIalog1 : public CTreeView.
	CCreateContext ccc;
	ccc.m_pNewViewClass = RUNTIME_CLASS(CDialog1);
	ccc.m_pCurrentDoc = NULL;
	ccc.m_pNewDocTemplate = NULL;
	ccc.m_pLastView = NULL;
	ccc.m_pCurrentFrame = NULL;

	// Because the CFRameWnd needs a window class, we will create
	// a new one. I just copied the sample from MSDN Help.
	// When using it in your project, you may keep CS_VREDRAW and
	// CS_HREDRAW and then throw the other three parameters.
	CString strMyClass = AfxRegisterWndClass(CS_VREDRAW |
		CS_HREDRAW,
		::LoadCursor(NULL, IDC_ARROW),
		(HBRUSH) ::GetStockObject(WHITE_BRUSH),
		::LoadIcon(NULL, IDI_APPLICATION));

	// Create the frame window with "this" as the parent
	m_pMyFrame = new CFrameWnd;
	m_pMyFrame->Create(strMyClass, _T(""), WS_CHILD,
		CRect(0, 0, 1, 1), this);
	m_pMyFrame->ShowWindow(SW_SHOW);
	m_pMyFrame->MoveWindow(0, 0, 300, 300);

	// and finally, create the splitter with the frame as
	// the parent
	m_cSplitter.CreateStatic(m_pMyFrame, 2, 2);

	m_cSplitter.CreateView(0, 0, RUNTIME_CLASS(CDialog1),
		CSize(100, 100), &ccc);
	m_cSplitter.CreateView(0, 1, RUNTIME_CLASS(CDialog1),
		CSize(100, 100), &ccc);
	m_cSplitter.CreateView(1, 0, RUNTIME_CLASS(CDialog1),
		CSize(100, 100), &ccc);
	m_cSplitter.CreateView(1, 1, RUNTIME_CLASS(CDialog1),
		CSize(100, 100), &ccc);

	return 0;
}



BOOL CDlgSplitDlg::OnInitDialog()
{
	CDialogEx::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 != nullptr)
	{
		BOOL bNameValid;
		CString strAboutMenu;
		bNameValid = strAboutMenu.LoadString(IDS_ABOUTBOX);
		ASSERT(bNameValid);
		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

	CRect cRect;

	// Get the rectangle of the custom window. The custom window
	// is just a a big button that is not visible and is disabled.
	// It's a trick to not use coordinates directly.
//	GetDlgItem(IDC_CUSTOM_WINDOW)->GetWindowRect(&cRect);
	GetClientRect(cRect);

	// Move the splitter
//	ScreenToClient(&cRect);
	m_pMyFrame->MoveWindow(&cRect);
	m_pMyFrame->ShowWindow(SW_SHOW);
	m_cSplitter.MoveWindow(0, 0, cRect.Width(), cRect.Height());
	m_cSplitter.ShowWindow(SW_SHOW);




	return TRUE;  // return TRUE  unless you set the focus to a control
}

 

 

 

from : Creating a Splitter Window in a Dialog Box in Three Easy Steps (codeguru.com)

 

 

 

 

 


첫 등록 : 2020.12.05

최종 수정 : 

단축 주소 : https://igotit.tistory.com/2722

 


 

댓글



 

비트코인




암호화폐       외환/나스닥/골드       암호화폐/외환/나스닥/골드 암호화폐/외환/나스닥/골드   암호화폐/외환/나스닥/골드
     
현물 |선물 인버스 |선물 USDT       전략매니저(카피트레이딩)     롤오버 이자 없는 스왑프리계좌
( 스왑프리 암호화폐도 거래 가능 )    
MT4, MT5 , cTrader 모두 지원     FTMO 계좌 매매운용. MT4,MT5