ListView, Rocker Down problem

B

Brofalad

Hi all,

I wonder if it is possible to inhibit the key down event from changing
the row in a listview. I have given the key down event a different
meaning and I don’t want the row to be changed if a listview is in
focus.
Is this possible?

Brofalad


private void DlgNewAvd_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Up))
{
// Rocker Up
// Up
}
if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
// My custom code. And I don't want the selected row to
be changes if a ListView has focus
}
....
....
}
 
C

Chris Tacke, eMVP

Sure, override the control's WndProc and handle it.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

Hi all,

I wonder if it is possible to inhibit the key down event from changing
the row in a listview. I have given the key down event a different
meaning and I don’t want the row to be changed if a listview is in
focus.
Is this possible?

Brofalad


private void DlgNewAvd_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Up))
{
// Rocker Up
// Up
}
if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
// My custom code. And I don't want the selected row to
be changes if a ListView has focus
}
....
....
}
 
C

Chris Tacke, eMVP

Sure, override the control's WndProc and handle it.


--

Chris Tacke, Embedded MVP
OpenNETCF Consulting
Giving back to the embedded community
http://community.OpenNETCF.com

Hi all,

I wonder if it is possible to inhibit the key down event from changing
the row in a listview. I have given the key down event a different
meaning and I don’t want the row to be changed if a listview is in
focus.
Is this possible?

Brofalad


private void DlgNewAvd_KeyDown(object sender, KeyEventArgs e)
{
if ((e.KeyCode == System.Windows.Forms.Keys.Up))
{
// Rocker Up
// Up
}
if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
// My custom code. And I don't want the selected row to
be changes if a ListView has focus
}
....
....
}
 
B

Brofalad

Thanks for your reply!

I tried this

public class myListView : System.Windows.Forms.ListView
{
protected override void WndProc(ref
System.Windows.Forms.Message m)
{
// My code
base.WndProc(ref m);
}
}
But I got the error: 'System.Windows.Forms.ListView' does not contain
a definition for 'WndProc'

What have I missed?

/Brofalad
 
B

Brofalad

Thanks for your reply!

I tried this

public class myListView : System.Windows.Forms.ListView
{
protected override void WndProc(ref
System.Windows.Forms.Message m)
{
// My code
base.WndProc(ref m);
}
}
But I got the error: 'System.Windows.Forms.ListView' does not contain
a definition for 'WndProc'

What have I missed?

/Brofalad
 
S

Simon Hart [MVP]

You need to implement the Microsoft.WindowsCE.Forms.MessageWindow class for
your control.
 
B

Brofalad

You need to implement the Microsoft.WindowsCE.Forms.MessageWindow class for
your control.

Sorry, I don't quite get the concept. I have used MessageWindow
before to receive custom windows messages for a Form. But I don't get
how to inhibit specific messages for a specific control.
Any samples?

/Brofalad
 
B

Brofalad

Thanks!

I feel like a newbie in this area.

I think I have to modify this area.

// Override the default WndProc behavior to examine messages.
protected override void WndProc(ref Message msg)
{
if (msg.Msg == WM_XXXXXXXXXXXXX) //
How do I get the right messagetype here
{
if ((int)msg.LParam == WM_YYYYYYYYY) // How
do I get the Rocker Down WM
{
if ((int)msg.WParam ==
m_uID) // Is it the uID for my ListBox I shall
test fore here, how do I get it?
{
// Here I shall kill the message I suppose,
but how?
}
}
}

}

/Brofalad
 
B

Brofalad

Problem solved in a much easier way.


if ((e.KeyCode == System.Windows.Forms.Keys.Down))
{
// My custom code. And I don't want the selected row in
the ListView to change
e.handled = true; <=========== !!!!!!!!!!!!!!!!!!!!!
}

/Brofalad
 

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

Top