Solved

Olevariant and Event

Posted on 2003-10-28
7
497 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 50 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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 you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Suggested Courses
Course of the Month5 days, 6 hours left to enroll

636 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