473,387 Members | 1,504 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Fire KeyDown in C++

T
Hi,

How do I fire the KeyDown event in Managed VC++? I am getting a
compile error saying "event does not have a raise method". Please
help.
regards,
T

May 14 '07 #1
5 4270
T
On May 14, 8:50 pm, T <sw.tejasvi...@gmail.comwrote:
Hi,

How do I fire the KeyDown event in Managed VC++? I am getting a
compile error saying "event does not have a raise method". Please
help.

regards,
T
I managed to fix this though I don't know why the compile failed. I
was trying to fire the event in a class derived from Panel. The fix is
to redeclare the event as:
__event KeyEventHandler *KeyDown;

May 14 '07 #2
Hi T,

"T" <sw***********@gmail.comschrieb im Newsbeitrag
news:11**********************@u30g2000hsc.googlegr oups.com...
Hi,

How do I fire the KeyDown event in Managed VC++? I am getting a
compile error saying "event does not have a raise method". Please
help.
Please show us the code you have so far and show the line in error.

--
SvenC

May 14 '07 #3
Hi T,

"T" <sw***********@gmail.comschrieb im Newsbeitrag
news:11**********************@k79g2000hse.googlegr oups.com...
On May 14, 8:50 pm, T <sw.tejasvi...@gmail.comwrote:
>Hi,

How do I fire the KeyDown event in Managed VC++? I am getting a
compile error saying "event does not have a raise method". Please
help.

regards,
T

I managed to fix this though I don't know why the compile failed. I
was trying to fire the event in a class derived from Panel. The fix is
to redeclare the event as:
__event KeyEventHandler *KeyDown;
As far as I know managed classes inherit public by default in contrast to
native C++. So did you explicitly inherit private from Panel? Alternatively
you could try to explicitly inherit with "public Panel"

Otherwise this could indicate a compiler bug.

--
SvenC

May 14 '07 #4
T
Hi SvenC,

Here is the code:
Expand|Select|Wrap|Line Numbers
  1. namespace NuDesign {
  2. using namespace System::Windows::Forms;
  3.  
  4. public __gc class ndPanel : public System::Windows::Forms::Panel {
  5. public:
  6. __event KeyEventHandler *KeyDown;
  7.  
  8. virtual bool ProcessCmdKey(Message __gc *msg, Keys key){
  9. if(msg->Msg == 0x100 && (key == Keys::Up || key == Keys::Down ||
  10. key == Keys::Left
  11. || key == Keys::Right)){
  12. KeyDown(0, new KeyEventArgs(key));
  13. }
  14. return false;
  15. }
  16. };
  17. }
  18.  
May 14 '07 #5

"SvenC" <sv***@community.nospamwrote in message
news:16**********************************@microsof t.com...
Hi T,

"T" <sw***********@gmail.comschrieb im Newsbeitrag
news:11**********************@k79g2000hse.googlegr oups.com...
>On May 14, 8:50 pm, T <sw.tejasvi...@gmail.comwrote:
>>Hi,

How do I fire the KeyDown event in Managed VC++? I am getting a
compile error saying "event does not have a raise method". Please
help.

regards,
T

I managed to fix this though I don't know why the compile failed. I
was trying to fire the event in a class derived from Panel. The fix is
to redeclare the event as:
__event KeyEventHandler *KeyDown;

As far as I know managed classes inherit public by default in contrast to
native C++. So did you explicitly inherit private from Panel?
Alternatively you could try to explicitly inherit with "public Panel"
..NET doesn't allow private inheritance.
>
Otherwise this could indicate a compiler bug.
No, it's the same in C# and VC++ 2005. Only the class which declares an
event can fire it. The public access refers to the ability to subscribe
handlers, not to trigger the event. Usually calling the base class has an
OnKeyDown method which you can call, resulting in the event being fired with
your parameters.

Or, you can hide the parent event as you've done, but anyone who subscribes
with a base class pointer won't see your event.
>
--
SvenC

May 14 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

34
by: Andrew DeFaria | last post by:
I thought this would be fairly straight forward but apparently it's not. Given the following html file: <!DOCTYPE html PUBLIC "-//w3c//dtd html 4.0 transitional//en"> <html> <head>...
6
by: datactrl | last post by:
Hi, all Is that possible to fire a "tab" key press event with javascript? jack
3
by: Frank T. Clark | last post by:
How do I redirect or capture keydown events in a parent form from a child form? I have a main form which displays another informational form marked "SizableToolWindow". Form child = new...
4
by: Anne | last post by:
hie again, i have 3 textbox and i would like the user to go to the next textbox by pressing the 'ENTER' key. i have tried using this: Private Sub txtRequestor_KeyDown(ByVal sender As...
16
by: schneider | last post by:
I can't get any of the Key events to fire in my UserControl. The control only contains a few labels. This is really annoying.. Anyone know whats going on? Thanks, Schneider
2
by: anoehre_1 | last post by:
Hi! Very simple Application: ------------------------------- this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.Form1_KeyDown);
3
by: MLM450 | last post by:
I have a control that handles the KeyDown event but it does not seem to execute when a combination of keys is pressed - like CTRL+Z. If I press CTRL, it executes. If I press Z, it executes. But the...
8
by: ApexData | last post by:
I'm using the OnKeyDown event in hopes of capturing a key being held down during the initial startup of my application. Does anyone know, at what point the OnKeyDown event fires? I checked to...
2
by: ershn | last post by:
Hello. I'm writing a windows mobile 2003 project for smartphone in vb.net. Using vs2003 compact framework 1.0. In most attempts on my forms I cannot get the keydown event to fire. I'm basically...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.