|
-
Feb 6th, 2003, 06:23 AM
#1
Thread Starter
Lively Member
MsgBox does not come to foreground
There is an application that calls an EXE that I developped in VB.NET
This EXE opens a word application:
Code:
objWordInstance = GetObject(, "Word.Application")
If objWordInstance Is Nothing Then
objWordInstance = CreateObject("Word.Application")
End If
After that I try to show a MessageBox but it is always hidden behind my word application. Any idea what to do?
-
Feb 6th, 2003, 11:23 AM
#2
Addicted Member
That happends alot in my apps too, but I couldn't fiqure it out.
-
Feb 6th, 2003, 02:10 PM
#3
Frenzied Member
Try this: objWordInstance.Visible = False
It might be the solution you're looking for.
~Peter

-
Feb 7th, 2003, 02:16 AM
#4
Thread Starter
Lively Member
Thanks, but I found another solution:
Now I use the optional parameter owner (type IWin32Window) to specify the application/window the messagebox belongs to.
-
Feb 10th, 2003, 08:15 AM
#5
Member
Hi Heike
How do you find the IWin32Window value to send as parameter. I have got the same problem, with with Visio. Visio has a WindowHandle32 property, an integer. What do I send through as parameter to make the form / messagebox modal to Visio.
Thanks in advance,
Linda
-
Feb 10th, 2003, 08:26 AM
#6
Thread Starter
Lively Member
Hi Linda,
first I built a new class
VB Code:
Public Class ActiveWindow
Implements IWin32Window
Private Declare Function GetForegroundWindow Lib "user32.dll" () As Integer
Private Sub New()
End Sub
Private Shared _window As ActiveWindow = New ActiveWindow()
'Properties
Public Shared ReadOnly Property Active() As IWin32Window
Get
Return _window
End Get
End Property
Public ReadOnly Property Handle() As IntPtr Implements System.Windows.Forms.IWin32Window.Handle
Get
Return New System.IntPtr(GetForegroundWindow())
End Get
End Property
End Class
Then I wrote the following sub
VB Code:
Public Function ShowMessageBox(ByVal strMessage As String, Optional ByVal strTitle As String = "", _
Optional ByVal objButtons As MessageBoxButtons = MessageBoxButtons.OK, _
Optional ByVal objIcon As MessageBoxIcon = MessageBoxIcon.Exclamation, _
Optional ByVal objDefaultButton As MessageBoxDefaultButton = MessageBoxDefaultButton.Button1) As DialogResult
Dim udtActiveWindow As ActiveWindow
Dim drReturn As DialogResult
Try
drReturn = MessageBox.Show(udtActiveWindow.Active, strMessage, strTitle, objButtons, objIcon, objDefaultButton)
Catch
ErrorMessage(Err.GetException.TargetSite.GetCurrentMethod.ReflectedType.Name, Err.GetException.TargetSite.GetCurrentMethod.Name)
End Try
Return drReturn
End Function
Hope that helps.
-
Feb 11th, 2003, 03:34 AM
#7
Member
Hi Heike,
Thanks for the code, it cleared up a lot. The problem I have now, is that I can't minimize Visio while the modal form / message box is open. Do you have the same problem? That bothers a bit, because I would like my form to act the same way as Visio's modal forms.
If you have any suggestions or ideas, please ...
Linda
-
Feb 11th, 2003, 03:51 AM
#8
Thread Starter
Lively Member
Linda,
indeed I do have the same problem or at least I would call it effect. But in my application I do find it senseful because if a message box is open, there is something the user must be informed of and I don't want him/her to do anything until the message was being read.
Unfortunately I have no idea. I would have thought that there might be an optional parameter or something like that to switch between modal and not modal but I can't find anything. Sorry....
But if you find something, please could you tell me?! (Maybe one day I need it, too)
Heike
-
Feb 11th, 2003, 03:56 AM
#9
Member
Hi Heike,
Thanks for the reply. I will let you know if I find anything that will solve this. Once again, thanks for your help and good luck with your app.
Linda
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|