////////////////////////////////////////////////////////////////
// 1998 Microsoft Systems Journal.
// If this code works, it was written by Paul DiLascia.
// If not, I don't know who wrote it.
// Compiles with Visual C++ 5.0 on Windows 95
//
#include "StdAfx.h"
#include "FormSwap2.h"
#include "MainFrm.h"
#include "LeftView.h"
#include "Forms.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
const ROWFORMVIEW = 0;
const COLFORMVIEW = 1;
const CXLIST = 50;
const IDLEFTVIEW = AFX_IDW_PANE_FIRST;
// Get the size of a dialog
static CSize GetDialogSize(LPCTSTR lpszTemplName, CWnd* pParent);
IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_WM_CREATE()
ON_COMMAND(ID_NEXT_FORM, OnViewNextForm)
ON_NOTIFY(LVN_ITEMCHANGED, IDLEFTVIEW, OnItemChanged)
END_MESSAGE_MAP()
static UINT indicators[] = {
ID_SEPARATOR, // status line indicator
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
CMainFrame::CMainFrame()
{
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
if (!m_wndToolBar.Create(this) ||
!m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) {
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
m_wndToolBar.ModifyStyle(0, TBSTYLE_FLAT);
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT))) {
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() |
CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
// Make frame just big enough to fit dialog
CSize sz = GetDialogSize(MAKEINTRESOURCE(IDD_DIALOG1), this);
CRect rc(CPoint(0,0), sz);
CalcWindowRect(&rc);
SetWindowPos(NULL, 0, 0, rc.Width(), rc.Height(),
SWP_NOMOVE|SWP_NOZORDER);
return 0;
}
//////////////////
// Client window created: Set up splitter window and save
// pointers to the two panes
//
BOOL CMainFrame::OnCreateClient( LPCREATESTRUCT /*lpcs*/, CCreateContext* pcc)
{
// create splitter window
if (!m_wndSplitter.CreateStatic(this, 1, 2))
return FALSE;
// Create left and right pane/views.
//
CSplitterWnd& sw = m_wndSplitter;
if (!sw.CreateView(0,0,RUNTIME_CLASS(CLeftView), CSize(CXLIST,100), pcc) ||
!sw.CreateView(ROWFORMVIEW, COLFORMVIEW,
FormData.GetViewClass(FormData.GetCurrentForm()),
CSize(0,0), // will get fixed in CMainFrame::OnCreate
pcc) ) {
TRACE("***CMainFrame: failed to create splitter views\n");
sw.DestroyWindow();
return FALSE;
}
// Double-check for ON_NOTIFY in message map above
ASSERT(AFX_IDW_PANE_FIRST == sw.IdFromRowCol(0,0));
return TRUE;
}
//////////////////
// User selected a different item: change the form view.
//
void CMainFrame::OnItemChanged(NMLISTVIEW* pnmlv, LRESULT* pRes)
{
if ((pnmlv->uChanged & LVIF_STATE) &&
(pnmlv->uNewState & LVIS_SELECTED)) {
ViewForm(pnmlv->iItem); // change it
}
*pRes = 0;
}
//////////////////
// Handle View | Next Form command
//
void CMainFrame::OnViewNextForm()
{
UINT iWhich = FormData.GetCurrentForm();
UINT nForms = FormData.GetMaxNumForms();
if (++iWhich >= nForms)
iWhich = 0;
ViewForm(iWhich);
}
//////////////////
// Change the view in the right pane
//
void CMainFrame::ViewForm(UINT iWhich)
{
if (iWhich != FormData.GetCurrentForm()) {
TRACE("\nCMainFrame::ViewForm: %d\n", iWhich);
CMySplitterWnd& sw = m_wndSplitter;
sw.ChangeView(ROWFORMVIEW, COLFORMVIEW, FormData.GetViewClass(iWhich));
FormData.SetCurrentForm(iWhich);
}
}
//////////////////
// Route commands to splitter window.
//
BOOL CMainFrame::OnCmdMsg(UINT nID, int nCode, void* pExtra,
AFX_CMDHANDLERINFO* pHandlerInfo)
{
// Pass to splitter
if (m_wndSplitter.OnCmdMsg(nID, nCode, pExtra, pHandlerInfo))
return TRUE;
// Call default routing--very important!
return CFrameWnd::OnCmdMsg(nID, nCode, pExtra, pHandlerInfo);
}
//////////////////
// CDialog class to get the size of a dialog.
// Assumes dialog is invisible (no WS_VISIBLE).
//
class CTempDlg : public CDialog {
public:
CRect m_rcDlg;
protected:
virtual BOOL OnInitDialog();
};
////////////////
// Initialize dialog: save size, then quit.
// Ignore "dialog failed" TRACE from MFC.
//
BOOL CTempDlg::OnInitDialog()
{
GetWindowRect(&m_rcDlg);
m_rcDlg -= m_rcDlg.TopLeft();
EndDialog(0);
return TRUE;
}
//////////////////
// static fn uses CTempDlg to get the size of any dialog used in a CFormView.
//
static CSize GetDialogSize(LPCTSTR lpszTemplName, CWnd* pParent)
{
CTempDlg dlg;
dlg.Create(lpszTemplName, pParent);
return dlg.m_rcDlg.Size();
}
//////////////////
// Calculate the size of the total frame, given a desired client (form) size.
// Start with client rect and add all the extra stuff.
//
void CMainFrame::CalcWindowRect(PRECT prcClient, UINT nAdjustType)
{
CRect rect(0, 0, 32767, 32767);
RepositionBars(0, 0xffff, AFX_IDW_PANE_FIRST, reposQuery,
&rect, &rect, FALSE);
CSize szBorder = m_wndSplitter.GetBorderSize();
CSize szSplitter = m_wndSplitter.GetSplitterSize();
prcClient->bottom += rect.Height() + // total toolbar height +
GetSystemMetrics(SM_CYMENU) + // menu +
GetSystemMetrics(SM_CYCAPTION) + // title bar +
2 * GetSystemMetrics(SM_CYSIZEFRAME) + // top/bottom window frame +
2 * szBorder.cy; // splitter borders
prcClient->right += CXLIST + // left pane width
2 * GetSystemMetrics(SM_CXSIZEFRAME) + // L/R window border
4 * szBorder.cx + // 2 panes==> 4 borders
szSplitter.cx; // 1 splitter
}
没有合适的资源?快使用搜索试试~ 我知道了~
FormSwap2.rar_FormSwap2_视图切换
共76个文件
h:15个
sbr:13个
cpp:13个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 2 浏览量
2022-09-21
05:20:33
上传
评论
收藏 2.77MB RAR 举报
温馨提示
MFC 视图切换程序.可以从工具栏选择视图,实时改变当前视图类型模式.
资源推荐
资源详情
资源评论
收起资源包目录
FormSwap2.rar (76个子文件)
FormSwap2
FormSwap2.dsp 5KB
View4.h 572B
FormSwap2.ncb 73KB
LeftView.cpp 2KB
MySplit.cpp 2KB
FormSwap2.rc 14KB
Doc.cpp 702B
View4.cpp 703B
StatLink.cpp 4KB
View3.cpp 703B
View1.h 572B
Doc.h 533B
LeftView.h 688B
Forms.cpp 1KB
HyprLink.cpp 624B
StatLink.h 2KB
FormSwap2.opt 48KB
RES
app.ico 1KB
Toolbar.bmp 598B
app.rc2 395B
Doc.ico 766B
msj.avi 49KB
View2.h 572B
FormSwap2.aps 80KB
TraceWin.h 5KB
FormSwap2.cpp 2KB
View3.h 572B
FormSwap2.dsw 543B
StdAfx.cpp 21B
MainFrm.cpp 6KB
resource.h 1KB
View2.cpp 703B
Forms.h 764B
MainFrm.h 1KB
FormSwap2.001 5KB
FormSwap2.plg 3KB
StdAfx.h 365B
View1.cpp 703B
HyprLink.h 695B
FormSwap2.mak 11KB
Debug
StdAfx.obj 53KB
View1.obj 15KB
MySplit.obj 11KB
FormSwap2.bsc 2.67MB
FormSwap2.sbr 0B
FormSwap2.exe 192KB
MySplit.sbr 0B
FormSwap2.pdb 1.06MB
LeftView.obj 24KB
View2.obj 15KB
FormSwap2.obj 39KB
doc.sbr 0B
mainfrm.sbr 0B
View3.sbr 0B
StatLink.obj 21KB
vc60.idb 217KB
FormSwap2.ilk 508KB
View4.sbr 0B
View4.obj 15KB
HyprLink.sbr 0B
FormSwap2.res 58KB
View1.sbr 0B
StdAfx.sbr 804KB
FormSwap2.pch 4.26MB
LeftView.sbr 0B
vc60.pdb 140KB
doc.obj 14KB
mainfrm.obj 38KB
Forms.sbr 0B
StatLink.sbr 0B
HyprLink.obj 4KB
Forms.obj 8KB
View3.obj 15KB
View2.sbr 0B
FormSwap2.h 474B
MySplit.h 799B
共 76 条
- 1
资源评论
局外狗
- 粉丝: 66
- 资源: 1万+
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功