Form controls loose focus - UnModal Forms

Form controls loose focus - UnModal Forms

hkilic896XF
Advocate Advocate
727 Views
8 Replies
Message 1 of 9

Form controls loose focus - UnModal Forms

hkilic896XF
Advocate
Advocate

Hi

AutoCAD 2026.Latest

I use several userforms for many years.

Today I realize that a userform controls; userform's ShowModal property id False; loose focus, AutoCAD UI automatically gets focus. 

When I try to write a text to textbox or editable dropdown combobox;

with mouse arrow I select the edit area on userform and mouse cursor automatically switches to AutoCAD UI Command line.

The running userform itself looses focus when any click on it with undesired way / should not to do so.. 

Caption of the form becomes dark black when I click on it and immediatelly turns to light gray color..

When ShowModel property of userform is True it works as desired. 

It wasn't like this more than 10 years. 🙂 😞

(Today Windows got an latest update, would this cause this behaviour?)

 

I urgenty need my userform.. with old behavious.

 

hkilic896XF_0-1765356226654.png

 

0 Likes
Accepted solutions (1)
728 Views
8 Replies
Replies (8)
Message 2 of 9

hkilic896XF
Advocate
Advocate

AcFocusCtrl.dll is no more exists in its folder. of Program Files\Common Files\Autodesk

and additional toolbox controls focuses(!) to that dll.

In References type library "AutoCAD Focus Control for VBA Type Library" reference is referencing Program Files\Common Files\Autodesk Shared\AcFocusCtrl16.dll file

 

Absent AcFocusCtrl.dll, new file AcFocusCtrl16.dll but toolbar controls still trying to place an absent control. So ShowModal = False user forms do not work anymore.

 

Removing existing & missing reference to AcFocusCtrl.dll and adding new AcFocusCtrl16.dll as new reference.. not working.

hkilic896XF_0-1765370163429.png

Additional controls still references old file..

hkilic896XF_1-1765370217387.png

And in toolbar it is defined as "Unknown"

hkilic896XF_3-1765370466374.png

 

And can not be used.. 

Windows says it is not trusted..

hkilic896XF_2-1765370394400.png

 

I think old reference must be removed from registry first, and then may be new ...16.dll file must be registered some how..

 

We need an urgent solution. !!

0 Likes
Message 3 of 9

hkilic896XF
Advocate
Advocate

How can it be.. really very annoying

 

hkilic896XF_0-1765373308009.png

 

0 Likes
Message 4 of 9

hkilic896XF
Advocate
Advocate
Accepted solution
Private Sub CommandButtonModal_Click()
    Me.Hide
    Me.show 1
End Sub

Private Sub CommandButtonModeless_Click()
    Me.Hide
    Me.show 0
End Sub

 

hkilic896XF_0-1765374861856.png

 

I add two buttons..

when I need Modeless I click to 0

when I need to write inside text boxes, etc. I click to 1 and switch to Modal

 

😂This is the way..

If there is a god or any kind of justice under the sky, we'll never keep on trying, till the end of time.. (flamenco enters..)

 

0 Likes
Message 5 of 9

hkilic896XF
Advocate
Advocate

hkilic896XF_0-1788216267049.png

 

0 Likes
Message 6 of 9

Norman_Yuan
Mentor
Mentor

