Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


Tip of the Day
Language: Visual Basic
Expertise: Beginner
Aug 6, 1997

MessageBox From OLE Server Comes Up Behind The App

You have a VB4-based OLE Automation server that has no main UI, and displays forms that are parented into Excel in response to various automation calls. Sometimes you need to display a message box instead of a form. If you haven't yet parented any forms into Excel, the message box frequently appears behind Excel. To make sure that the message box appears where the user can see it--if all your forms are modal--the best way is to compile the VB4 OLE Automation server as an in-process server (DLL). The server becomes part of Excel's process space, and all forms and message boxes are automatically parented as you would expect them to be. If your forms are modeless, you cannot use the DLL approach. Your OLE Automation server must be an EXE. The following workaround should do the trick. Create a hidden, modeless form and use SetParent to make it a child of Excel's main window. Make this the first thing you do when Excel gets an instance of your object. Create a Public (visible throughout your project, but not outside) method for the hidden modeless form. The Public method takes the same parameters as a message box, and its job is to call MsgBox with those parameters. When your server needs to display a message box when no other form is parented to Excel, call this method. Excel should never hide the message box.
A. Nicklas
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date