D I Don't really understand, You are truing to hook a TNotifyEvent The methods were example of how to use RTTI to hook them...
Please Elucidate Neven ----- Original Message ----- From: "Donovan J. Edye" <[EMAIL PROTECTED]> To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> Sent: Thursday, November 21, 2002 12:48 PM Subject: Re: [DUG]: [Q] Event Hooking..... > N, > > Thanks. However unless I am still missing something here then this is still > a problem: > > EmbeddedComponent.OnEvent := nil; > TControlLink.Active := TRUE; > EmbeddedComponent..OnEvent := MyEventAssignedAtRunTimeBecauseICan; > > Dont see how MyEventAssignedAtRunTimeBecauseICan would ever be called. > > At 12:32 21/11/2002 +1300, you wrote: > >D > > > >You can you it with RTTI, Hope this helps > > > > FControlEvent: TMethod; > > FNewOnControlEvent: TMethod; > > > > > >procedure TControlLink.SetOnControlEvent; > >begin > > if not (csDesigning in ComponentState) and > > (FControl <> nil) and > > (FEventName <> '') then > > if IsPublishedProp(FControl,FEventName) then > > begin > > FControlEvent := GetMethodProp(FControl,FEventName); > > with FNewOnControlEvent do > > begin > > Code := @TControlLink.OnControlEvent; > > Data := Self; > > end; > > SetMethodProp(FControl,FEventName,FNewOnControlEvent); > > end; > >end; > > > >procedure TControlLink.ResetOnControlEvent; > >begin > > if not (csDesigning in ComponentState) and (FControl <> nil) then > > begin > > FNewOnControlEvent := GetMethodProp(FControl,'OnControlEvent'); > > if FNewOnControlEvent.Data = Self then {still pointing at us} > > SetMethodProp(FControl,'OnControlEvent',FControlEvent); > > end; > >end; > > > >procedure TControlLink.OnControlEvent; > >begin > > if not FActive then Exit; > > if FControl <> nil then > > begin > > // do our stuff > > end; > > if Assigned(FControlEvent.Code) then // call the original > > TNotifyEvent(FControlEvent)(TObject(FControl)); > >end; > > > > > >----- Original Message ----- > >From: "Donovan J. Edye" <[EMAIL PROTECTED]> > >To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]> > >Sent: Thursday, November 21, 2002 11:42 AM > >Subject: [DUG]: [Q] Event Hooking..... > > > > > > > G'Day, > > > > > > I was just curious about some approaches to achieve responding to the > >event > > > of an embedded component in my component. Clear as mud? An example: > > > > > > Lets say I have a component MyComponent that has a published property > > > MyButton : TButton. Now I want to take some action when the user clicks > >the > > > button assigned to MyButton. However any code that they have assigned to > > > the click event for the button must also be fired. > > > > > > So basically I want to transparently hook the OnClick event. The only way > >I > > > can think of doing this is by responding to the apropriate CN_*, CM_* > > > message. Is there another way to do this? If not what messages should I be > > > looking at responding to? > > > > > > > > > > > > -- Donovan > > > ---------------------------------------------------------------------- > > > Donovan J. Edye [www.edye.wattle.id.au] > > > Namadgi Systems [www.namsys.com.au] > > > Voice: +61 2 6285-3460 > > > Fax: +61 2 6285-3459 > > > TVisualBasic = Class(None); > > > Heard just before the 'Big Bang': "...Uh Oh...." > > > ---------------------------------------------------------------------- > > > GXExplorer [http://www.gxexplorer.org] Freeware Windows Explorer > > > replacement. Also includes freeware delphi windows explorer components. > > > ---------------------------------------------------------------------- > > > > > > >--------------------------------------------------------------------------- > > New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] > > Website: http://www.delphi.org.nz > >To UnSub, send email to: [EMAIL PROTECTED] > >with body of "unsubscribe delphi" > >Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/ > > -- Donovan > ---------------------------------------------------------------------- > Donovan J. Edye [www.edye.wattle.id.au] > Namadgi Systems [www.namsys.com.au] > Voice: +61 2 6285-3460 > Fax: +61 2 6285-3459 > TVisualBasic = Class(None); > Heard just before the 'Big Bang': "...Uh Oh...." > ---------------------------------------------------------------------- > GXExplorer [http://www.gxexplorer.org] Freeware Windows Explorer > replacement. Also includes freeware delphi windows explorer components. > ---------------------------------------------------------------------- > --------------------------------------------------------------------------- New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED] Website: http://www.delphi.org.nz To UnSub, send email to: [EMAIL PROTECTED] with body of "unsubscribe delphi" Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/