Well, not sure where is the source of the info you showed here, AI (the like of ChatGPT,...)? It was definitely not all correct. AcFocusCtrl16.dll, which comes with recent versions of AutoCAD (since Autodesk ditched the 32bit version and also adopted 64 bit VBA, is 64 bit component and I have no problem use it with Acad's VBA UserForm when showing as modeless (although only for test purpose, not in real production development, because I had stopped developing VBA code in AutoCAD for many years for good). I tested this (VBA modeless UserForm + AcFocusCtrl16.dll) with each version since at least Acad2019 and all the way to latest Acad2017. They work as expected (again, I never need to use them in real development project).

 

So, I'd say, using VBA UserForm as modeless UI that needs AcFocusCtrl does work, but VBA development is basically not worth the effort/investment in most, if not all, cases.

 

 

 

Norman Yuan

Drive CAD With Code

EESignature

Message 7 of 9

13lacIe
Explorer
Explorer

Ran into the same issue and figured it out after a lot of debugging and comparing.

The cause appears to be a bad Microsoft policy introduced a little over a year ago that disables all ActiveX controls by default. The policy is being applied inconsistently, and Autodesk's focus control appears to rely on ActiveX functionality.

 

The relevant registry setting is:

 

HKEY_CURRENT_USER\SOFTWARE\Microsoft\Office\Common\Security

 

with the value name:

 

DisableAllActiveX

 

When DisableAllActiveX is set to 1, the modeless user form fails to function correctly. When it is set to 0 (or the value is not present), the modeless user form works as expected.

 

Users can also modify this setting through Office applications by navigating to:

 

File > Options > Trust Center > Trust Center Settings > ActiveX Settings

 

and changing "Disable all controls without notification" to any other option. The state of the Safe Mode checkbox does not appear to affect the AutoCAD VBA user form.

 

What makes this issue particularly confusing is that "Disable all controls without notification" can appear selected on both working and non-working computers. On the working systems, however, the corresponding registry value had never actually been created, allowing ActiveX controls to continue functioning despite the displayed setting. If a user changes the setting and then changes it back, Office creates the DisableAllActiveX registry value, which then causes the user form to stop working.

For similar issues before this change it likely meant that ActiveX was failing without notice even though it wasn't blocked by policy.


Message 8 of 9

robthenry0
Participant
Participant

The focus issue with unmodal forms sounds like it could be related to how focus is being managed when the form loses and regains activation. A small VBA example showing the form setup and the controls involved would make it easier to determine whether the behavior comes from the form properties, event handling, or Windows focus behavior.

0 Likes
Message 9 of 9

Norman_Yuan
Mentor
Mentor

@13lacIe , Thank you for pointed out the real reason that the AcFocus control stops working or does not work. Yes it is cause the by MS office's security setting that disable Activex Control, which is a MS Office feature existing long ago before MS Office 365 made it as default setting in 2025. Since I always used stand-alone MS Office suite, thus this has no impact for me to try/verify that AcFocus control has always worked with my AutoCAD of all versions/all computers.

 

Let me try to give the situation a summary to what I/we know so far:

 

1. In the era of AutoCAD used 32-VBA (There was a period of time when AutoCAD had both 32 and 64 bit version, AutoCAD' VBA is 32-bit ONLY, because MS refused to make 64-bit VBA available not only to third paties, including Autodesk, but also it self's Office apps, until MS found out they had to provide 64-bit VBA for widely used Office Suite, especially for Excel), the activeX control to be used with modeless form in AutoCAD is AcFocusCtrl.dll, which is 32-bit version. Since Autodesk stopped its 32-bit version, and later moved its VBA to 64-bit version, that 32-bit AcFucusCtrl.dll is gone. The 64-bit replacement is AcFocusCtrl16.dll, which sits in C:\Program Files\Common Files\Autodesk Shared\ folder.

 

So,  if one has a VBA project that was built on 32-bit VBA, and used AcFocusCtrl.dll, the VBA project would not work with later AutoCAD because the VBA is now 64-bit. In this case, one can simply open the old VBA project and replace it with the acFocus control from AcFocusCtrl16.dll. Then the VBA project should be back working, assume there is no other 32-bit component used.

 

2. The MS Office security impact. Yes, "Disbale all ActiveX controls" is the one preventing AcFocus working with AutoCAD VBA. It is an unfortunate move for MS to plug possible security hole with widely used Office VBA apps, but Autodesk simply ignore its possible impact to its VBA users, or simply not even paid attention at all. If one installed MS Office 365, this "Disable..." is default. If the MS office is a standalone suite, or installed quite earlier, the "Disable..." setting is not in effect unless one goes to MS Office App->Options->Trust Center Settings..." to explicitly enable it.

 

The impact to AutoCAD VBA's modeless UI is like this:

a. A VBA project with modeless UserForm suddenly stops working. If open the VBA in VBA IDE, there is no AcFocus control sitting on the UserForm (however, the AcFocus control may still presented on ToolBox, or right-click the toolbox and select "Additional Controls..." and the AcFocus control is still listed). One can close AutoCAD session, go to MS Office app and uncheck the option of "Disable all ActiveX controls..."; come back to AutoCAD and run the VBA project to see the modelss UserForm's focusing comes back.

 

So, when one is creating a new VBA macro in AutoCAD and wants to add AcFocus to a UserForm, even the AcFocus control is available on the ToolBox, it simply cannot be drag-dropped onto the UserForm, if the "Disable all..." is enabled.

 

Again, this is only meant for the situations where someone who has a working VBA projects with modeless UI, and suddenly find it stopped working. At this point, it makes little sense to build new VBA project with this known hassle, IMO.

 

Norman Yuan

Drive CAD With Code

EESignature