📄 y_msg.cpp
字号:
// Y_Msg.cpp : implementation file
//
#include "stdafx.h"
#include "Img_ListView1.h"
#include "Y_Msg.h"
#include "Y_c.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
extern struct SOCKUSERDEF SockUserDef;
extern int SendData(WORD Command,WORD RecvUserID,char *SendBuffer);
/////////////////////////////////////////////////////////////////////////////
// Y_Msg dialog
Y_Msg::Y_Msg(CWnd* pParent /*=NULL*/)
: CDialog(Y_Msg::IDD, pParent)
{
//{{AFX_DATA_INIT(Y_Msg)
//}}AFX_DATA_INIT
}
void Y_Msg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(Y_Msg)
DDX_Control(pDX, IDC_BUTTON6, m_Btn6);
DDX_Control(pDX, IDCANCEL, m_Cancel);
DDX_Control(pDX, IDC_EDIT5, m_Edit5);
DDX_Control(pDX, IDC_EDIT4, m_Edit4);
DDX_Control(pDX, IDC_EDIT3, m_Edit3);
DDX_Control(pDX, IDC_BUTTON5, m_Btn5);
DDX_Control(pDX, IDC_BUTTON4, m_Btn4);
DDX_Control(pDX, IDC_BUTTON3, m_Btn3);
DDX_Control(pDX, IDC_BUTTON2, m_Btn2);
DDX_Control(pDX, IDC_BUTTON1, m_Btn1);
DDX_Control(pDX, IDC_RICHTEXTCTRL1, m_Edit1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(Y_Msg, CDialog)
//{{AFX_MSG_MAP(Y_Msg)
ON_BN_CLICKED(IDC_BUTTON2, OnButton2)
ON_BN_CLICKED(IDC_BUTTON3, OnButton3)
ON_BN_CLICKED(IDC_BUTTON1, OnButton1)
ON_BN_CLICKED(IDC_BUTTON6, OnButton6)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// Y_Msg message handlers
BOOL Y_Msg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
int cx=::GetSystemMetrics (SM_CXSCREEN);
int cy=::GetSystemMetrics (SM_CYSCREEN);
int Width,Height;
RECT Rect;
this->GetWindowRect (&Rect);
Width = Rect.right -Rect.left ;
Height = Rect.bottom -Rect.top ;
Rect.left = cx/2 - Width/2;
Rect.right = cx/2 + Width/2;
Rect.top = cy/2 - Height/2;
Rect.bottom = cy/2 + Height/2;
MoveWindow(&Rect,TRUE);
//SetWindowPos(&this->wndTopMost,cx/2 -50,cy/2-50,100,200,WS_EX_TOPMOST);
// CenterWindow();
EBkColor=m_Edit1.GetBackColor ();
ShowMsg();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void Y_Msg::OnButton2()
{
// TODO: Add your control notification handler code here
CString tempString;
m_Edit1.GetWindowText (tempString);
if(tempString.GetLength ())
{
SendData(COMMAND4,(WORD)FriendID,(char *)(LPCTSTR)tempString);
OnCancel();
}
else
{
MessageBox("发送区不能为空");
}
}
void Y_Msg::OnButton3()
{
// TODO: Add your control notification handler code here
m_Btn1.ShowWindow (SW_HIDE);
m_Btn3.ShowWindow (SW_HIDE);
m_Btn6.ShowWindow (SW_HIDE);
m_Btn2.ShowWindow (SW_SHOW);
m_Btn5.ShowWindow (SW_SHOW);
m_Cancel.ShowWindow (SW_SHOW);
m_Edit1.EnableWindow(TRUE);
m_Edit1.SetBackColor (EBkColor);
m_Edit1.SetWindowText ("");
// m_Edit1.UpdateData (FALSE);
}
void Y_Msg::OnButton1()
{
// TODO: Add your control notification handler code here
OnCancel();
}
void Y_Msg::OnCancel()
{
// TODO: Add extra cleanup here
CDialog::OnCancel();
}
void Y_Msg::OnButton6()
{
// TODO: Add your control notification handler code here
ShowMsg();
}
int Y_Msg::ShowMsg()
{
CString tempString;
if(FriendIndex==-1)
{
m_Btn1.ShowWindow (SW_HIDE);
m_Btn3.ShowWindow (SW_HIDE);
m_Btn6.ShowWindow (SW_HIDE);
m_Btn2.ShowWindow (SW_SHOW);
m_Btn5.ShowWindow (SW_SHOW);
m_Cancel.ShowWindow (SW_SHOW);
return FALSE;
}
if(SockUserDef.Friend[FriendIndex].RcvBuffer.GetSize())
{
tempString =
(LPCTSTR)SockUserDef.Friend[FriendIndex].RcvBuffer.GetAt(0);
// SockUserDef.Friend[FriendIndex].RcvBuffer.GetSize()-1) ;
if(tempString.GetLength ())//如果长度不为0,则显示
{
m_Btn1.ShowWindow (SW_SHOW);
m_Btn3.ShowWindow (SW_SHOW);
m_Btn6.ShowWindow (SW_SHOW);
m_Btn2.ShowWindow (SW_HIDE);
m_Btn5.ShowWindow (SW_HIDE);
m_Cancel.ShowWindow (SW_HIDE);
if(SockUserDef.Friend[FriendIndex].RcvBuffer.GetSize()>1)
{
m_Btn6.EnableWindow (TRUE);
}
else
{
m_Btn6.EnableWindow (FALSE);
}
m_Edit1.SetBackColor ((long)RGB(128,128,128));
m_Edit1.EnableWindow (FALSE);
m_Edit1.SetWindowText ((LPCTSTR)tempString);
}
SockUserDef.Friend[FriendIndex].RcvBuffer.RemoveAt(0);
}
if(!SockUserDef.Friend[FriendIndex].RcvBuffer.GetSize())
{
//如果接收区已变为空,则向主框发出变为空的消息
::SendMessage (AfxGetApp()->m_pMainWnd->m_hWnd,WM_ANIMDISP,0,FriendIndex);
}
return true;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -