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

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

?? multtimer2.cpp

?? window下的多線程編程參考書。值得一讀
?? CPP
字號:
//
// FILE: MultTimer2.cpp
//
// Copyright (c) 1997 by Aaron Michael Cohen and Mike Woodring
//
/////////////////////////////////////////////////////////////////////////
#include "MultTimer2.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;

// static class variable for tracking child dialog threads...
CMclQueue<CMcl4MfcGUIThread *> CMultTimerDlg::m_cqChildThreads;

// CMultTimerApp application class member functions...
BOOL CMultTimerApp::InitInstance(void) {
    CMultTimerDlg *pDlg = new CMultTimerDlg();
  
    // this is also the application main window...
    m_pMainWnd = pDlg;

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

    return TRUE;
}

// CMultTimerThread thread class member functions...
CMultTimerThread::InitInstance(void) {
    // create a dialog that will run on a secondary thread...
    CMultTimerDlg *pDlg = new CMultTimerDlg();

    // set the dialog as the thread's main window,
    // this will allow the framework to terminate the
    // thread when the dialog box window is destroyed...
    SetMainWnd(pDlg);

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

    return TRUE;
}

BOOL CMultTimerThread::PreTranslateMessage( MSG *pMsg) {
    if (pMsg->message == WM_SHUTDOWN_THREAD) {
        // handle this message...
        OnShutdownThread( pMsg->wParam, pMsg->lParam);
        return 1;
    }
    else {
        // continue normal message processing...
        return 0;
    }
}

afx_msg void CMultTimerThread::OnShutdownThread( UINT wParam, LONG lParam) {
    // DestroyWindow is supposed to be called by the thread that
    // created the window...
    // The Primary thread tells the child threads to destroy their
    // windows and themselves by sending the WM_SHUTDOWN_THREAD message
    // which the child thread uses to call DestroyWindow in the correct
    // thread context...
    GetMainWnd()->DestroyWindow();
}    

// 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) {
            // loop through the CMcl4MfcGUIThread pointers in our list
            // and shutdown each of the child dialogs...
            CMcl4MfcGUIThread *pThread;
            while (m_cqChildThreads.Get( pThread, 0)) {
                // Use the CWinThread object to instruct the thread to terminate...
                // The thread may have previously terminated, in which case this
                // will do nothing since the child thread's message pump
                // has already terminated...
                pThread->PostThreadMessage( WM_SHUTDOWN_THREAD, 0, 0);

                ///////////////////////////////////////////////////////////
                // AN ASIDE:
                // Sending a WM_CLOSE message to a MFC dialog box causes
                // the OnCancel member function to be called, which is not
                // what we want here.
                // The proper way to close a modeless dialog such as this 
                // is to have the dialog thread call DestroyWindow, which
                // we can do by sending a WM_SYSCOMMAND message with
                // the SC_CLOSE parameter...                
                ///////////////////////////////////////////////////////////

                // wait for the thread to exit...
                pThread->Wait(INFINITE);

                // delete the CMcl4MfcGUIThread object...
                delete pThread;
            }

            // destroy the modeless dialog window,
            // since this is the main window, the application
            // will exit...
            DestroyWindow();
        }
        else {
            // destroy the modeless dialog window...
            // this also terminates the thread since
            // the dialog was set to be the m_pMainWnd of the thread...
            DestroyWindow();
        }
    }
    else {
        CDialog::OnSysCommand( nID, lParam);
    }
}

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

    // add the CMcl4MfcGUIThread pointer to our list of threads...
    m_cqChildThreads.Put(pThread);
}

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, show all zero's
    // if the timer is not running...
    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一区二区三区免费野_久草精品视频
