首页
社区
课程
招聘
未解决 [已解决]单/多线程变量数据共享与交换.
发表于: 2019-3-27 06:03 1599

未解决 [已解决]单/多线程变量数据共享与交换.

2019-3-27 06:03
1599
 想知道单/多线程中全局变量或变量数据是如何交换,我查了相关资料,但是没看懂,可能是我智商不够....
我在使用单线程读写全局变量进行图形绘制, 当Image数组中的数据需要进行更新时, 通过定义的一个全局变量置Bool为TRUE通知线程Image数组有数据更新,需要线程进入等待.结果Boom,查出原因是上一刻全局变量bool是False线程认为Image数组没有进行数据更新.实际已经开始数据更新了. 
改用互斥体进行更新通知,结果仍然boom,猜测原因同上... 然后我改用全局变量DrawThread置bool为False通知线程有数据更新,自动销毁. WaitForSingleObject等待线程销毁. 但还是出现问题. 有时候会等待超时...没有查出原因.按理说每秒循环200+次数FPS即使我将销毁判断放在线程头部也不应该会出现等待超时..
 虽然通过TerminateThread 强制销毁,但是觉得这样做可能会出现很多问题,实际上也出现了,有时候BeginPaint后没执行EndPaint就被强制销毁了.下次创建线程时就会出现无法绘制的情况...
  希望能有线程数据更新交换相关资料.. 万分感谢..
