亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? progresswnd.cpp

?? 《MFC窗口程序設計》書籍源碼 詳細講解MFC框架程序設計
?? CPP
字號:
// ProgressWnd.cpp : implementation file
//
// Written by Chris Maunder (chrismaunder@codeguru.com)
// Copyright 1998-2002
//
// CProgressWnd is a drop-in popup progress window for use in
// programs that a time consuming. Check out the header file
// or the accompanying HTML doc file for details.
//
// This code may be used in compiled form in any way you desire. This
// file may be redistributed by any means PROVIDING it is not sold for
// profit without the authors written consent, and providing that this
// notice and the authors name is included. If the source code in 
// this file is used in any commercial application then an email to
// the me would be nice.
//
// This file is provided "as is" with no expressed or implied warranty.
// The author accepts no liability if it causes any damage to your
// computer, causes your pet cat to fall ill, increases baldness or
// makes you car start emitting strange noises when you start it up.
//
// Expect bugs.
// 
// Please use and enjoy. Please let me know of any bugs/mods/improvements 
// that you have found/implemented and I will fix/incorporate them into this
// file. 
//
// Updated May 18 1998 - added PeekAndPump function to allow modal operation,
//                       with optional "Cancel on ESC" (Michael <mbh-ep@post5.tele.dk>)
//         Nov 27 1998 - Removed modal stuff from PeekAndPump
//         Dec 18 1998 - added WS_EX_TOPMOST to the creation flag
//         Apr 14 2002 - Added SaveCurrentSettings to OnCancel (Geert Delmeiren)
//         Apr 22 2002 - Minor mods by Luke Gabello

#include "stdafx.h"
#include "ProgressWnd.h"

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

#define IDC_CANCEL   10
#define IDC_TEXT     11
#define IDC_PROGRESS 12

LPCTSTR szSection = _T("Settings");   
LPCTSTR szEntryX  = _T("X");
LPCTSTR szEntryY  = _T("Y");

/////////////////////////////////////////////////////////////////////////////
// CProgressWnd

CProgressWnd::CProgressWnd()
{
    CommonConstruct();
}

CProgressWnd::CProgressWnd(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth /* = FALSE */)
{
    CommonConstruct();
    m_strTitle = pszTitle;

    Create(pParent, pszTitle, bSmooth);
}

void CProgressWnd::CommonConstruct()
{

    m_wRenenableWnd  = NULL;

    m_nNumTextLines  = 4;
    m_nPrevPos       = 0;
    m_nPrevPercent   = 0;
    m_nStep          = 1;
    m_nMinValue      = 0;
    m_nMaxValue      = 100;

    m_strTitle       = _T("進度條");
    m_strCancelLabel = _T("取消 ");
    m_bCancelled     = FALSE;
    m_bModal         = FALSE;

    m_bPersistantPosition = TRUE;   // saves and restores position automatically
}

CProgressWnd::~CProgressWnd()
{
    DestroyWindow();
}

BOOL CProgressWnd::Create(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth /* = FALSE */)
{
    BOOL bSuccess;

    // Register window class
    CString csClassName = AfxRegisterWndClass(CS_OWNDC|CS_HREDRAW|CS_VREDRAW,
                                              ::LoadCursor(NULL, IDC_APPSTARTING),
                                              CBrush(::GetSysColor(COLOR_BTNFACE)));

    // Get the system window message font for use in the cancel button and text area
    NONCLIENTMETRICS ncm;
    ncm.cbSize = sizeof(NONCLIENTMETRICS);
    VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
    m_font.CreateFontIndirect(&(ncm.lfMessageFont)); 

    // If no parent supplied then try and get a pointer to it anyway
    if (!pParent)
        pParent = AfxGetMainWnd();

    // Create popup window
    bSuccess = CreateEx(WS_EX_DLGMODALFRAME|WS_EX_TOPMOST, // Extended style
                        csClassName,                       // Classname
                        pszTitle,                          // Title
                        WS_POPUP|WS_BORDER|WS_CAPTION,     // style
                        0,0,                               // position - updated soon.
                        390,130,                           // Size - updated soon
                        pParent->GetSafeHwnd(),            // handle to parent
                        0,                                 // No menu
                        NULL);    
    if (!bSuccess) 
		return FALSE;

    // Now create the controls
    CRect TempRect(0,0,10,10);

    bSuccess = m_Text.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_NOPREFIX|SS_LEFTNOWORDWRAP,
                             TempRect, this, IDC_TEXT);
    if (!bSuccess)
		return FALSE;

    DWORD dwProgressStyle = WS_CHILD|WS_VISIBLE;
#ifdef PBS_SMOOTH    
    if (bSmooth)
       dwProgressStyle |= PBS_SMOOTH;
#endif
    bSuccess = m_wndProgress.Create(dwProgressStyle, TempRect, this, IDC_PROGRESS);
    if (!bSuccess) 
		return FALSE;

    bSuccess = m_CancelButton.Create(m_strCancelLabel, 
                                     WS_CHILD|WS_VISIBLE|WS_TABSTOP| BS_PUSHBUTTON, 
                                     TempRect, this, IDC_CANCEL);
    if (!bSuccess)
		return FALSE;

    m_CancelButton.SetFont(&m_font, TRUE);
    m_Text.SetFont(&m_font, TRUE);

    // Resize the whole thing according to the number of text lines, desired window
    // width and current font.
    SetWindowSize(m_nNumTextLines, 400);

    // Center and show window
    if (m_bPersistantPosition)
        GetPreviousSettings();
    else
        CenterWindow();

    Show();

    return TRUE;
}

BOOL CProgressWnd::GoModal(LPCTSTR pszTitle /*=_T("Progress")"*/, BOOL bSmooth /*=FALSE*/)
{
    CWnd *pMainWnd = AfxGetMainWnd();

    if (!::IsWindow(m_hWnd) && !Create(pMainWnd, pszTitle, bSmooth))
        return FALSE;

    // Walk up the window chain to find the main parent wnd and disable it. 
    CWnd * wnd = this;
    do {
        CWnd * parent = wnd->GetParent();

        // if we have no parent (ie. the main window)
        // or if our parent is disabled, 
        // then this is the window that we will want to remember for reenabling
        if (!parent || !parent->IsWindowEnabled()) {
            m_wRenenableWnd = wnd;
            m_wRenenableWnd->EnableWindow(FALSE);
            break;
        }
        wnd = parent;
    } while (1);

    // Re-enable this window
    EnableWindow(TRUE);

    m_bModal = TRUE;

    return TRUE;
}
    
void CProgressWnd::SetWindowSize(int nNumTextLines, int nWindowWidth /*=390*/)
{
    int nMargin = 10;
    CSize EdgeSize(::GetSystemMetrics(SM_CXEDGE), ::GetSystemMetrics(SM_CYEDGE));

    CRect TextRect, CancelRect, ProgressRect;
    CSize CancelSize;

    // Set up a default size for the text area in case things go wrong
    TextRect.SetRect(nMargin,nMargin, nWindowWidth-2*nMargin, 100+2*nMargin);

    // Get DrawText to tell us how tall the text area will be (while we're at
    // it, we'll see how big the word "Cancel" is)
    CDC* pDC = GetDC();
    if (pDC)
	{
        CFont* pOldFont = pDC->SelectObject(&m_font);
        CString str = _T("M");
        for (int i = 0; i < nNumTextLines-1; i++)
			str += _T("\nM");
        pDC->DrawText(str, TextRect, DT_CALCRECT|DT_NOCLIP|DT_NOPREFIX);
        TextRect.right = TextRect.left + nWindowWidth;
        CancelSize = pDC->GetTextExtent(m_strCancelLabel + _T("  ")) +
                                             CSize(EdgeSize.cx*4, EdgeSize.cy*3);
        pDC->SelectObject(pOldFont);
        ReleaseDC(pDC);
    }
    
    // Work out how big (and where) the cancel button should be
    CancelRect.SetRect(TextRect.right-CancelSize.cx, TextRect.bottom+nMargin, 
                       TextRect.right, TextRect.bottom+nMargin + CancelSize.cy);


    // Work out how big (and where) the progress control should be
    ProgressRect.SetRect(TextRect.left, CancelRect.top + EdgeSize.cy, 
                         CancelRect.left-nMargin, CancelRect.bottom - EdgeSize.cy);


    // Resize the main window to fit the controls
    CSize ClientSize(nMargin + TextRect.Width() + nMargin,
                     nMargin + TextRect.Height() + nMargin + CancelRect.Height() + nMargin);

    CRect WndRect, ClientRect;
    GetWindowRect(WndRect); GetClientRect(ClientRect);
    WndRect.right = WndRect.left + WndRect.Width()-ClientRect.Width()+ClientSize.cx;
    WndRect.bottom = WndRect.top + WndRect.Height()-ClientRect.Height()+ClientSize.cy;
    MoveWindow(WndRect);

    // Now reposition the controls...
    m_wndProgress.MoveWindow(ProgressRect);
    m_CancelButton.MoveWindow(CancelRect);
    m_Text.MoveWindow(TextRect);
}

void CProgressWnd::Clear() 
{ 
    SetText(_T(""));
    SetPos(0);
    m_bCancelled = FALSE; 
    m_nPrevPos = 0;

    if (::IsWindow(GetSafeHwnd()))
        UpdateWindow();
}

void CProgressWnd::Hide()  
{ 
    if (!::IsWindow(GetSafeHwnd())) 
        return;

    if (IsWindowVisible())
    {
        ShowWindow(SW_HIDE);
        ModifyStyle(WS_VISIBLE, 0);
    }
}

void CProgressWnd::Show()  
{ 
    if (!::IsWindow(GetSafeHwnd()))
        return;

    if (!IsWindowVisible())
    {
        ModifyStyle(0, WS_VISIBLE);
        ShowWindow(SW_SHOWNA);
        RedrawWindow(NULL,NULL,RDW_ERASE|RDW_FRAME|RDW_INVALIDATE|RDW_UPDATENOW);
    }
}

void CProgressWnd::SetRange(int nLower, int nUpper, int nStep /* = 1 */)    
{
    if (!::IsWindow(GetSafeHwnd())) 
        return;

    // To take advantage of the Extended Range Values we use the PBM_SETRANGE32
    // message intead of calling CProgressCtrl::SetRange directly. If this is
    // being compiled under something less than VC 5.0, the necessary defines
    // may not be available.
#ifdef PBM_SETRANGE32
    ASSERT(-0x7FFFFFFF <= nLower && nLower <= 0x7FFFFFFF);
    ASSERT(-0x7FFFFFFF <= nUpper && nUpper <= 0x7FFFFFFF);
    m_wndProgress.SendMessage(PBM_SETRANGE32, (WPARAM) nLower, (LPARAM) nUpper);
#else
    ASSERT(0 <= nLower && nLower <= 65535);
    ASSERT(0 <= nUpper && nUpper <= 65535);
    m_wndProgress.SetRange(nLower, nUpper);
#endif

    m_nMaxValue = nUpper;
    m_nMinValue = nLower;
    m_nStep     = nStep;

    m_wndProgress.SetStep(nStep);
}

int CProgressWnd::OffsetPos(int nPos)
{ 
    if (!::IsWindow(GetSafeHwnd())) 
        return m_nPrevPos;

    Show();

    return SetPos(m_nPrevPos + nPos);  
}

int CProgressWnd::StepIt()                
{
    if (!::IsWindow(GetSafeHwnd())) 
        return m_nPrevPos;

    Show();

    return SetPos(m_nPrevPos + m_nStep); 
}

int CProgressWnd::SetStep(int nStep)
{
    int nOldStep = m_nStep;
    m_nStep = nStep;
    if (!::IsWindow(GetSafeHwnd())) 
        return nOldStep;

    return m_wndProgress.SetStep(nStep); 
}

