Author Topic: On App Activate Event  (Read 6525 times)

0 Members and 1 Guest are viewing this topic.

ML

  • Guest
On App Activate Event
« on: October 16, 2007, 12:39:42 PM »

Hi

On the App Activate Event Procedure, I am trying to run the below code however, the code is not working on App Activate; instead it is working when I minimize and amximize the App Window.
Am I using the wrong Event oe Method here?

May be I should be using the macro
Code: [Select]
Sub acadstartup()
 'code here
End Sub
Instead????

Thanks Mark

Code: [Select]
Private Sub AutoCAD_AppActivate()

Dim Preferences As AcadPreferences
Dim CurrMenuFile As String

Set Preferences = ThisDrawing.Application.Preferences
CurrMenuFile = Preferences.Files.MenuFile

Select Case CurrMenuFile
 Case Is = "Land"
  ThisDrawing.SendCommand "wscurrent" & vbCr & "Land Destop Complete" & vbCr
 Case Else
  ThisDrawing.SendCommand "wscurrent" & vbCr & "Map Classic" & vbCr
End Select

End Sub

quamper

  • Guest
Re: On App Activate Event
« Reply #1 on: October 16, 2007, 02:02:25 PM »
Are you trying to do something on activation or something else like on loading? Activation is what you are talking about.. if the program is in the background and then you select it, or unminimizing you've just "activated" the application.

See this msdn article http://msdn2.microsoft.com/en-us/library/dyz95fhy(VS.80).aspx

ML

  • Guest
Re: On App Activate Event
« Reply #2 on: October 16, 2007, 02:03:53 PM »

Yes

I was referring to on startup

Mark

ML

  • Guest
Re: On App Activate Event
« Reply #3 on: October 16, 2007, 02:17:36 PM »

OK

I have an acadstartup macro in my acad.dvb file
with the above (first post) code in it.

I am initializing VBA by having acvba.arx inside my acad.rx file.
I also have my acad.dvb file in Startup Suite.

Also, here is proof that VBA is initializing and running my startup macro:
After I start ACAD, I hit F2 and get this:
However, my workspace is not physically switching to Map Classic
Any ideas?????

Initializing VBA System...
Loading VBA startup file...wscurrent
Map Classic

Guest

  • Guest
Re: On App Activate Event
« Reply #4 on: October 16, 2007, 02:40:56 PM »
Instead of SendCommand, try this...

ThisDrawing.SetVariable("wscurrent", "Map Classic")

...since the Work Space is a system variable.


I've never really had much luck with SendCommand.   :-(

ML

  • Guest
Re: On App Activate Event
« Reply #5 on: October 16, 2007, 02:44:39 PM »

Matt
That is a great idea!

You are right, it is a system variable DUH :)
That would be much better then the send command.

The send command certainly does have some use but I try to avoid it when possible.

The interesting thing is that the macro works fine if I run it from within ACAD but not on startup

I think you just touched on something; I don't think VBA likes the idea of sending commands to the command line on startup

Let's see

Thanks

Mark

Guest

  • Guest
Re: On App Activate Event
« Reply #6 on: October 16, 2007, 02:46:49 PM »
Good luck!

ML

  • Guest
Re: On App Activate Event
« Reply #7 on: October 16, 2007, 02:55:40 PM »

THanks Matt!

The only problem is that this syntax
Code: [Select]
ThisDrawing.SetVariable("wscurrent", "Map Classic")
is incorrect

So, first I am trying to work that out

Mark

Guest

  • Guest
Re: On App Activate Event
« Reply #8 on: October 16, 2007, 02:57:52 PM »

THanks Matt!

The only problem is that this syntax
Code: [Select]
ThisDrawing.SetVariable("wscurrent", "Map Classic")
is incorrect

So, first I am trying to work that out

Mark

Yeah, you're right.  I was messing around with it and had MsgBox in front of it.  Just remove the parentheseseseses and you should be all set.

ML

  • Guest
Re: On App Activate Event
« Reply #9 on: October 16, 2007, 02:59:39 PM »

Nope, that doesn't work either LOL

Don't you love it, it is always the small things :)

It probably has to be setvariable wscurrent = etc etc

ML

  • Guest
Re: On App Activate Event
« Reply #10 on: October 16, 2007, 03:14:36 PM »

Matt

The help screen says

Code: [Select]
Dim strData As String
 sysVarName = "DCTCUST"
 strData = "My Custom Dictionary"
 sysVarData = strData        ' String data
 ThisDrawing.SetVariable sysVarName, sysVarData

This tells me

I need

Code: [Select]
ThisDrawing.SetVariable("wscurrent", Map Classic)

but this method is not working????????

I never have a problem when I use getvariable

Mark


ML

  • Guest
Re: On App Activate Event
« Reply #11 on: October 16, 2007, 03:17:36 PM »

Actually
I take that back; according to the help, it should be
Code: [Select]
ThisDrawing.SetVariable ("wscurrent", "Map Classic")

But I got it

It is this:
Code: [Select]
ThisDrawing.SetVariable "wscurrent", "Map Classic"

Now, I can get back to the original problem :)






ML

  • Guest
Re: On App Activate Event
« Reply #12 on: October 16, 2007, 03:23:04 PM »

I am having a post with myself here :lol:

The help screen was correct the whole time; it is my brain that is not right  :lol: :)

Ok, well that did it!

No sendcommand  in The acadstartup

So, in my Acadstartup macro
I have:

Code: [Select]
Sub Acadstartup()
Set AutoCAD = ThisDrawing.Application

Dim Preferences As AcadPreferences
Dim CurrMenuFile As String

Set Preferences = ThisDrawing.Application.Preferences
CurrMenuFile = Preferences.Files.MenuFile

Select Case CurrMenuFile
 Case Is = "Land"
   ThisDrawing.SetVariable "wscurrent", "Land Destop Complete"
 Case Else
   ThisDrawing.SetVariable "wscurrent", "Map Classic"
End Select

End Sub

All seems to be working well

Thanks for the clue Matt!

Mark

Guest

  • Guest
Re: On App Activate Event
« Reply #13 on: October 16, 2007, 03:30:14 PM »
Is this a typo??

Quote
ThisDrawing.SetVariable "wscurrent", "Land Destop Complete"

Should there be a K in there??!?

ML

  • Guest
Re: On App Activate Event
« Reply #14 on: October 16, 2007, 03:33:39 PM »

Yes, it is thank you :)
That's all I need is to spend another 30 minutes figuring that one out LOL

Mark