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

📄 dswindow.cpp

📁 TabBars的开源源码
💻 CPP
字号:
/***************************************************************************/
/* NOTE:                                                                   */
/* This document is copyright (c) by Oz Solomonovich.  All non-commercial  */
/* use is allowed, as long as this document not altered in any way, and    */
/* due credit is given.                                                    */
/***************************************************************************/

// DSWindow.cpp : implementation file
//
// This is a specialized tab manager window used to subclassed DevStudio
// document windows.  It's main responsibility is to manage the difference
// between zoomed and normal window states (zoomed windows require room
// for the tabs).
//

//this line was inserted and notified to you
//I remove some function or porpert which this addin do not use
//it cound not be replaced by original file

#include "stdafx.h"
#include "TabBars.h"
#include "Commands.h"
#include "TabManagerWnd.h"
#include "TabBarWnd.h"
//#include "Options.h"
#include "Commands.h"
#include "DSWindow.h"
//#include "Config.h"

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


#define SWP_NOEVERYTHING  \
    (SWP_NOSIZE | SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE)


/////////////////////////////////////////////////////////////////////////////
// CDSWindow

CDSWindow::CDSWindow(IGenericWindow *pGWindow, HWND hDSWindow, 
    CTabBarsWnd *pTabsWnd) : CTabManagerWindow(pGWindow, hDSWindow)
{
    m_cResizeRef = 0;
    m_bLastZoom  = FALSE;
    m_LastOrientation = SnapOrientations(999);  // default: illegal value
    m_iTimerCount = 0;
//    m_idTimer = SetTimer(101, 100, NULL);
}

CDSWindow::~CDSWindow()
{
    if (pGlobalActiveDSWindow == this)
    {
       pGlobalActiveDSWindow = NULL;
    }
}


BEGIN_MESSAGE_MAP(CDSWindow, CTabManagerWindow)
    //{{AFX_MSG_MAP(CDSWindow)
    ON_WM_WINDOWPOSCHANGING()
    ON_WM_DESTROY()
	ON_WM_CLOSE()
	ON_WM_TIMER()
	//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CDSWindow message handlers

void CDSWindow::OnDestroy() 
{
    KillTimer(m_idTimer);

    if (m_bManaging)
    {
        pGlobalTabs->ShowWindow(SW_HIDE);
    }

    // BUG BUG: DevStudio won't issue a Window Deactivation event when the
    // last window is closed.  we'll overcome this by forcing a tab update
    // after each window is closed
    if (cfg_iSnap == ssMDI)
    {
        pGlobalTabs->UpdateTabs();
    }

    CTabManagerWindow::OnDestroy();
}

void CDSWindow::PostNcDestroy() 
{
    if (pGlobalActiveDSWindow == this)
    {
        pGlobalActiveDSWindow = NULL;
        delete this;
    }

    CTabManagerWindow::PostNcDestroy();
}

// This timer even is used to periodically check that the tabs are in sync.
// with the current window list.  Since a full tab update takes time and
// may cause unwanted flicker, it is done only every 10 timer calls.  In all
// other cases, the tabs are updated if the number of windows isn't the same
// as the number of tabs (see below).
void CDSWindow::OnTimer(UINT nIDEvent) 
{
    // first, a sanity check:
    ASSERT(this == pGlobalActiveDSWindow);    
    ASSERT(pGlobalTabs);

    CTabManagerWindow::OnTimer(nIDEvent);

    if (nIDEvent == m_idTimer)
    {
/*        if (++m_iTimerCount == cfg_iRefreshInterval  &&  cfg_bAutoRefresh)
        {
            // Refresh at the given auto-refresh rate.  Sometimes things like
            // asterisks on tabs aren't updated, and we can compensate for
            // that be forcing the tabs to update
            PostUpdateMessage();
            m_iTimerCount = 0;
        }
        else
*/        {
            // Quick check: update only if the number of windows changed.  
            // When the user causes a docked DevStudio window (i.e. Output,
            // Disassembly, etc.) to open or close, we get no direct 
            // notification.  In some circumstances, the only evidence that 
            // anything changed is the fact that the number of windows isn't
            // the same as the number of tabs.
            // This check is preformed every 1/2 second.
            if ((m_iTimerCount % 5) == 0)
            {
                CheckTabCount();
            }                
        }
    }
}

void CDSWindow::OnWindowPosChanging(WINDOWPOS FAR* lpwndpos) 
{
    if ((lpwndpos->flags & (SWP_NOMOVE | SWP_NOSIZE)) != (SWP_NOMOVE | SWP_NOSIZE))
    {
        // Sometimes, this function is called twice for the same window area 
        //  (e.g. when running a program), thus the window's size might be 
        //  decreased too much.  
        //  We use reference counting to assure that the window size is only
        //  changed once (m_cResizeRef).

        m_cResizeRef++;

        if (m_cResizeRef == 1)
        {
            if (IsZoomed() != m_bLastZoom   || cfg_iOrientation != m_LastOrientation)
            {
                m_bLastZoom = IsZoomed();
                m_LastOrientation = SnapOrientations(cfg_iOrientation);

                // Zoomed windows need to be resized to make room for the 
                //  tabs.  They also need a border.
                if (m_bLastZoom)
                {
                    int cyCaption = GetSystemMetrics(SM_CYCAPTION) + 4;

                    if(cfg_iOrientation == soBottom)
                    {
                        SetBorder(CRect(4, 0, 0, 3));
                    }

                    SetMakeSpace(true);
                }
                else
                {
                    SetBorder(CRect(0, 0, 0, 0));
                    SetMakeSpace(false);
                }
            }
        }

        m_cResizeRef--;
    }
    else
    {
        int i = 0;
    }

    CTabManagerWindow::OnWindowPosChanging(lpwndpos);
}


/////////////////////////////////////////////////////////////////////////////
// CDSWindow attributes

bool CDSWindow::SetManaging(bool bManaging)
{
    if (m_bManaging  &&  !bManaging)
    {
        pGlobalTabs->ShowWindow(SW_HIDE);
    }

    return CTabManagerWindow::SetManaging(bManaging);
}

// needed for compatibility with Visual Assist 
HWND CDSWindow::GetSaferHwnd()
{
    if (!this) 
			return NULL;
    return ::IsWindow(m_hWnd)? m_hWnd : NULL;
}

⌨️ 快捷键说明

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