当前位置:网站首页>C 语言手写 QQ-AI 版
C 语言手写 QQ-AI 版
2022-07-29 05:07:00 【cpp编程】

2. 库文件
#include "tx_qq.h" #pragma comment(lib, "tx_qq.lib") int main(void) { printf("hello world\n"); return 0; }char ip_addr[32]; int main(void) { printf("请输入对方的 IP 地址: "); scanf_s("%s", ip_addr, sizeof(ip_addr)); return 0; }
最常用的网络协议 TCP 与 UDP

什么是 IP 地址

什么是端口

298 服务

198 服务


SOCKET
serverSocket;
sockaddr_in sockAddr;
#define PORT 2021
#include <winsock.h>
#pragma comment(lib, "ws2_32.lib") int main(void) {
printf("请输入对方的 IP 地址: ");
scanf_s("%s", ip_addr, sizeof(ip_addr));
if (!TCPInit(&serverSocket, &sockAddr, ip_addr, PORT)) { printf("网络初始化失败!\n"); return -1; }return 0; }void connect() { // 连接服务器端(发起网络连接请求) connect(serverSocket, (SOCKADDR*)&sockAddr, sizeof(sockAddr)); printf("已经接入!\n"); } int main(void) { printf("请输入对方的 IP 地址: "); scanf_s("%s", ip_addr, sizeof(ip_addr)); if (!init()) { printf("网络初始化失败!\n"); return -1; }printf("正在连接奇牛客服...\n"); connect(); return 0; }HWND hwnd; // 聊天窗口句柄 int screenWidth; int screenHeight; int msgHeight; // 新气泡的 y 坐标 IMAGE imgBg; //聊天窗口背景 IMAGE imageArrows[2]; //气泡的箭头 IMAGE imageHeads[2]; //人物的头像 // 三个按钮 Button btnClose; Button btnTitle; Button btnSend; void initUI() { // 1. 创建聊天窗口 initgraph(WINDOW_WIDTH, WINDOW_HEIGHT, EW_SHOWCONSOLE); // 创建绘图窗口 setbkmode(TRANSPARENT); // 2. 移动窗口位置 screenWidth = GetSystemMetrics(SM_CXSCREEN); screenHeight = GetSystemMetrics(SM_CYSCREEN); hwnd = GetHWnd(); //获取当前窗口句柄 SetWindowLong( //设置窗口属性说 hwnd, GWL_STYLE, //设定一个新的窗口风格。 //GetWindowLong 获取指定串口的属性 GetWindowLong(hwnd, GWL_STYLE) - WS_CAPTION);//WS_CAPTION 带标题栏的窗口风格 MoveWindow(hwnd, screenWidth / 8, 100, WINDOW_WIDTH, WINDOW_HEIGHT, false); // 3. 绘制背景图片 loadimage(&imgBg, "res/bg.png"); putimage(0, 0, &imgBg); // 4. 加载气泡尾巴和头像 loadimage(&imageArrows[0], "res/left_arrow.jpg", 6, 8, true); loadimage(&imageArrows[1], "res/right_arrow.jpg", 6, 8, true); loadimage(&imageHeads[1], "res/niu.jpg", 44, 51, true); loadimage(&imageHeads[0], "res/rock.jpg", 55, 51, true); // 5. 初始化 3 个按钮
// 5.1 初始化关闭按钮 initButton(&btnClose, "res/close_normal.jpg", "res/close_press.jpg", 32, 33, 0); btnClose.x = WINDOW_WIDTH - 32; btnClose.y = 0; // 5.2 初始化标题按钮 initButton(&btnTitle, "res/title.jpg", "res/title.jpg", 460, 39, 0); btnTitle.x = 0; btnTitle.y = 0; // 5.3 初始化发送按钮 initButton(&btnSend, "res/send_normal.jpg", "res/send_press.jpg", 88, 28, 0); btnSend.x = 337; btnSend.y = 784; // 6. 初始化气泡位置 msgHeight = 120; // 7. 设置编辑区域的文本颜色 setcolor(BLACK); }
调用 initUI
int main(void) {printf("请输入对方的 IP 地址: "); scanf_s("%s", ip_addr, sizeof(ip_addr)); if (!init()) { printf("网络初始化失败!\n"); return -1; }printf("正在连接奇牛客服...\n"); connect(); initUI(); return 0; }
程序,通过“多线程”来实现“一心多用”
int main(void) { printf("请输入对方的 IP 地址: "); scanf_s("%s", ip_addr, sizeof(ip_addr)); if (!init()) { printf("网络初始化失败!\n"); return -1; }printf("正在连接奇牛客服...\n"); connect(); initUI(); DWORD threadID = 0; HANDLE handleSecond = CreateThread(NULL, 0, ThreadFuncRcv, 0, 0, &threadID); HANDLE handleEdit = CreateThread(NULL, 0, msgEditHandle, NULL, 0, &threadID); return 0; }DWORD WINAPI ThreadFuncRcv(LPVOID param) { return NULL; }DWORD WINAPI msgEditHandle(LPVOID param) { return NULL; }DWORD WINAPI msgEditHandle(LPVOID param) { textBox(10, 663, 420, 110, LINE_HEIGHT, WHITE, BLACK, msgEdit, &msgLen); return NULL; }void mainUI() { while (1) { MOUSEMSG m = GetMouseMsg(); FlushMouseMsgBuffer(); //不能少,后缀快速拖动顶部的标题按钮,将导致鼠标消息太多, 出现混乱!switch (m.uMsg) { case WM_MOUSEMOVE: if (checkButtonSelect(&btnTitle, &m)) { } else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true; drawButton(&btnSend); }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); } else { // 检查鼠标是否从按钮内移动到按钮之外 if (btnClose.pressed == true) { // 鼠标从关闭按钮移出 btnClose.pressed = false; drawButton(&btnClose); }if (btnSend.pressed == true) { // 鼠标从发送按钮移出 btnSend.pressed = false; drawButton(&btnSend); } }break; case WM_LBUTTONDOWN: if (checkButtonSelect(&btnTitle, &m)) { }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); }else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true;
drawButton(&btnSend); }break; case WM_LBUTTONUP: if (checkButtonSelect(&btnClose, &m)) { //btnClose.pressed = false; //drawButton(&btnClose); closegraph(); exit(0); }else if (checkButtonSelect(&btnSend, &m)) { }else if (checkButtonSelect(&btnTitle, &m)) { }break; } } }调用 mainUI
int main(void) { printf("请输入对方的 IP 地址: "); scanf_s("%s", ip_addr, sizeof(ip_addr)); if (!init()) { printf("网络初始化失败!\n"); return -1; }printf("正在连接奇牛客服...\n"); connect(); initUI(); DWORD threadID = 0; HANDLE handleSecond = CreateThread(NULL, 0, ThreadFuncRcv, 0, 0, &threadID); HANDLE handleEdit = CreateThread(NULL, 0, msgEditHandle, NULL, 0, &threadID); mainUI(); system("pause");
return 0; }void mainUI() { bool titleDrag = false; //表示“标题栏”是否被单击拖动 int titleLastX; //窗口的上一次位置(X 坐标位置) int titleLastY; //窗口的上一次位置(X 坐标位置) while (1) { MOUSEMSG m = GetMouseMsg(); FlushMouseMsgBuffer(); //不能少,后缀快速拖动顶部的标题按钮,讲导致鼠标消息太多, 出现混乱!switch (m.uMsg) {
case WM_MOUSEMOVE: // 鼠标滑过标题栏 if (checkButtonSelect(&btnTitle, &m)) { if (btnTitle.pressed == true) { if (titleDrag == false) { // 此时标题栏已经被点击按下,正准备拖动 titleLastX = m.x; // 记录初始坐标 titleLastY = m.y; titleDrag = true; }else { // 此时标题栏已经被点击按下,正在拖动 // 计算拖动偏移量 int offX = m.x - titleLastX; int offY = m.y - titleLastY; moveWindow(hwnd, offX, offY); // 根据拖动偏移量,移动窗口 } } } else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true; drawButton(&btnSend); }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); } else { // 检查鼠标是否从按钮内移动到按钮之外 if (btnClose.pressed == true) { // 鼠标从关闭按钮移出 btnClose.pressed = false; drawButton(&btnClose); }if (btnSend.pressed == true) { // 鼠标从发送按钮移出 btnSend.pressed = false; drawButton(&btnSend); } }break; case WM_LBUTTONDOWN: if (checkButtonSelect(&btnTitle, &m)) { btnTitle.pressed = true; // 单击按下标题栏 }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); }
else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true; drawButton(&btnSend); }break; case WM_LBUTTONUP: if (checkButtonSelect(&btnClose, &m)) { //btnClose.pressed = false; //drawButton(&btnClose); closegraph(); exit(0); }else if (checkButtonSelect(&btnSend, &m)) { }else if (checkButtonSelect(&btnTitle, &m)) { // 松开标题栏按钮(左键抬起) btnTitle.pressed = false; titleDrag = false; }break; } } }msg_t msgAll[5]; int msgCount = 0; int currentMsgIndex = -1; //当前最近的一条信息的索引 void mainUI() { bool titleDrag = false; //表示“标题栏”是否被单击拖动 int titleLastX; //窗口的上一次位置(X 坐标位置) int titleLastY; //窗口的上一次位置(X 坐标位置) while (1) { MOUSEMSG m = GetMouseMsg(); FlushMouseMsgBuffer(); //不能少,后缀快速拖动顶部的标题按钮,讲导致鼠标消息太多, 出现混乱!
switch (m.uMsg) { case WM_MOUSEMOVE: // 鼠标滑过标题栏 if (checkButtonSelect(&btnTitle, &m)) { if (btnTitle.pressed == true) { if (titleDrag == false) { // 此时标题栏已经被点击按下,正准备拖动 titleLastX = m.x; // 记录初始坐标 titleLastY = m.y; titleDrag = true; }else { // 此时标题栏已经被点击按下,正在拖动 // 计算拖动偏移量 int offX = m.x - titleLastX; int offY = m.y - titleLastY; moveWindow(hwnd, offX, offY); // 根据拖动偏移量,移动窗口 } } } else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true; drawButton(&btnSend); }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); } else { // 检查鼠标是否从按钮内移动到按钮之外 if (btnClose.pressed == true) { // 鼠标从关闭按钮移出 btnClose.pressed = false; drawButton(&btnClose); }if (btnSend.pressed == true) { // 鼠标从发送按钮移出 btnSend.pressed = false; drawButton(&btnSend); } }break; case WM_LBUTTONDOWN: if (checkButtonSelect(&btnTitle, &m)) { btnTitle.pressed = true; // 单击按下标题栏 }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose);
}else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true; drawButton(&btnSend); }break; case WM_LBUTTONUP: if (checkButtonSelect(&btnClose, &m)) { //btnClose.pressed = false; //drawButton(&btnClose); closegraph(); exit(0); }else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = false; drawButton(&btnSend); int ret = send(serverSocket, msgEdit, msgLen, 0); printf("已经发送%d 个字符\n", ret); currentMsgIndex = (currentMsgIndex + 1) % (sizeof(msgAll) / sizeof(msgAll[0]));msgEdit[msgLen] = 0; strcpy(msgAll[currentMsgIndex].msg, msgEdit); memset(msgEdit, 0, sizeof(msgEdit)); msgLen = 0; msgAll[currentMsgIndex].type = SEND; msgCount++; //drawMsg(); drawMsg(msgAll, currentMsgIndex, &msgHeight, imageArrows, imageHeads); }else if (checkButtonSelect(&btnTitle, &m)) { // 松开标题栏按钮(左键抬起) btnTitle.pressed = false; titleDrag = false; }break; } } }DWORD WINAPI ThreadFuncRcv(LPVOID param) { char buff[4096]; while (1) { int ret = recv(serverSocket, buff, sizeof(buff), 0); if (ret <= 0) return false; buff[ret] = 0; //添加字符串结束符 printf("收到:%s\n", buff); currentMsgIndex = (currentMsgIndex + 1) % (sizeof(msgAll) / sizeof(msgAll[0])); strcpy(msgAll[currentMsgIndex].msg, buff); msgAll[currentMsgIndex].type = RECEIVE; msgCount++; //drawMsg(); drawMsg(msgAll, currentMsgIndex, &msgHeight, imageArrows, imageHeads); }return NULL; }#include "tx_qq.h" #pragma comment(lib, "tx_qq.lib") int main(void) { printf("hello world\n"); return 0; }
#include <winsock.h> #pragma comment(lib, "ws2_32.lib") #define PORT 2021 SOCKET serverSocket; bool init() { WSADATA wsaData; int err = WSAStartup(MAKEWORD(1, 1), &wsaData); if (err != 0) { return false; }serverSocket = socket(PF_INET, SOCK_STREAM, IPPROTO_TCP); sockaddr_in sockAddr; sockAddr.sin_family = PF_INET; sockAddr.sin_addr.S_un.S_addr = 0; sockAddr.sin_port = htons(PORT); // 绑定套接字 bind(serverSocket, (SOCKADDR*)&sockAddr, sizeof(sockAddr)); // 创建监听队列 listen(serverSocket, 1); return NULL; }int main() { init(); ...... system("pause"); return 0; }SOCKET clientSock;
void waitAccept() { SOCKADDR client; // 监控端的网络地址(相当于客户端的网络地址) int nSize = sizeof(client); printf("等待客户端发起连接...\n"); clientSock = accept(serverSocket, &client, &nSize); printf("客户端已经接入!\n"); }int main(void) { init(); waitAccept(); return 0; }HWND hwnd; // 聊天窗口句柄 int screenWidth; int screenHeight; int msgHeight; // 新气泡的 y 坐标 IMAGE imgBg; //聊天窗口背景 IMAGE imageArrows[2]; //气泡的箭头 IMAGE imageHeads[2]; //人物的头像 // 三个按钮 Button btnClose; Button btnTitle; Button btnSend; void initUI() { // 1. 创建聊天窗口 initgraph(WINDOW_WIDTH, WINDOW_HEIGHT, EW_SHOWCONSOLE); // 创建绘图窗口 setbkmode(TRANSPARENT); // 2. 移动窗口位置 screenWidth = GetSystemMetrics(SM_CXSCREEN); screenHeight = GetSystemMetrics(SM_CYSCREEN); hwnd = GetHWnd(); //获取当前窗口句柄 SetWindowLong( //设置窗口属性说
hwnd, GWL_STYLE, //设定一个新的窗口风格。 //GetWindowLong 获取指定串口的属性 GetWindowLong(hwnd, GWL_STYLE) - WS_CAPTION);//WS_CAPTION 带标题栏的窗口风格 MoveWindow(hwnd, screenWidth * 0.7 , 100, WINDOW_WIDTH, WINDOW_HEIGHT, false); // 3. 绘制背景图片 loadimage(&imgBg, "res/bg.png"); putimage(0, 0, &imgBg); // 4. 加载气泡尾巴和头像 loadimage(&imageArrows[0], "res/left_arrow.jpg", 6, 8, true); loadimage(&imageArrows[1], "res/right_arrow.jpg", 6, 8, true); loadimage(&imageHeads[0], "res/niu.jpg", 44, 51, true); loadimage(&imageHeads[1], "res/rock.jpg", 55, 51, true); // 5. 初始化 3 个按钮 // 5.1 初始化关闭按钮 initButton(&btnClose, "res/close_normal.jpg", "res/close_press.jpg", 32, 33, 0); btnClose.x = WINDOW_WIDTH - 32; btnClose.y = 0; // 5.2 初始化标题按钮 initButton(&btnTitle, "res/title.jpg", "res/title.jpg", 460, 39, 0); btnTitle.x = 0; btnTitle.y = 0; // 5.3 初始化发送按钮 initButton(&btnSend, "res/send_normal.jpg", "res/send_press.jpg", 88, 28, 0); btnSend.x = 337; btnSend.y = 784; // 6. 初始化气泡位置 msgHeight = 120; // 7. 设置编辑区域的文本颜色 setcolor(BLACK); }
调用 initUI
int main(void) { init(); waitAccept(); initUI(); return 0; }int main() { init(); waitAccept(); initUI(); DWORD dwThreadID = 0; HANDLE handleSecond = CreateThread(NULL, 0, ThreadFuncRcv, 0, 0, &dwThreadID); HANDLE handleEdit = CreateThread(NULL, 0, msgEditHandle, NULL, 0, &dwThreadID);
mainUI(); system("pause"); return 0; }DWORD WINAPI ThreadFuncRcv(LPVOID param) { return NULL; }DWORD WINAPI msgEditHandle(LPVOID param) { return NULL; }char msgEdit[1024]; int msgLen; DWORD WINAPI msgEditHandle(LPVOID param) { textBox(10, 663, 420, 110, LINE_HEIGHT, WHITE, BLACK, msgEdit, &msgLen); return NULL; }void mainUI() { while (1) { MOUSEMSG m = GetMouseMsg(); FlushMouseMsgBuffer(); //不能少,后缀快速拖动顶部的标题按钮,将导致鼠标消息太多, 出现混乱!switch (m.uMsg) { case WM_MOUSEMOVE: if (checkButtonSelect(&btnTitle, &m)) { } else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true;
drawButton(&btnSend); }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); } else { // 检查鼠标是否从按钮内移动到按钮之外 if (btnClose.pressed == true) { // 鼠标从关闭按钮移出 btnClose.pressed = false; drawButton(&btnClose); }if (btnSend.pressed == true) { // 鼠标从发送按钮移出 btnSend.pressed = false; drawButton(&btnSend); } }break; case WM_LBUTTONDOWN: if (checkButtonSelect(&btnTitle, &m)) { }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); }else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true; drawButton(&btnSend); }break; case WM_LBUTTONUP: if (checkButtonSelect(&btnClose, &m)) { //btnClose.pressed = false; //drawButton(&btnClose); closegraph(); exit(0); }else if (checkButtonSelect(&btnSend, &m)) { }else if (checkButtonSelect(&btnTitle, &m)) { }
break; } } }int main(void) { init(); waitAccept(); initUI(); DWORD dwThreadID = 0; HANDLE handleSecond = CreateThread(NULL, 0, ThreadFuncRcv, 0, 0, &dwThreadID); HANDLE handleEdit = CreateThread(NULL, 0, msgEditHandle, NULL, 0, &dwThreadID); mainUI(); return 0; }void mainUI() { bool titleDrag = false; //表示“标题栏”是否被单击拖动 int titleLastX; //窗口的上一次位置(X 坐标位置) int titleLastY; //窗口的上一次位置(X 坐标位置) while (1) { MOUSEMSG m = GetMouseMsg(); FlushMouseMsgBuffer(); //不能少,后缀快速拖动顶部的标题按钮,讲导致鼠标消息太多, 出现混乱!switch (m.uMsg) { case WM_MOUSEMOVE: // 鼠标滑过标题栏 if (checkButtonSelect(&btnTitle, &m)) { if (btnTitle.pressed == true) { if (titleDrag == false) { // 此时标题栏已经被点击按下,正准备拖动 titleLastX = m.x; // 记录初始坐标 titleLastY = m.y; titleDrag = true;
}else { // 此时标题栏已经被点击按下,正在拖动 // 计算拖动偏移量 int offX = m.x - titleLastX; int offY = m.y - titleLastY; moveWindow(hwnd, offX, offY); // 根据拖动偏移量,移动窗口 } } } else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true; drawButton(&btnSend); }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); } else { // 检查鼠标是否从按钮内移动到按钮之外 if (btnClose.pressed == true) { // 鼠标从关闭按钮移出 btnClose.pressed = false; drawButton(&btnClose); }if (btnSend.pressed == true) { // 鼠标从发送按钮移出 btnSend.pressed = false; drawButton(&btnSend); } }break; case WM_LBUTTONDOWN: if (checkButtonSelect(&btnTitle, &m)) { btnTitle.pressed = true; // 单击按下标题栏 }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); }else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true; drawButton(&btnSend); }break; case WM_LBUTTONUP: if (checkButtonSelect(&btnClose, &m)) { //btnClose.pressed = false;
//drawButton(&btnClose); closegraph(); exit(0); }else if (checkButtonSelect(&btnSend, &m)) { }else if (checkButtonSelect(&btnTitle, &m)) { // 松开标题栏按钮(左键抬起) btnTitle.pressed = false; titleDrag = false; }break; } } }msg_t msgAll[5]; int msgCount = 0; int currentMsgIndex = -1; //当前最近的一条信息的索引 void mainUI() { bool titleDrag = false; //表示“标题栏”是否被单击拖动 int titleLastX; //窗口的上一次位置(X 坐标位置) int titleLastY; //窗口的上一次位置(X 坐标位置) while (1) { MOUSEMSG m = GetMouseMsg(); FlushMouseMsgBuffer(); //不能少,后缀快速拖动顶部的标题按钮,将导致鼠标消息太多, 出现混乱!switch (m.uMsg) { case WM_MOUSEMOVE: if (checkButtonSelect(&btnTitle, &m)) { if (btnTitle.pressed == true) { if (titleDrag == false) { // 此时标题栏已经被点击按下,正准备拖动 titleLastX = m.x; // 记录初始坐标 titleLastY = m.y; titleDrag = true; }else { // 此时标题栏已经被点击按下,正在拖动
// 计算拖动偏移量 int offX = m.x - titleLastX; int offY = m.y - titleLastY; moveWindow(hwnd, offX, offY); // 根据拖动偏移量,移动窗口 } } }else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true; drawButton(&btnSend); }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); }else {// 检查鼠标是否从按钮内移动到按钮之外 if (btnClose.pressed == true) { // 鼠标从关闭按钮移出 btnClose.pressed = false; drawButton(&btnClose); }if (btnSend.pressed == true) { // 鼠标从发送按钮移出 btnSend.pressed = false; drawButton(&btnSend); } }break; case WM_LBUTTONDOWN: if (checkButtonSelect(&btnTitle, &m)) { btnTitle.pressed = true; // 单击按下标题栏 }else if (checkButtonSelect(&btnClose, &m)) { btnClose.pressed = true; drawButton(&btnClose); }else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = true; drawButton(&btnSend); }break; case WM_LBUTTONUP: if (checkButtonSelect(&btnClose, &m)) { closegraph();
exit(0); }else if (checkButtonSelect(&btnSend, &m)) { btnSend.pressed = false; drawButton(&btnSend); //int ret = send(serverSocket, msgEdit, msgLen, 0); int ret = send(clientSock, msgEdit, msgLen, 0); printf("已经发送%d 个字符\n", ret); currentMsgIndex = (currentMsgIndex + 1) % (sizeof(msgAll) / sizeof(msgAll[0]));msgEdit[msgLen] = 0; strcpy(msgAll[currentMsgIndex].msg, msgEdit); memset(msgEdit, 0, sizeof(msgEdit)); msgLen = 0; msgAll[currentMsgIndex].type = SEND; msgCount++; //drawMsg(); drawMsg(msgAll, currentMsgIndex, &msgHeight, imageArrows, imageHeads); }else if (checkButtonSelect(&btnTitle, &m)) { // 松开标题栏按钮(左键抬起) btnTitle.pressed = false; titleDrag = false; }break; } } }DWORD WINAPI ThreadFuncRcv(LPVOID param) { while (1) { char buff[1024]; int ret = recv(clientSock, buff, sizeof(buff), 0); if (ret <= 0) { printf("对方已下线\n");
closesocket(clientSock); //TerminateThread(); waitAccept(); }else {buff[ret] = 0; printf("[收到] %s\n", buff); currentMsgIndex = (currentMsgIndex + 1) % (sizeof(msgAll) / sizeof(msgAll[0])); strcpy(msgAll[currentMsgIndex].msg, buff); msgAll[currentMsgIndex].type = RECEIVE; msgCount++; //drawMsg(); drawMsg(msgAll, currentMsgIndex, &msgHeight, imageArrows, imageHeads); } }return NULL; }今天的分享就到这里了,大家要好好学C语言/C++哟~
欢迎转行和学习编程的伙伴,利用更多的资料学习成长比自己琢磨更快哦!
对于准备学习C/C++编程的小伙伴,如果你想更好的提升你的编程核心能力(内功)不妨从现在开始!
整理分享(多年学习的源码、项目实战视频、项目笔记,基础入门教程)加下方群获取哦~
C语言C++编程学习交流圈子,QQ群:763855696 【点击进入】
边栏推荐
- ARFoundation入门教程7-url动态加载图像跟踪库
- 源码编译pytorch坑
- 开源汇智创未来 | 2022开放原子全球开源峰会 openEuler 分论坛圆满召开
- Huawei ilearning AI mathematics foundation course notes
- Solve the warning prompt of MySQL mapping file
- Ros1 dead chicken data is stored in txt and SQLite
- 自贸经济中架起的“隐形桥梁”:国货精品与中国AI力量
- 6.3 references
- Google gtest事件机制
- 学习数据库的第一个程序
猜你喜欢

关于servlet中实现网站的页面跳转

Create a mindscore environment in modelars, install mindvision, and conduct in-depth learning and training (Huawei)

【文件下载】Easyexcel快速上手

How does WPS take quick screenshots? WPS quick screenshot method

Deep learning brush a bunch of tricks of SOTA

学习数据库的第一个程序

What if the office prompts that the system configuration cannot run?

传奇开区网站如何添加流量统计代码

ARFoundation从零开始3-创建ARFoundation项目

This article takes you to understand the implementation of surround notification @around and final notification @after
随机推荐
传奇开区网站如何添加流量统计代码
后置通知的流程分析与功能实现有哪些内容你还记得吗?
Open the tutorial of adding and modifying automatically playing music on the open zone website
Qml类型:State 状态
Deadlock to be resolved
向往的开源之多YOUNG新生 | 从开源到就业的避坑指南来啦!
tmux随笔
【微信小程序--解决display:flex最后一行对齐问题。(不连续排列会分到两边)】
Huawei ilearning AI mathematics foundation course notes
关于thymeleaf的配置与使用
What servers are needed to build mobile app
Scikit learn -- steps and understanding of machine learning application development
How to make the characters in the photos laugh? HMS core video editing service one click smile function makes people smile more naturally
Architecture analysis of three-tier project and parameter name injection of construction method
Pivot table of odoo development tutorial
ARFoundation入门教程10-平面检测和放置
pytorch学习笔记
7.3-function-templates
SM整合原来这么简单,步骤清晰(详细)
Button for QT custom switch effect