int CProgressWnd::SetPos(int nPos)                    
{
#ifdef PBM_SETRANGE32
    ASSERT(-0x7FFFFFFF <= nPos && nPos <= 0x7FFFFFFF);
#else
    ASSERT(0 <= nPos && nPos <= 65535);
#endif

    if (!::IsWindow(GetSafeHwnd())) 
        return m_nPrevPos;

    Show();

    CString strTitle;
    int nPercentage;
    
    m_nPrevPos = nPos;

    if (m_nMaxValue > m_nMinValue)
        nPercentage = (int) (((nPos - m_nMinValue)*100.0)/(m_nMaxValue - m_nMinValue) + 0.5);
    else
        nPercentage = 0;

    if (nPercentage != m_nPrevPercent) 
    {
        m_nPrevPercent = nPercentage;
        strTitle.Format(_T("%s [%d%%]"),m_strTitle,nPercentage);
        SetWindowText(strTitle);
    }
    return m_wndProgress.SetPos(nPos);        
}

void CProgressWnd::SetText(LPCTSTR fmt, ...)
{
    if (!::IsWindow(GetSafeHwnd())) 
        return;

    va_list args;
    TCHAR buffer[512];

    va_start(args, fmt);
    _vstprintf(buffer, fmt, args);
    va_end(args);

    m_Text.SetWindowText(buffer);
}

BEGIN_MESSAGE_MAP(CProgressWnd, CWnd)
    //{{AFX_MSG_MAP(CProgressWnd)
    ON_WM_ERASEBKGND()
	//}}AFX_MSG_MAP
    ON_BN_CLICKED(IDC_CANCEL, OnCancel)
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CProgressWnd message handlers

BOOL CProgressWnd::OnEraseBkgnd(CDC* pDC) 
{
    // Fill background with Catchment background colour
    CBrush backBrush(GetSysColor(COLOR_BTNFACE));
    CBrush* pOldBrush = pDC->SelectObject(&backBrush);
    CRect rect;
    pDC->GetClipBox(&rect);     // Erase the area needed
    pDC->PatBlt(rect.left, rect.top, rect.Width(), rect.Height(), PATCOPY);
    pDC->SelectObject(pOldBrush);

    return TRUE;
}

void CProgressWnd::OnCancel() 
{
    if (m_bPersistantPosition)
        SaveCurrentSettings();

    m_bCancelled = TRUE;
    Hide();

    if (m_bModal)
        PostMessage(WM_CLOSE);

    CWnd *pWnd = AfxGetMainWnd();
    if (pWnd && ::IsWindow(pWnd->m_hWnd))
        pWnd->SetForegroundWindow();
}


BOOL CProgressWnd::DestroyWindow() 
{
    if (m_bPersistantPosition)
        SaveCurrentSettings();

    if (m_bModal)
    {
        m_bModal = FALSE;
        CWnd *pMainWnd = AfxGetMainWnd();

        if (m_wRenenableWnd)
            m_wRenenableWnd->EnableWindow(TRUE);
    }
	
    return CWnd::DestroyWindow();
}

// Message pumping function that can either be used to pump messages during
// long operations. This version will only pass messages to this window (and
// all child windows). (Thanks to Michael <mbh-ep@post5.tele.dk> for this)
void CProgressWnd::PeekAndPump(BOOL bCancelOnESCkey /*= TRUE*/)
{
    if (m_bModal && ::GetFocus() != m_hWnd)
        SetFocus();

    MSG msg;
    while (!m_bCancelled && ::PeekMessage(&msg, NULL,0,0,PM_NOREMOVE)) 
    {
        if (bCancelOnESCkey && (msg.message == WM_CHAR) && (msg.wParam == VK_ESCAPE))
            OnCancel();

        // Cancel button disabled if modal, so we fake it.
        if (m_bModal && (msg.message == WM_LBUTTONUP))
        {
            CRect rect;
            m_CancelButton.GetWindowRect(rect);
            if (rect.PtInRect(msg.pt))
                OnCancel();
        }
  
        if (!AfxGetApp()->PumpMessage()) 
        {
            ::PostQuitMessage(0);
            return;
        } 
    }
}

