|                                 Thomas Holdt                				   
 Guest
 
 
 
 | 
                | Setting visibility of the task pane depending on the displayed folder in a single outlook window works fine. When a second window with an explorer is opened, how could the pane instances be accessed and how are they connected to the windows/explorers?
 
 Chuck
 | 
 | 
  
        |                                 Dmitry Kostochko                				   
 Add-in Express team
 
 
 Posts: 2887
 Joined: 2004-04-05
 
 | 
                | Hi Thomas, 
 All created Outlook forms are located in the FormInstances collection. You can also easily access all open Explorer windows using the Explorers collection of the Outlook Object Model. Each TadxOLForm instance has the ExplorerObj property. So, you can find a form embedded into a particular Explorer window using the following code:
 
 
 
function TAddInModule.GetFormByExplorer(const AExplorer: _Explorer): TadxOLForm;
var
  i: integer;
  adxForm: TadxOLForm;
begin
  Result := nil;
  for i := 0 to adxOlFormsManager1.Items[0].FormInstanceCount - 1 do begin
    adxForm := adxOlFormsManager1.Items[0].FormInstances[i];
    if Self.GetOutlookWindowHandle(adxForm.ExplorerObj) = Self.GetOutlookWindowHandle(AExplorer) then begin
      Result := adxForm;
      Break;
    end;
  end;
end;
 | 
 | 
  
        |                                 Thomas Holdt                				   
 Guest
 
 
 
 | 
                | Hi Dmitry, 
 thanks for your answer, but maybe i am a little to stupid to understand....
 
 I have a taskpane, which works well in one window . I can make it visible depending on which kind of folder is visible.
 The problem appears, when other windows are opened.
 
 If a inspector window ist opened (for example creating a appointment), i don't want the taskpane to show up.
 (i can manage this, switching of the pane (visible := false) when a new window is opened and reshowing it, when the
 main form is used again).
 
 But if a new Inspector is opened for a calendar, the pane should show, independent of which kind of folder is opened in the main window .
 
 This does not work and i can't find out...
 
 if  and when there is multiple instances of the pane
 How i can find out, to which of the explorers they belong
 How to set visible/non visible independent
 
 When i use your proposed funtions on all explorers, are the adxforms the instances of the panes?
 
 Greetings
 
 Chuck
 | 
 | 
  
        |                                 Dmitry Kostochko                				   
 Add-in Express team
 
 
 Posts: 2887
 Joined: 2004-04-05
 
 | 
                | Hi Thomas, 
 I am really sorry but I do not understand what you are trying to achieve. May be you can give me the key points of your add-in's behavior? For example:
 1. if an appointment inspector is opened
 1.1.   all forms embedded into all Explorer windows should be hidden
 
 2. if an appointment inspector is closed
 2.1. all forms embedded into all Explorer windows should be shown
 
 3. if the selected folder is Inbox
 3.1. the form embedded into the current Explorer window should be shown
 
 4. if ?
 
 
 When i use your proposed funtions on all explorers, are the adxforms the instances of the panes?  
 Yes, you can type cast the adxForm variable from my example to your pane's type.
 
 Also, please let me know what Outlook pane types you use. Do you use Advanced Outlook regions (the TadxOLFormsManager component) or Office Custom Task panes (the TaskPanes collection of your add-in module)?
 | 
 | 
  
        |                                 Thomas Holdt                				   
 Guest
 
 
 
 | 
                | H i Dimitry 
 you put me on the right way.....
 
 I achieved the controll of visibility with following code
 
 
 
 
	j := 0;
   	for it in             
        adxMOREMultiCalendar.TaskPanes.Items[0].Instances do begin
        tpi :=  (it as TadxCustomTaskPaneInstance);
        handle := adxMOREMultiCalendar.GetOutlookWindowHandle(tpi.Window);   
        myexplorer := nil;
        for i := 1	to adxMOREMultiCalendar.OutlookApp.Explorers.Count do begin
            if adxMOREMultiCalendar.GetOutlookWindowHandle(adxMOREMultiCalendar.OutlookApp.Explorers.Item(i))=handle then begin               
                myexplorer := adxMOREMultiCalendar.OutlookApp.Explorers.Item(i);
            end;
        end;
        if myexplorer<>nil then begin
            if (inttostr(myexplorer.CurrentFolder.DefaultItemType)='1') then begin
                tpi.Visible := GenerallyVisible;                
            end else begin
                tpi.Visible := false;                
            end;
        end else begin
            tpi.Visible := false;
        end;
        inc(j);
	end;
 
 
 But there are two issues left.
 
 1. When opening a new explorer, no taskpane is created until I switch for instance from calendar to mail and back. Is there any way to force outlook to create  a new pane instance in the newly opened Explorer Window?
 
 2. Is there a way to detect if a pane is closed by the User or closed by Outlook because of visibility change?
 
 Greetings
 
 Thomas Holdt
 | 
 | 
  
        |                                 Andrei Smolin                				   
 Add-in Express team
 
 
 Posts: 19177
 Joined: 2006-05-11
 
 | 
                | Hello Thomas, 
 It looks like you try to manipulate the visibility of all form instances in all context. In what event the code above is invoked? Please note that the recommended way to prevent an advanced task pane from being shown is to set TadxOlFrom.Visible := false in the TadxOlForm.OnADXBeforeFormShow event.
 
 When the user closes the form, the TadxOlForm.ADXCloseButtonClick event is raised.
 
 
 Andrei Smolin
 Add-in Express Team Leader
 | 
 |