如何停止Windows消息 [英] how to stop a windows message

查看:70
本文介绍了如何停止Windows消息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何停止发送消息?例如,对话框中有控件,有时我需要此控件发送消息并处理它,但有时我不希望该消息,只是忽略它?

让我补充细节.
我想根据我定义的索引对单词进行排序.我在对话框中添加了两个虚拟列表,第一个在排序之前显示单词,第二个在排序之后显示单词.
我们知道虚拟列表需要添加一些消息处理程序功能,如下所示:(由于单词数量巨大,因此只有虚拟列表才能无延迟地显示它)



how can I stop sending a message ? like, there is control on my dialog, sometimes I need this control send message and I handle it , but sometimes I don''t want that message ,just ignore it?

let me add detail.
I want to sort words according to the index I defined. I added two virtual list on my dialog, in the first one I displayed words before sorting, in the second I displayed words after sorting.
as we know virtual list needed to add some message handler function like below: (since the amount of word is huge, only virtual list can display it without delay)



void CUWordSortDlg::OnGetdispinfoList1(NMHDR* pNMHDR, LRESULT* pResult) 
{
	LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
	// TODO: Add your control notification handler code here
	//Create a pointer to the item
	LV_ITEM* pItem= &(pDispInfo)->item;
	
	//Which item number?
	int itemid = pItem->iItem;
	
	//Do the list need text information?
	if (pItem->mask & LVIF_TEXT)
	{
		CString text;
		//Which column?
		if(pItem->iSubItem == 0)
		{
			//Text is name
			CString temp; 
			temp.Format(L"%d",itemid);
			text = temp;
				
		}
		else if (pItem->iSubItem == 1)
		{
			//Text is slogan
			text = qArr.GetAt(itemid);
		}
		
		//Copy the text to the LV_ITEM structure
		//Maximum number of characters is in pItem->cchTextMax
		lstrcpyn(pItem->pszText, text, pItem->cchTextMax);
	}
	*pResult = 0;
}




两个虚拟列表添加了与我显示的功能相同的功能.

qArr在排序之前和排序之后都保存单词.

排序后,一旦我对第一个虚拟列表进行了任何操作,它都会更改其内容(内容将像第二个虚拟列表一样进行排序).

我希望在排序之前和之后都不要更改第一个虚拟列表的内容.




two virtual list added same function like as I showed.

qArr save the words both before sorting and after sorting.

after sort ,once I did any operate on first virtual list , it change its content(contents is became sorted like second virtual list).

I wish not to change content of first virtual list both before and after sorting.

how can I solve that problem?

推荐答案

您必须创建一个处理程序,该处理程序根据您设置的条件执行或不执行某些操作.

绝对没有理由在您的问题中生气地笑.
You have to create a handler that either does or does not do something based on some condition that you set.

There''s also absolutely no reason to put an angry smiley in your question.


alim428253写道:
alim428253 wrote:

但有时我不想要该消息,只是忽略它吗?

but sometimes I don''t want that message ,just ignore it?


是的,忽略它(即什么都不做,只能在您的消息处理程序中使用它.)

顺便说一句,你为什么不高兴?
:)


Yes, ignore it (i.e. do nothing but consume it in your message handler).

BTW Why are you upset?
:)


您需要在事件处理程序实现中添加对忽略条件的检查.

You need to add a check for your ignore condition in the event handler implementation.

if(!isIgnore){// whatever your actual condition is 

   //do stuff

}
else return;



此外,您还需要查看事件处理程序的实现,它显然具有指向结果值的指针,这可能有助于您在返回(或不返回)之前将其设置为非0的值.

SH



also you need to look at the event handler implementation it clearly has a pointer to a result value it may be helpful for you to set this to something other than 0 before return( or not).

SH


这篇关于如何停止Windows消息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