Notifications
Clear all
[Closed] MaxForm minimizing together with Max
Oct 19, 2022 7:41 am
Hello friends. Haven’t been here long time.
I was waiting when the search on this forum will finally start working.
I wonder if you have a working solution to attach a MaxForm to Max to be minimizable together with Max itself.
Version 1.
(
try
(
dotNetDialog.close()
)
catch()
Preformatted text`dotNetDialog = dotNetObject "MaxCustomControls.MaxForm"
dotNetDialog.size = dotNetObject "System.Drawing.Size" 500 500
dotNetDialog.Text = "Dot Net - NO Flicker Example"
dotNetUI = dotNetObject "FlowLayoutPanel"
dockStyle = dotNetClass "System.Windows.Forms.DockStyle"
dotNetUI.Dock = dockStyle.Fill
dotNetDialog.Controls.add dotNetUI
dotNetDialog.showmodeless()
)
Version 2
(
try
(
dotNetDialog.close()
)
catch()
dotNetDialog = dotNetObject "MaxCustomControls.MaxForm"
dotNetDialog.size = dotNetObject "System.Drawing.Size" 500 500
dotNetDialog.Text = "Dot Net - NO Flicker Example"
dotNetUI = dotNetObject "FlowLayoutPanel"
dockStyle = dotNetClass "System.Windows.Forms.DockStyle"
dotNetUI.Dock = dockStyle.Fill
dotNetDialog.Controls.add dotNetUI
thePtr = DotNetObject "System.IntPtr" (windows.getMAXHWND())
dotNetDialog.Show ((dotnetclass "System.Windows.Forms.Control").fromHandle thePtr)
)
Version 3
(
try
(
dotNetDialog.close()
)
catch()
dotNetDialog = dotNetObject "MaxCustomControls.MaxForm"
dotNetDialog.size = dotNetObject "System.Drawing.Size" 500 500
dotNetDialog.Text = "Dot Net - NO Flicker Example"
dotNetUI = dotNetObject "FlowLayoutPanel"
dockStyle = dotNetClass "System.Windows.Forms.DockStyle"
dotNetUI.Dock = dockStyle.Fill
dotNetDialog.Controls.add dotNetUI
theHwnd = (dotNetObject "System.Windows.Forms.NativeWindow").FromHandle (DotNetObject "System.IntPtr" (windows.getMAXHWND()))
dotNetDialog.Show(theHwnd)
)
Version 4 (c# function by DenisT)
(
try
(
dotNetDialog.close()
)
catch()
dotNetDialog = dotNetObject "MaxCustomControls.MaxForm"
dotNetDialog.size = dotNetObject "System.Drawing.Size" 500 500
dotNetDialog.Text = "Dot Net - NO Flicker Example"
dotNetUI = dotNetObject "FlowLayoutPanel"
dockStyle = dotNetClass "System.Windows.Forms.DockStyle"
dotNetUI.Dock = dockStyle.Fill
dotNetDialog.Controls.add dotNetUI
dotNetDialog.Showmodeless()
fn CreateAssembly =
(
src = "using System;"
src += "using System.Runtime.InteropServices;"
src += "class User32"
src += "{"
src += "[DllImport(\"User32.DLL\", EntryPoint=\"SetWindowLong\")]"
src += "public static extern Int32 SetWindowLong(IntPtr hWnd, Int32 index, Int32 newVal);"
src += "[DllImport(\"User32.dll\", SetLastError = true)]"
src += "public static extern IntPtr SetParent(IntPtr hWndChild, IntPtr hWndNewParent);"
src += "[DllImport(\"User32.dll\", ExactSpelling=true, CharSet=CharSet.Auto)]"
src += "public static extern IntPtr GetParent(IntPtr hWnd);"
src += "[DllImport(\"User32.dll\", SetLastError = true, CharSet = CharSet.Auto)]"
src += "public static extern bool SetWindowText(IntPtr hwnd, String lpString);"
src += "}"
csharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
compilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
compilerParams.GenerateInMemory = true
compilerResults = csharpProvider.CompileAssemblyFromSource compilerParams #(src)
User32Assembly = compilerResults.CompiledAssembly
User32Assembly.CreateInstance "User32"
)
user32 = CreateAssembly()
user32.SetParent dotNetDialog.Handle (windows.getMAXHWND())
)
The only working version is 4, the only moment, the form has borders, even if I use dotNetDialog.Showmodeless()
Tested with Max 2023