modal dialog display problem after switch between applications

U

upxtechie

Hello,
I have been trying to work out a solution for some time to solve a problem
with modal dialogs. Starting the modal dialog from the COM Add-In (MS Word
2000) is okay and basically behaves as expected - as long as I do not change
to the window of another application. But when the modal dialog is shown and
I switch to another window (e.g. windows explorer) and return back to my
Office application by means of the taskbar (click on the instance of the
office application in the taskbar) the trouble begins. The frame of the
office application is opened, but it's contents is only partly
refreshed/repainted. The application does not receive the focus, probably due
to the modal dialog which is still open. But that modal dialog is not shown
(repainted). The only way I have found to get the modal dialog shown again is
to set the focus to another application (e.g windows explorer, maximise it in
size, and minimize it in size. Only now the modal dialog is shown again.

Some technical details:
I have developed my add-in with Visual Studio 6 (SP6) + MS Office Developer,
with Win2000 SP3 and MS Office 2000 SP3 in the background.

I have tested the display of the modal dialogs (without success) with the
following calls inside the word designer object:
frmXY.show vbModal
frmXY.show vbModal, Me
I have also tried the API function SetWindowPos Lib "User32" (...) without
success.

Any help will be appreciated very much.

Thanks - Joerg
 
P

Peter Huang [MSFT]

Hi

Which programming language are you using?
Based on my test with a VB6 word addin, I can not reproduce the problem,
you may have a try and let me know the result.

Option Explicit
Public VBInstance As Word.Application
Dim mfrmAddIn As New frmAddIn

Private Sub AddinInstance_OnConnection(ByVal Application As Object, ByVal
ConnectMode As AddInDesignerObjects.ext_ConnectMode, ByVal AddInInst As
Object, custom() As Variant)
On Error GoTo error_handler
Set VBInstance = Application
Debug.Print VBInstance.Name
Exit Sub
error_handler:
MsgBox Err.Description
End Sub

Private Sub AddinInstance_OnStartupComplete(custom() As Variant)
mfrmAddIn.Show vbModal
mfrmAddIn.Show vbModal, Me
End Sub

Also if you still have any concern, can you provide a simple reproduce
sample with detailed reproduce steps, so that I can reproduce on my side
and troubleshooting the issue.


Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
U

upxtechie

Hello,
I am doing my coding in VB6 as well. All my software versions (Win2000,
Office2000, VS6, Office Designer 2000) are German.

I have just created two test projects: one with my own code, another with
your code. And in both projects I failed to get a solution for my problem. So
I guess that it is best to give you more details on how I have developed my
projects:

1. Start VB6, new project type "stadard-EXE"

2. Add links to:
Microsoft Office 9.0 Object Library
Microsoft Word 9.0 Object Library
Microsoft Add-In Designer
Microsoft Visual Basic 6.0 Extensibility (optional)

3. Change project properties to:
project type = Active-DLL
start-object = (none)

4. Add Add-In class, set properties to:
public = true
application = Microsoft Word
Version of the application = Microsoft Word 9.0
load behavior = Startup

5. Add code to designer, e.g. your code from your last mailing

6. Code at the form to be displayed in modal mode:
I have not added any specific code to the form. Only the name of the form
was adopted to correspond to the form name used in the designer class.

That's it in terms of building the add-in. The reproduction of the problem
goes as follows:

1. Start the add-in from within VS (or register the add-in with regsvr32
plus configure the registry in
HKEY_LOCALMACHINE\Software\Microsoft\Office\Word\Addins\<addIn-Name>.<designer-class> with DWord "LoadBehavior = 3")

2. Start Word. The dialog is shown in modal state in front of Word

3. Start another application (e.g. Windows Explorer) and bring it to full
size.

4. Use the taskbar to switch back to Word. Now I always get a Word-Windows
which is only partly repainted, without any modal dialog shown. Still the
invisible dialog keeps it's hand on Word, so I can not set the focus on Word.
One possibility to view the modal dialog again is to use the function
"display desktop" from the taskbar. After all application windows are
minimized, a click on the application instance of word on the taskbar shows
the modal dialog. This time only the dialog is shown, but not the Word
application itself.

Best regards,
Joerg
 
T

Tom Winter

upxtechie said:
1. Start the add-in from within VS...
<snip>

I assume you mean that you are hitting the "run" button within VB6, rather
than actually compiling your add-in. This is most likely why you are getting
the weird behavior. Try compiling your add-in and the weird behavior will
probably go away. I see this all the time when running projects from within
the VB6 IDE.
 
U

upxtechie

Thanks for this hint, but it proves not to be the solution. I have tried the
way you have described it (first build the add-in, then run it from VS), and
it exacly behaved the same way as before.
I have also ported the code to another environment (Win XP Pro SP1, VS6 SP6,
Office XP SP3, MS Office XP Developer V.10 SP1) and have used the same build
procedure - again with no positive results.
Also the installation of a build com add-in dll to a windows system which
has no VS IDE installed does not result in any different behavior.

Best regards,
Joerg
 
T

Tom Winter

No, that's not what I meant. Don't run it from within VS at all. Compile it,
register it if needed, then just start the Office application and let your
add-in run as though it were "installed" on your system. Running it from
within the VS IDE will always cause the messy behavior. Letting it run
"normally" will not. (Sorry, I'm not sure of the right term here to
communicate what I mean.)

-Tom
 
U

upxtechie

Well, as far as I understand you one way of my tests was exactly like you
have suggested it right now: build the add-in as a dll, put it on another
Windows system, register it and start Word. But also that procedure comes to
the same result.

Is there any public VB-project for a COM add-in available (most favorable
for MS Word 2000) using a modal dialog ? I wonder if such project would run
in my VS or dll build on my system would function correctly.

Regards,
Joerg
 
P

Peter Huang [MSFT]

Hi

It seems hard to reproduce the problem.
Here is a KB link for your reference.
How To Build an Office 2000 COM Add-In in Visual Basic (238228)
http://support.microsoft.com/default.aspx?scid=KB;EN-US;238228

Also have you tried to use the Visual Basic Addin Wizard to generate a
simple addin and just pop up a msgbox in the onConnection or show a modal
form?

Or can you package your test addin VB6 poject with the compiled dll for me
to have a test?
You can reach me by removing the "online" from my email address.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
T

Tom Winter

Well, not sure what to say now. You're not turning off ScreenUpdating in
Word are you? Any chance you can show is the code you're using?
 
U

upxtechie

Well, I probably did not disable ScreenUpdating in Word, for I even do not
kow how to do it. And there is also not any line of code in my project that
looks like that. I also did not find any configuration option in the Word
application.

In the meantime I have forwarded a VB-project to Peter Huang [MSFT] by
E-Mail, and it looks like he can reproduce the problem.

In terms of how to build a VB-project that can reproduce the problem please
have a look at the first post from Peter Huang and my reply on that. Or send
me an e-mail to joerg.brinker "AT" uniplex.de, and I will reply with a
complete VB-project attached.

Regards,
Joerg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top