//新手,代码可能有点乱,请谅解.. 
#define ThreadMutexLockDeleay 3500 //这里等待3.5秒绘制线程销毁. 如果设置最大值,就会直接进入最大值假死无限等待.
//启动绘制线程;
void WINAPI RunDrawD3D() {
	DrawThread = TRUE;
	CloseHandle(G_lpDrawThread);
	G_lpDrawThread = CreateThread(NULL, NULL, (LPTHREAD_START_ROUTINE)DrawD3D, NULL, NULL, NULL);
	if (!G_lpDrawThread) { MessageBox(NULL, L"绘制线程启动失败!", NULL, MB_OK); ExitProcess(NULL); }
}
//关闭绘制线程;
void WINAPI CloseDrawD3D() {
	//通知绘制线程退出
	DrawThread = FALSE;
	//等待线程退出
	DWORD WaitObject = WaitForSingleObject(G_lpDrawThread, ThreadMutexLockDeleay);
	//如果等待线程超出时长,强制终止线程;
	if (WaitObject != WAIT_OBJECT_0) {
		DWORD ExitCode;
		GetExitCodeThread(G_lpDrawThread, &ExitCode);
		TerminateThread(G_lpDrawThread, ExitCode);
	}
}
//删除当前选中图片;
void WINAPI DeleteImageInfo() {
	if (ImageInfo.MaxImage <= 0)return;
	CloseDrawD3D();
	if (ImageInfo.Image[SelectIndex].Texture)
		ImageInfo.Image[SelectIndex].Texture->Release();
	
	for (UINT i = SelectIndex; i < ImageInfo.MaxImage - 1; i++) {
		memcpy(&ImageInfo.Image[i], &ImageInfo.Image[i + 1], sizeof(ImageTexturInfo));
	}
	ImageInfo.MaxImage--;
	if (ImageInfo.MaxImage <= 0) {
		LocalFree(ImageInfo.Image);
		ImageInfo = { 0 };
	}
	RunDrawD3D();
}
//这是绘制线程; 审视了好多遍了, 自认为没有什么地方会使绘制线程无限等待销毁的代码.....
void WINAPI DrawD3D() {
	char Biit[50];
	srand(GetTickCount());
	sprintf(Biit, "线程成功创建!=-%d--\n", rand() % 1000);
	OutputDebugStringA(Biit);
	while (DrawThread) {
		LPDIRECT3DDEVICE9 D3DDevice9 = D2Dx9.GetD3Devicex9();
		if (!D3DDevice9)continue;
		sprintf(Biit, "线程:%d", DrawThread);
		SetWindowTextA(GetDlgItem(G_hWnd, IDC_CHECK_PlayAnimate), Biit);
		D3DDevice9->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(0, 0, 0), 1.0f, 0);
		if (SUCCEEDED(D3DDevice9->BeginScene())) {
			UINT X = (ClRect.left - GlRect.left) - 10, Y = (ClRect.top - GlRect.top) - 32;
			for (UINT i = 0; i < ImageInfo.MaxImage; i++) {
				if(!ImageInfo.Image)break;
				//判断是动画帧还是背景图片;
				if (ImageInfo.Image[i].ImgLoadType == Image) {
					if (MousePoint.x - X > ImageInfo.Image[i].x && MousePoint.x + X < ImageInfo.Image[i].x + ImageInfo.Image[i].Width
						&& MousePoint.y - Y > ImageInfo.Image[i].y && MousePoint.y + Y < ImageInfo.Image[i].y + ImageInfo.Image[i].Height) {
						if (!ISMove)CurrencyIndex = i;
					}
				}
				//如果是动画帧
				else if (ImageInfo.Image[i].ImgLoadType == Animate) {
					PAnimateImage pAnimat = &ImageInfo.Image[i].Animate[ImageInfo.Image[i].AnimateTickIndex];
					if (MousePoint.x - X > pAnimat->x && MousePoint.x - X < pAnimat->x + pAnimat->Width
						&& MousePoint.y - Y > pAnimat->y && MousePoint.y - Y < pAnimat->y + pAnimat->Height) {
						if (!ISMove)CurrencyIndex = i;
					}
				}
			}
			//判断是否在图片选区中
			if (ImageInfo.MaxImage > CurrencyIndex) {
				if (!ImageInfo.Image)continue;
				if (ImageInfo.Image[CurrencyIndex].ImgLoadType == Image) {
					if (MousePoint.x - X > ImageInfo.Image[CurrencyIndex].x && MousePoint.x - X < ImageInfo.Image[CurrencyIndex].x + ImageInfo.Image[CurrencyIndex].Width
						&& MousePoint.y - Y > ImageInfo.Image[CurrencyIndex].y && MousePoint.y - Y < ImageInfo.Image[CurrencyIndex].y + ImageInfo.Image[CurrencyIndex].Height) {
						if (MousePoint.KeyCode == MK_LBUTTON && MousePoint.KeyState == WM_LBUTTONDOWN) {
							if (SelectIndex != CurrencyIndex) {
								//是否高亮选中图片;
								if (SelectIndex < ImageInfo.MaxImage) {
									ImageInfo.Image[SelectIndex].RectAngleColor = D3DCOLOR_XRGB(255, 255, 255);
									ImageInfo.Image[SelectIndex].HeightLight = FALSE;
								}
								ImageInfo.Image[CurrencyIndex].HeightLight = TRUE;
								ImageInfo.Image[CurrencyIndex].RectAngleColor = D3DCOLOR_XRGB(255, 0, 0);
								SelectIndex = CurrencyIndex;
								IsTip = TRUE;//是否提示一次当前选中图片信息;
							}
							ISMove = TRUE;//是否选中一个图片
							//记录鼠标选中是的坐标点
							if (BOMouse.OldTick == 0xF841F || BOMouse.OldTick == 0) {
								BOMouse.x = MousePoint.x - (int)ImageInfo.Image[CurrencyIndex].x;
								BOMouse.y = MousePoint.y - (int)ImageInfo.Image[CurrencyIndex].y;
								BOMouse.OldTick = 0x6F414;
							}
							//根据鼠标移动移动选中图片坐标x;
							ImageInfo.Image[CurrencyIndex].x = (float)MousePoint.x - BOMouse.x;
							//限制图片不超出绘制区
							if (ImageInfo.Image[CurrencyIndex].x < 0)ImageInfo.Image[CurrencyIndex].x = 0;
							else if (ImageInfo.Image[CurrencyIndex].x > (lRect.right - lRect.left) - ImageInfo.Image[CurrencyIndex].Width)
								ImageInfo.Image[CurrencyIndex].x = (float)(lRect.right - lRect.left) - ImageInfo.Image[CurrencyIndex].Width;
							//根据鼠标移动移动选中图片坐标y;
							ImageInfo.Image[CurrencyIndex].y = (float)MousePoint.y - BOMouse.y;
							//限制图片不超出绘制区
							if (ImageInfo.Image[CurrencyIndex].y < 0)ImageInfo.Image[CurrencyIndex].y = 0;
							else if (ImageInfo.Image[CurrencyIndex].y > (lRect.bottom - lRect.top) - ImageInfo.Image[CurrencyIndex].Height)
								ImageInfo.Image[CurrencyIndex].y = (float)(lRect.bottom - lRect.top) - ImageInfo.Image[CurrencyIndex].Height;
						}
						if (MousePoint.KeyCode == MK_RBUTTON && MousePoint.KeyState == WM_RBUTTONDOWN) {
							if (SelectIndex != CurrencyIndex) {
								//是否高亮选中图片;
								if (SelectIndex < ImageInfo.MaxImage) {
									ImageInfo.Image[SelectIndex].RectAngleColor = D3DCOLOR_XRGB(255, 255, 255);
									ImageInfo.Image[SelectIndex].HeightLight = FALSE;
								}
								ImageInfo.Image[CurrencyIndex].HeightLight = TRUE;
								ImageInfo.Image[CurrencyIndex].RectAngleColor = D3DCOLOR_XRGB(255, 0, 0);
								SelectIndex = CurrencyIndex;
								IsTip = TRUE;//是否提示一次当前选中图片信息;
							}
						}
					}
				}
				else if (ImageInfo.Image[CurrencyIndex].ImgLoadType == Animate) {
					AnimateImage pAnimat = ImageInfo.Image[CurrencyIndex].Animate[ImageInfo.Image[CurrencyIndex].AnimateTickIndex];
					if (MousePoint.x - X > pAnimat.x && MousePoint.x - X < pAnimat.x + pAnimat.Width
						&& MousePoint.y - Y > pAnimat.y && MousePoint.y - Y < pAnimat.y + pAnimat.Height) {
						if (MousePoint.KeyCode == MK_LBUTTON && MousePoint.KeyState == WM_LBUTTONDOWN) {
							if (SelectIndex != CurrencyIndex|| SelectAnimateIndex != ImageInfo.Image[CurrencyIndex].AnimateTickIndex) {
								//是否高亮选中图片;
								if (SelectIndex < ImageInfo.MaxImage) {
									ImageInfo.Image[SelectIndex].RectAngleColor = D3DCOLOR_XRGB(255, 255, 255);
									ImageInfo.Image[SelectIndex].HeightLight = FALSE;
								}
								ImageInfo.Image[CurrencyIndex].HeightLight = TRUE;
								ImageInfo.Image[CurrencyIndex].RectAngleColor = D3DCOLOR_XRGB(255, 0, 0);
								SelectIndex = CurrencyIndex;
								SelectAnimateIndex = ImageInfo.Image[CurrencyIndex].AnimateTickIndex;
								IsTip = TRUE;//是否提示一次当前选中图片信息;
							}
							ISMove = TRUE;//是否选中一个图片
							//记录鼠标选中是的坐标点
							if (BOMouse.OldTick == 0xF841F || BOMouse.OldTick == 0) {
								BOMouse.x = MousePoint.x - (int)pAnimat.x;
								BOMouse.y = MousePoint.y - (int)pAnimat.y;
								BOMouse.OldTick = 0x6F414;
							}
							//根据鼠标移动移动选中图片坐标x;
							PAnimateImage pAnimat2 = &ImageInfo.Image[CurrencyIndex].Animate[ImageInfo.Image[CurrencyIndex].AnimateTickIndex];
							pAnimat2->x = (float)MousePoint.x - BOMouse.x;
							//限制图片不超出绘制区
							if (pAnimat2->x < 0) { 
								pAnimat2->x = 0; 
							}
							else if (pAnimat2->x > (lRect.right - lRect.left) - pAnimat2->Width)
								pAnimat2->x = (float)(lRect.right - lRect.left) - pAnimat2->Width;
							//根据鼠标移动移动选中图片坐标y;
							pAnimat2->y = (float)MousePoint.y - BOMouse.y;
							//限制图片不超出绘制区
							if (pAnimat2->y < 0)pAnimat2->y = 0;
							else if (pAnimat2->y > (lRect.bottom - lRect.top) - pAnimat2->Height)
								pAnimat2->y = (float)(lRect.bottom - lRect.top) - pAnimat2->Height;
						}
						if (MousePoint.KeyCode == MK_RBUTTON && MousePoint.KeyState == WM_RBUTTONDOWN) {
							if (SelectIndex != CurrencyIndex) {
								//是否高亮选中图片;
								if (SelectIndex < ImageInfo.MaxImage) {
									ImageInfo.Image[SelectIndex].RectAngleColor = D3DCOLOR_XRGB(255, 255, 255);
									ImageInfo.Image[SelectIndex].HeightLight = FALSE;
								}
								ImageInfo.Image[CurrencyIndex].HeightLight = TRUE;
								ImageInfo.Image[CurrencyIndex].RectAngleColor = D3DCOLOR_XRGB(255, 0, 0);
								SelectIndex = CurrencyIndex;
								IsTip = TRUE;//是否提示一次当前选中图片信息;
							}
						}
						if (MousePoint.KeyCode == MK_MBUTTON && MousePoint.KeyState == WM_MBUTTONDOWN) {
							//记录鼠标选中是的坐标点
							if (BOMouse.OldTick == 0xF841F || BOMouse.OldTick == 0) {
								BOMouse.x = MousePoint.x - (int)pAnimat.x;
								BOMouse.y = MousePoint.y - (int)pAnimat.y;
								BOMouse.OldTick = 0x6F414;
							}
							for (UINT i = 0; i < ImageInfo.Image[CurrencyIndex].AnimateMaxCout; i++) {
								//根据鼠标移动移动选中图片坐标x;
								PAnimateImage pAnimat2 = &ImageInfo.Image[CurrencyIndex].Animate[i];
								pAnimat2->x = (float)MousePoint.x - BOMouse.x;
								//限制图片不超出绘制区
								if (pAnimat2->x < 0) {
									pAnimat2->x = 0;
								}
								else if (pAnimat2->x > (lRect.right - lRect.left) - pAnimat2->Width)
									pAnimat2->x = (float)(lRect.right - lRect.left) - pAnimat2->Width;
								//根据鼠标移动移动选中图片坐标y;
								pAnimat2->y = (float)MousePoint.y - BOMouse.y;
								//限制图片不超出绘制区
								if (pAnimat2->y < 0)pAnimat2->y = 0;
								else if (pAnimat2->y > (lRect.bottom - lRect.top) - pAnimat2->Height)
									pAnimat2->y = (float)(lRect.bottom - lRect.top) - pAnimat2->Height;
							}
						}
					}
				}
			}
			//判断是否释放选中图片
			if (MousePoint.KeyState == WM_LBUTTONUP || MousePoint.KeyState == WM_RBUTTONUP|| MousePoint.KeyState == WM_MBUTTONUP) {
				ISMove = FALSE;
				BOMouse.x = 0;
				BOMouse.y = 0;
				BOMouse.OldTick = 0xF841F;
			}
			//绘制所有图片
			for (UINT i = 0; i < ImageInfo.MaxImage; i++) {
				if (ImageInfo.Image != nullptr) {
					if (ImageInfo.Image[i].ImgLoadType == Image) {
						//选中图片是否高亮显示
						if (SendMessage(GetDlgItem(G_hWnd, IDC_CHECK_HeightLight), BM_GETCHECK, 0, 0) == BST_CHECKED) {
							if (ImageInfo.Image[i].HeightLight)
								D2Dx9.DrawTexture(ImageInfo.Image[i].Texture, ImageInfo.Image[i].x, ImageInfo.Image[i].y, ImageInfo.Image[i].Width, ImageInfo.Image[i].Height, ImageInfo.Image[i].Scale, 0.0f, D3DCOLOR_XRGB(255, 0, 0));
							else D2Dx9.DrawTexture(ImageInfo.Image[i].Texture, ImageInfo.Image[i].x, ImageInfo.Image[i].y, ImageInfo.Image[i].Width, ImageInfo.Image[i].Height, ImageInfo.Image[i].Scale);
						}
						else D2Dx9.DrawTexture(ImageInfo.Image[i].Texture, ImageInfo.Image[i].x, ImageInfo.Image[i].y, ImageInfo.Image[i].Width, ImageInfo.Image[i].Height, ImageInfo.Image[i].Scale);
						//选中图片边框是否显示
						if (SendMessage(GetDlgItem(G_hWnd, IDC_CHECK_IsRectangle), BM_GETCHECK, 0, 0) == BST_CHECKED)
							D2Dx9.DrawRectagle(ImageInfo.Image[i].x, ImageInfo.Image[i].y, ImageInfo.Image[i].x + ImageInfo.Image[i].Width, ImageInfo.Image[i].y + ImageInfo.Image[i].Height,
								1.0f, ImageInfo.Image[i].RectAngleColor);
					}
					else if (ImageInfo.Image[i].ImgLoadType == Animate) {
						if (SendMessage(GetDlgItem(G_hWnd, IDC_CHECK_PlayAnimate), BM_GETCHECK, 0, 0) == BST_CHECKED) {
							if (GetTickCount() - ImageInfo.Image[i].OldAnimateTick > ImageInfo.Image[i].AnimateDelay) {
								ImageInfo.Image[i].OldAnimateTick = GetTickCount();
								ImageInfo.Image[i].AnimateTickIndex++;
							}
						}
						if (ImageInfo.Image[i].AnimateMaxCout <= ImageInfo.Image[i].AnimateTickIndex) {
							ImageInfo.Image[i].AnimateTickIndex = 0;
						}
						AnimateImage pAnimat = ImageInfo.Image[i].Animate[ImageInfo.Image[i].AnimateTickIndex];
						//选中图片是否高亮显示
						if (SendMessage(GetDlgItem(G_hWnd, IDC_CHECK_HeightLight), BM_GETCHECK, 0, 0) == BST_CHECKED) {
							if (ImageInfo.Image[i].HeightLight) {
								D2Dx9.DrawTexture(pAnimat.Texture, pAnimat.x, pAnimat.y, pAnimat.Width, pAnimat.Height, pAnimat.Scale, 0.0f, D3DCOLOR_XRGB(255, 0, 0));
							}
							else D2Dx9.DrawTexture(pAnimat.Texture, pAnimat.x, pAnimat.y, pAnimat.Width, pAnimat.Height, pAnimat.Scale);
						}
						else D2Dx9.DrawTexture(pAnimat.Texture, pAnimat.x, pAnimat.y, pAnimat.Width, pAnimat.Height, pAnimat.Scale);
						//选中图片边框是否显示
						if (SendMessage(GetDlgItem(G_hWnd, IDC_CHECK_IsRectangle), BM_GETCHECK, 0, 0) == BST_CHECKED)
							D2Dx9.DrawRectagle(pAnimat.x, pAnimat.y, pAnimat.x + pAnimat.Width, pAnimat.y + pAnimat.Height, 1.0f, ImageInfo.Image[i].RectAngleColor);
					}
				}
			}
			//显示绘制帧数;
			if (OldFpsTick == 0 || GetTickCount() - OldFpsTick > 1100) {
				OldFpsTick = GetTickCount();
				NewFPSCount = FPSCount;
				FPSCount = 0;
			}
			else FPSCount++;
			char FPSOut[50];
			sprintf(FPSOut, "FPS:%d,X:%dY:%d", NewFPSCount, MousePoint.x, MousePoint.y);
			D2Dx9.DrawFont(FPSOut, 12, NULL, FALSE, "隶书", &lRect, D3DCOLOR_XRGB(255, 0, 0));
			D3DDevice9->EndScene();
			D3DDevice9->Present(NULL, NULL, NULL, NULL);
			if (IsTip) {
				char ImgInfo[256] = { 0 };
				if (ImageInfo.Image[SelectIndex].ImgLoadType == Image) {
					sprintf(ImgInfo, "图片X:%.2f\t\t图片Y:%.2f\r\n\r\n图片高:%d\t\t图片宽:%d\r\n\r\n图片索引:%d\t\t图片总数:%d\r\n", ImageInfo.Image[SelectIndex].x, ImageInfo.Image[SelectIndex].y,
						ImageInfo.Image[SelectIndex].Width, ImageInfo.Image[SelectIndex].Height, CurrencyIndex, ImageInfo.MaxImage);
					SetWindowTextA(GetDlgItem(G_hWnd, IDC_Label_Tip), ImgInfo);
					HWND EditHwnd = GetDlgItem(G_hWnd, IDC_EDIT_Path);
					SetWindowText(EditHwnd, ImageInfo.Image[SelectIndex].ImageFile);
					UINT Strlen = wcslen(ImageInfo.Image[SelectIndex].ImageFile);
					SendMessage(EditHwnd, EM_SETSEL, Strlen, Strlen);
					sprintf(ImgInfo, "%.2f", ImageInfo.Image[SelectIndex].Scale);
					SetWindowTextA(GetDlgItem(G_hWnd, IDC_EDIT_Scale), ImgInfo);
					SendMessage(GetDlgItem(G_hWnd, IDC_COMBO_LoadStyle), CB_SETCURSEL, 1, NULL);
				}
				else if (ImageInfo.Image[SelectIndex].ImgLoadType == Animate) {
					AnimateImage pAnimat = ImageInfo.Image[SelectIndex].Animate[ImageInfo.Image[SelectIndex].AnimateTickIndex];
					sprintf(ImgInfo, "图片X:%.2f\t\t图片Y:%.2f\r\n\r\n图片高:%d\t\t图片宽:%d\r\n\r\n动画索引:%d\t\t动画总帧:%d\r\n\r\n动画帧时:%dms/ts\t", pAnimat.x, pAnimat.y,
						pAnimat.Width, pAnimat.Height, ImageInfo.Image[SelectIndex].AnimateTickIndex, ImageInfo.Image[SelectIndex].AnimateMaxCout, ImageInfo.Image[SelectIndex].AnimateDelay);
					SetWindowTextA(GetDlgItem(G_hWnd, IDC_Label_Tip), ImgInfo);
					HWND EditHwnd = GetDlgItem(G_hWnd, IDC_EDIT_Path);
					SetWindowText(EditHwnd, pAnimat.ImageFile);
					UINT Strlen = wcslen(pAnimat.ImageFile);
					SendMessage(EditHwnd, EM_SETSEL, Strlen, Strlen);
					sprintf(ImgInfo, "%.2f", pAnimat.Scale);
					SetWindowTextA(GetDlgItem(G_hWnd, IDC_EDIT_Scale), ImgInfo);
					SendMessage(GetDlgItem(G_hWnd, IDC_COMBO_LoadStyle), CB_SETCURSEL, 0, NULL);
				}
				/*BYTE *Rgb = (BYTE*)&ImageInfo.Image[SelectIndex].RectAngleColor;
				sprintf(ImgInfo, "%d", Rgb[2]);
				SetWindowTextA(GetDlgItem(G_hWnd, IDC_EDIT_ColorR), ImgInfo);
				sprintf(ImgInfo, "%d", Rgb[1]);
				SetWindowTextA(GetDlgItem(G_hWnd, IDC_EDIT_ColorG), ImgInfo);
				sprintf(ImgInfo, "%d", Rgb[0]);
				SetWindowTextA(GetDlgItem(G_hWnd, IDC_EDIT_ColorB), ImgInfo);*/
				IsTip = FALSE;
			}
		}
		else D3DDevice9->EndScene(); //因为有时会因为上一次开始绘制没有执行结束绘制就被强制销毁了所以加上了这句代码
		Sleep(5);
	}
	sprintf(Biit, "线程成功退出!=-%d--\n", rand() % 1000);
	OutputDebugStringA(Biit);
}


