T
TC
Hello All,
I am working on an addin for Outlook and I am displaying a form as modeless.
I am able to make that form stay on top via the SetWindowPos API.
However, when the user deactivates Outlook by switching to another
application, I want the form to be released from being on top.
One would assume that I could use the same API and set the form to
HWND_NOTOPMOST but this is not so easy.
The top level Application object from within Outlook does not have Activate
and Deactivate events like other Office Suite application. The Explorer
object does but these events fire off wildly while still within Outlook
itself depending upon what the user's selection is.
I tried something like the code below:
' Test to see if the top window is indeed Outlook
hWindowHandle = FindWindow(g_constrOUTLOOK, vbNullString)
hWindowHandle2 = GetForegroundWindow()
If hWindowHandle = hWindowHandle2 Then
lngResult = SetWindowPos(hHandle, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
Else
lngResult = SetWindowPos(hHandle, HWND_BOTTOM, 0, 0, 0, 0, FLAGS)
End If
The idea being that if the top level window is not Outlook, release the form
from the top. I would call the above function from the Activate /
Deactivate events caused by the Explorer object. From within the VB IDE, it
works quite nicely. Once compiled, the events fire off in such a way that
it locks my machine up. I've tried various changes to the logic but none
work.
The above said, I was wondering if there is a way to attach the .dll's form
to the Outlook application as a child form?
Any ideas?
Thanks & Regards,
TC
I am working on an addin for Outlook and I am displaying a form as modeless.
I am able to make that form stay on top via the SetWindowPos API.
However, when the user deactivates Outlook by switching to another
application, I want the form to be released from being on top.
One would assume that I could use the same API and set the form to
HWND_NOTOPMOST but this is not so easy.
The top level Application object from within Outlook does not have Activate
and Deactivate events like other Office Suite application. The Explorer
object does but these events fire off wildly while still within Outlook
itself depending upon what the user's selection is.
I tried something like the code below:
' Test to see if the top window is indeed Outlook
hWindowHandle = FindWindow(g_constrOUTLOOK, vbNullString)
hWindowHandle2 = GetForegroundWindow()
If hWindowHandle = hWindowHandle2 Then
lngResult = SetWindowPos(hHandle, HWND_TOPMOST, 0, 0, 0, 0, FLAGS)
Else
lngResult = SetWindowPos(hHandle, HWND_BOTTOM, 0, 0, 0, 0, FLAGS)
End If
The idea being that if the top level window is not Outlook, release the form
from the top. I would call the above function from the Activate /
Deactivate events caused by the Explorer object. From within the VB IDE, it
works quite nicely. Once compiled, the events fire off in such a way that
it locks my machine up. I've tried various changes to the logic but none
work.
The above said, I was wondering if there is a way to attach the .dll's form
to the Outlook application as a child form?
Any ideas?
Thanks & Regards,
TC