<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>[C# MicroStation CE] Prevent entering modal state / close dialogs</title><link>https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/235148/c-microstation-ce-prevent-entering-modal-state-close-dialogs</link><description>Hi all, 
 I am currently building an application for processing dgn files using IPC (inter-process communication) method. Everything seems to be working quite nicely except for when a modal dialog is created that will block the current thread, preventing</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: [C# MicroStation CE] Prevent entering modal state / close dialogs</title><link>https://communities.bentley.com/thread/731666?ContentTypeID=1</link><pubDate>Wed, 14 Sep 2022 02:50:13 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:ccc7428d-6269-4f15-99d6-abdb75f2ccd2</guid><dc:creator>Edward Ashbolt</dc:creator><description>&lt;p&gt;Thank you very much for your suggestion Yongan, this is working perfectly now! Whenever a dialog is opened the event handler will automatically close it. Here is the code for anyone interested:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;//Add event handler
Bentley.Interop.MicroStationDGN.Application app = Bentley.MstnPlatformNET.InteropServices.Utilities.ComApp;
app.AddModalDialogEventsHandler(new ModalDialogEventHandler());
...

//Event handler class
public class ModalDialogEventHandler : IModalDialogEvents
{
    public void OnDialogOpened(string DialogBoxName, ref MsdDialogBoxResult DialogResult)
    {
        //I may need to assing other dialog results through try{}catch{} statements, but for now &amp;quot;OK&amp;quot; works fine
        DialogResult = MsdDialogBoxResult.OK;
    }
    public void OnDialogClosed(string DialogBoxName, MsdDialogBoxResult DialogResult)
    {
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Can&amp;#39;t believe how much simpler this problem becomes when utilising the interop library...&lt;/p&gt;
&lt;p&gt;Thanks again for helping to resolve this issue that has been giving me a headache for quite some time now!&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Ed&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [C# MicroStation CE] Prevent entering modal state / close dialogs</title><link>https://communities.bentley.com/thread/731643?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2022 23:24:20 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:b00dd00a-e3f7-41ca-8ff6-f91addfbaa7d</guid><dc:creator>Edward Ashbolt</dc:creator><description>&lt;p&gt;Thanks Yongan,&lt;/p&gt;
&lt;p&gt;I forgot about the modal handler available in VBA! Perhaps this might work:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;Implements IModalDialogEvents
Private Sub IModalDialogEvents_OnDialogClosed(ByVal DialogBoxName As String, ByVal DialogResult As MsdDialogBoxResult)

End Sub

Private Sub IModalDialogEvents_OnDialogOpened(ByVal DialogBoxName As String, DialogResult As MsdDialogBoxResult)

    &amp;#39;   Send cancel request to any opened dialogs
        DialogResult = msdDialogBoxResultCancel

End Sub&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I removed the check for &amp;quot;DialogBoxName&amp;quot;, so it should cancel any dialogs that trigger this event. Will give it a go from within my add-in and see if this solves the issue.&lt;br /&gt;Thanks!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Ed&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [C# MicroStation CE] Prevent entering modal state / close dialogs</title><link>https://communities.bentley.com/thread/731409?ContentTypeID=1</link><pubDate>Tue, 13 Sep 2022 02:33:36 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:3ed07a53-09d6-4f17-b27d-a2289b3c6ad3</guid><dc:creator>Yongan.Fu</dc:creator><description>&lt;p&gt;To automatically close an modal dialog, I normally record a MicroStation macro and then promote it to a VBA code. After modification of it (if needed), runing this VBA code from keyin can implement your requirement.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [C# MicroStation CE] Prevent entering modal state / close dialogs</title><link>https://communities.bentley.com/thread/731155?ContentTypeID=1</link><pubDate>Mon, 12 Sep 2022 00:42:45 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:4f225d25-d011-43fc-84ba-a96b75fb9338</guid><dc:creator>Edward Ashbolt</dc:creator><description>[quote userid="2175" url="~/products/programming/microstation_programming/f/microstation-programming---forum/235148/c-microstation-ce-prevent-entering-modal-state-close-dialogs/730959"]Using Bentley provided IPC interface, we can simplify IPC prorgamming.[/quote]
&lt;p&gt;Yes I used this IPC example for a starting point, unfortunately there is no handling of modal forms though!&lt;/p&gt;
[quote userid="2175" url="~/products/programming/microstation_programming/f/microstation-programming---forum/235148/c-microstation-ce-prevent-entering-modal-state-close-dialogs/730959"]Why use OpenBuildings engine to open an OpenBridge file?[/quote]
&lt;p&gt;This was just an example, however to elaborate on why this is the case in this example we do use OpenBuildings to export IFC files since Bentley has not provided support for IFC exports in many of their design applications, and it would be quite a lot more work to build my own IFC export tool. I&amp;#39;m sure there will be other tasks within the same authoring application where MicroStation opens a dialog box (this is not uncommon), blocking further execution on the active thread, so I need to handle this somehow since the&amp;nbsp;system runs autonomously on a server and I do not want&amp;nbsp;to&amp;nbsp;be worrying about whether a simple alert/dialog box has prevented all other tasks from continuing: Hence the requirement for handling modal forms.&lt;/p&gt;
&lt;p&gt;Hope that makes sense!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [C# MicroStation CE] Prevent entering modal state / close dialogs</title><link>https://communities.bentley.com/thread/730959?ContentTypeID=1</link><pubDate>Fri, 09 Sep 2022 08:53:11 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:bcc0181f-1058-4367-8004-7987d71848c1</guid><dc:creator>Yongan.Fu</dc:creator><description>[quote userid="2269" url="~/products/programming/microstation_programming/f/microstation-programming---forum/235148/c-microstation-ce-prevent-entering-modal-state-close-dialogs/730383"]MicroStation is almost irrelevant here!&amp;nbsp; Yours is a general question about writing .NET IPC classes.&amp;nbsp; Consult a website that deals with advanced .NET development.&amp;nbsp; For example, &lt;a title="StackOverflow: IPC Mechanisms in C# - Usage and Best Practices" href="https://stackoverflow.com/questions/56121/ipc-mechanisms-in-c-sharp-usage-and-best-practices" rel="noopener noreferrer" target="_blank"&gt;StackOverflow&lt;/a&gt;.[/quote]
&lt;p&gt;In MS SDK example, there are three IPC examples under folder&amp;nbsp;C:\Program Files\Bentley\MicroStationCONNECTSDK\examples\IPCs. Using Bentley provided IPC interface, we can simplify IPC prorgamming.&lt;/p&gt;
[quote userid="750386" url="~/products/programming/microstation_programming/f/microstation-programming---forum/235148/c-microstation-ce-prevent-entering-modal-state-close-dialogs/730556"]using the OpenBuildings engine to open an OpenBridge file, when closing the file it might prompt if I want OpenBuildings to take ownership of the file and save (can&amp;#39;t remember the exact words but hopefully you get what I mean!)[/quote]
&lt;p&gt;Why use OpenBuildings engine to open an OpenBridge file?&amp;nbsp;OpenBuildings and OpenBridge are different displine softwares and I know OpenBridge is somewhat special design. A few of normal MicroStation operations can not be exectued in it. If you just want to execute some keyins to several OpenBridge files, Batch Process utility is a better choice without needing to code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [C# MicroStation CE] Prevent entering modal state / close dialogs</title><link>https://communities.bentley.com/thread/730556?ContentTypeID=1</link><pubDate>Wed, 07 Sep 2022 23:30:26 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:a3102469-89f4-4796-87f2-eb8096041d59</guid><dc:creator>Edward Ashbolt</dc:creator><description>[quote userid="2473" url="~/products/programming/microstation_programming/f/microstation-programming---forum/235148/c-microstation-ce-prevent-entering-modal-state-close-dialogs/730356"]Out of the box MicroStation does not offer too much, I think only very simple IPC interface, allowing to send key-ins, is available[/quote]
&lt;p&gt;Yes I am just using this basic interface provided in the SDK example but customised to suit what I need&lt;/p&gt;
[quote userid="2473" url="~/products/programming/microstation_programming/f/microstation-programming---forum/235148/c-microstation-ce-prevent-entering-modal-state-close-dialogs/730356"]How it can happen a modal dialog opens? Do you use key-ins to control MicroStation and some tool that you start opens such dialog?[/quote]
&lt;p&gt;Yes that&amp;#39;s correct I&amp;#39;m simply using key-ins to control MicroStation, and every now and again a modal dialog will be opened requesting input (and blocking execution). For example if using the OpenBuildings engine to open an OpenBridge file, when closing the file it might prompt if I want OpenBuildings to take ownership of the file and save (can&amp;#39;t remember the exact words but hopefully you get what I mean!)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [C# MicroStation CE] Prevent entering modal state / close dialogs</title><link>https://communities.bentley.com/thread/730555?ContentTypeID=1</link><pubDate>Wed, 07 Sep 2022 23:24:09 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:bcf787d7-ae63-4993-bad9-341101243e37</guid><dc:creator>Edward Ashbolt</dc:creator><description>&lt;p&gt;Actually the bit that I&amp;#39;m struggling with is entirely MicroStation - whenever MicroStation launches a dialog box I want to&amp;nbsp;close it programmatically. Looking at the .NET API it seems there is limited support&amp;nbsp;for working with dialogs etc. however the native API has some classes that seem appropriate,&amp;nbsp;however I am yet to see success with them. I was hoping that perhaps someone else has come across a solution to this problem within the MicroStation API&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [C# MicroStation CE] Prevent entering modal state / close dialogs</title><link>https://communities.bentley.com/thread/730383?ContentTypeID=1</link><pubDate>Wed, 07 Sep 2022 08:10:24 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:ece5a4f5-9789-4098-8113-9c35f1b3e134</guid><dc:creator>Jon Summers</dc:creator><description>[quote userid="750386" url="~/products/programming/microstation_programming/f/microstation-programming---forum/235148/c-microstation-ce-prevent-entering-modal-state-close-dialogs"]I am currently building an application for processing dgn files using IPC (inter-process communication) method[/quote]
&lt;p&gt;MicroStation is almost irrelevant here!&amp;nbsp; Yours is a general question about writing .NET IPC classes.&amp;nbsp; Consult a website that deals with advanced .NET development.&amp;nbsp; For example, &lt;a title="StackOverflow: IPC Mechanisms in C# - Usage and Best Practices" href="https://stackoverflow.com/questions/56121/ipc-mechanisms-in-c-sharp-usage-and-best-practices" rel="noopener noreferrer" target="_blank"&gt;StackOverflow&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [C# MicroStation CE] Prevent entering modal state / close dialogs</title><link>https://communities.bentley.com/thread/730356?ContentTypeID=1</link><pubDate>Wed, 07 Sep 2022 05:58:47 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:e9ba7383-08b5-4fb2-b274-8177cdd8db2c</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Edward,&lt;/p&gt;
[quote userid="750386" url="~/products/programming/microstation_programming/f/microstation-programming---forum/235148/c-microstation-ce-prevent-entering-modal-state-close-dialogs"]I am currently building an application for processing dgn files using IPC (inter-process communication) method.[/quote]
&lt;p&gt;It does not tell too much, because IPC is only an information a communication between processes is used.&lt;/p&gt;
&lt;p&gt;But technically, what approach you choose and what tools do you use? Out of the box MicroStation does not offer too much, I think only very simple IPC interface, allowing to send key-ins, is available. Do you use this one or you implement own application, running in MicroStation, used to communication with MicroStation process?&lt;/p&gt;
[quote userid="750386" url="~/products/programming/microstation_programming/f/microstation-programming---forum/235148/c-microstation-ce-prevent-entering-modal-state-close-dialogs"]Has anyone found any methods for closing out&amp;nbsp;modal dialogs when they are opened?[/quote]
&lt;p&gt;How it can happen a modal dialog opens? Do you use key-ins to control MicroStation and some tool that you start opens such dialog?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>