[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)

最后于 2019-3-27 19:08 被ezrealik编辑 ,原因:
上传的附件:
收藏
免费 1
支持
分享
最新回复 (5)
雪    币: 894
活跃值: (3555)
能力值: ( LV7,RANK:140 )
在线值:
发帖
回帖
粉丝
2
多线程操作DrawThread的话,使用临界区或者原子级操作会好一点。使用互斥应该也是一样可以的。
代码中用到了SendMessage,这个函数是会等待消息处理函数执行完毕才返回的,你审查一下几个SendMessage的消息处理函数。
2019-3-27 11:34
1
雪    币: 12857
活跃值: (9172)
能力值: ( LV9,RANK:280 )
在线值:
发帖
回帖
粉丝
3
用Event做通知,另一边WaitForSingle/MultiObject
2019-3-27 11:51
1
雪    币: 1570
活跃值: (383)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
4
yeyeshun 多线程操作DrawThread的话,使用临界区或者原子级操作会好一点。使用互斥应该也是一样可以的。 代码中用到了SendMessage,这个函数是会等待消息处理函数执行完毕才返回的,你审查一下几个S ...
谢谢你的帮助,应该是这个原因.  我去试试把SendMessage换线程外面看看
2019-3-27 12:43
0
雪    币: 894
活跃值: (3555)
能力值: ( LV7,RANK:140 )
在线值:
发帖
回帖
粉丝
5
ezrealik 谢谢你的帮助,应该是这个原因. 我去试试把SendMessage换线程外面看看
可可以改成PostMessage,这个函数是发送完就返回,不等待
2019-3-27 13:39
1
雪    币: 1570
活跃值: (383)
能力值: ( LV3,RANK:30 )
在线值:
发帖
回帖
粉丝
6
谢谢.  我需要SendMessage获取窗口控件状态,postMessage的话没办法获取控件信息. 我吧sendmessage放在线程外面了.
2019-3-27 19:07
0
游客
登录 | 注册 方可回帖
返回
//