久久久久久久精| 国产 日韩 欧美大片| 美女在线视频一区| 成人av免费在线播放| 欧美久久久久免费| 中文字幕一区av| 精品综合免费视频观看| 欧美丝袜丝交足nylons图片| 国产欧美视频在线观看| 日韩av电影免费观看高清完整版 | 久久99精品国产麻豆不卡| 日韩理论片网站| 麻豆国产精品777777在线| 粉嫩av一区二区三区| 日韩免费高清视频| 亚洲精品欧美激情| 丁香激情综合国产| 欧美一区二区三区在线观看 | 欧美日韩国产不卡| 中文字幕亚洲一区二区va在线| 亚洲成人免费视| 91在线高清观看| 中文字幕中文字幕一区| 国产精品影音先锋| 欧美成人艳星乳罩| 日本成人在线一区| 911国产精品| 日韩黄色在线观看| 欧美夫妻性生活| 亚洲超丰满肉感bbw| 欧美日本韩国一区二区三区视频| 日韩理论片一区二区| 97久久精品人人做人人爽| 亚洲国产精品高清| 成人蜜臀av电影| 中文字幕色av一区二区三区| 国产精品一二三区在线| 久久久国产午夜精品| 国内精品嫩模私拍在线| 久久综合九色欧美综合狠狠| 久久66热偷产精品| 国产清纯美女被跳蛋高潮一区二区久久w| 免费成人av资源网| 欧美精品一区二区三区在线| 国产一区在线观看视频| 精品国产一区二区三区久久影院 | 久久久午夜精品理论片中文字幕| 精品中文av资源站在线观看| 精品成人免费观看| 国产精品一区二区果冻传媒| 国产精品全国免费观看高清| www.视频一区| 亚洲在线一区二区三区| 91精品国产综合久久精品| 日本aⅴ精品一区二区三区| 欧美一级一区二区| 国产精品一区二区果冻传媒| 中文字幕一区二区5566日韩| 色偷偷一区二区三区| 亚洲国产精品久久人人爱蜜臀| 欧美亚洲一区二区在线观看| 日日夜夜精品视频天天综合网| 欧美一级理论性理论a| 国产成人精品午夜视频免费| 美女视频免费一区| 久久精品亚洲麻豆av一区二区| 盗摄精品av一区二区三区| 亚洲一二三级电影| 精品国产3级a| 欧美性受xxxx| 国产高清在线观看免费不卡| 亚洲综合视频网| 日韩亚洲欧美在线| 91麻豆.com| 激情欧美一区二区三区在线观看| 国产精品天美传媒| 欧美一区二区黄色| a亚洲天堂av| 午夜不卡在线视频| 久久久久久电影| 色诱亚洲精品久久久久久| 亚洲一区二区在线播放相泽 | 精品美女一区二区三区| 韩国精品主播一区二区在线观看| 综合av第一页| 51精品秘密在线观看| 白白色 亚洲乱淫| 亚洲国产精品久久久久婷婷884 | 色婷婷综合视频在线观看| 精品一区二区三区影院在线午夜 | 欧美视频完全免费看| 亚洲国产裸拍裸体视频在线观看乱了| 国产很黄免费观看久久| 国产精品理论片在线观看| 成人三级伦理片| 欧美老年两性高潮| 不卡的电视剧免费网站有什么| 亚洲一区在线观看免费观看电影高清| 精品人伦一区二区色婷婷| 色婷婷激情一区二区三区| 国产一区在线看| 亚洲mv在线观看| 亚洲精品你懂的| 久久久精品黄色| 久久一留热品黄| 欧美日韩高清一区二区三区| 欧美综合视频在线观看| 国产精品资源在线观看| 久久av资源站| 一区二区三区精品久久久| 亚洲欧洲美洲综合色网| 日韩精品在线一区| 国产精品高潮呻吟久久| 欧美精品日日鲁夜夜添| 另类欧美日韩国产在线| 成人99免费视频| 精品伊人久久久久7777人| 热久久免费视频| 亚洲无线码一区二区三区| 亚洲激情自拍视频| 国产精品污www在线观看| 国产精品久久毛片a| 久久久美女毛片| 欧美综合天天夜夜久久| 91麻豆国产福利在线观看| 99久久久精品| 国产精品一卡二卡在线观看| 美女在线视频一区| 国产精品原创巨作av| 国产在线观看一区二区| 国产成人精品免费| 国产一区二区三区精品欧美日韩一区二区三区 | 精东粉嫩av免费一区二区三区| 天天免费综合色| 五月天国产精品| 韩国三级在线一区| 国模一区二区三区白浆| 粉嫩在线一区二区三区视频| 国产福利一区在线| 91成人免费在线视频| 色婷婷久久久综合中文字幕| 欧美撒尿777hd撒尿| 欧美日韩在线免费视频| 色爱区综合激月婷婷| 精品少妇一区二区三区免费观看| 99re这里只有精品视频首页| 成人精品免费网站| 欧美性大战久久久| 欧美日韩国产免费一区二区| 欧美xxxx老人做受| 国产午夜久久久久| 一区二区三区中文免费| 一区二区三区四区乱视频| 日韩黄色片在线观看| 国产在线国偷精品产拍免费yy| 日韩视频免费观看高清在线视频| 日韩一区二区免费视频| 国产精品麻豆99久久久久久| 亚洲黄网站在线观看| 久久国产人妖系列| 日本中文字幕一区| eeuss鲁一区二区三区| 国产很黄免费观看久久| 欧美三级在线视频| 欧美电影免费提供在线观看| 国产欧美日韩激情| 美女免费视频一区二区| 国产不卡视频在线播放| 欧美日韩免费观看一区二区三区| 日韩一区二区精品| 亚洲制服丝袜av| 国产一区二三区好的| 欧美日韩国产综合视频在线观看| 日韩一区二区三区四区五区六区| 国产精品国产成人国产三级| 视频一区在线播放| 97国产精品videossex| 欧美精品日韩一本| 亚洲综合色视频| 日韩高清不卡一区| 一本久久精品一区二区| 欧美巨大另类极品videosbest | 处破女av一区二区| 日韩精品一区在线| 综合激情网...| 国产精品一区二区久久精品爱涩 | 亚洲第一搞黄网站| 99re66热这里只有精品3直播| 91精品国产综合久久蜜臀 | 久久99精品国产.久久久久| 91碰在线视频| 中文字幕视频一区二区三区久| 免费精品视频在线| 91精品国产高清一区二区三区| 亚洲色图19p| 色综合色综合色综合 | 日韩片之四级片| 日韩av在线发布| 色婷婷亚洲综合| 亚洲一级片在线观看|