[Closed] dotNet Form on top of Max only?
So I have a form that I want to keep on top of Max. Setting topMost forces it to the top of everything. Placing another dialog, even Max dialogs over Max results in anything drawing in the form to be on top of everything. Is there a way to force it to at least only be on top of Max?
Any good cheats, like if Max looses focus force it to the back?
And is there a way to not be able to select anything that is displayed in the form? This is the transparent form that I have so anything that is drawn into the form stops you from clicking on objects in Max or doing anything else. Any where the form is transparent you can click on objects.
form=dotNetObject "form"
form.AllowTransparency=false
form.BackColor=(dotNetClass "system.drawing.color").fromArgb 0 0 255
-- form.TransparencyKey=(dotNetClass "system.drawing.color").fromArgb 0 0 255
form.ShowInTaskBar =false
form.FormBorderStyle=form.FormBorderStyle.none
form.TopMost=true
form.show()
--form.close()
instead of ising dotnetobject “Form” you can use dotNetObject “MaxCustomControls.MaxForm”
maxWin = dotNetObject "MaxCustomControls.MaxForm"
maxWin.size = dotNetObject "System.Drawing.Size" 800 600
maxWin.text = "Max DotNet Dialog"
maxWin.showmodeless()
this maxForm has the same properties and methods as “Form” but has the max dialog behavior …
Have you tried the MaxCustomControls.MaxForm? And then using the ShowModal() method?
form=dotNetObject "MaxCustomControls.MaxForm"
form.AllowTransparency=false
form.BackColor=(dotNetClass "system.drawing.color").fromArgb 0 0 255
--form.TransparencyKey=(dotNetClass "system.drawing.color").fromArgb 0 0 255
form.ShowInTaskBar =false
form.FormBorderStyle=form.FormBorderStyle.none
form.TopMost=true
form.showmodal()
Although I dont think transparency works with this way.
Note: Press Alt+F4 to close the window after running the script
Cheers.
I saw that but I can’t get transparency working with the MaxCustomControls.MaxForm. Would be nice if it would work as I would use it. I don’t want it to be model in that I want it always there just not affecting how you work. I’m most of the way to having that just not quite far enough.
try(form.close())catch()
fn formPaint sender arg=
(
rec=dotNetObject "system.drawing.rectangle" 2 2 200 200
bgColor=(dotNetClass "system.drawing.color").red
brush=dotnetobject "System.Drawing.SolidBrush" bgColor
arg.graphics.FillRectangle brush rec
)
form=dotNetObject "form"
form.AllowTransparency=false
form.BackColor=(dotNetClass "system.drawing.color").fromArgb 0 0 255
form.TransparencyKey=(dotNetClass "system.drawing.color").fromArgb 0 0 255
form.ShowInTaskBar =false
form.FormBorderStyle=form.FormBorderStyle.none
form.TopMost=true
dotnet.addEventHandler form "paint" formPaint
dotnet.setLifeTimeControl form #dotNet
form.show()
--form.close()
Hey Paul, I don’t know if I quite understood, but the first example you have, if you add controls to the form, they work and are transparent. I just added a button and there and a label, and changed it’s backcolor. Dunno if this is it but here goes:
try(form.close())catch()
form=dotNetObject "form"
form.AllowTransparency=false
form.BackColor=(dotNetClass "system.drawing.color").fromArgb 1 1 255
form.TransparencyKey=(dotNetClass "system.drawing.color").fromArgb 1 1 255
form.ShowInTaskBar =false
form.FormBorderStyle=form.FormBorderStyle.none
form.TopMost=true
form.location=dotNetObject "System.Drawing.Point" 200 200
tbutton = dotnetobject "button"
tbutton.text="Test"
tbutton.backcolor=(dotNetClass "system.drawing.color").fromArgb 127 127 127
lblTest=dotnetobject "system.windows.forms.label"
lblTest.text="Test Label"
lblTest.Location=dotNetObject "System.Drawing.Point" 0 30
lblTest.backcolor=(dotNetClass "system.drawing.color").fromArgb 127 127 127
form.controls.add(tbutton)
form.controls.add(lblTest)
form.show()
--form.close()
I’m not using any controls at all. I’m drawing into the form using rectangles, text and lines. I don’t have a problem with the transparency of the form at all, I want the rectangles that I draw in to have a level of transparency so that I can see through them. Look at the last example that I posted, can you make red fillRectangle 50% transparent for instance.
Denis, have you been able to make that dialog transparent? It doesn’t work for me and I just get a gray dialog.
Got the Max form to work. Looks like I had to use showModeless before setting any parameters on the dialog. If you set all the parameters and then showModeless it doesn’t work.
Let me see if this will work in the full script now.
try(form.close())catch()
fn formPaint sender arg=
(
rec=dotNetObject "system.drawing.rectangle" 2 2 200 200
bgColor=(dotNetClass "system.drawing.color").red
brush=dotnetobject "System.Drawing.SolidBrush" bgColor
arg.graphics.FillRectangle brush rec
)
-- form=dotNetObject "form"
form=dotNetObject "MaxCustomControls.MaxForm"
form.showmodeless()
-- form.show()
form.AllowTransparency=true
form.opacity=10
form.BackColor=(dotNetClass "system.drawing.color").fromArgb 0 255 0
form.TransparencyKey=(dotNetClass "system.drawing.color").fromArgb 0 255 0
form.ShowInTaskBar =false
form.FormBorderStyle=form.FormBorderStyle.none
-- form.TopMost=true
dotnet.addEventHandler form "paint" formPaint
dotnet.setLifeTimeControl form #dotNet
LHM_methods.formatProps form