How to access an object in a TadxOlForm from TAddInModule.adxOutlookAppEvents1ItemSend

Add-in Express™ Support Service
That's what is more important than anything else

How to access an object in a TadxOlForm from TAddInModule.adxOutlookAppEvents1ItemSend
Need to change a property on an object held in the Outlook Custom Form when Item is sent 
GKoehn


Guest


I create a delphi object in the outlook custom form when the user pulls up a new email.
Object is created in adxOlFormADXBeforeFormShow event.
When the user sends the email I get notified in the OutlookAppEvents.ItemSend event.
The custom form is still showing when I get notified.
How can I reach into the custom form at that time and access the delphi object I created when the custom form was shown on a new email?
Posted 27 Mar, 2013 16:04:46 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hello Gregory,

I would suggest using TadxOlFormsCollectionItem.FormInstances[index] to enumerate form instances created by the specified TadxOlFormsCollectionItem.

function TAddInModule.FindCurrentForm(
  Item: TadxOlFormsCollectionItem): TadxOlForm;
var
  ActiveWindowHandle: HWND;
  i: integer;
begin
  result := nil;
  ActiveWindowHandle := GetActiveWindow();
  for i := 0 to Item.FormInstanceCount - 1 do begin
    if (Item.FormInstances[i].Visible
      and Item.FormInstances[i].Active) then begin
      //An active form in an advanced form region has Visible = true , Active = true
      //An inactive form in an advanced form region has Visible = true , Active = false
      if ((ActiveWindowHandle = Item.FormInstances[i].Handle)
        or (ActiveWindowHandle = Item.FormInstances[i].CurrentOutlookWindowHandle)) then begin
        result := Item.FormInstances[i];
        break;
      end;
    end;
  end;
end;



Andrei Smolin
Add-in Express Team Leader
Posted 28 Mar, 2013 06:05:22 Top