📄 mainfrm.cpp
字号:
// mainfrm.cpp : implementation of the CMainFrame class
//
// This is a part of the Microsoft Foundation Classes C++ library.
// Copyright (C) 1992-1997 Microsoft Corporation
// All rights reserved.
//
// This source code is only intended as a supplement to the
// Microsoft Foundation Classes Reference and related
// electronic documentation provided with the library.
// See these sources for detailed information regarding the
// Microsoft Foundation Classes product.
#include "stdafx.h"
#include "drawcli.h"
#include "LinkServer.h"
#include "QKDYXCFZ.h"
#include "SetParameter.h"
#include "mainfrm.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
const int SNAP_WIDTH=120; //the width of the combo box
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(ID_MENU_SELWELL, CmdMenuSelwell)
ON_UPDATE_COMMAND_UI(ID_MENU_SELWELL, OnUpdateMenuSelwell)
ON_COMMAND(ID_MENU_LINKSERVER, CmdMenuLinkserver)
ON_WM_CLOSE()
ON_COMMAND(ID_MENU_PARAMETER, OnMenuParameter)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
static UINT BASED_CODE 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
//m_bAutoMenuEnable = FALSE;
}
CMainFrame::~CMainFrame()
{
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
//个人新加
if(!BeginLogin())
return -1;
WINDOWPLACEMENT wp;
if (LoadWindowPlacement (&wp))
{
//wp.showCmd = AfxGetApp()->m_nCmdShow;
SetWindowPlacement(&wp);
}
if (CMDIFrameWnd::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
}
m_wndStatusBar.SetPaneInfo(1,IDS_LOGINNAME,0,200);
m_wndStatusBar.SetPaneInfo(2,IDS_LOGINDEPTNAME,0,60);
m_wndStatusBar.SetPaneInfo(3,IDS_LOGINDEPTNAME,0,60);
m_wndStatusBar.SetPaneText(1,"坐标位置");
m_wndStatusBar.SetPaneText(2," ");
m_wndStatusBar.SetPaneText(3,"油田图幅");
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndToolBar);
int index = 0;
RECT rect;
//找到指定的工具项
while(m_wndToolBar.GetItemID(index)!=ID_TOOL_ZOOM)
index++;
//设置指定工具项的宽度并获取新的区域 80是宽度
m_wndToolBar.SetButtonInfo(index, ID_TOOL_ZOOM, TBBS_SEPARATOR, 80);
m_wndToolBar.GetItemRect(index, &rect);
//设置位置
rect.top-=1;
rect.bottom += 200;
// 创建并显示
if (!m_wndToolBar.m_wndZoom.Create(WS_CHILD|WS_VISIBLE | CBS_AUTOHSCROLL |
CBS_DROPDOWNLIST | CBS_HASSTRINGS ,
rect, &m_wndToolBar, ID_TOOL_ZOOM))
{
TRACE0("Failed to create combo-box\n");
return FALSE;
}
m_wndToolBar.m_wndZoom.ShowWindow(SW_SHOW);
//填充内容
m_wndToolBar.m_wndZoom.AddString("400%");
m_wndToolBar.m_wndZoom.AddString("300%");
m_wndToolBar.m_wndZoom.AddString("200%");
m_wndToolBar.m_wndZoom.AddString("150%");
m_wndToolBar.m_wndZoom.AddString("100%");
m_wndToolBar.m_wndZoom.AddString("80%");
m_wndToolBar.m_wndZoom.AddString("60%");
m_wndToolBar.m_wndZoom.AddString("40%");
m_wndToolBar.m_wndZoom.AddString("20%");
m_wndToolBar.m_wndZoom.AddString("10%");
m_wndToolBar.m_wndZoom.SetCurSel(4);
//*******************创建 油井列表 Tab****************************************
if (!m_wndMyBarWellList.Create(_T("选择区块"),this,IDColBar_wndMyBarWellList))
{
TRACE0("Failed to create mybar\n");
return -1;
}
//油井列表 设置样式
m_wndMyBarWellList.SetBarStyle(m_wndMyBarWellList.GetBarStyle() | CBRS_TOOLTIPS |
CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
//停靠控制
m_wndMyBarWellList.EnableDocking(CBRS_ALIGN_ANY);
DockControlBar(&m_wndMyBarWellList, AFX_IDW_DOCKBAR_RIGHT);///停靠在左边
m_TabWell.Create(TCS_MONOSPACE|TCS_UP|WS_VISIBLE,CRect(0,0,250,100),&m_wndMyBarWellList,IDColTabCt_TabWell);//IDColBar_wndMyBarReadMe
m_TabWell.AddPage(RUNTIME_CLASS(CQKDYXCFZ),IDD_QKDYXCFZ,"砂体图",IDI_ICON1);
//m_TabWell.AddPage(RUNTIME_CLASS(CListWellPM),IDD_LISTWELL_PM,"剖面图",IDI_ICON1);
m_TabWell.UpdateWindow(); ///更新TabControl
//默认先为不显示列表
//ShowControlBar(&m_wndMyBarWellList, !m_wndMyBarWellList.IsVisible(), FALSE);
//**************************
return 0;
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
void CMainFrame::CmdMenuSelwell()
{
// TODO: Add your command handler code here
ShowControlBar(&m_wndMyBarWellList, !m_wndMyBarWellList.IsVisible(), FALSE);
}
void CMainFrame::OnUpdateMenuSelwell(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable();
pCmdUI->SetCheck(m_wndMyBarWellList.IsVisible());
}
void CMainFrame::CmdMenuLinkserver()
{
// TODO: Add your command handler code here
CLinkServer dlg;
dlg.DoModal();
}
BOOL CMainFrame::CreateComboBox(UINT nID)
{
int index = 0;
RECT rect;
//找到指定的工具
while(m_wndToolBar.GetItemID(index)!=nID)
index++;
//设置指定工具的宽度并获取新的区域
m_wndToolBar.SetButtonInfo(index, nID, TBBS_SEPARATOR, SNAP_WIDTH);
m_wndToolBar.GetItemRect(index, &rect);
//设置位置
rect.top+=2;
rect.bottom += 200;
// 创建并显示
if (!m_wndToolBar.m_wndZoom.Create(WS_CHILD|WS_VISIBLE | CBS_AUTOHSCROLL |
CBS_DROPDOWNLIST | CBS_HASSTRINGS ,
rect, &m_wndToolBar, nID))
{
TRACE0("Failed to create combo-box\n");
return FALSE;
}
m_wndToolBar.m_wndZoom.ShowWindow(SW_SHOW);
return TRUE;
}
BOOL CMainFrame::BeginLogin()
{
CLinkServer dlg;
if(dlg.DoModal() == IDOK)
{
dlg.DestroyWindow();
return TRUE;
}
else
{
dlg.DestroyWindow();
return FALSE;
}
}
BOOL CMainFrame::LoadWindowPlacement(LPWINDOWPLACEMENT pwp)
{
CString strBuffer =
AfxGetApp()->GetProfileString ("Settings", "WindowPos");
if (strBuffer.IsEmpty ())
return FALSE;
int cRead = _stscanf (strBuffer, "%i:%i:%i:%i:%i:%i:%i:%i:%i:%i",
&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);
if (cRead != 10)
return FALSE;
return TRUE;
}
void CMainFrame::SaveWindowPlacement(LPWINDOWPLACEMENT pwp)
{
CString strBuffer;
strBuffer.Format("%i:%i:%i:%i:%i:%i:%i:%i:%i:%i",
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 ("Settings","WindowPos",strBuffer);
}
void CMainFrame::OnClose()
{
// TODO: Add your message handler code here and/or call default
WINDOWPLACEMENT wp;
if (GetWindowPlacement(&wp))
{
// if (IsZoomed ())
// {
// wp.flags |= WPF_RESTORETOMAXIMIZED;
// }
SaveWindowPlacement(&wp);
}
CMDIFrameWnd::OnClose();
}
void CMainFrame::OnMenuParameter()
{
// TODO: Add your command handler code here
CSetParameter dlg;
dlg.DoModal();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -