[Closed] dotNet Form on top of Max only?
Thanks Pete. It is indeed the blending of the BG color with the transparency value of the painted color, you can really see this when you change the blending methods. I think that I have another possible solution to the transparency and that is to draw in a label that is the same size as the form and use it as a sort of layer. It isn’t exactly what I want but it will be close enough. I can paint the items that I want to have a tranparency into a base layer and the items that I don’t want in a layer above.
The last thing that I thought I had an answer for and it turns out that I don’t is the transparent problem. I figured I could use a label as a sort of layer and make it transparent or not but it also shows the same problems as the drawing methods.
Any one have any other ideas on this?
Here is another problem with the transparencies. Notice that even though the top label is transparent it only shows the form below, not the other label below it. Looks like the transparency of a control is only transparent to its parent form.
try(form.close())catch()
solidBrush1=(dotnetobject "System.Drawing.SolidBrush" ((dotNetClass "system.drawing.color").fromArgb 255 0 0))
solidBrush2=(dotnetobject "System.Drawing.SolidBrush" ((dotNetClass "system.drawing.color").fromArgb 0 255 0))
form=dotNetObject "form"
fn lb1Paint sender arg=
(
arg.graphics.fillRectangle solidBrush1 (dotNetObject "system.drawing.rectangle" 0 0 20 20)
)
fn lb2Paint sender arg=
(
arg.graphics.fillRectangle solidBrush2 (dotNetObject "system.drawing.rectangle" 20 20 20 20)
)
lb1=dotNetObject "label"
lb1.bounds=dotNetObject "system.drawing.rectangle" 0 0 200 200
lb1.backColor=(dotNetClass "system.drawing.color").fromArgb 255 0 0
dotNet.addEventHandler lb1 "paint" lb1Paint
lb2=dotNetObject "label"
lb2.bounds=dotNetObject "system.drawing.rectangle" 0 0 200 200
lb2.backColor=(dotNetClass "system.drawing.color").fromArgb 0 0 0 0
dotNet.addEventHandler lb2 "paint" lb2Paint
form.controls.add lb2
form.controls.add lb1
form.show()
This is the only way that I can see layers of drawing if any one is interested.
try(form.close())catch()
solidBrush1=(dotnetobject "System.Drawing.SolidBrush" ((dotNetClass "system.drawing.color").fromArgb 255 0 0))
solidBrush2=(dotnetobject "System.Drawing.SolidBrush" ((dotNetClass "system.drawing.color").fromArgb 0 255 0))
solidBrush3=(dotnetobject "System.Drawing.SolidBrush" ((dotNetClass "system.drawing.color").fromArgb 0 0 255))
form=dotNetObject "form"
fn lb1Paint sender arg=
(
arg.graphics.fillRectangle solidBrush1 (dotNetObject "system.drawing.rectangle" 0 0 20 20)
)
fn lb2Paint sender arg=
(
arg.graphics.fillRectangle solidBrush2 (dotNetObject "system.drawing.rectangle" 20 20 20 20)
)
fn lb3Paint sender arg=
(
arg.graphics.fillRectangle solidBrush3 (dotNetObject "system.drawing.rectangle" 40 40 20 20)
)
lb1=dotNetObject "label"
lb1.bounds=dotNetObject "system.drawing.rectangle" 0 0 200 200
lb1.backColor=(dotNetClass "system.drawing.color").fromArgb 0 0 0 0
dotNet.addEventHandler lb1 "paint" lb1Paint
lb2=dotNetObject "label"
lb2.bounds=dotNetObject "system.drawing.rectangle" 0 0 200 200
lb2.backColor=(dotNetClass "system.drawing.color").fromArgb 0 0 0 0
dotNet.addEventHandler lb2 "paint" lb2Paint
lb3=dotNetObject "label"
lb3.bounds=dotNetObject "system.drawing.rectangle" 0 0 200 200
lb3.backColor=(dotNetClass "system.drawing.color").fromArgb 0 0 0 0
dotNet.addEventHandler lb3 "paint" lb3Paint
form.controls.add lb1
lb1.controls.add lb2
lb2.controls.add lb3
form.show()
you can parent the form to max:
maxw = dotnetobject "MaxCustomControls.Win32HandleWrapper" (dotnetobject "System.IntPtr" (Windows.GetMAXHWND()))
form.show(maxw)
it works for me
Thanks Dennis, not sure what worked for you. I am doing that in my code how ever I’m also trying to get transparencies to work one on top of the other with labels. If one label in on top of another the one below will not show even if the top one is transparent.
probably I don’t understand how it supposes to be… could you show some image with desired result?
Just run the last chunk of code that I posted, that is what I want but notice that each label has to be added to the previous to be able to see each rectangle that is being drawn in each. If I add each label to the form directly they over draw each other.
Another interesting find is that a form that is open over the Max viewport with nothing in it but transparent slows the Max viewport FPS down considerably. Any one know why?