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

📄 simgui.h

📁 window下的多线程编程参考书。值得一读
💻 H
字号:
//
// FILE: SimGUI.h
//
// Copyright (c) 1997 by Aaron Michael Cohen and Mike Woodring
//
/////////////////////////////////////////////////////////////////////////
#include <afxwin.h>
#include <afxext.h>

// Mcl class library for use with MFC...
#include "Mcl4Mfc.h"

// definitions of simulation objects...
#include "Simulation.h"

// initial client window size...
#define WINDOW_WIDTH            768
#define WINDOW_HEIGHT           768

// bitmap dimensions...
#define BITMAP_HEIGHT           128
#define BITMAP_WIDTH            128

// bitmap layout constants...
#define BOWL_SPACING            102
#define PHILOSOPHER_SPACING     92

// CDiningSim application object definition...
class CDiningSim : public CWinApp {
public:
    virtual BOOL InitInstance(void);
};

// CDiningSimWindow main window definition...
class CDiningSimWindow : public CFrameWnd {
private:
    BOOL m_bRunning;
    CBitmap m_cbmBowl;
    CBitmap m_cbmPhilosophers;
    CBitmap m_cbmForks;
    int m_nPhilosopherState[NUMBER_PHILOSOPHERS];
    int m_nForkState[NUMBER_PHILOSOPHERS];
    CString m_csUserMessage;
    CRect m_crLastTextRect;
    int m_nTableSide;
    CSimulation m_cSimulation;
    int m_nHScrollPos, m_nVScrollPos;
    int m_nHScrollPosMax, m_nVScrollPosMax;
    CPoint m_ptMaxWindowSize;

public:
    CDiningSimWindow();

protected:
    DECLARE_MESSAGE_MAP()

    // standard message handlers...
    afx_msg void OnPaint();
    afx_msg BOOL OnEraseBkgnd(CDC *pDC);
    afx_msg void OnRun();
    afx_msg void OnStop();
    afx_msg void OnUpdateRunUI( CCmdUI *pCmdUI);
    afx_msg void OnUpdateStopUI( CCmdUI *pCmdUI);
    afx_msg void OnExit();
    afx_msg void OnDestroy();
    afx_msg void OnSize( UINT nType, int cx, int cy );
    afx_msg void OnVScroll( UINT nCode, UINT nPos, CScrollBar *pScrollBar);
    afx_msg void OnHScroll( UINT nCode, UINT nPos, CScrollBar *pScrollBar);
    afx_msg void OnGetMinMaxInfo( MINMAXINFO FAR* lpMMI);

    // user defined message handlers...
    afx_msg LONG OnDiningSimPhilosopherUpdate( UINT uPhilosopher, LONG lNewState);
    afx_msg LONG OnDiningSimForkUpdate( UINT uFork, LONG lNewState);

    // simulation control functions...
    void StartSimulation(void);
    void StopSimulation(void);
    void ShowUserMessage( CString csMessage);

    // drawing functions...
    void DrawSimulation(CDC *pDC);
    void DrawPhilosopher(CDC *pDC, UINT uPhilosopher);
    void DrawFork(CDC *pDC, UINT uFork);
    void DrawUserMessage(CDC *pDC);

    // helper functions...
    static POINT ComputeSeatPosition( POINT ptCenter, int nPositions, int iPosition, int iRadius);
    static POINT ComputeForkPosition( POINT ptCenter, int nPositions, int iPosition, int iRadius);
    static void ErrorExit( LPCTSTR lpMsg);
};

⌨️ 快捷键说明

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