2019-01-05 20:21:43 +08:00
|
|
|
|
// TalkManager.cpp: implementation of the CTalkManager class.
|
|
|
|
|
|
//
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
#include "stdafx.h"
|
|
|
|
|
|
#include "TalkManager.h"
|
|
|
|
|
|
#include "Common.h"
|
|
|
|
|
|
#include "resource.h"
|
|
|
|
|
|
#include <IOSTREAM>
|
|
|
|
|
|
#include <mmsystem.h>
|
|
|
|
|
|
|
|
|
|
|
|
#pragma comment(lib, "WINMM.LIB")
|
|
|
|
|
|
using namespace std;
|
|
|
|
|
|
#define ID_TIMER_POP_WINDOW 1
|
|
|
|
|
|
#define ID_TIMER_DELAY_DISPLAY 2
|
|
|
|
|
|
#define ID_TIMER_CLOSE_WINDOW 3
|
|
|
|
|
|
|
2019-01-26 10:35:10 +08:00
|
|
|
|
#define WIN_WIDTH 360
|
2019-01-15 21:48:37 +08:00
|
|
|
|
#define WIN_HEIGHT 200
|
2019-01-05 20:21:43 +08:00
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
// Construction/Destruction
|
|
|
|
|
|
//////////////////////////////////////////////////////////////////////
|
2025-01-01 18:36:44 +08:00
|
|
|
|
char g_Buffer[TALK_DLG_MAXLEN] = {0};
|
2019-01-05 20:21:43 +08:00
|
|
|
|
UINT_PTR g_Event = 0;
|
|
|
|
|
|
|
|
|
|
|
|
IOCPClient* g_IOCPClientObject = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
extern HINSTANCE g_hInstance;
|
|
|
|
|
|
|
|
|
|
|
|
CTalkManager::CTalkManager(IOCPClient* ClientObject, int n):CManager(ClientObject)
|
|
|
|
|
|
{
|
|
|
|
|
|
BYTE bToken = TOKEN_TALK_START; //<2F><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
|
|
|
|
|
|
m_ClientObject->OnServerSending((char*)&bToken, 1);
|
|
|
|
|
|
g_IOCPClientObject = ClientObject;
|
|
|
|
|
|
WaitForDialogOpen();
|
2025-01-15 18:49:15 +08:00
|
|
|
|
Mprintf("Talk <20><><EFBFBD><EFBFBD>\n");
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
CTalkManager::~CTalkManager()
|
|
|
|
|
|
{
|
2025-01-15 18:49:15 +08:00
|
|
|
|
Mprintf("Talk <20><><EFBFBD><EFBFBD>\n");
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
VOID CTalkManager::OnReceive(PBYTE szBuffer, ULONG ulLength)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch(szBuffer[0])
|
|
|
|
|
|
{
|
|
|
|
|
|
case COMMAND_NEXT:
|
|
|
|
|
|
{
|
|
|
|
|
|
NotifyDialogIsOpen();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
{
|
2025-01-01 18:36:44 +08:00
|
|
|
|
memcpy(g_Buffer, szBuffer, min(ulLength, sizeof(g_Buffer)));
|
2019-01-05 20:21:43 +08:00
|
|
|
|
//<2F><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>DLG
|
|
|
|
|
|
DialogBox(g_hInstance,MAKEINTRESOURCE(IDD_DIALOG),
|
|
|
|
|
|
NULL,DialogProc); //SDK C MFC C++
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-02-06 03:34:57 +08:00
|
|
|
|
INT_PTR CALLBACK CTalkManager::DialogProc(HWND hDlg, UINT uMsg,
|
2019-01-05 20:21:43 +08:00
|
|
|
|
WPARAM wParam, LPARAM lParam)
|
|
|
|
|
|
{
|
|
|
|
|
|
switch(uMsg)
|
|
|
|
|
|
{
|
|
|
|
|
|
case WM_TIMER:
|
|
|
|
|
|
{
|
|
|
|
|
|
OnDlgTimer(hDlg);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case WM_INITDIALOG:
|
|
|
|
|
|
{
|
2025-01-01 18:36:44 +08:00
|
|
|
|
// <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
|
LONG_PTR exStyle = GetWindowLongPtr(hDlg, GWL_EXSTYLE);
|
|
|
|
|
|
// <20>Ƴ<EFBFBD> WS_EX_APPWINDOW <20><>ʽ<EFBFBD><CABD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> WS_EX_TOOLWINDOW <20><>ʽ
|
|
|
|
|
|
exStyle &= ~WS_EX_APPWINDOW;
|
|
|
|
|
|
exStyle |= WS_EX_TOOLWINDOW;
|
|
|
|
|
|
SetWindowLongPtr(hDlg, GWL_EXSTYLE, exStyle);
|
|
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
OnInitDialog(hDlg);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
2025-01-01 18:36:44 +08:00
|
|
|
|
case WM_COMMAND:
|
|
|
|
|
|
if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
|
|
|
|
|
|
{
|
|
|
|
|
|
KillTimer(hDlg, ID_TIMER_CLOSE_WINDOW);
|
|
|
|
|
|
BYTE bToken = TOKEN_TALKCMPLT;
|
|
|
|
|
|
g_IOCPClientObject->OnServerSending((char*)&bToken, 1);
|
|
|
|
|
|
EndDialog(hDlg, LOWORD(wParam));
|
|
|
|
|
|
return (INT_PTR)TRUE;
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
2019-01-05 20:21:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID CTalkManager::OnInitDialog(HWND hDlg)
|
|
|
|
|
|
{
|
|
|
|
|
|
MoveWindow(hDlg, 0, 0, 0, 0, TRUE);
|
|
|
|
|
|
|
2019-01-18 17:37:15 +08:00
|
|
|
|
static HICON hIcon = LoadIcon(NULL, MAKEINTRESOURCE(IDI_ICON_MSG));
|
2019-01-15 21:48:37 +08:00
|
|
|
|
::SendMessage(hDlg, WM_SETICON, (WPARAM)hIcon, (LPARAM)hIcon);
|
|
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
SetDlgItemText(hDlg,IDC_EDIT_MESSAGE,g_Buffer);
|
|
|
|
|
|
|
2019-01-18 17:37:15 +08:00
|
|
|
|
::SetFocus(GetDesktopWindow());
|
|
|
|
|
|
|
2019-01-05 20:21:43 +08:00
|
|
|
|
memset(g_Buffer,0,sizeof(g_Buffer));
|
|
|
|
|
|
|
|
|
|
|
|
g_Event = ID_TIMER_POP_WINDOW;
|
|
|
|
|
|
SetTimer(hDlg, g_Event, 1, NULL); //ʱ<>ӻص<D3BB>
|
|
|
|
|
|
|
|
|
|
|
|
PlaySound(MAKEINTRESOURCE(IDR_WAVE),
|
|
|
|
|
|
g_hInstance,SND_ASYNC|SND_RESOURCE|SND_NODEFAULT);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VOID CTalkManager::OnDlgTimer(HWND hDlg) //ʱ<>ӻص<D3BB>
|
|
|
|
|
|
{
|
|
|
|
|
|
RECT Rect;
|
|
|
|
|
|
static int Height=0;
|
|
|
|
|
|
SystemParametersInfo(SPI_GETWORKAREA, 0, &Rect,0);
|
|
|
|
|
|
int y=Rect.bottom-Rect.top;;
|
|
|
|
|
|
int x=Rect.right-Rect.left;
|
|
|
|
|
|
x=x-WIN_WIDTH;
|
|
|
|
|
|
|
|
|
|
|
|
switch(g_Event)
|
|
|
|
|
|
{
|
|
|
|
|
|
case ID_TIMER_CLOSE_WINDOW:
|
|
|
|
|
|
{
|
|
|
|
|
|
if(Height>=0)
|
|
|
|
|
|
{
|
|
|
|
|
|
Height-=5;
|
|
|
|
|
|
MoveWindow(hDlg, x,y-Height, WIN_WIDTH, Height,TRUE);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
KillTimer(hDlg,ID_TIMER_CLOSE_WINDOW);
|
|
|
|
|
|
BYTE bToken = TOKEN_TALKCMPLT; // <20><><EFBFBD><EFBFBD>ͷ<EFBFBD>ļ<EFBFBD> Common.h
|
2019-01-26 10:35:10 +08:00
|
|
|
|
g_IOCPClientObject->OnServerSending((char*)&bToken, 1); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>͵<EFBFBD>ָ<EFBFBD><D6B8>
|
2019-01-05 20:21:43 +08:00
|
|
|
|
EndDialog(hDlg,0);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case ID_TIMER_DELAY_DISPLAY:
|
|
|
|
|
|
{
|
|
|
|
|
|
KillTimer(hDlg,ID_TIMER_DELAY_DISPLAY);
|
|
|
|
|
|
g_Event = ID_TIMER_CLOSE_WINDOW;
|
|
|
|
|
|
SetTimer(hDlg,g_Event, 5, NULL);
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
case ID_TIMER_POP_WINDOW:
|
|
|
|
|
|
{
|
|
|
|
|
|
if(Height<=WIN_HEIGHT)
|
|
|
|
|
|
{
|
|
|
|
|
|
Height+=3;
|
|
|
|
|
|
MoveWindow(hDlg ,x, y-Height, WIN_WIDTH, Height,TRUE);
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
KillTimer(hDlg,ID_TIMER_POP_WINDOW);
|
|
|
|
|
|
g_Event = ID_TIMER_DELAY_DISPLAY;
|
|
|
|
|
|
SetTimer(hDlg,g_Event, 4000, NULL);
|
|
|
|
|
|
}
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|