AddOwnedForm functionallity with extern application?

  • Thread starter Thread starter Prozon
  • Start date Start date
P

Prozon

Hi!
I want to make a form i vb.net wish will lay as a little window on the
side of the main window of an extern program. Pretty much like a
tool-window or something to photoshop.
When the extern program is minimized I want also the form to be
minimized and when the extrern app is bringed to front again I want my
form to do the same. Is this possible? With a win-api or something?

I want the functionallity to be pretty much like this code in .net.
Dim fOwnedForm As New OwnedForm()
Me.AddOwnedForm(fOwnedForm)
fOwnedForm.Show()

Best Regards
/ Steve
 
This is what you need....

WindowsAPI.SetWindowLong(<your form handle>, -8 /*GWL_HWNDPARENT*/, <the
extern application handle>);

In my case WindowsAPI is a class that I have written which I use to make API
calls.

using System;

using System.Runtime.InteropServices;

namespace MyWinAPI

{




public class WindowsAPI

{

public WindowsAPI()

{

//

// TODO: Add constructor logic here

//

}

[DllImport("user32.dll")]

public static extern long SetWindowLong(IntPtr hwnd, int index, long
newValue);

}

}

I have written a show method in my form as follows :

public new void Show()

{

long hOwner = <I don't know how you are getting your owner handle>;

System.IntPtr pOwner = new IntPtr(hOwner);

base.Show();

WindowsAPI.SetWindowLong(this.Handle, -8 /*GWL_HWNDPARENT*/,
pOwner.ToInt32());

}

Note that I have changed the owner after the form is shown, not sure whether
it works if the owner is set first and then the form is shown.

HTH,

--Saurabh
 
Hello,

I think that the subject discussing here is related to my problem that I am now facing.
So, if you have any hint or suggestion, please let me know.

I want to make a modeless dialog form on excel application by using VB.NET.
I found a following good document and I could successfully compile it. Then I could open a modal dialog in excel.

"Tips and Tricks: Building Microsoft Office Add-ins with
Visual C# .NET and Visual Basic .NET"

http://msdn.microsoft.com/library/d...officeadd-inswithvisualcnetvisualbasicnet.asp

In the document, I changed the following command

selectionForm.ShowDialog()

to

selectionForm.Show()

and I could successfully open a modeless dialog.

HOWEVER, this dialog window is hidden under the excel window when the excel window is set to TOP position by clicking its title bar.

In VBA, I know that modeless dialog window is always shown above the excel window even if the excel title bar is clicked.

In VB.NET, I want to make my modeless dialog shown always above the EXCEL window like VBA.

I tried SetWindowLong function or SetParent function, but I could not successfully do it.

So, if you have any hint or suggestion, please let me know.
I have been struggling for about three weeks....
Help!
 
Hello,

I think that the subject discussing here is related to my problem that I am now facing.
So, if you have any hint or suggestion, please let me know.

I want to make a modeless dialog form on excel application by using VB.NET.
I found a following good document and I could successfully compile it. Then I could open a modal dialog in excel.

"Tips and Tricks: Building Microsoft Office Add-ins with
Visual C# .NET and Visual Basic .NET"

http://msdn.microsoft.com/library/d...officeadd-inswithvisualcnetvisualbasicnet.asp

In the document, I changed the following command

selectionForm.ShowDialog()

to

selectionForm.Show()

and I could successfully open a modeless dialog.

HOWEVER, this dialog window is hidden under the excel window when the excel window is set to TOP position by clicking its title bar.

In VBA, I know that modeless dialog window is always shown above the excel window even if the excel title bar is clicked.

In VB.NET, I want to make my modeless dialog shown always above the EXCEL window like VBA.

I tried SetWindowLong function or SetParent function, but I could not successfully do it.

So, if you have any hint or suggestion, please let me know.
I have been struggling for about three weeks....
Help!
 
Hello,

I think that the subject discussing here is related to my problem that I am now facing.
So, if you have any hint or suggestion, please let me know.

I want to make a modeless dialog form on excel application by using VB.NET.
I found a following good document and I could successfully compile it. Then I could open a modal dialog in excel.

"Tips and Tricks: Building Microsoft Office Add-ins with
Visual C# .NET and Visual Basic .NET"

http://msdn.microsoft.com/library/d...officeadd-inswithvisualcnetvisualbasicnet.asp

In the document, I changed the following command

selectionForm.ShowDialog()

to

selectionForm.Show()

and I could successfully open a modeless dialog.

HOWEVER, this dialog window is hidden under the excel window when the excel window is set to TOP position by clicking its title bar.

In VBA, I know that modeless dialog window is always shown above the excel window even if the excel title bar is clicked.

In VB.NET, I want to make my modeless dialog shown always above the EXCEL window like VBA.

I tried SetWindowLong function or SetParent function, but I could not successfully do it.

So, if you have any hint or suggestion, please let me know.
I have been struggling for about three weeks....
Help!
 
Back
Top