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

📄 mainfrm.cpp

📁 ado封装类,adoconn,用法有具体实例,包括查询数据库,列表显示等
💻 CPP
字号:
// MainFrm.cpp : implementation of the CMainFrame class
//

#include "stdafx.h"
#include "MKJC.h"
#include "YDLS.h"
#include "MainFrm.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMainFrame

IMPLEMENT_DYNCREATE(CMainFrame, CFrameWnd)

BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
	//{{AFX_MSG_MAP(CMainFrame)
	ON_WM_CREATE()
	ON_COMMAND(ID_VIEW_YDJD, OnViewYdjd)
	ON_MESSAGE( WM_REDRAW, OnRedraw)
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()

static UINT indicators[] =
{
	ID_SEPARATOR,           // status line indicator
	ID_INDICATOR_CAPS,
	ID_INDICATOR_NUM,
	ID_INDICATOR_SCRL,
};

/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction

CMainFrame::CMainFrame()
{
	// TODO: add member initialization code here
	
}

CMainFrame::~CMainFrame()
{
}

int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	
	if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
		| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) ||
		!m_wndToolBar.LoadToolBar(IDR_MAINFRAME))
	{
		TRACE0("Failed to create toolbar\n");
		return -1;      // fail to create
	}

	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
	}

	// TODO: Delete these three lines if you don't want the toolbar to
	//  be dockable
	m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
	EnableDocking(CBRS_ALIGN_ANY);
	DockControlBar(&m_wndToolBar);
	// 创建ControlBar
	if (!m_wndMyBar1.Create(_T("我的控制条"),this,CSize(500,100),TRUE,123)) 
	{ 
		TRACE0("Failed to create mybar\n"); return -1; 
	} 
    if (!m_wndMyBar2.Create(_T("我的控制条2"),this,CSize(100,100),TRUE,124))
	{ 
		TRACE0("Failed to create mybar\n"); return -1;
	}

	//停靠控制
	m_wndMyBar1.SetBarStyle(m_wndMyBar1.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC); 
    m_wndMyBar2.SetBarStyle(m_wndMyBar2.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
    m_wndMyBar1.EnableDocking(CBRS_ALIGN_ANY);
    m_wndMyBar2.EnableDocking(CBRS_ALIGN_ANY);
    DockControlBar(&m_wndMyBar1, AFX_IDW_DOCKBAR_LEFT);///停靠在左边
    DockControlBar(&m_wndMyBar2, AFX_IDW_DOCKBAR_BOTTOM);///停靠在右边
		//在创建ControlBar后创建编辑控件
    m_wndEdit.Create(WS_VSCROLL|WS_CHILD|WS_VISIBLE|ES_AUTOVSCROLL| ES_MULTILINE|ES_WANTRETURN,//指定编辑控件的风格
		CRect(0,0,0,0),
		&m_wndMyBar2,101);
	m_wndEdit.ModifyStyleEx(0,WS_EX_CLIENTEDGE);
	//---------------Create TabCtrl---------
	m_TabCtrl.Create(TCS_DOWN | WS_CHILD | WS_VISIBLE,
		CRect(0,0,100,100),  &m_wndMyBar1, 125);  //将TabCtrl加入到左面的控制栏中。

	//----------------将Dialog加入到TabCtrl中--------------------------
	m_TabCtrl.AddPage(RUNTIME_CLASS(CMainDialog),IDD_MAINDIALOG,"控制面板",IDI_ICON1);
    m_TabCtrl.UpdateWindow();

	return 0;
}

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
	if( !CFrameWnd::PreCreateWindow(cs) )
		return FALSE;
	// TODO: Modify the Window class or styles here by modifying
	//  the CREATESTRUCT cs

	return TRUE;
}

/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics

#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
	CFrameWnd::AssertValid();
}

void CMainFrame::Dump(CDumpContext& dc) const
{
	CFrameWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers


void CMainFrame::OnViewYdjd() 
{
	// TODO: Add your command handler code here
	CYDLS ydls;
	ydls.DoModal();
}

LRESULT CMainFrame::OnRedraw(WPARAM wParam, LPARAM lParam)
{
	AfxMessageBox( _T("accept!"));
	return 1;
}

⌨️ 快捷键说明

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