📄 mainfrm.cpp
字号:
pDock = new CDockBarEx;
if (!pDock->Create(this,
WS_CLIPSIBLINGS|WS_CLIPCHILDREN|WS_CHILD|WS_VISIBLE |
dwDockBarMapEx[i][1], dwDockBarMapEx[i][0]))
{
AfxThrowResourceException();
}
}
}
}
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::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
}
CString strName;
strName.LoadString(IDS_TOOLBAR);
m_wndToolBar.SetWindowText(strName);
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
}
{ // dodanie pola do wy渨ietlania aktualnego wiersza i kolumny
UINT uID;
UINT uStyle;
int nWidth;
CRect rectArea(0,0,0,0);
if (m_strFormat.LoadString(IDS_ROW_COLUMN))
{
CString str;
str.Format(m_strFormat,99999,999);
m_wndStatusBar.GetPaneInfo(1, uID, uStyle, nWidth);
#ifdef USE_CRYSTAL_EDIT
m_wndStatusBar.SetPaneInfo(1, uID, SBPS_NOBORDERS | SBPS_DISABLED, 1);
#else
CClientDC dc(&m_wndStatusBar);
dc.SelectObject(m_wndStatusBar.GetFont());
dc.DrawText(str, -1, rectArea, DT_SINGLELINE | DT_CALCRECT);
m_wndStatusBar.SetPaneInfo(1, uID, uStyle, rectArea.Width());
#endif
}
m_wndStatusBar.GetPaneInfo(2, uID, uStyle, nWidth);
m_wndStatusBar.SetPaneInfo(2, uID, uStyle, 16); // szeroko滄 obrazka
m_bmpCode.LoadMappedBitmap(IDB_CODE);
m_bmpDebug.LoadMappedBitmap(IDB_DEBUG);
m_pfnOldProc = (WNDPROC)::SetWindowLong(m_wndStatusBar.m_hWnd,GWL_WNDPROC,(LONG)StatusBarWndProc);
}
// TODO: Remove this if you don't want tool tips or a resizeable toolbar
m_wndToolBar.SetBarStyle(m_wndToolBar.GetBarStyle() | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC);
EnableDockingEx(CBRS_ALIGN_ANY); //CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
// 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);
// TODO: Change the value of ID_VIEW_REGISTERBAR to an appropriate value: // 1. Open the file resource.h // 2. Find the definition for the symbol ID_VIEW_REGISTERBAR // 3. Change the value of the symbol. Use a value in the range // 0xE804 to 0xE81A that is not already used by another symbol // CG: The following block was inserted by the 'Dialog Bar' component {
// Initialize dialog bar m_wndRegisterBar
if (!m_wndRegisterBar.Create(this,
CBRS_RIGHT | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_HIDE_INPLACE | CBRS_SIZE_FIXED, ID_VIEW_REGISTERBAR))
{
TRACE0("Failed to create dialog bar m_wndRegisterBar\n");
return -1; // fail to create
}
// m_wndRegisterBar.SetBarStyle(CBRS_BORDER_TOP|CBRS_BORDER_BOTTOM|CBRS_BORDER_LEFT|CBRS_BORDER_RIGHT);
m_wndRegisterBar.EnableDocking(0); //CBRS_ALIGN_ANY);
DockControlBar(&m_wndRegisterBar);
FloatControlBar(&m_wndRegisterBar, CPoint(100, 100));
// EnableDocking(0); //CBRS_ALIGN_ANY);
// DockControlBar(&m_wndRegisterBar);
// FloatControlBar(&m_wndRegisterBar,CPoint(10,10)); } if (!m_wndHelpBar.Create(this, AFX_IDW_CONTROLBAR_LAST))
{
TRACE0("Failed to create help bar\n");
return -1; // fail to create
}
m_wndHelpBar.EnableDocking(CBRS_ALIGN_LEFT | CBRS_ALIGN_RIGHT);
m_wndHelpBar.SetWindowText("Dynamic Help");
DockControlBar(&m_wndHelpBar);
// LoadBarState(REG_ENTRY_LAYOUT);
bool bEmptyInfo= true;
{
CDockState state;
state.LoadState(REG_ENTRY_LAYOUT);
for (int i=0; i < state.m_arrBarInfo.GetSize(); i++)
{
CControlBarInfo* pInfo= (CControlBarInfo*)(state.m_arrBarInfo[i]);
if (pInfo->m_nBarID == ID_VIEW_REGISTERBAR)
pInfo->m_bVisible = false; // registerBar zawsze ukryty po starcie aplikacji
}
bEmptyInfo = state.m_arrBarInfo.GetSize() == 0;
SetDockState(state);
}
if (bEmptyInfo) // pierwsze uruchomienie aplikacji w systemie?
{
CPoint point(32,32); // pocz箃kowe po硂縠nie
CMiniDockFrameWnd* pDockFrame = CreateFloatingFrame(CBRS_ALIGN_TOP);
ASSERT(pDockFrame != NULL);
pDockFrame->SetWindowPos(NULL, point.x, point.y, 0, 0,
SWP_NOSIZE|SWP_NOZORDER|SWP_NOACTIVATE);
if (pDockFrame->m_hWndOwner == NULL)
pDockFrame->m_hWndOwner = m_wndRegisterBar.m_hWnd;
CDockBar* pDockBar = (CDockBar*)pDockFrame->GetDlgItem(AFX_IDW_DOCKBAR_FLOAT);
ASSERT(pDockBar != NULL);
ASSERT_KINDOF(CDockBar, pDockBar);
ASSERT(m_wndRegisterBar.m_pDockSite == this);
// if this assertion occurred it is because the parent of pBar was not
// initially this CFrameWnd when pBar's OnCreate was called
// (this control bar should have been created with a different
// parent initially)
pDockBar->DockControlBar(&m_wndRegisterBar);
pDockFrame->RecalcLayout(true);
pDockFrame->ShowWindow(SW_HIDE);
// pDockFrame->UpdateWindow();
m_wndRegisterBar.ModifyStyle(WS_VISIBLE,0);
}
for (int i =0; cfonts[i]; i++) // utworzenie font體
{
// cfonts[i]->DeleteObject();
cfonts[i]->CreateFontIndirect(fonts[i]);
}
m_Memory.Create(theApp.m_global.GetMem(), theApp.m_global.GetStartAddr(), CMemoryInfo::VIEW_MEMORY);
m_ZeroPage.Create(theApp.m_global.GetMem(), 0x00, CMemoryInfo::VIEW_ZEROPAGE);
m_Stack.Create(theApp.m_global.GetMem(), 0x00, CMemoryInfo::VIEW_STACK);
m_wndLog.Create();
return 0;
}
//-----------------------------------------------------------------------------
LRESULT CALLBACK CMainFrame::StatusBarWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
CWnd *pWnd= FromHandlePermanent(hWnd);
// ASSERT (pWnd->IsKindOf(RUNTIME_CLASS(CStatusBar)));
switch (msg)
{
case WM_PAINT:
{
LRESULT ret= (*CMainFrame::m_pfnOldProc)(hWnd,msg,wParam,lParam);
if (ret == 0)
{
bool bCode;
if (theApp.m_global.IsDebugger()) // jest dzia砤j筩y debugger ?
bCode = false;
else if (theApp.m_global.IsCodePresent()) // jest kod programu?
bCode = true;
else
return ret; // ani kodu programu, ani debuggera
CRect rect;
(*m_pfnOldProc)(hWnd,SB_GETRECT,2,(LPARAM)(RECT *)rect); // miejsce na obrazek - wymiary
int borders[3];
(*m_pfnOldProc)(hWnd,SB_GETBORDERS,0,(LPARAM)borders); // grubo滄 obw骴ki
rect.DeflateRect(borders[0]+1,borders[1]-1);
CClientDC dc(pWnd);
if (dc)
{
CDC memDC;
memDC.CreateCompatibleDC(&dc);
if (memDC)
{
CBitmap *pOldBmp= memDC.SelectObject(bCode ? &m_bmpCode : &m_bmpDebug);
dc.BitBlt(rect.left+2, rect.top, rect.Width(), rect.Height(), &memDC, 0, 0, SRCCOPY);
memDC.SelectObject(pOldBmp);
}
}
}
return ret;
}
default:
return (*CMainFrame::m_pfnOldProc)(hWnd,msg,wParam,lParam);
}
}
//-----------------------------------------------------------------------------
afx_msg LRESULT CMainFrame::OnStartDebugger(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
RECT rect;
m_wndStatusBar.SendMessage(SB_GETRECT,2,(LPARAM)&rect); // miejsce na obrazek - wymiary
m_wndStatusBar.InvalidateRect(&rect); // obrazek pch硑 do przerysowania
return 0;
}
afx_msg LRESULT CMainFrame::OnExitDebugger(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
RECT rect;
m_wndStatusBar.SendMessage(SB_GETRECT,2,(LPARAM)&rect); // miejsce na obrazek - wymiary
m_wndStatusBar.InvalidateRect(&rect); // obrazek pch硑 do przerysowania
return 0;
}
afx_msg LRESULT CMainFrame::OnChangeCode(WPARAM /*wParam*/, LPARAM /*lParam*/)
{
RECT rect;
m_wndStatusBar.SendMessage(SB_GETRECT,2,(LPARAM)&rect); // miejsce na obrazek - wymiary
m_wndStatusBar.InvalidateRect(&rect); // obrazek pch硑 do przerysowania
return 0;
}
//-----------------------------------------------------------------------------
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
CWinApp *pApp = AfxGetApp();
CRect desk;
::SystemParametersInfo(SPI_GETWORKAREA, 0, desk, 0);
cs.x = pApp->GetProfileInt(REG_ENTRY_MAINFRM, REG_POSX, 50);
cs.y = pApp->GetProfileInt(REG_ENTRY_MAINFRM, REG_POSY, 50);
cs.cx = pApp->GetProfileInt(REG_ENTRY_MAINFRM, REG_SIZX, desk.Width() - 100);
cs.cy = pApp->GetProfileInt(REG_ENTRY_MAINFRM, REG_SIZY, desk.Height() - 100);
// prevent from appearing outside desk area
if (cs.x < desk.left)
cs.x = desk.left;
if (cs.y < desk.top)
cs.y = desk.top;
if (cs.x + cs.cx > desk.right)
cs.x = desk.right - min(cs.cx, desk.Width());
if (cs.y + cs.cy > desk.bottom)
cs.y = desk.bottom - min(cs.cy, desk.Height());
if (pApp->GetProfileInt(REG_ENTRY_MAINFRM, REG_STATE, 0)) // maximize?
C6502App::m_bMaximize = true;
// C6502App::m_bFileNew = pApp->GetProfileInt(REG_ENTRY_MAINFRM,REG_FILENEW,1); // new file
ConfigSettings(true); // odczyt ustawie
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -