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

📄 mainfrm.cpp

📁 Ever wanted to just type tail -f error_log on Windows?Envious of your Unix friends who can track cha
💻 CPP
📖 第 1 页 / 共 2 页
字号:
// 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::SetTop (void)
{
  ModifyStyleEx (m_bAlwaysOnTop ? 0 : WS_EX_TOOLWINDOW, m_bAlwaysOnTop ? WS_EX_TOOLWINDOW : 0, 0);
  
  SetWindowPos (m_bAlwaysOnTop ? &wndTopMost : &wndNoTopMost, 0, 0, 0, 0, 
                SWP_SHOWWINDOW | SWP_FRAMECHANGED | SWP_NOMOVE | SWP_NOSIZE);
}

void CMainFrame::OnAlwaysTop() 
{
  m_bAlwaysOnTop = !m_bAlwaysOnTop;

  SetTop ();
}

void CMainFrame::OnUpdateAlwaysTop(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
  if (pCmdUI->m_pMenu)
    pCmdUI->SetCheck (m_bAlwaysOnTop ? MF_CHECKED : MF_UNCHECKED);


}

void CMainFrame::OnUpdateEditCopy(CCmdUI* pCmdUI) 
{
	// TODO: Add your command update UI handler code here
  if (pCmdUI->m_pMenu)
    pCmdUI->Enable (TRUE);	
}

void CMainFrame::OnEditCopy() 
{
  CMDIChildWnd* pChild = NULL;
  CTailView* pView = NULL;

  pChild = MDIGetActive();

  if (!pChild)
    return;

// Get the active view attached to the active MDI child// window.
  pView = (CTailView*) pChild->GetActiveView ();

  if (pView)
    pView->CopyText ();

}

void CMainFrame::OnClose() 
{
  RECT rc;
  CTailApp* app;
  WINDOWPLACEMENT wp;
  CMDIChildWnd* pChild = NULL;
//  BOOL bMax = FALSE;
  CSettings* pSettings = NULL;

  GetWindowRect (&rc);

  CTailView* pView = NULL;

  pChild = MDIGetActive();

  app = (CTailApp*) AfxGetApp ();

  pSettings = app->GetSettings ();

  if (pChild)
  {
    pChild->GetWindowPlacement (&wp);

    pSettings->SetMaxChild (wp.showCmd == SW_SHOWMAXIMIZED);
  }

  pSettings->SetWindowRect (rc);

  pSettings->Save ();

/*  if (app)
  {
    app->WriteProfileInt (_T("Settings"), _T("Left"), rc.left);
    app->WriteProfileInt (_T("Settings"), _T("Top"), rc.top);
    app->WriteProfileInt (_T("Settings"), _T("Right"), rc.right);
    app->WriteProfileInt (_T("Settings"), _T("Bottom"), rc.bottom);

    app->WriteProfileInt (_T("Settings"), _T("AlwaysOnTop"), m_bAlwaysOnTop);
    app->WriteProfileInt (_T("Settings"), _T("BeepOnChange"), theApp.m_bBeepOnChanges);
    app->WriteProfileInt (_T("Settings"), _T("Timeout"), theApp.m_nTimeout);
    app->WriteProfileInt (_T("Settings"), _T("Maximised"), bMax);
    app->WriteProfileInt (_T("Settings"), _T("IgnoreHotStartup"), theApp.m_bIgnoreHotStartup);
    app->WriteProfileInt (_T("Settings"), _T("ShowAllLines"), theApp.m_bShowAllLines);
    app->WriteProfileInt (_T("Settings"), _T("AutoLoadLastFile"), theApp.m_bAutoLoad);
    app->WriteProfileInt (_T("Settings"), _T("HighlightLine"), theApp.m_bHighlightLine);
    app->WriteProfileInt (_T("Settings"), _T("HighlightWholeLine"), theApp.m_bHighlightWholeLine);
    app->WriteProfileInt (_T("Settings"), _T("HighlightColour"), theApp.m_lHighlightColour);
    app->WriteProfileInt (_T("Settings"), _T("ShowWorkspace"), theApp.m_bShowWorkspace);
    app->WriteProfileInt (_T("Settings"), _T("WordWrap"), theApp.m_bWordWrap);
    app->WriteProfileInt (_T("Settings"), _T("BackGroundColour"), theApp.m_lBackGroundColour);

    LPCSTR lpszRegKey = NULL;
    HKEY hKey = NULL;

    lpszRegKey = theApp.m_pszRegistryKey;

    if (theApp.m_bGotFont)
    {
      if ((ERROR_SUCCESS == RegOpenKey (HKEY_CURRENT_USER, "Software", &hKey))
      && (ERROR_SUCCESS == RegOpenKey (hKey, lpszRegKey, &hKey))
      && (ERROR_SUCCESS == RegOpenKey (hKey, "Tail for Win32", &hKey))
      && (ERROR_SUCCESS == RegOpenKey (hKey, "Settings", &hKey)))
      {
        RegSetValueEx (hKey, "Font", NULL, REG_BINARY, (LPBYTE) &theApp.stLogFont, sizeof (LOGFONT));
      }
    }
  } */

  pSettings->SaveKeywords ();

  Shell_NotifyIcon (NIM_DELETE,&m_stNotifyIcon);     

	CMDIFrameWnd::OnClose();
}

void CMainFrame::OnShowHotLines() 
{
  CTailApp* theApp = (CTailApp*) AfxGetApp ();
  CSettings* pSettings = theApp->GetSettings ();

  pSettings->SetShowAllLines (!pSettings->m_bShowAllLines);	
}

void CMainFrame::OnUpdateShowHotLines(CCmdUI* pCmdUI) 
{
  CTailApp* theApp = (CTailApp*) AfxGetApp ();
  CSettings* pSettings = theApp->GetSettings ();

  if (pCmdUI->m_pMenu)
  {
    pCmdUI->SetCheck (pSettings->GetShowAllLines() ? MF_UNCHECKED : MF_CHECKED);	
  }
}

void CMainFrame::OnAutoload() 
{
  CSettings* pSettings = theApp.GetSettings ();

  pSettings->SetAutoLoad (!pSettings->GetAutoLoad());	
}

void CMainFrame::OnUpdateAutoload(CCmdUI* pCmdUI) 
{
  CSettings* pSettings = theApp.GetSettings ();

  if (pCmdUI->m_pMenu)
  {
    pCmdUI->SetCheck (pSettings->GetAutoLoad() ? MF_CHECKED : MF_UNCHECKED);	
  }
}

void CMainFrame::OnUpdateViewWorkspace(CCmdUI* pCmdUI) 
{
  CSettings* pSettings = theApp.GetSettings ();

  if (pCmdUI->m_pMenu)
  {
    pCmdUI->SetCheck (pSettings->GetShowWorkspace() ? MF_CHECKED : MF_UNCHECKED);	
  }
}

void CMainFrame::OnNewWorkspace() 
{
  theApp.m_pWorkspace->AddNewWorkspace ();	
}

void CMainFrame::OnSize(UINT nType, int cx, int cy) 
{
	CMDIFrameWnd::OnSize(nType, cx, cy);
	
  if (SIZE_MINIMIZED == nType)
  {
/*    m_stNotifyIcon.cbSize = sizeof (NOTIFYICONDATA);
    m_stNotifyIcon.hWnd = GetSafeHwnd();
    m_stNotifyIcon.uID = IDI_APPICON;
    m_stNotifyIcon.uFlags = NIF_TIP | NIF_ICON | NIF_MESSAGE;
    m_stNotifyIcon.uCallbackMessage = WM_NOTIFY_CALLBACK;
    m_stNotifyIcon.hIcon = AfxGetApp()->LoadIcon (IDI_APPICON);
    
    GetWindowText (m_stNotifyIcon.szTip, 200);
    
    Shell_NotifyIcon (NIM_ADD,&m_stNotifyIcon);
    
    ShowWindow (SW_MINIMIZE);
    ShowWindow (SW_HIDE); */
  }	
}

// New window proc to handle tray icon callback.
LRESULT CMainFrame::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 
{
  switch (message)
  {
  case WM_NOTIFY_CALLBACK:
//    ShowWindow (SW_SHOWNA);

    if (lParam == WM_LBUTTONDBLCLK)
    {
      SetForegroundWindow();
    }

    if (lParam == WM_RBUTTONDOWN)
    {
      CPoint point;
      CMenu* pmenu;
      CMenu* pPopup;

      GetCursorPos(&point);

      pmenu = GetSystemMenu(FALSE);
      //     VERIFY(menu.LoadMenu(IDR_POPUP_MENU));
      
//      if (pPopup = pmenu->GetSubMenu(0))
      pPopup = pmenu;
      {
        //      if (!m_hWndPrevious)
        //        pPopup->EnableMenuItem(ID_UNDO, MF_GRAYED|MF_BYCOMMAND);
        SetForegroundWindow();
        pPopup->TrackPopupMenu (TPM_LEFTALIGN|TPM_BOTTOMALIGN|TPM_RIGHTBUTTON, 
                                point.x, 
                                point.y,
                                this);
      }
    }

    break;

  }

	return CMDIFrameWnd::WindowProc(message, wParam, lParam);
}

void CMainFrame::OnViewWorkspace() 
{
  CSettings* pSettings = theApp.GetSettings ();

	if(::IsWindow(m_WorkspaceBar))
	{
		ShowControlBar(&m_WorkspaceBar, !pSettings->m_bShowWorkspace, FALSE);
	}
  
  pSettings->m_bShowWorkspace = !pSettings->m_bShowWorkspace;
}

⌨️ 快捷键说明

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