PreFilterMessage maximize problem

  • Thread starter Thread starter Olo
  • Start date Start date
O

Olo

Hello,

I added Prefilter function to main form, becouse I have to catch key event
globaly. Everything is ok except maximize command. When I press MaximizeBox
it doesn't work.

Bellow you find me PreFilerMessage :

public bool PreFilterMessage(ref Message m)
{
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;

const int WM_MDIMAXIMIZE = 0x0225;
if(!m_designer.IsPropertyGridFocus)
{
switch ((int)m.WParam)
{
case 9: // tab
return true;
case 37: // left
m_designer.KeyLeftCmd();
return true;
case 38: // up
m_designer.KeyUpCmd();
return true;
case 39: // right
m_designer.KeyRightCmd();
return true;
case 40: // down
m_designer.KeyDownCmd();
return true; // this means that we handled the code
case SC_MAXIMIZE: //maximize
this.WindowState = FormWindowState.Maximized;
return true;
default:
Console.Out.WriteLine((int)m.WParam);
return false; // this means that we want the DefProc to

//}
}
}

Regards,
Olo.
 
Hi Olo,

You don't check for the type of the message
You check WParam of every message that goes thru the message filter. Many
messages can have those numbers in WParam, but they mean different things.
 
Thanks Stoitcho,

It works :).

I add one conndition and it's ok :

if(m.Msg == 256) {
switch ((int)m.WParam)
{
case 9: // tab
return true;
case 37: // left
m_designer.KeyLeftCmd();
return true;
case 38: // up
m_designer.KeyUpCmd();
return true;
case 39: // right
m_designer.KeyRightCmd();
return true;
case 40: // down
m_designer.KeyDownCmd();
return true; // this means that we handled the code
default:
return false;
}


U¿ytkownik "Stoitcho Goutsev (100) said:
Hi Olo,

You don't check for the type of the message
You check WParam of every message that goes thru the message filter. Many
messages can have those numbers in WParam, but they mean different things.
--

Stoitcho Goutsev (100) [C# MVP]


Hello,

I added Prefilter function to main form, becouse I have to catch key event
globaly. Everything is ok except maximize command. When I press MaximizeBox
it doesn't work.

Bellow you find me PreFilerMessage :

public bool PreFilterMessage(ref Message m)
{
const int SC_MINIMIZE = 0xF020;
const int SC_MAXIMIZE = 0xF030;

const int WM_MDIMAXIMIZE = 0x0225;
if(!m_designer.IsPropertyGridFocus)
{
switch ((int)m.WParam)
{
case 9: // tab
return true;
case 37: // left
m_designer.KeyLeftCmd();
return true;
case 38: // up
m_designer.KeyUpCmd();
return true;
case 39: // right
m_designer.KeyRightCmd();
return true;
case 40: // down
m_designer.KeyDownCmd();
return true; // this means that we handled the code
case SC_MAXIMIZE: //maximize
this.WindowState = FormWindowState.Maximized;
return true;
default:
Console.Out.WriteLine((int)m.WParam);
return false; // this means that we want the DefProc to

//}
}
}

Regards,
Olo.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top