📄 qqsendmessage.cpp
字号:
// QQSendMessage.cpp : implementation file
//
#include "stdafx.h"
#include "MyQQ.h"
#include "QQSendMessage.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CQQSendMessage dialog
CQQSendMessage::CQQSendMessage(CWnd* pParent /*=NULL*/)
: CDialog(CQQSendMessage::IDD, pParent)
{
//{{AFX_DATA_INIT(CQQSendMessage)
//}}AFX_DATA_INIT
}
void CQQSendMessage::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CQQSendMessage)
DDX_Control(pDX, IDC_STATIC1, m_static1);
DDX_Control(pDX, IDC_LIST1, m_list1);
//}}AFX_DATA_MAP
}
BEGIN_MESSAGE_MAP(CQQSendMessage, CDialog)
//{{AFX_MSG_MAP(CQQSendMessage)
ON_WM_ERASEBKGND()
ON_BN_CLICKED(IDC_SEND, OnSend)
ON_EN_SETFOCUS(IDC_EDITSHOWMES, OnSetfocusEditshowmes)
ON_WM_CREATE()
ON_BN_CLICKED(IDC_SEND2, OnSend2)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CQQSendMessage message handlers
BOOL CQQSendMessage::OnInitDialog()
{
listboxitem=0;
CDialog::OnInitDialog();
CenterWindow(GetDesktopWindow());
CRect rect;
m_list1.GetWindowRect(&rect);
if(!btMyface.Create("▼对方形象>>", WS_CHILD| WS_BORDER|WS_VISIBLE ,
CRect(0, 0, rect.Width(), 22), &m_list1, 101))
{
MessageBox("创建按钮失败");
return -1;
}
if(!btQQ.Create("▼我的QQ秀>>", WS_CHILD|WS_VISIBLE ,
CRect(0, 100, rect.Width(), 125), &m_list1, 102))
{
MessageBox("创建按钮失败");
return -1;
}
return TRUE;
}
BOOL CQQSendMessage::OnEraseBkgnd(CDC* pDC)
{
CRect rc;
GetClientRect(&rc);
CBrush brush, *pOldbrush;
brush.CreateSolidBrush(RGB(93, 183, 255));
pOldbrush=pDC->SelectObject(&brush);
pDC->FillRect(&rc, &brush);
pDC->SelectObject(pOldbrush);
return true;
}
void CQQSendMessage::OnSend()
{
// TODO: Add your control notification handler code here
CString str, mes;
GetDlgItem(IDC_EDIT1)->GetWindowText(str);
if(str.GetLength()<1)
{
MessageBox("发送消息不能为空");
return;
}
CEdit *pEditCtrl=(CEdit *)GetDlgItem(IDC_EDITSHOWMES);
pEditCtrl->GetWindowText(mes);
mes+="生产实习(10000)说:\r\n ";
mes+=str+"\r\n";
pEditCtrl->SetWindowText(mes);
//////////////////////////////////////////////////////////////////////////
// 模拟回复
PlaySound("msg.wav", AfxGetResourceHandle(),
SND_RESOURCE|SND_ASYNC|SND_NODEFAULT);
mes+=msg+"回复时说:\r\n";
mes+="此人已死,有事请烧香......\r\n";
pEditCtrl->SetWindowText(mes);
pEditCtrl->LineScroll(pEditCtrl->GetLineCount());
GetDlgItem(IDC_EDIT1)->SetWindowText("");
GetDlgItem(IDC_EDIT1)->SetFocus();
}
void CQQSendMessage::OnSetfocusEditshowmes()
{
// TODO: Add your control notification handler code here
GetDlgItem(IDC_EDIT1)->SetFocus();
}
int CQQSendMessage::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CDialog::OnCreate(lpCreateStruct) == -1)
return -1;
return 0;
}
BOOL CQQSendMessage::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if(pMsg->message==WM_KEYDOWN)
{
if(pMsg->wParam==VK_RETURN && GetKeyState(VK_CONTROL)&0x80)
{
{
//处理发送对话的内容
OnSend();
return 1;
}
}
}
return CDialog::PreTranslateMessage(pMsg);
}
void CQQSendMessage::OnSend2()
{
// TODO: Add your control notification handler code here
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -