⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gridfrm.cpp

📁 mfc internals 源码 mfc internals 源码
💻 CPP
字号:
// gridfrm.cpp : implementation file
//

// This is a part of the Objective Grid C++ Library.
// Copyright (C) 1995 ClassWorks, Stefan Hoenig.
// All rights reserved.
//
// This source code is only intended as a supplement to
// the Objective Grid Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding
// the Objective Grid product.
//

#include "stdafx.h"
#include "gridfrm.h"

#ifndef _GXCOMBO_H_
#include "gxctrl.h"
#endif

#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif

IMPLEMENT_DYNCREATE(CGridMDIFrameWnd, CMDIFrameWnd)

#define new DEBUG_NEW

/////////////////////////////////////////////////////////////////////////////
// Helpers for saving/restoring window state

static char BASED_CODE szSection[] = "Settings";
static char BASED_CODE szWindowPos[] = "WindowPos";
static char BASED_CODE szFormat[] = "%u,%u,%d,%d,%d,%d,%d,%d,%d,%d";

static BOOL PASCAL NEAR ReadWindowPlacement(LPWINDOWPLACEMENT pwp, LPCSTR szSection)
{
	CString strBuffer = AfxGetApp()->GetProfileString(szSection, szWindowPos);
	if (strBuffer.IsEmpty())
		return FALSE;

	WINDOWPLACEMENT wp;
	int nRead = sscanf(strBuffer, szFormat,
		&wp.flags, &wp.showCmd,
		&wp.ptMinPosition.x, &wp.ptMinPosition.y,
		&wp.ptMaxPosition.x, &wp.ptMaxPosition.y,
		&wp.rcNormalPosition.left, &wp.rcNormalPosition.top,
		&wp.rcNormalPosition.right, &wp.rcNormalPosition.bottom);

	if (nRead != 10)
		return FALSE;

	wp.length = sizeof wp;
	*pwp = wp;
	return TRUE;
}

static void PASCAL NEAR WriteWindowPlacement(LPWINDOWPLACEMENT pwp, LPCSTR szSection)
	// write a window placement to settings section of app's ini file
{
	char szBuffer[sizeof("-32767")*8 + sizeof("65535")*2];

	sprintf(szBuffer, szFormat,
		pwp->flags, pwp->showCmd,
		pwp->ptMinPosition.x, pwp->ptMinPosition.y,
		pwp->ptMaxPosition.x, pwp->ptMaxPosition.y,
		pwp->rcNormalPosition.left, pwp->rcNormalPosition.top,
		pwp->rcNormalPosition.right, pwp->rcNormalPosition.bottom);

	AfxGetApp()->WriteProfileString(szSection, szWindowPos, szBuffer);
}

/////////////////////////////////////////////////////////////////////////////
// CGridMDIFrameWnd

CGridMDIFrameWnd::CGridMDIFrameWnd()
{
}

CGridMDIFrameWnd::~CGridMDIFrameWnd()
{
}


BEGIN_MESSAGE_MAP(CGridMDIFrameWnd, CMDIFrameWnd)
	//{{AFX_MSG_MAP(CGridMDIFrameWnd)
	ON_WM_CLOSE()
	ON_WM_NCACTIVATE()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

//  ON_WM_ACTIVATEAPP()
//  ON_WM_ACTIVATE()

/////////////////////////////////////////////////////////////////////////////
// CGridMDIFrameWnd message handlers


void CGridMDIFrameWnd::OnClose()
{
	// before it is destroyed, save the position of the window
	if (m_sSection.GetLength() > 0)
	{
		WINDOWPLACEMENT wp;
		wp.length = sizeof wp;
		if (GetWindowPlacement(&wp))
		{
			wp.flags = 0;
			if (IsZoomed())
				wp.flags |= WPF_RESTORETOMAXIMIZED;
			// and write it to the .INI file
			WriteWindowPlacement(&wp, m_sSection);
		}
	}
	CMDIFrameWnd::OnClose();
}

BOOL CGridMDIFrameWnd::ShowWindow(int nCmdShow)
{
	WINDOWPLACEMENT wp;

	if (m_sSection.GetLength() > 0 && ReadWindowPlacement(&wp, m_sSection))
	{
		wp.ptMaxPosition.x = 0;
		wp.ptMaxPosition.y = 0;
		if (nCmdShow != SW_SHOWNORMAL)
			wp.showCmd = nCmdShow;
		SetWindowPlacement(&wp);
		return CWnd::ShowWindow(wp.showCmd);
	}

	return CWnd::ShowWindow(nCmdShow);
}

/*
void CGridMDIFrameWnd::CreateOrActivateFrame(CDocTemplate* pTemplate,
	CRuntimeClass* pViewClass)
{
	// If an instance of the class specified by pViewClass already exists,
	// then activate the MDI child window containing
	// the view.  Otherwise, create a new view for the document.

	CMDIChildWnd* pMDIActive = MDIGetActive();
	ASSERT(pMDIActive != NULL);
	CDocument* pDoc = pMDIActive->GetActiveDocument();
	ASSERT(pDoc != NULL);

	CView* pView;
	POSITION pos = pDoc->GetFirstViewPosition();
	while (pos != NULL)
	{
		pView = pDoc->GetNextView(pos);
		if (pView->IsKindOf(pViewClass))
		{
			pView->GetParentFrame()->ActivateFrame();
			return;
		}
	}

	CMDIChildWnd* pNewFrame
		= (CMDIChildWnd*)(pTemplate->CreateNewFrame(pDoc, NULL));
	if (pNewFrame == NULL)
		return;     // not created
	ASSERT(pNewFrame->IsKindOf(RUNTIME_CLASS(CMDIChildWnd)));
	pTemplate->InitialUpdateFrame(pNewFrame, pDoc);
	// MDITile(MDITILE_HORIZONTAL);
}
*/

BOOL CGridMDIFrameWnd::OnNcActivate(BOOL bActive)
{
	// TRACE("OnNcActivate(%d)\n", bActive);

	if (CGXGridCombo::GetComboBoxDropDown())
		return TRUE;

	return CMDIFrameWnd::OnNcActivate(bActive);
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -