Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Olevariant and Event

Posted on 2003-10-28
7
Medium Priority
?
500 Views
Last Modified: 2010-04-05
How to assign an procedure to  an Olevariant?
(Olevariant<--(TNotifyEvent or some thing like it))
0
Comment
Question by:skullvn
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
7 Comments
 

Accepted Solution

by:
jgilm earned 200 total points
ID: 9636886
You didn't say what you wanted to do with the OleVariant. I'll give you an example of what you can do, but it is ONLY valid within the context of the currently running instance of the application. You would not be able to use it from another application or from another instance of the same application. With this in mind, here you go (using a TNotifyEvent as the example):

{Global variable}
var
  MyTest: OleVariant;

procedure TForm1.Button1Click(Sender: TObject);
begin
  beep;
end;

procedure TForm1.Button2Click(Sender: TObject);
var
  ne  : TNotifyEvent;
begin
  ne := self.Button1Click;

  // assign the integer value of the pointer to the method to the OleVariant
  MyTest := Integer(@ne);
end;

procedure TForm1.Button3Click(Sender: TObject);
var
  ne2 : TNotifyEvent;
begin
  // convert the OleVariant back to a pointer and have ne2 point to the method.
  @ne2 := ptr(integer(MyTest));

  // call the method
  ne2(self);
end;


Again, this is dependent upon the current execution of the application. You can't store this in a database or a file and expect to be able to use it again during another execution of the application. Because of that, there are a number of better ways to assign methods/procedures/fuctions to variables. However, I believe I answered your question as asked.
0
 

Author Comment

by:skullvn
ID: 9649724
Sorry! But UR code is unusable in my instance!
I try to assign my procedure to DHTMLEdit.DOM.onkeydown (<-- a Olevariant)
and I get a error message: Not implemented!
I don't know why because I can easily assign my procedure DHTMLEdit.Ononkeydown but get very hard in assigning my procedure to DHTMLEdit.DOM.onkeydown. can U help me in solving this problem?
0
 

Expert Comment

by:jgilm
ID: 9651644
Unfortunately I don't know what component you are using nor what you are trying to accomplish. You will have to post a lot more information about your problem.
0
 

Author Comment

by:skullvn
ID: 9656389
OK! I use a TDHTMLEdit. I found TDHTMLEdit contain sub Object DOM, this sub Object contain Onkeydown, a Olevariant. I think I can assign Onkeydown with a TnotifyEvent and try to assign my procedure to it. this is my problem!
0
 

Expert Comment

by:jgilm
ID: 9659207
I found a few links about this control. You might want to do a google search. Because I've never used this component, this is the best I can give you.

My guess is that the event you want to attach a handler to needs an interface. Look at this message in yahoogroups
http://groups.yahoo.com/group/delphi-dhtmledit/message/1495

This group is specifically about the Tdhtmledit control, so you might be able to get more help there.
--jgilm
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question