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

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

?? multtimer.cpp

?? window下的多線程編程參考書。值得一讀
?? CPP
字號:
//
// FILE: MultTimer.cpp
//
// Copyright (c) 1997 by Aaron Michael Cohen and Mike Woodring
//
/////////////////////////////////////////////////////////////////////////
#include "MultTimer.h"

// define the single application instance...
CMultTimerApp theApp;

// static class variables for popping up the dialogs just to 
// the right and below the last one...
int CMultTimerDlg::s_LastDialogX = 0;
int CMultTimerDlg::s_LastDialogY = 0;

// CMultTimerApp application class member functions...
BOOL CMultTimerApp::InitInstance(void) {
    // no child threads at first...
    m_lChildThreadCount = 0;

    CMultTimerDlg *pDlg = new CMultTimerDlg();
  
    // this is also the application main window...
    m_pMainWnd = pDlg;

    // inform the user...
    CString csTitle;
    pDlg->GetWindowText(csTitle);
    csTitle += " (primary thread)";
    pDlg->SetWindowText(csTitle);

    return TRUE;
}

void CMultTimerApp::IncrementChildThreadCount(void) {
    ::InterlockedIncrement(&m_lChildThreadCount);
}

void CMultTimerApp::DecrementChildThreadCount(void) {
    ::InterlockedDecrement(&m_lChildThreadCount);
}

BOOL CMultTimerApp::CanExitNow(void) {
    return (m_lChildThreadCount == 0);
}

CMultTimerThread::InitInstance(void) {
    // increase the application child thread count...
    theApp.IncrementChildThreadCount();

    // create a dialog that will run on a secondary thread...
    CMultTimerDlg *pDlg = new CMultTimerDlg();
    
    // set the main window for this thread
    // the thread will exit when this window closes...
    SetMainWnd(pDlg);

    // inform the user...
    CString csTitle;
    pDlg->GetWindowText(csTitle);
    csTitle += " (child thread)";
    pDlg->SetWindowText(csTitle);

    return TRUE;
}

int CMultTimerThread::ExitInstance(void) {
    // decrease the application child thread count...
    theApp.DecrementChildThreadCount();

    // call the parent class implementation...
    int nStatus = CMcl4MfcGUIThread::ExitInstance();

    // delete ourselves...
    delete this;

    // return the saved status...
    return nStatus;
}

// CMultTimerDlg dialog class message map...
BEGIN_MESSAGE_MAP( CMultTimerDlg, CDialog)
    ON_WM_PAINT()
    ON_WM_SYSCOMMAND()
END_MESSAGE_MAP()

// CMultTimerDlg dialog class member functions...
CMultTimerDlg::CMultTimerDlg() {
    m_ctStartTime = 0;
    m_bTimerRunning = FALSE;
    m_nTicks = 0;

    // The parent of the dialog window will be sent
    // WM_ACTIVATE and WM_ACTIVATEAPP messages when the new dialog 
    // is made active. these are sent from the thread of the new
    // dilaog and this will cause the dialog to be frozen 
    // if the parent is blocked, even if the parent window is
    // processed on another thread.
    //
    // In addition the system may attach the raw input queue of the
    // new thread to the thread of the parent if the parent is a
    // dialog box.
    //
    // It is best to use the desktop window as the
    // parent (or the new dialog window itself, 
    // which amounts to the same thing) so that the new dialog
    // has no dependancies on windows from other threads. Using
    // null makes the main window m_pMainWnd 
    // the dialog's parent.
    //
    // If the default parent is used, or the parent window
    // is NULL, the application main window will be used as
    // the parent, and this causes the blocking problem.
    Create(IDD_MULTTIMER_DLG, GetDesktopWindow());
}

void CMultTimerDlg::PostNcDestroy() {
    delete this;
}

