473,794 Members | 2,880 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing in a OnMouseDown/OnMouseUp event handler as a parameter of a function

Hi all,

I have created a class which contains many TShapes, TLabels and
TPanels. What I want to be able to do is when creating this class, is
passing in a pointer to OnMouseDown and OnMouseUp events. Thereby, the
user of the class can create their own event handlers for those events.
The idea is that by passing in the event handlers, these event
handlers are assigned to the appropriate events for each of the objects
in the class. However, I am having trouble declaring the constructor:

eg.
class SpecialButton : public TObject {
__published:
TShape *TLCorner;
TShape *TRCorner; // ...etc....

__public:
__fastcall SpecialButton(T MouseEvent mouseDown, TMouseEvent
mouseUp); // ??????
};

Your suggestions on this would be greatly appreciated.

Thanks,
Kyzer

Jul 23 '05 #1
2 2913
> Hi all,

I have created a class which contains many TShapes, TLabels and
TPanels. What I want to be able to do is when creating this class, is passing in a pointer to OnMouseDown and OnMouseUp events. Thereby, the user of the class can create their own event handlers for those events. The idea is that by passing in the event handlers, these event
handlers are assigned to the appropriate events for each of the objects in the class. However, I am having trouble declaring the constructor:
eg.
class SpecialButton : public TObject {
__published:
What's __published?
TShape *TLCorner;
TShape *TRCorner; // ...etc....

__public:
What's __public?
__fastcall SpecialButton(T MouseEvent mouseDown, TMouseEvent
mouseUp); // ??????
What's __fastcall?
};

Your suggestions on this would be greatly appreciated.


What's the problem?
Jonathan

Jul 23 '05 #2

"Kyzer" <ky******@hotma il.com> wrote in message news:11******** **************@ g14g2000cwa.goo glegroups.com.. .
Hi all,

I have created a class which contains many TShapes, TLabels and
TPanels. What I want to be able to do is when creating this class, is
passing in a pointer to OnMouseDown and OnMouseUp events. Thereby, the
user of the class can create their own event handlers for those events.
The idea is that by passing in the event handlers, these event
handlers are assigned to the appropriate events for each of the objects
in the class. However, I am having trouble declaring the constructor:

eg.
class SpecialButton : public TObject {
__published:
TShape *TLCorner;
TShape *TRCorner; // ...etc....

__public:
__fastcall SpecialButton(T MouseEvent mouseDown, TMouseEvent
mouseUp); // ??????
};

Your suggestions on this would be greatly appreciated.

Try newsgroups.borl and.com and look for a discussion with
VCL in the title. You'll get better help there. What you probably
want to do is to define a virtual function called by the event and allow
a derived class to override it.

BTW, even Borland doesn't support __public: AFAIK.
Jul 23 '05 #3

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

Similar topics

7
49584
by: Pavils Jurjans | last post by:
Hallo, I have been programming for restricted environments where Internet Explorer is a standard, so I haven't stumbled upon this problem until now, when I need to write a DOM-compatible code. The question is about best practices for passing parameters to an event function. I have, say, the following HTML:
2
6213
by: Bender | last post by:
Hi, I am wanting to capture an onmousedown event without firing the body tags onload event. Also, if anyone could explain why this happens that would be excellent. I can't see how an onmousedown event could bubble up to an onload event. NOTE: If you put an alert() statement in the onmousedown event handler the body onload event doesn't get fired.
1
2471
by: coolsti | last post by:
I am trying to let the user drag a rectangle over an image, which will then let the user zoom in on the dragged area. However, I am doing something wrong in implementing the onmousedown and onmouseup events. Everything is very simple so far. I just defined an onMouseDown event to record the event's x and y locations as the starting point, and an onMouseUp event to record the x and y of the end point, and this function gives me the...
1
1405
by: sameth | last post by:
I wrote a script that uses onmousedown and onmouseup in javascript that works great in ie and firefox on windows2000. It looks as if the pocketpc 2003 ie browser dosn't support onmousedown or onmouseup and only such as onclick. I need to be able to submit a form when the mouse is held down on a button and submit a different form when the mouse is lifted up from the button. could anyone tell me of anything I could substitute onmousedown...
6
4751
by: RC | last post by:
<a href="#" onmousedown="callMyFunction()">Press the mouse button</a> What I expect is when I or an user move mouse pointer over that link, and press the mouse button. Then will "callMyFunction()" over and over again until I release the mouse button (mouseup). But what I found out the onmousedown is just acts the same as onclick. It only "callMyFunction" once. If I want to call again, I need to keep repeat mousedown, mouseup like...
9
7604
by: jon | last post by:
Hello, I'm trying to experiment with some javascript to do some custom dragdrop handling. I wish to use the onMouseDown event to trigger the start of my drag, and onMouseup for a potentential drop. I hope to turn on the onmouseup only in onmousedown. And eventually go one step further and incorporate onmousemove for a true drag workflow. I'm running into a problem however, where after mousedown, mouseup will not fire when I release...
4
2386
by: simon | last post by:
hi, I would like to separate my javascript completely from my xhtml. in the end there should be only <script type="text/javascript" src="javalib.js"></script> in the head-tag to my javascript. Because I want to use some ajax-requests and other javascript-functions on my xhtml, I need to dynamically add event handlers to any possible dom-elements. All solutions I found so fare are for specific, pre-known
1
3803
by: NeilCarmichael | last post by:
I am flummoxed, I'm relatively new to javascript and I can't get my onmousedown onmouseup script to work. simply, I want to fire one function when I click down on a graphic and a second when I release. I tried different combinations of onmousedown onmouseup and onclick and putting them in div's img's and anchor's but I can't get it to work, any ideas?
0
9519
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10000
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9037
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7538
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5436
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5563
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4113
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2920
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.