Hi, I`m new here and, of course, have a small problem.
I need to create a program with VC++ 6 Builder where:
Press ENTER once - open picture,
Press ENTER Twice - start a music.
I can`t figure out how to check if user press ENTER twice, can anybody help me?
My Code:
void __fastcall TForm1::ListBox1KeyPress(TObject *Sender, char &Key)
{
switch( Key )
{
case 'VK_RETURN':
{ atidarytpav(); }
break;
}
The :ListBox1KeyPress method takes a pointer to a TObject called Sender. Mostly, every event handler, in c++, will have at least a Sender parameter. When the button is clicked, the event handler (:ListBox1KeyPress) for the KeyPress event is called.
The parameter "Sender" references the control that was used to call the method. If you press on the ListBox1 control, causing the ListBox1KeyPress method to be called, a reference or pointer to the ListBox1 object is passed to ListBox1KeyPress in the parameter called Sender
The :ListBox1KeyPress method takes a pointer to a TObject called Sender. Mostly, every event handler, in c++, will have at least a Sender parameter. When the button is clicked, the event handler (:ListBox1KeyPress) for the KeyPress event is called.
The parameter "Sender" references the control that was used to call the method. If you press on the ListBox1 control, causing the ListBox1KeyPress method to be called, a reference or pointer to the ListBox1 object is passed to ListBox1KeyPress in the parameter called Sender
Sorry, but my MSDN doesn't mention anything looking like TObject. And I don't need anything but TObject description in order to help you.
Sorry, but my MSDN doesn't mention anything looking like TObject. And I don't need anything but TObject description in order to help you.
Must be Borland's library. In .NET there is a base class called Object, from which everything derives. WinForms' implementation of event handler callbacks take two parameters, Object Sender and an event argument class. This looks to use the same concept. So a TObject pointer is just a base pointer to some control that is responsible for raising the event.
No, it might be and it might be not.
And the fact is there is not.
Originally Posted by Chris_F
In .NET there is a base class called Object, from which everything derives. WinForms' implementation of event handler callbacks take two parameters, ...
I am not the originator of this thread, so I have no need to ask this question anywhere. Even then, I merely stated that the code he posted is similar to .NET in design. However TObject is most assuredly not a part of the .NET library, so asking this question there would be extremely foolish.
Originally Posted by VictorN
No, it might be and it might be not.
And the fact is there is not.
Admittedly I haven't done much research, but everything I've seen while searching seems to tie the TObject class to Borland/C++ and Delphi. Do I have any proof that this is what alone882 is using? No. But I'd be willing to make a wager that it is.
Lastly, I fail to see how this is even relevant. His problem isn't with his use of the GUI library, it's a simple problem that could arise in MFC, .NET, Delphi, or what have you. He simply needs to create a variable to store whether or not the button has been clicked previously to see which action should be taken.
Last edited by Chris_F; January 3rd, 2011 at 06:07 AM.
alone882 these days there are quite few that use Borland C++ Builder. Version 6 is also very old/outdated so I guess that will make it even harder to get help.
I would try http://embarcadero.com/ and see if they have a link to some C++ Builder community.
Debugging is twice as hard as writing the code in the first place.
Therefore, if you write the code as cleverly as possible, you are, by
definition, not smart enough to debug it.
- Brian W. Kernighan
I can`t figure out how to check if user press ENTER twice, can anybody help me?
This implies some waiting should be done after first Enter for a short period to see if the second Enter comes (similar to mouse double click logic).
The form starts timer (say, 200-500ms) on first Enter and set some flag which should be reset when the second Enter arrives before the timer elapses. In case another Enter arrives when the flag is set, it means "double Enter" event to fire (resetting the flag as well). In case timer elapses with the flag set (which means there was no second Enter within the period), it resets the flag and fires "single Enter" event.
Bookmarks