Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Saturday, June 7, 2025 
 
slxdeveloper.com Community Forums  
   
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!
 Architect Forums - SalesLogix .NET Extensions
Forum to discuss the use of .NET Extensions in SalesLogix version 7 and higher. View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix .NET Extensions | New ThreadView:  Search:  
 Author  Thread: Resize a .Net View
Joern Engmann
Posts: 27
 
Resize a .Net ViewYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Nov 07 8:17 AM
Hi,

I made .Net Usercontrol (according to the .Net Account Detail View from Sage SDK Samples) but I want that the Control fills the View.
How can I set the Height and Width of my Usercontrol so that it always fills out the SLX View even when it's resized?

Joern
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Resize a .Net ViewYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Nov 07 8:37 AM
I have an example of that in the sample code and screencast here: http://www.slxdeveloper.com/page.aspx?action=viewarticle&articleid=91

Basically, I like to declare my RECT like this:

[Serializable, StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public RECT(int left, int top, int right, int bottom)
{
Left = left;
Top = top;
Right = right;
Bottom = bottom;
}

public int Left;
public int Top;
public int Right;
public int Bottom;

public int Height { get { return Bottom - Top; } }
public int Width { get { return Right - Left; } }
public Size Size { get { return new Size(Width, Height); } }
}


So it has built in Height, Width and Size properties. Then for my UserControl, I use the HWND of the parent (where I am embedding it) and call the Win32Api GetWindowRect to get a RECT for the parent container (using the struct above). Then I just set the Size of the UserControl from the Size of the parent area returned in the RECT from GetWindowRect. Something like this:

//hwnd is the handle of the parent container

RECT rect;
if (GetWindowRect(hwnd, out rect))
{
MyUserControl.Size = rect.Size;
}


Make sense? Also, don't forget to add the DllImport for GetWindowRect.

using System.Runtime.InteropServices;
//...

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);


-Ryan
[Reply][Quote]
Joern Engmann
Posts: 27
 
Re: Resize a .Net ViewYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 15 Nov 07 10:03 AM
Ok thanks a lot, it works now.
One more Question. How can I react in my Usercontrol on the resize event of the parent (SLX) view?

Joern
[Reply][Quote]
Jason Webb
Posts: 16
 
Re: Resize a .Net ViewYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 17 Nov 07 3:57 PM
A way that I have done this is to declare my usercontrol as com visible (just like Ryan told you to) then in the Run function of your extension do a "return this" so that when you execute your extension you get a pointer back to the form. Save that pointer to a global var in your script and just call the resize method in your parent forms resize event. Here is an example that extends Ryans example.

in the extension:
public object Run(object[] Args)
{
return this;
}

public void RefreshSize(IntPtr parent)
{
Win32.RECT rect;
Win32.GetWindowRect(parent, out rect);
this.Size = rect.Size;
}

then from the slx form

Dim ext ' this variable will hold the handle for the loaded .NET Extension
Dim frm 'this varuable will hold the actual form

public Sub SupportAXFormChange(Sender)
'if we have already created one then we close it and create another one
If ext = "" Then
ext = Application.Managed.Create("Extensions", "Extensions.CustomControl")
End If

'launch the .net customization
Set frm = Application.Managed.Run(ext, Form.HWND)
End Sub

Sub SupportAXFormResize(Sender)
if ext <> "" then
frm.RefreshSize Form.HWND
end if
End Sub


Hope that is helpful.
[Reply][Quote]
Mark Dykun
Posts: 297
 
Re: Resize a .Net ViewYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 18 Dec 07 6:44 AM
What I do is add a method to my .net control called SetSize(x,y, width,height) and just call that from the appropiate size event. Since the control at that point is already sited onto its host I do not have to worry abount HWNDs.

Inside my method I then call

this.Bounds = new Rectangle(x,y,width,height);

Mark
[Reply][Quote]
Jason Webb
Posts: 16
 
Re: Resize a .Net ViewYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 19 Dec 07 9:45 AM
That is good to know. I guess I was doing a little overkill. Thanks.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 6/7/2025 6:09:00 AM