The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
|
|
embeding .NET forms in SLX tabs...
Posted: 20 Mar 07 7:46 PM
|
fiogf49gjkf0d is it possible to pass the SLX form's handle and size in the args array, and avoid making the win32 api calls? something like: in SLX.... Dim ext ext = Application.Managed.Create("dotNetApp", "dotNetApp.Form1") Application.Managed.Run ext, form.parent
in the .NET app... me.parent = args(0) |
|
|
|
Re: embeding .NET forms in SLX tabs...
Posted: 21 Mar 07 1:25 AM
|
fiogf49gjkf0d Absolutely.
Concept is exactly the same as what is done in these examples here: http://www.slxdeveloper.com/page.aspx?action=viewarticle&articleid=91 Only difference is that instead of loading the .NET assembly via COM, you're loading it as a .NET Extension.
You just need to pass the form's HWND property to the extension, then you can easily get it size in the same way as I did in the samples I linked to and use the SetParent API to embed a .NET control on the tab.
One of the samples does just that (embed a .NET control on a form). The only difference is how you're instanciating the object (the samples do it via COM so it would work with any version of SLX, you'll just be loading it as an extension).
Make sense? |
|
|
|
Re: embeding .NET forms in SLX tabs...
Posted: 21 Mar 07 9:35 AM
|
fiogf49gjkf0d 1:30 ? Ryan, do you ever sleep?
It does make sense...your advanced contacts tab example is what I was working from...just havn't gotten something right yet... I'm passing the forms's HWND from SLX but in .NET i'm not casting something right...i think
|
|
|
| |
|
Re: embeding .NET forms in SLX tabs...
Posted: 21 Mar 07 10:39 AM
|
fiogf49gjkf0d Originally posted by Duncan Cook
I think he just has an identical twin brother, also called Ryan Farley |
|
Not a twin, my clone. hehe. |
|
|
|
Re: embeding .NET forms in SLX tabs...
Posted: 21 Mar 07 10:41 AM
|
fiogf49gjkf0d Originally posted by John Crumpton
1:30 ? Ryan, do you ever sleep?
It does make sense...your advanced contacts tab example is what I was working from...just havn't gotten something right yet... I'm passing the forms's HWND from SLX but in .NET i'm not casting something right...i think
|
|
I slept once. I didn't really care too much for it.
So can you give me a run down of what exactly seems to be going wrong? |
|
|
|
Re: embeding .NET forms in SLX tabs...
Posted: 21 Mar 07 10:45 AM
|
fiogf49gjkf0d That explains why your new avatar photo looks younger than the old one.
Any chance of revealing the cloning source code |
|
|
| |
|
Re: embeding .NET forms in SLX tabs...
Posted: 21 Mar 07 11:11 AM
|
fiogf49gjkf0d i'm passing the SLX form's HWND it's comming in as an integer I think my problem is trying to cast from integer to intptr... not sure how to do that...
|
|
|
|
Re: embeding .NET forms in SLX tabs...
Posted: 21 Mar 07 11:19 AM
|
fiogf49gjkf0d AHA!
in SLX... Application.Managed.Run ext, form.HWND
in .NET Win32.SetParent(Me.Handle, System.Convert.ToInt32(Args(0))) Me.Show()
|
|
|
|
Re: embeding .NET forms in SLX tabs...
Posted: 21 Mar 07 11:27 AM
|
fiogf49gjkf0d Originally posted by John Crumpton
i'm passing the SLX form's HWND it's comming in as an integer I think my problem is trying to cast from integer to intptr... not sure how to do that...
|
|
Don't pass it in as an int, pass it in as an object, and then convert to an IntPtr like this:
IntPtr hwnd = new IntPtr((int)Args[0]); |
|
|
|
Re: embeding .NET forms in SLX tabs...
Posted: 21 Mar 07 11:28 AM
|
fiogf49gjkf0d Originally posted by John Crumpton
AHA!
in SLX... Application.Managed.Run ext, form.HWND
in .NET Win32.SetParent(Me.Handle, System.Convert.ToInt32(Args(0))) Me.Show()
|
|
So does that mean you have it working now then? |
|
|
| |
|
Re: embeding .NET forms in SLX tabs...
Posted: 21 Mar 07 2:25 PM
|
fiogf49gjkf0d UHG!... SetPArent works fine. I'm having problems with GetWindowRect... not sure if I got it wrong when i converted the win32 class to VB.... The first time it loads, it works fine, but when the onchange event fires again, the size and position are all messed up
Here's what I have for the Win32 class... I didn't intentionally change anything from the C# version....
Class Win32 _ Public Shared Function SetParent(ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr End Function
_ Public Shared Function GetWindowRect(ByVal hWnd As IntPtr, ByRef lpRect As RECT) As Boolean End Function
_ Public Structure RECT Public Left As Integer Public Top As Integer Public Right As Integer Public Bottom As Integer
Public Sub New(ByVal left_ As Integer, ByVal top_ As Integer, ByVal right_ As Integer, ByVal bottom_ As Integer) Left = left_ Top = top_ Right = right_ Bottom = bottom_ End Sub
Public ReadOnly Property Height() As Integer Get Return Bottom - Top End Get End Property
Public ReadOnly Property Width() As Integer Get Return Right - Left End Get End Property
Public ReadOnly Property Size() As Size Get Return New Size(Width, Height) End Get End Property
Public ReadOnly Property Location() As Point Get Return New Point(Left, Top) End Get End Property
Public Function ToRectangle() As Rectangle Return Rectangle.FromLTRB(Left, Top, Right, Bottom) End Function
Public Shared Function FromRectangle(ByVal rectangle As Rectangle) As RECT Return New RECT(rectangle.Left, rectangle.Top, rectangle.Right, rectangle.Bottom) End Function End Structure End Class
and here's my Run event for the form...
Public Function Run(ByVal Args() As Object) As Object _ Implements IRunnable.Run Try ParentHWND = System.Convert.ToInt32(Args(0)) ResizeForm(ParentHWND) Win32.SetParent(Me.Handle, ParentHWND)
Me.Show() Catch ex As Exception MessageBox.Show(ex.Message) End Try Return Nothing End Function
Private Sub ResizeForm(ByVal hwnd As IntPtr) Dim Rect As New Win32.RECT
If Win32.GetWindowRect(hwnd, Rect) Then Me.Size = Rect.Size Me.Top = 2 Me.Left = 2 End If End Sub
and here's where I'm instantiating it in SLX...
Sub AXFormChange(Sender) Dim ext If Application.GlobalInfo.IndexOf("LeadActivitiesObject") = -1 Then ext = Application.Managed.Create ("SLXActivities","SLXActivities.Form1") Application.Managed.Run ext, form.HWND Application.GlobalInfo.Add "LeadActivitiesObject", ext set ext = nothing Else ext = Application.GlobalInfo("LeadActivitiesObject") Application.Managed.Run ext, form.HWND set ext = Nothing End If End Sub |
|
|
|