Allow wxAutomationObject::GetInstance() create new instance if needed.
When getting an instance of an OLE automation object, it is often useful to connect to the existing instance if any or start a new one otherwise. Make GetInstance() behave like this by default while still allowing to use the wxAutomationInstance_UseExistingOnly flag to reestablish the old behaviour. Also improve the error reporting in wxAutomationObject. See #12489. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66262 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -26,6 +26,16 @@ typedef unsigned short* WXBSTR;
|
||||
#undef GetObject
|
||||
#endif
|
||||
|
||||
// Flags used with wxAutomationObject::GetInstance()
|
||||
enum wxAutomationInstanceFlags
|
||||
{
|
||||
// Only use the existing instance, never create a new one.
|
||||
wxAutomationInstance_UseExistingOnly = 0,
|
||||
|
||||
// Create a new instance if there are no existing ones.
|
||||
wxAutomationInstance_CreateIfNeeded = 1
|
||||
};
|
||||
|
||||
/*
|
||||
* wxAutomationObject
|
||||
* Wraps up an IDispatch pointer and invocation; does variant conversion.
|
||||
@@ -44,9 +54,10 @@ public:
|
||||
|
||||
// Get a dispatch pointer from the current object associated
|
||||
// with a ProgID, such as "Excel.Application"
|
||||
bool GetInstance(const wxString& progId) const;
|
||||
bool GetInstance(const wxString& progId,
|
||||
int flags = wxAutomationInstance_CreateIfNeeded) const;
|
||||
|
||||
// Get a dispatch pointer from a new instance of the the class
|
||||
// Get a dispatch pointer from a new instance of the class
|
||||
bool CreateInstance(const wxString& progId) const;
|
||||
|
||||
// Low-level invocation function. Pass either an array of variants,
|
||||
|
Reference in New Issue
Block a user