PDA

View Full Version : AcadDocument_Activate not fired ...



mulyadi_ibrahim
2008-06-02, 08:46 AM
Hi...
I want to force a login screen (form) very time I launch autoCAD for the 1st time. So, I put this code in my AcadDocument_Activate event :

frmLogin.Show

But some how this event not getting fired when I start autoCAD by doubleclicking on autoCAD drawing (<mydrawing>.dwg file). It seems that this event will be fired when I open another autoCAD drawing ( or when 2 or more drawing already open - switch from one to another drawing will also fired this event).

I need to get the login form show up and user response to it before user doing anything to the drawing.....

What is the best way to handle this????

Thanks
MIB

RobertB
2008-06-02, 03:51 PM
You don't need an event. You need to launch your code from Acad.lsp which is configured out of the box to only run once at the start of a new AutoCAD session.

Altough, I question the need for a secondary login. Why aren't the Windows credentials enough? They are certainy more secure than what you can do in VBA.

mulyadi_ibrahim
2008-06-03, 06:10 AM
You don't need an event. You need to launch your code from Acad.lsp which is configured out of the box to only run once at the start of a new AutoCAD session.

Altough, I question the need for a secondary login. Why aren't the Windows credentials enough? They are certainy more secure than what you can do in VBA.

Thanks RobertB for ur reply..
I'm not that good with LISP. I try to use acad.dvb instead. I put these codes in my acad.dvb:


Option Explicit

Sub ACADStartup()
Call AcadApplication.RunMacro("C:\Projects\MyVBA\GMain.dvb!GMain.App_StartMacro")
End Sub

--------------------------
In my GMain.dvb - Module GMain


Public Sub App_StartMacro()
frmLogin.Show
End Sub

----------------------------
Manage to get the Login form appears, but unable to set focus to the form (Can not keyin into textbox - keep loosing focus). It seems that autoCAD was still in the process of Loading VBA startup file, when the login form appears.

p/s: Need the login form to get userid & password to connect to MS SQL Database and access database. Need to populates some data from database into drawing's title block.

Thanks


Moderator Note:

Please use [ CODE ] tags... (http://forums.augi.com/misc.php?do=bbcode#code)

Opie
2008-06-03, 02:24 PM
Do each one of your users have a user account that connects to MS SQL / Access databases? Could you not use the loginname system variable to query the database with a predefined user/password for your program?

RobertB
2008-06-03, 06:47 PM
Manage to get the Login form appears, but unable to set focus to the form (Can not keyin into textbox - keep loosing focus). It seems that autoCAD was still in the process of Loading VBA startup file, when the login form appears.
You should be able to check the IsQuiescent property to wait until displaying the form.

mulyadi_ibrahim
2008-06-04, 05:09 AM
Hi...

I think I just need to know where to properly calls my Login form when AutoCAD launch for the 1st time.

I guess it should be called when AcadState IsQuiescent = TRUE (AutoCAD is idle). But where/when is that???

Regards
MIB