What's new

How to programmatically maximize an AD Window

alexfranke

Senior Member
How to programmatically maximize an AD Window

Someone was asking how to do this in the public API forum, so I thought I'd share the answer here, too. It's in C#, but the VB implementation is very similar. This isn't really "Modeling related API discussion", but there's wasn't a more appropriate place to put it. (How about a "General" forum in the 3rd party API support forums?)

To try it out, open a new instance of Notepad, be sure it's not maximized, and add this to your code:

Code:
WinAPI.Windows.Maximize(\"Untitled - Notepad\");
Here's the class file:

Code:
using System;
using System.Runtime.InteropServices; 

namespace WinAPI
{
	public sealed class Windows
	{
		private const int WM_SYSCOMMAND = 0x0112;
		private const int SC_MAXIMIZE = 0xF030;

		[DllImport( \"User32.dll\" )]
		private static extern Int32 FindWindow( String lpClassName, String lpWindowName );
		[DllImport( \"user32.dll\" )]
		private static extern int SendMessage( IntPtr hWnd, int Msg, int wParam, int lParam );

		public static void Maximize( string title )
		{
			int hWnd = FindWindow( null, title );
			SendMessage( (IntPtr)hWnd, WM_SYSCOMMAND, SC_MAXIMIZE, 0 );
		}
	}
}

Cheers,
Alex
 

shubhab

Member


Hi Alex,

As you mentioned, we will soon add a General Section in this forum, where everything other than the topics in other Main Sections could be covered, like the one you posted here.
Thanks for having suggested this.

Shubha,
Alibre, Inc.
 
Top