Click here to Skip to main content
15,921,694 members
Home / Discussions / C#
   

C#

 
AnswerRe: How can i know witch button was click ? Pin
Luc Pattyn27-Jul-07 13:53
sitebuilderLuc Pattyn27-Jul-07 13:53 
GeneralThank you very much. Pin
Yanshof27-Jul-07 14:10
Yanshof27-Jul-07 14:10 
Questionto center TabPage Scroll Bar [modified] Pin
fatihbilmuh27-Jul-07 11:59
fatihbilmuh27-Jul-07 11:59 
QuestionI need practical ideas for IT engineering Graduation Project Pin
michaelqog27-Jul-07 11:00
michaelqog27-Jul-07 11:00 
AnswerRe: I need practical ideas for IT engineering Graduation Project Pin
snorkie27-Jul-07 11:09
professionalsnorkie27-Jul-07 11:09 
AnswerRe: I need practical ideas for IT engineering Graduation Project Pin
Paul Conrad28-Jul-07 11:24
professionalPaul Conrad28-Jul-07 11:24 
QuestionHow can I edit a database row and then update it ? Pin
eni_9427-Jul-07 10:43
eni_9427-Jul-07 10:43 
QuestionWindows Forms Messages Problem Pin
gopher_uk27-Jul-07 9:57
gopher_uk27-Jul-07 9:57 
Hi,

I'm trying to receive windows messages to notify my program of when it has been deactivated or activated. I've used the following class, and a basic windows form to try it out:

public class AppMessageFilter : IMessageFilter
{
private const int WM_ACTIVATEAPP = 0x001C;

public bool PreFilterMessage(ref Message m)
{
if (m.Msg == WM_ACTIVATEAPP)
{
//Lost focus:
if ((int)m.WParam == 0)
{
MessageBox.Show("Deactivated");
}
//Gained focus:
else
{
MessageBox.Show("Activated");
}
}
return false;
}
}

And....

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
Application.AddMessageFilter(new AppMessageFilter());
}
}

However, this does not work. I've tried different windows messages (e.g. WM_ACTIVATEAPP and WM_ACTIVATE), but neither get filtered in the PreFilterMessage method when I switch from my form to another application (e.g. internet explorer or another window). I'm only using the MessageBox parts to test it works - i've also tried omitting these and testing to see if breakpoints are reached.
I've tried this on both Windows 2000 and Vista 64. Any ideas where i'm going wrong?





Thanks
James
AnswerRe: Windows Forms Messages Problem Pin
User 665829-Jul-07 7:14
User 665829-Jul-07 7:14 
QuestionFile Streamer Problems Pin
ytubis27-Jul-07 9:44
ytubis27-Jul-07 9:44 
AnswerRe: File Streamer Problems Pin
BoneSoft27-Jul-07 9:55
BoneSoft27-Jul-07 9:55 
AnswerRe: File Streamer Problems Pin
Luc Pattyn27-Jul-07 9:59
sitebuilderLuc Pattyn27-Jul-07 9:59 
AnswerRe: File Streamer Problems Pin
snorkie27-Jul-07 10:01
professionalsnorkie27-Jul-07 10:01 
AnswerRe: File Streamer Problems Pin
PhilDanger27-Jul-07 10:34
PhilDanger27-Jul-07 10:34 
QuestionPerformance difference?? Pin
Shy Agam27-Jul-07 9:42
Shy Agam27-Jul-07 9:42 
AnswerRe: Performance difference?? Pin
BoneSoft27-Jul-07 9:52
BoneSoft27-Jul-07 9:52 
AnswerRe: Performance difference?? Pin
Shy Agam27-Jul-07 10:02
Shy Agam27-Jul-07 10:02 
GeneralRe: Performance difference?? Pin
Luc Pattyn27-Jul-07 10:10
sitebuilderLuc Pattyn27-Jul-07 10:10 
GeneralRe: Performance difference?? Pin
Shy Agam27-Jul-07 10:13
Shy Agam27-Jul-07 10:13 
AnswerRe: Performance difference?? Pin
Luc Pattyn27-Jul-07 10:06
sitebuilderLuc Pattyn27-Jul-07 10:06 
GeneralRe: Performance difference?? Pin
BoneSoft27-Jul-07 10:29
BoneSoft27-Jul-07 10:29 
GeneralRe: Performance difference?? Pin
Luc Pattyn27-Jul-07 10:46
sitebuilderLuc Pattyn27-Jul-07 10:46 
AnswerRe: Performance difference?? Pin
Paul Conrad27-Jul-07 10:07
professionalPaul Conrad27-Jul-07 10:07 
AnswerRe: Performance difference?? Pin
snorkie27-Jul-07 10:51
professionalsnorkie27-Jul-07 10:51 
GeneralRe: Performance difference?? Pin
PIEBALDconsult27-Jul-07 13:38
mvePIEBALDconsult27-Jul-07 13:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.