// CMultTimerDlg dialog class message map handlers...
BOOL CMultTimerDlg::OnInitDialog() {
    CDialog::OnInitDialog();

    // attach our member object to the edit control...
    m_ceSeconds.SubclassDlgItem( IDC_SECONDS, this);
    m_ceSeconds.SetWindowText("5");

    // we must set the new dialog box as the foreground
    // window because dialogs created on secondary threads
    // will pop up BEHIND the active application window...
    SetForegroundWindow();

    // set the dialog icon...
    HICON hIcon = AfxGetApp()->LoadIcon(IDI_MULTTIMER);
    SetIcon( hIcon, TRUE);

    // place the window offset from the last one we created...
    if (s_LastDialogX || s_LastDialogY) {
        // not the first dialog...
        s_LastDialogX += 10;
        s_LastDialogY += 10;
        SetWindowPos( NULL, s_LastDialogX, s_LastDialogY, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
    }
    else {
        // this is the first dialog, center it and remember
        // where we put it...
        CenterWindow();
        CRect cr;
        GetWindowRect(cr);
        s_LastDialogX = cr.left;
        s_LastDialogY = cr.top;
    }

    return TRUE;
}

void CMultTimerDlg::OnSysCommand( UINT nID, LPARAM lParam) {
    if ((nID & 0xFFF0) == SC_CLOSE) {
        // treat the main window specially...
        if (this == theApp.m_pMainWnd) {
            // this is the dialog on the primary thread,
            // check if the other dialog threads have exited and
            // only exit the program if this is TRUE...
            if (theApp.CanExitNow()) {
                // destroy the modeless dialog window,
                // since this is the main window, the application
                // will exit...
                DestroyWindow();
            }
            else {
                AfxMessageBox( "Cannot exit, child dialogs still open.", MB_ICONSTOP);
            }
        }
        else {
            // destroy the modeless dialog window...
            DestroyWindow();

            // Destroying the main window for a thread will cause the
            // thread to exit. If we had not set the main window for the
            // thread to this window, we could exit the thread with a
            // call to ::PostQuitMessage(0);
        }
    }
    else {
        CDialog::OnSysCommand( nID, lParam);
    }
}

void CMultTimerDlg::OnCancel() {
    // create a new dialog box running on it's own thread...
    new CMultTimerThread();

    // dialog box thread C++ object will delete itself in
    // it's ExitInstance handler...
}

void CMultTimerDlg::OnOK() {
    // tell the OnPaint handler that we are running...
    m_bTimerRunning = TRUE;

    // read the user input...
    CString csTime;
    m_ceSeconds.GetWindowText(csTime);

    // convert to clock ticks...
    m_nTicks = atoi(csTime) * CLOCKS_PER_SEC;

    // read the current time...
    m_ctStartTime = clock();

    // run in a tight loop...
    // we need the RedrawWindow to use SendMessage calls to
    // invoke the OnPaint handler when we are not processing
    // the application message loop...
    while ((clock() - m_ctStartTime) < m_nTicks) {
        // invalidate the time portion of the window and
        // update the display...
        RedrawWindow( m_crLastPaint, NULL, RDW_INVALIDATE | RDW_UPDATENOW);

        // update the display ten times a second...
        Sleep(100);    
    }

    // all done, tell the OnPaint handler we've stopped...
    m_bTimerRunning = FALSE;

    // update the time display one last time, this time we
    // don't need the RDW_UPDATENOW because we are going to
    // process messages again...
    RedrawWindow( m_crLastPaint, NULL, RDW_INVALIDATE);
}

afx_msg void CMultTimerDlg::OnPaint() {
    CPaintDC dc(this);

    // read the current time...
    clock_t ctNow = clock();
    clock_t ctRemaining;

    // compute the time remaining, 
    // if the timer is not running show all zero's...
    if (m_bTimerRunning) {
        ctRemaining = m_nTicks - ctNow + m_ctStartTime;
    }
    else {
        ctRemaining = 0;
    }

    // compute the parts of time...
    int hours = ctRemaining / (CLOCKS_PER_SEC * 60 * 60);
    ctRemaining -= hours * (CLOCKS_PER_SEC * 60 * 60);
    int minutes = ctRemaining / (CLOCKS_PER_SEC * 60);
    ctRemaining -= minutes * (CLOCKS_PER_SEC * 60);
    int seconds = ctRemaining / (CLOCKS_PER_SEC);
    ctRemaining -= seconds * CLOCKS_PER_SEC;
    int hundreths = (ctRemaining * 100) / CLOCKS_PER_SEC;

    // format the time string...
    CString csTime;
    csTime.Format( "%02d:%02d:%02d:%02d", hours, minutes, seconds, hundreths);

    // compute the size of the time string...
    CSize sz = dc.GetTextExtent(csTime);

    // place time centered, one-fourth down in the window...
    CRect cr;
    GetClientRect(cr);
    int x = (cr.Width() - sz.cx) >> 1;
    int y = (cr.Height() - sz.cy) >> 2;

    m_crLastPaint = CRect( x, y, x + sz.cx, y + sz.cy);

    // set up the DC to draw the countdown time...
    UINT oldAlign = dc.SetTextAlign( TA_TOP | TA_LEFT);
    COLORREF oldBkColor = dc.SetBkColor( ::GetSysColor(COLOR_3DFACE));

    // use GREEN for a running timer and RED for a stopped timer...
    COLORREF oldTextColor = dc.SetTextColor( (m_bTimerRunning) ? RGB(0, 255, 0) : RGB(255, 0, 0));

    dc.ExtTextOut( x, y, ETO_OPAQUE, NULL, csTime, NULL);

    // restore the DC...
    dc.SetTextAlign(oldAlign);
    dc.SetBkColor(oldBkColor);
    dc.SetTextColor(oldTextColor);
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
免费高清在线一区| 丝袜诱惑制服诱惑色一区在线观看| 在线免费观看成人短视频| 欧美bbbbb| 一区二区三区在线免费观看| 久久只精品国产| 欧美日韩精品欧美日韩精品 | 欧美日韩的一区二区| 国产精品一区二区无线| 亚洲国产日韩在线一区模特| 国产三级精品三级| 欧美www视频| 911国产精品| 欧美色区777第一页| av成人老司机| 717成人午夜免费福利电影| 91在线一区二区| 风间由美一区二区三区在线观看 | 国产精品久线在线观看| 日韩欧美一区在线| 在线免费一区三区| 不卡免费追剧大全电视剧网站| 精品一区二区三区在线播放| 午夜激情久久久| 亚洲一区在线免费观看| 国产精品家庭影院| 欧美国产日韩亚洲一区| 精品久久免费看| 日韩一区二区中文字幕| 欧美精品乱人伦久久久久久| 色婷婷久久综合| 91免费版在线| 91免费在线看| 色综合天天综合| 色综合一区二区| 色成年激情久久综合| 色先锋久久av资源部| 99精品视频一区二区三区| www.日韩在线| 色婷婷综合久色| 欧美中文字幕一区二区三区 | 欧美高清视频在线高清观看mv色露露十八 | 91视频观看免费| 99久久久精品| 在线观看精品一区| 欧美性受xxxx黑人xyx性爽| 91麻豆精品秘密| 在线免费观看一区| 精品视频123区在线观看| 欧美色老头old∨ideo| 在线国产亚洲欧美| 欧美日韩亚洲综合在线| 欧美精品久久久久久久多人混战| 欧美日本乱大交xxxxx| 制服丝袜一区二区三区| 日韩一级免费观看| 久久久久久99久久久精品网站| 久久久久久久综合日本| 亚洲国产成人自拍| 亚洲男人天堂av| av在线一区二区三区| 欧美午夜理伦三级在线观看| 欧美日本一道本| 欧美videos中文字幕| 久久久无码精品亚洲日韩按摩| 国产三级一区二区三区| 国产精品国产精品国产专区不蜜| 亚洲欧美日韩一区二区 | www久久久久| 国产日韩精品久久久| 国产精品家庭影院| 天天操天天干天天综合网| 免费高清成人在线| 99热这里都是精品| 欧美精品乱人伦久久久久久| 欧美成人a∨高清免费观看| 国产精品欧美久久久久一区二区| 一级女性全黄久久生活片免费| 五月天激情小说综合| 国产一区视频网站| 91丨porny丨国产入口| 欧美精品三级在线观看| 国产亚洲短视频| 亚洲成人激情自拍| 国产成人啪午夜精品网站男同| 99精品视频中文字幕| 日韩欧美国产小视频| 亚洲欧美偷拍三级| 激情小说欧美图片| 欧美午夜精品一区二区三区| 久久网站最新地址| 天天色天天操综合| 成人动漫一区二区在线| 日韩免费高清视频| 尤物av一区二区| 国产成人午夜精品5599 | 精品成人私密视频| 一区二区免费看| 国产电影一区二区三区| 欧美久久久久免费| 自拍偷拍亚洲欧美日韩| 激情六月婷婷久久| 欧美人成免费网站| 中文字幕在线不卡一区| 久久99精品视频| 欧美日韩日日夜夜| 亚洲欧洲日韩综合一区二区| 精品中文字幕一区二区小辣椒| 91免费版在线| 国产精品美女久久久久久2018| 日本不卡高清视频| 欧洲av一区二区嗯嗯嗯啊| 国产精品美女一区二区| 韩国女主播一区二区三区| 欧美高清视频在线高清观看mv色露露十八| 国产精品久久久一本精品| 韩国v欧美v亚洲v日本v| 日韩视频一区二区三区| 亚洲二区在线视频| 欧美视频一二三区| 亚洲精品国产无套在线观| 国产成人免费视频| 精品奇米国产一区二区三区| 婷婷六月综合亚洲| 午夜精品久久久久久久久| 91成人在线精品| 亚洲精品中文字幕乱码三区| 成人高清在线视频| 中文字幕欧美激情一区| 国产成人h网站| 国产婷婷一区二区| 国产高清精品久久久久| 久久综合狠狠综合| 国产一区二区成人久久免费影院| 精品乱人伦小说| 国内偷窥港台综合视频在线播放| 日韩精品一区二区三区在线播放| 五月婷婷激情综合| 在线综合视频播放| 日韩国产欧美视频| 欧美成人在线直播| 国内外成人在线| 欧美韩国日本一区| 成人黄动漫网站免费app| 国产精品久久久久久久久久久免费看 | 欧美专区在线观看一区| 亚洲一区二区三区四区在线观看 | 国产精品人人做人人爽人人添| 成人国产精品免费| 亚洲日本免费电影| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 又紧又大又爽精品一区二区| 欧美视频在线观看一区二区| 视频一区国产视频| 精品国产乱码久久| 高清国产一区二区| 中文字幕一区三区| 日日夜夜一区二区| 麻豆成人av在线| 久久精品99国产精品日本| 日韩**一区毛片| 一区二区三区四区不卡在线| 久久久久久久综合| 日韩欧美在线影院| 色婷婷久久99综合精品jk白丝 | 成人av资源在线观看| 日韩和的一区二区| 亚洲一区二区三区四区中文字幕| 久久精品人人做人人爽人人| 日韩一二三区视频| 久久九九99视频| 91一区一区三区| 日韩福利电影在线观看| 久久久99精品免费观看| 一本到高清视频免费精品| 免费在线一区观看| 综合欧美一区二区三区| 91精品国产欧美日韩| 高清视频一区二区| 天天色综合天天| 国产精品情趣视频| 日韩欧美美女一区二区三区| 国产盗摄女厕一区二区三区| 亚洲综合激情另类小说区| 91精品麻豆日日躁夜夜躁| 国产成人av电影| 日本特黄久久久高潮| 国产精品美女久久久久久久久久久| 欧美日本韩国一区| av男人天堂一区| 国产一区二区三区免费播放 | 性做久久久久久久免费看| 精品国产免费视频| 欧美私模裸体表演在线观看| 韩国一区二区视频| 亚洲成人av免费| 国产精品久久三区| 精品国产伦理网| 91精品婷婷国产综合久久竹菊| www.日韩av|