当前位置:网站首页>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 【点击进入】
边栏推荐
- MySQL many to many relationship, grouping and splicing to query multiple data to one data
- Arfoundation starts from scratch 8-geospatial API (geospatial) development
- MySQL sorts the queried result set according to the specified sequence
- "Invisible Bridge" built in the free trade economy: domestic products and Chinese AI power
- Self join and joint query of MySQL
- What servers are needed to build mobile app
- 2022年泰迪杯数据挖掘挑战赛C题方案及赛后总结
- How to solve the problem of configuring the progress every time Office2010 is opened?
- Let you understand several common traffic exposure schemes in kubernetes cluster
- Deep learning brush a bunch of tricks of SOTA
猜你喜欢
Qml控件:ComboBox
6.3 references
2022年泰迪杯数据挖掘挑战赛C题方案及赛后总结
Pytorch learning notes
Arfoundation starts from scratch 3- create an arfoundation project
TCP three handshakes and four waves
Apache POI implements excel import, read data, write data and export
【2022新生学习】第三周要点
玩家访问网站自动弹窗加QQ群方法以及详细代码
Five correlation analysis, one of the most important skills of data analysts
随机推荐
Qml控件:ComboBox
Wechat picture identification
Diagram of odoo development tutorial
Arfoundation starts from zero 9-ar anchor
Self join and joint query of MySQL
MySQL many to many relationship, grouping and splicing to query multiple data to one data
Use annotation test in idea
Operator operation list of spark
关于thymeleaf的配置与使用
自贸经济中架起的“隐形桥梁”:国货精品与中国AI力量
pytorch学习笔记
Network Security Learning - Intranet Security 1
Jackson parsing JSON detailed tutorial
Let you understand several common traffic exposure schemes in kubernetes cluster
What if excel is stuck and not saved? The solution of Excel not saved but stuck
How to solve the problem of configuring the progress every time Office2010 is opened?
Deadlock analysis using jstack, jconsole, and jvisualvm
QML定制TabBar
Raspberry pie 4B + Intel neural computing stick (stick2) +yolov5 feasibility study report
Young freshmen yearn for more open source | here comes the escape guide from open source to employment!