Hi,
I have a problem with modeless window. It stays on top even when it loses focus.
This is how I show the form:
Dim myForm As New myFormClass
Autodesk.AutoCAD.ApplicationServices.Application.ShowModelessDialog(formOwner, myForm)
Any ideas? TopMost property is set to False.
I think that is because you are using the ShowModelessDialog function and autocad threats your form as it is a paletteset. because you know palettesets are modeless windows but they are always on top. i advise you to use Form instances Hide method in forms lost focus event.
but that's not the behavior i want, the modeless window is the Help window and i want the user to be able to have the help shown and work with the program, be able to swithch to help and back.
the minimize works, but it's not that comfortable
Does making help window autohide solve your problem? You can create a paletteset instead of a form and make the paletteset autohide.
if not try Form.Show() instead of Application.ShowModelessDialog().
i tried Form.Show with the same result, i guess I'm doing something fundamentally wrong, or it's AutoCAD that's causing the problem
but I'm more inclined to blame AutoCAD, because when I make a winform application, it works fine
i'm using Civil 2012, but i run it as clean AutoCAD
did you use AcApp.ShowModalDialog for the main window, or did you use Form.ShowDialog ?
I am opening the modeless form from a modal form
form1 has a button (or responds to keypress event) that opens form2, form1 is modal, form2 is modeless
I'm just the opposite. No matter whether I apply TopMost or not, I can't switch to display it. I can only see this Form in the taskbar.
I have the most confusing problem, I have written two Forms, Form1 and Form2. Form2 can be displayed on top regardless of whether TopMost is set, but Form1 cannot be displayed anyway, and the Form can only be seen on the taskbar. Very infuriating, no distinction or difference to be found at all.
In ARX, you can handle WM_ACAD_KEEPFOCUS
https://help.autodesk.com/view/OARX/2024/ENU/?guid=GUID-90046447-0787-4FF8-8E91-870F085931A0
Not sure how to handle this on .NET. I’m sure there’s a hook
Anyway, I don't know what the difference is between Form1 and Form2, and why are they treated differently? I probably know that it is related to window focus, but I want to know why these two are treated differently? One is normal and the other is always abnormal.
Of course, I will also try the method you mentioned to ensure that it is directly relevant. However, finding the patterns and characteristics of the problems I am currently facing is meaningful.
@kelidesign wrote:
Anyway, I don't know what the difference is between Form1 and Form2, and why are they treated differently? I probably know that it is related to window focus, but I want to know why these two are treated differently? One is normal and the other is always abnormal.
patterns and characteristics of the problems I am currently facing is meaningful.
What does "I don't know what the difference..." mean? Your code creates/shows the forms, doe it not?
You should post your code that creates the forms (or even the code in the [Form].Designer.cs) and shows the forms. The video does not help much for identify the possible issues here.
Norman Yuan
Of course I submitted it, in the Test.zip compressed package. Submitted along with the video.
You did not mention, but the video clip shows that your running the code against AutoCAD 2018 (or, pre-2025 version, for that matters). However, when I open the *.csproj file, it CLEARLY shows that you selected WRONG project template of the Visual Studio: you used project template for .NET CORE class library, instead of class library template for .NET Framework. Things get event more confusing is that how come you can managed to make this project to target .NET Framework 4.6.2?
This is how a .NET Framework class project's Properties window look like:
This is how a .NET 8 class library project Properties window look like (FOR ACAD2025!)
However, this is YOUR PROJECT:
I am quite confused that how could you managed .NET Framework as target framework into .NET Core class library project? Did you somehow MANUALLY edited the project file?
Since you are targeting pre-AutoCAD2025 versions of AutoCAD, you MUST create the class library with .NET Framework project template. I think that is the cause of your issue.
Norman Yuan
Yes, the new project architecture supports this, in a simpler and more effective way, and there is no problem. I did this very early on and it has been working fine, you can try to create a traditional project, I don't think it is a core factor.
OK. I used your project, made necessary changes: since the oldest AutoCAD version I have access to is Acad2021, so I had to change the referenced AutoCAD managed assemblies to Acad2021's, and in turn, change the .NET Framework to 4.7x, instead of your original 4.6x.
See the video clip: the 2 forms showed correctly (as modal dialog):
Here I do not believe the fact you use Acad2018/.NET Framework 4.6x is the cause of your issue: I have used Application.ShowModelessDialog() for all these years since Acad2006, and certainly in AutoCAD2018 with .NET Framework 4.6.x a few years back.
So, your issue is probably an strange, isolated issue to your specific computer/AutoCAD2018/.NET Framework4.6.x. Have you tried with other version of AutoCAD, in other computer? Have you made sure the "Copy Local" of the referenced AutoCAD assemblies are set to False?
Norman Yuan
Can't find what you're looking for? Ask the community or share your knowledge.