// Retores the previous window size from the registry
void CProgressWnd::GetPreviousSettings()
{
    int x = AfxGetApp()->GetProfileInt(szSection, szEntryX, -1);
    int y = AfxGetApp()->GetProfileInt(szSection, szEntryY, -1);

    if (x >= 0 && x < GetSystemMetrics(SM_CXSCREEN) &&
        y >= 0 && y < GetSystemMetrics(SM_CYSCREEN))
    {
        SetWindowPos(NULL, x,y, 0,0, SWP_NOSIZE|SWP_NOZORDER);
    }
    else
        CenterWindow();
}

// Saves the current window position registry
void CProgressWnd::SaveCurrentSettings()
{   
    if (!IsWindow(m_hWnd))
        return;

    CRect rect;
    GetWindowRect(rect);

    AfxGetApp()->WriteProfileInt(szSection, szEntryX, rect.left);
    AfxGetApp()->WriteProfileInt(szSection, szEntryY, rect.top);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人免费视频国产在线观看| 成人av免费观看| 亚洲18女电影在线观看| 一区二区三区四区视频精品免费 | 欧美在线一二三四区| 日韩电影一二三区| 裸体在线国模精品偷拍| 亚洲成人在线观看视频| 亚洲精品国产a久久久久久 | 精品一区二区三区日韩| 轻轻草成人在线| 石原莉奈一区二区三区在线观看 | 捆绑调教美女网站视频一区| 亚洲h精品动漫在线观看| 精品一区二区三区的国产在线播放| 国产一区二区不卡在线| 色综合久久99| 日韩免费福利电影在线观看| 久久久久免费观看| 国产精品久线观看视频| 性做久久久久久免费观看 | 中国色在线观看另类| 中文字幕制服丝袜成人av| 亚洲人成在线播放网站岛国| 午夜欧美大尺度福利影院在线看| 成人18视频日本| 精品福利一二区| 亚洲欧洲三级电影| 看片的网站亚洲| 老色鬼精品视频在线观看播放| 国产精品自在在线| 在线中文字幕一区二区| 精品av久久707| 亚洲一区在线观看免费| 精品午夜久久福利影院 | 国产成人精品影视| 欧美探花视频资源| 欧美午夜精品久久久久久孕妇 | 日韩专区中文字幕一区二区| 丁香天五香天堂综合| 欧美无砖专区一中文字| 天使萌一区二区三区免费观看| 99re热这里只有精品免费视频| 国产欧美日韩视频在线观看| 国产精品一区二区在线播放| 欧美日韩亚州综合| 亚洲综合男人的天堂| 99国产精品99久久久久久| 精品国产成人系列| 粉嫩av一区二区三区在线播放| 国产网红主播福利一区二区| 亚洲香肠在线观看| 欧美伊人久久久久久久久影院| 亚洲欧美日韩成人高清在线一区| 成人app网站| 中文字幕永久在线不卡| 粉嫩嫩av羞羞动漫久久久 | 欧美这里有精品| 一区二区三区在线视频播放| 91精品国产综合久久久久| av男人天堂一区| 国产一区欧美日韩| 中文字幕亚洲精品在线观看 | 欧美一级黄色片| 国产九色sp调教91| 午夜久久久久久久久久一区二区| 精品国产1区二区| 国产福利91精品一区| 亚洲六月丁香色婷婷综合久久| 欧美日韩国产在线观看| 国产乱码精品一区二区三区av| 亚洲一线二线三线久久久| 国产日韩欧美麻豆| 日韩一级高清毛片| 欧美色视频一区| 国产福利精品一区二区| 蜜臀精品一区二区三区在线观看 | 亚洲大尺度视频在线观看| 日韩理论片网站| 国产精品拍天天在线| 一区二区三区免费在线观看| 老司机精品视频一区二区三区| 亚洲精品国产无天堂网2021| 国产精品视频看| 国产日韩精品久久久| www国产亚洲精品久久麻豆| 日韩欧美国产综合| 欧美一级xxx| 678五月天丁香亚洲综合网| 欧美性大战久久久| 欧美一区二区三区免费观看视频 | 色综合久久中文字幕| 色又黄又爽网站www久久| 极品少妇xxxx偷拍精品少妇| 亚洲欧美日韩中文字幕一区二区三区| 国产欧美日韩精品一区| 亚洲少妇30p| 亚洲自拍都市欧美小说| 亚洲成人资源在线| 日本成人在线一区| av激情成人网| 精品少妇一区二区三区日产乱码| 日韩精品一区二区三区视频在线观看 | 久久综合色综合88| 亚洲精品成人精品456| 一区二区三区精品在线| 日韩美女久久久| 午夜视频在线观看一区二区 | 亚洲精品伦理在线| 国产在线不卡视频| 精品视频一区三区九区| 国产精品婷婷午夜在线观看| 午夜av区久久| 色一情一伦一子一伦一区| 日韩三级免费观看| 亚洲国产三级在线| 久久91精品久久久久久秒播| 成人午夜视频免费看| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 欧美日韩免费不卡视频一区二区三区| 国产欧美日韩在线观看| 男人的j进女人的j一区| 91久久线看在观草草青青| 国产精品久久久久影院| 国产一级精品在线| 日韩一级高清毛片| 日韩和欧美的一区| 欧美一区二区私人影院日本| 亚洲激情欧美激情| 日本道色综合久久| 日韩伦理av电影| 97国产精品videossex| 亚洲精品高清在线| 青娱乐精品视频| 欧美日韩极品在线观看一区| 国产精品欧美极品| 成人免费视频一区| 亚洲视频一区在线| 欧美日韩中文精品| 黄色日韩网站视频| 国产精品国产自产拍高清av| 一本到不卡免费一区二区| 亚洲一区二区视频| 久久精品视频在线看| 成人国产亚洲欧美成人综合网| 亚洲理论在线观看| 5566中文字幕一区二区电影| 韩国毛片一区二区三区| 亚洲欧洲日产国产综合网| 欧美午夜精品免费| 国产一区二区h| 亚洲a一区二区| 国产精品视频一区二区三区不卡| 日本韩国欧美三级| 精品在线你懂的| 亚洲国产一区二区三区青草影视| 538prom精品视频线放| 99精品国产一区二区三区不卡| 亚洲18影院在线观看| 亚洲欧美综合另类在线卡通| 欧美一二三区精品| 欧美日韩一区二区三区免费看| 狠狠网亚洲精品| 蓝色福利精品导航| 亚洲国产精品久久久久秋霞影院 | 青青草国产成人av片免费| 综合久久综合久久| 国产精品不卡在线| 国产亚洲成av人在线观看导航| 日韩一级免费观看| 日韩西西人体444www| 69堂亚洲精品首页| 欧美三级在线播放| 这里是久久伊人| 在线播放欧美女士性生活| 欧美日韩美少妇| 久久影院视频免费| 亚洲国产成人一区二区三区| 亚洲综合在线观看视频| 国内精品不卡在线| 欧美日韩不卡视频| 亚洲欧美一区二区不卡| 中文字幕一区二区三区色视频| 亚洲精选免费视频| 成人综合婷婷国产精品久久| 69堂精品视频| 亚洲最大的成人av| 国产成人免费视频 | 久久99国产精品久久99| 在线观看日韩精品| 亚洲欧洲综合另类| 亚洲免费资源在线播放| 性做久久久久久免费观看| 亚洲欧洲制服丝袜| 日韩av二区在线播放| 五月综合激情日本mⅴ| 91网站黄www| 久久综合九色综合97婷婷| 亚洲午夜精品久久久久久久久| 国产一区二区在线观看视频|