📄 bankdlg.cpp
字号:
// BankDlg.cpp : implementation file
//
//#include <queue>
#include "stdafx.h"
#include "Bank.h"
#include "BankDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAboutDlg dialog used for App About
queue<int> q;
int number=0;
HANDLE hMutex1;
HANDLE hMutex2;
class CAboutDlg : public CDialog
{
public:
CAboutDlg();
// Dialog Data
//{{AFX_DATA(CAboutDlg)
enum { IDD = IDD_ABOUTBOX };
//}}AFX_DATA
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CAboutDlg)
protected:
virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support
//}}AFX_VIRTUAL
// Implementation
protected:
//{{AFX_MSG(CAboutDlg)
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
{
//{{AFX_DATA_INIT(CAboutDlg)
//}}AFX_DATA_INIT
}
void CAboutDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAboutDlg)
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
//{{AFX_MSG_MAP(CAboutDlg)
// No message handlers
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBankDlg dialog
//using namespace std;
BOOL CBankDlg::m_btn1=FALSE;
BOOL CBankDlg::m_btn2=FALSE;
BOOL CBankDlg::m_btn6=FALSE;
BOOL CBankDlg::m_window1=FALSE;
BOOL CBankDlg::m_window2=FALSE;
BOOL CBankDlg::m_window3=FALSE;
BOOL CBankDlg::m_window4=FALSE;
CBankDlg::CBankDlg(CWnd* pParent /*=NULL*/)
: CDialog(CBankDlg::IDD, pParent)
{
//{{AFX_DATA_INIT(CBankDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
// Note that LoadIcon does not require a subsequent DestroyIcon in Win32
m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
}
void CBankDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CBankDlg)
DDX_Control(pDX, IDC_BUTTON2, m_b2);
DDX_Control(pDX, IDC_BUTTON1, m_b1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CBankDlg, CDialog)
//{{AFX_MSG_MAP(CBankDlg)
ON_WM_SYSCOMMAND()
ON_WM_PAINT()
ON_WM_QUERYDRAGICON()
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_STATIC1, OnStatic1)
ON_BN_CLICKED(IDC_STATIC2, OnStatic2)
ON_BN_CLICKED(IDC_STATIC3, OnStatic3)
ON_BN_CLICKED(IDC_STATIC4, OnStatic4)
ON_WM_CTLCOLOR()
ON_BN_CLICKED(IDC_STATICTIME, OnStatictime)
ON_WM_TIMER()
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON4, OnButton4)
ON_BN_CLICKED(IDC_BUTTON5, OnButton5)
ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
ON_BN_CLICKED(IDC_TEXT, OnText)
ON_BN_CLICKED(IDC_BUTTON7, OnButton7)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_DATA,OnData)
ON_MESSAGE(WM_DATA,OnData2)
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CBankDlg message handlers
BOOL CBankDlg::OnInitDialog()
{
CDialog::OnInitDialog();
SetTimer(1, 1000, NULL);
// Add "About..." menu item to system menu.
// IDM_ABOUTBOX must be in the system command range.
ASSERT((IDM_ABOUTBOX & 0xFFF0) == IDM_ABOUTBOX);
ASSERT(IDM_ABOUTBOX < 0xF000);
//SetDialogBkColor(RGB(255,0,0),RGB(255,255,0));
CMenu* pSysMenu = GetSystemMenu(FALSE);
if (pSysMenu != NULL)
{
CString strAboutMenu;
strAboutMenu.LoadString(IDS_ABOUTBOX);
if (!strAboutMenu.IsEmpty())
{
pSysMenu->AppendMenu(MF_SEPARATOR);
pSysMenu->AppendMenu(MF_STRING, IDM_ABOUTBOX, strAboutMenu);
}
}
// Set the icon for this dialog. The framework does this automatically
// when the application's main window is not a dialog
SetIcon(m_hIcon, TRUE); // Set big icon
SetIcon(m_hIcon, FALSE); // Set small icon
//HOLLOW_BRUSH
m_brush.CreateStockObject(HOLLOW_BRUSH);
// CFont my_CFont;
my_CFont.CreateFont(
20, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"Arial"); // lpszFacename
my_CFont1.CreateFont(
15, // nHeight
0, // nWidth
0, // nEscapement
0, // nOrientation
FW_NORMAL, // nWeight
FALSE, // bItalic
FALSE, // bUnderline
0, // cStrikeOut
ANSI_CHARSET, // nCharSet
OUT_DEFAULT_PRECIS, // nOutPrecision
CLIP_DEFAULT_PRECIS, // nClipPrecision
DEFAULT_QUALITY, // nQuality
DEFAULT_PITCH | FF_SWISS, // nPitchAndFamily
"Arial"); // lpszFacename
( GetDlgItem (IDC_EDIT1) ) ->SetFont( &my_CFont );
( GetDlgItem (IDC_EDIT2) ) ->SetFont( &my_CFont );
( GetDlgItem (IDC_EDIT3) ) ->SetFont( &my_CFont );
( GetDlgItem (IDC_EDIT6) ) ->SetFont( &my_CFont );
( GetDlgItem (IDC_EDIT4) ) ->SetFont( &my_CFont );
( GetDlgItem (IDC_EDIT5) ) ->SetFont( &my_CFont );
( GetDlgItem (IDC_TEXT) ) ->SetFont( &my_CFont );
// TODO: Add extra initialization here
// HWND hwnd=m_hWnd;
RECVPARAM *pRecvParam=new RECVPARAM;
pRecvParam->hwnd=m_hWnd;
HANDLE hThread1=CreateThread(NULL,0,WinProc1,(LPVOID)pRecvParam,0,NULL);
CloseHandle(hThread1);
HANDLE hThread2=CreateThread(NULL,0,WinProc2,(LPVOID)pRecvParam,0,NULL);
CloseHandle(hThread2);
HANDLE hThread3=CreateThread(NULL,0,WinProc3,(LPVOID)pRecvParam,0,NULL);
CloseHandle(hThread3);
HANDLE hThread6=CreateThread(NULL,0,WinProc4,(LPVOID)pRecvParam,0,NULL);
CloseHandle(hThread6);
HANDLE hThread4=CreateThread(NULL,0,QUHAO1,(LPVOID)pRecvParam,0,NULL);
CloseHandle(hThread4);
HANDLE hThread5=CreateThread(NULL,0,QUHAO2,(LPVOID)pRecvParam,0,NULL);
CloseHandle(hThread5);
HANDLE hThread7=CreateThread(NULL,0,QUHAO3,(LPVOID)pRecvParam,0,NULL);
CloseHandle(hThread7);
hMutex1=CreateMutex(NULL,FALSE,"tickets1");
hMutex2=CreateMutex(NULL,FALSE,"tickets2");
return TRUE; // return TRUE unless you set the focus to a control
}
void CBankDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID & 0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout;
dlgAbout.DoModal();
}
else
{
CDialog::OnSysCommand(nID, lParam);
}
}
// If you add a minimize button to your dialog, you will need the code below
// to draw the icon. For MFC applications using the document/view model,
// this is automatically done for you by the framework.
void CBankDlg::OnPaint()
{
if (IsIconic())
{
CPaintDC dc(this); // device context for painting
SendMessage(WM_ICONERASEBKGND, (WPARAM) dc.GetSafeHdc(), 0);
// Center icon in client rectangle
int cxIcon = GetSystemMetrics(SM_CXICON);
int cyIcon = GetSystemMetrics(SM_CYICON);
CRect rect;
GetClientRect(&rect);
int x = (rect.Width() - cxIcon + 1) / 2;
int y = (rect.Height() - cyIcon + 1) / 2;
// Draw the icon
dc.DrawIcon(x, y, m_hIcon);
}
else
{
CPaintDC dc(this);
CRect rc;
GetClientRect(&rc);
int nHeight = rc.Height();
int t=0;
int j=0;
for (int i = 0; nHeight >=t; nHeight --, j ++)
{
CPen pen;
pen.CreatePen(PS_SOLID, 1, RGB(255, 255 ,i));
CPen *pOldPen = dc.SelectObject(&pen);
dc.MoveTo(rc.left, j);
dc.LineTo(rc.right, j);
dc.SelectObject(pOldPen);
pen.DeleteObject();
i = max(180, i - 1);
}
}
}
// The system calls this to obtain the cursor to display while the user drags
// the minimized window.
HCURSOR CBankDlg::OnQueryDragIcon()
{
return (HCURSOR) m_hIcon;
}
void CBankDlg::OnButton1()
{
m_btn1=TRUE;
}
void CBankDlg::OnButton2()
{
m_btn2=TRUE;
}
DWORD WINAPI CBankDlg::WinProc1( LPVOID lpParameter)
{char str[10];
int ID=IDC_EDIT1;
char str1[10]="暂停服务";
HWND hwnd=((RECVPARAM*)lpParameter)->hwnd;
while(TRUE){
if(m_window1)
::PostMessage(hwnd,WM_DATA,(WPARAM)ID,(LPARAM)str1);
else{
WaitForSingleObject(hMutex1,INFINITE);
if(q.size()!=0){
itoa( q.front(), str, 10);
q.pop();
::PostMessage(hwnd,WM_DATA,(WPARAM)ID,(LPARAM)str);
}
ReleaseMutex(hMutex1);
}
Sleep(2000);
}
return 0;
}
DWORD WINAPI CBankDlg::WinProc2( LPVOID lpParameter)
{
char str[10];
int ID=IDC_EDIT2;
char str1[10]="暂停服务";
HWND hwnd=((RECVPARAM*)lpParameter)->hwnd;
while(TRUE)
{ if(m_window2)
::PostMessage(hwnd,WM_DATA,(WPARAM)ID,(LPARAM)str1);
else{
WaitForSingleObject(hMutex1,INFINITE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -