SetFocus back to control on my form after user selection in Acad

SetFocus back to control on my form after user selection in Acad

mdhutchinson
Advisor Advisor
431 Views
2 Replies
Message 1 of 3

SetFocus back to control on my form after user selection in Acad

mdhutchinson
Advisor
Advisor
I have this code block in ThisDrawing module inside
AcadDocument_SelectionChanged event procedure.
the event runs fine but I'd like to send the focus back to the form (modeless form with AcFocusCtrl1)
In the code I get intellesence as I should and this code block is evalueated without error... but the focus doesn't go back to the control on the form.
What am I doing wrong?

Option Explicit
Private objIDE As VBIDE.VBE
''''''
Set objIDE = Application.VBE
objIDE.ActiveWindow.SetFocus
objIDE.Windows.Item("frmContNum").SetFocus
frmContNum.LViewPCNData.SetFocus
0 Likes
432 Views
2 Replies
Replies (2)
Message 2 of 3

Anonymous
Not applicable
Why you want to get a form in VBA IDE focused? Do you mean when a drawing's
selection changed (user make selection on the drawing, then Acad opens VBA
IDE so user can change the design of the form? I bet that is not what you
want, but your code is trying that, although it is not working, because the
VBAIDE window is not shown.

I do not know how to get focus back to modeless form by code, but it
definitely has nothing to do with VBIDE.VBE.


"hutch" wrote in message news:5842691@discussion.autodesk.com...
I have this code block in ThisDrawing module inside
AcadDocument_SelectionChanged event procedure.
the event runs fine but I'd like to send the focus back to the form
(modeless form with AcFocusCtrl1)
In the code I get intellesence as I should and this code block is evalueated
without error... but the focus doesn't go back to the control on the form.
What am I doing wrong?

Option Explicit
Private objIDE As VBIDE.VBE
''''''
Set objIDE = Application.VBE
objIDE.ActiveWindow.SetFocus
objIDE.Windows.Item("frmContNum").SetFocus
frmContNum.LViewPCNData.SetFocus
0 Likes
Message 3 of 3

mdhutchinson
Advisor
Advisor
I figured that much on my own... and abandoned the effort.

What I was after:

User selects specific block references in the drawing and the matching item in a list box is highlighted...
or... user selects item in a list box and the matching block in the drawing is highlighted.
This much works as I want.

What I was after was to allow the user to select the blocks in the drawing and capture a keystroke from the user that will run my cmdbutton click event.
I thought what I might do was to load a lisp file that would temporarily redefine a few lisp c: commands that will work in concert with my application.
0 Likes