| Author |
Message |
RMS
Joined: 27 Aug 2005
Posts: 15
|
Posted:
Sat May 12, 2007 1:28 am Post subject:
Fine tuning a simple VBA application |
|
|
I use a dialog input box on all my VBA programs, is there code to end it after execution to remove that box from the cad window and make the cad window active again for drawing?
_________________ vacuum tube guitar amps www.dreamtone.org |
|
| Back to top |
|
 |
Fatty
Joined: 08 Jun 2006
Posts: 9
Location: Sankt-Petersburg, Russia
|
Posted:
Sat May 12, 2007 6:20 pm Post subject:
Re: Fine tuning a simple VBA application |
|
|
| RMS wrote: | | I use a dialog input box on all my VBA programs, is there code to end it after execution to remove that box from the cad window and make the cad window active again for drawing? |
Hi
Did you try to add the OK button on this form?
Something like that should help I hope
| Code: | Private Sub CommandButton1_Click()
Unload Me '// that means to unload your form
End Sub |
~'J'~ |
|
| Back to top |
|
 |
RMS
Joined: 27 Aug 2005
Posts: 15
|
Posted:
Sun May 13, 2007 1:06 am Post subject:
|
|
|
Well that does work, BUT it brings me back to the VBA Module. Is there any code that I can write to keep me in the active AutoCAD screen?
_________________ vacuum tube guitar amps www.dreamtone.org |
|
| Back to top |
|
 |
Fatty
Joined: 08 Jun 2006
Posts: 9
Location: Sankt-Petersburg, Russia
|
Posted:
Sun May 13, 2007 7:33 am Post subject:
|
|
|
| RMS wrote: | | Well that does work, BUT it brings me back to the VBA Module. Is there any code that I can write to keep me in the active AutoCAD screen? |
I have not found link on thread where
was thrown the same question, here is a copy
of the answer
Citation:
"If you use The ACFocusCtrl and have a vbmodeless form then you can use this code
to switch from the userform back to your autocad window."
| Code: |
'//written by arcticad
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Public Declare Function SetForegroundWindow Lib "user32" (ByVal hWnd As Long) As Long
Public Declare Function SetActiveWindow Lib "user32" (ByVal hWnd As Long) As Long
Sub SwitchFocus()
Dim AcadHandle As Long
Dim FormHandle As Long
Dim acadApp As AcadApplication
Dim WindowReturn As Long
Set acadApp = GetObject(, "AutoCAD.Application")
AcadHandle = FindWindow(vbNullString, acadApp.Caption)
'<your code goes here>
'jump back to Acad
WindowReturn = SetActiveWindow(AcadHandle)
End Sub |
The similar method with using of API function 'SetFocus'
Search google API-GUID 3.0 that has a very good
explanation of these functions with code
Hth
~'J'~ |
|
| Back to top |
|
 |
Fatty
Joined: 08 Jun 2006
Posts: 9
Location: Sankt-Petersburg, Russia
|
|
| Back to top |
|
 |
|
|
|
|