Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
  HOME    TRACKER    Visual Basic

Screensaver Activate/Deactivate Event

Hi there,

Does anybody know of a way how I could create an event which fires when the screensaver is activated and deactivated.

Many thanks

Edited by - glennandrewcooper on 2/8/2004 3:27:37 AM

View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Activate/Deactivate Event Doesn't Fire When MDI Child
Please someone help me,
my problem is the following:
i had a nice application (it still is), but my boss wanted it to be an MDI Application, I say: 'No problem' and start changing some forms to MDI Child, but now, when my form is MDI Child, it DOESN'T do the (de)activate event, how is that possible?
Any ideas are welcome

Search before you ask - if you don't know where to search, ask before you search

How Do I Deactivate Screensaver Password?
I want to deactivate the screensaver password.. I know how to Turn on/off the screensaver using api using SystemParametersInfo, but to deactivate the password is another matter.

Thanks for the help.

Oh ya.. this will be for WinNT or Win2k

Activate/deactivate USB Port, Any API?
How could I activate/deactivate a USB port ? (any API ?)

Activate/Deactivate Firewall
hi, does any1 have any code for activating and deactivating the default windows firewall?


How To Track Window Activate And Deactivate?
Hi I was wondering if anyone had any sample code to track when a window has been activated and deactivated using a WIN API?


Deactivate/activate Code In Excel Files
is there a way to deactivate code (excluding the use of comments) in a master file and then activate (or automatically insert) the code as the file is transformed and creates new files? i am basically using macros in a master file to repackage select sheets and create smaller files, but i need the module of code to only be active/inserted in the smaller files. thanks!

How Can I Activate/deactivate A Device Connected To LPT1 With Vb?
Hi everybody,

My requirement is to activate an external device say, MP3 player for
half an hour after that it should be deactived and also by default it
should be deactivated. How can I do this? Pls specify the dll for this?
After all it is a timer related switching s/w!!!
With LOVE,
Thanxs in advance

How To Make The Timer Activate Then DEACTIVATE After Button Is Released
Hey I am making a pong game (for a school project) I can get the ball to bounce randomly off all four walls and now I need to make the handle respond to the arrow keys. I know how to get the arrow keys to put a value into my variable. But how do i make the timer only activate when the key is down and Deactivate when the key is released?

Im sorry if this is confusing its fairly hard to explain. Let me try to sum up.
-Making Pong
-Need to make handle move
-Know how to make the up arrow key add a value to my current variable.
-But need to make the timer control activate and deactive when the button is pressed and released... Or is this even how I would go about doing this?

Please try to understand

Public Event In Form Deactivate Event
How do you make a dynamic array created in the Form Deactivate Event able to be “public” or used in other events such as Form resize event.

Is there another way other than storing the array in a public sub?


Deactivate Event
In a form shown as modal, there's a command button with this line of code:


Then, in Sub Form_Deactivate I had placed some code to perform a few cleanup operations. I thought the deactivate event would be triggered by Me.Hide, but it wasn't. Am I doing something wrong or is this like it should be?

Workbook Deactivate Event
I´m trying to deactivate or hide some controls in excel with a vb code.
I hide the controls when some sheets are activate with the code:

Private Sub Worksheet_Activate()
'some code. works fine
end sub
and then unhide the controls again with the code

Private Sub Worksheet_Deactivate()
'some code. works fine.
end sub
The problems is that if the sheet is not deactivate, but is the workbook that is deactivate, for example if I change to another workbook, the second code is never run and the controls remain on hide mode.
Im trying to run some code when I change to another woorkbook.
I tried to put the code in the App_WorkbookDeactivate() sub, but that subrutine doesn't run when I change to another workbook.

Private Sub App_WorkbookDeactivate()
'Code never run!
end sub
I also tried
App_WorkbookDeactivate(ByVal Wb As Workbook)

I´m placing this code in the sheet code.

Any ideas?

Application Deactivate Event?
Is there an application EVENT which determines if the focus of an application has been lost? Such as the form_deactivate event but for the entire application.

What I want to do is, if the application has lost focus/deactivated then I wan to bring the focus back immediately, i.e. something like an annoying popup that never goes away

Also, if this can be done via the API only, this is an acceptable solution.


Deactivate Event Not Limited Inside Vb
I am making a VB6 project.
I allso use Word automation.
I want to use the deactivate event,
only this is only triggered among the vb forms and is not triggered when going to my Word document. Is there a solution for.

The problem i have is the following. When the focus is on my VB form and cursor is on a textbox when i move from the VBform to my Word document i want logically trigger the textbox_validate event. But because the cursor stays in the textbox of my vb form the validate event is not triggerd, alternatively i was looking a way to use the vbform deactivate event but this allso isn't triggerd

DeActivate Event: Using Selections In The Workbook That's Being Deactivated.
Hi there,

I'm trying to write some code for the DeActivate event of a certain workbook. The problem is that the code should use the values in some cells of the workbook that is being deactivated. I cannot seem to activate the workbook from the DeActivate event's code. The values are on an invisible sheet, and I would like to select them (the values represent indexnumbers of toolbars that I want to make visible). What should I do?

Embedded Chart Selected - Workbook Deactivate Event Not Triggered In VBA
It seems that if you have an embedded chart selected on a worksheet that the Workbook_Deactivate() event is not triggered.

Originally I thought this behavior was a coding error, so I set up a simple sheet with 1 chart on it and the Workbook_Deactivate() and Workbook_Activate() events with a Msgbox command in both events to indicate when I enter them. Turns out that if the chart is selected, the Workbook_Deactivate() event doesn't trigger when switching workbooks, but the Workbook_Activate() event does trigger when coming back in. When the chart is not selected, both trigger. This is really non-intuitive to me as you can't set a chart event on an embedded chart without creating an event class (as far as I know).

I did create an event class just to check it out and it works (myChartClass_Deactivate()). However, that means I would need to set every embedded chart in my workbook to the class??? and also set a Workbook_SheetActivate event to catch for when I just deselect a chart and do not leave the workbook ("If ActiveWorkbook.Name <> ThisWorkbook.Name Then ..." works as I only care about the chart deactivate event to indicate that I left the workbook).

This can't be correct. Am I missing something here or is that what you really need to do?

thx in advance

Activate Event
The Form_Activate event should be triggered when ever a form is made the current window (eg. Click a different window, and then click the first window). Is this correct?

It seems that it will not respond like that for me. The activate event will be triggered only when the window is first opened and I cannot trigger it again.

Any insight would be appreciated.

Activate Event
How do I force the activate event to occur? We have an application here that used to have entirely modal forms, and the users were prevented from accessing the desktop or other apps while it was running. I am required to make all forms non-modal and minimizable so that users can now access the desktop. My problem is the activate event of each form is not occurring, just the load. What is the best way to handle this?

Activate Event
When is a activate event of a form really used?

Trapping NT Screensaver Event And Returning A 'no Thanks' Msg
Hi, We're running NT4 SP6 & VB6 . I would like to trap the activate screensaver event generated by NT. I have found out that when a screen saver starts, NT posts a WM_SYSCOMMAND message to the foreground window with WPARAM as SC_SCREENSAVE. Do any of you good people have some code that will return a 'No thanks, don't activate' message to NT?
Also we're moving to Windows 2003 server & XP professional as the client in the next few months so some code that will run in that environment would also be much appreciated.

Many thanks Chris

Mouse Move Event (Screensaver)
How do I put a mousemove or a keypress event on the code that doesn't have to be focus on specific controls so that I can invoke the event no matters when I am and which controls I focus on ?

How do I keep track the position of my mouse on the screen in code like the x,y coordinates ?

Form Activate Event
I don't get Form Activate events (or Deactivate, Got/lost Focus events) when I swap to/from my VB6 app from another app. I should, shouldn't I!

Put a long, multiline label and a command button on a form
Put this in the form's code

Private Sub Form_Load()
Label1 = "Load"
End Sub

Private Sub Form_Initialize()
Label1 = Label1 & vbCrLf & "Initialize"
End Sub

Private Sub Form_Activate()
Label1 = Label1 & vbCrLf & "Activate"
End Sub

Private Sub Form_GotFocus()
Label1 = Label1 & vbCrLf & "Got Focus"
End Sub

Private Sub Form_Deactivate()
Label1 = Label1 & vbCrLf & "Deactivate"
End Sub

Private Sub Form_LostFocus()
Label1 = Label1 & vbCrLf & "Lost Focus"
End Sub

Private Sub Command1_Click()
Label1 = Label1 & vbCrLf & "Click"
End Sub

Run and click some other app and then back to the form..

Form Activate Event

I have a form where I store data to access db. After that I close the first form and open a second form (with vbmodal), where I try to read the data with data controller. But the data just isn't there. The problem is this (at least my guess is this) When the second form opens and the data controller tries to read from access db, the access table is not saved yet. I have also tried to refresh the data controller in form activate event, but it's not the solution because this form was in modal mode and the form activate event does not occur.

Can anyone tell how to solve this problem?

MDIFORM Activate Event
In mdiform On One Menu I have written like this


When I Unload Form1 then it comes again to Mdiform

Which event is firing when focus comes again to Mdiform
Because Activate Event is not firing


Form Activate Event
I have a code which pastes a large amount of information cell by cell from one excel sheet to another which takes a lot of time .I want to hide the process going on by putting a form in front with an animated gif in it.Please help.I tried with a form with lot of control on it and put my code in the form activate event but while processing the code,the form appears white and no control i diplayed.I don't know why .May be because the multitasking has been too much for my PC.Anyway I have deleted all control from the form and is planning to put animated gif.

Activate Event Of An MDI Child
I have an MDI application, I have set some forms to be MDI children(FormA and FormB). This is the scenario. I click a button on FormA to open Form B. I am using Now from FormB I want to open FormA. So I use My question is why is the activate event not firing on FormA when I called it to open from FormB, I have code under the activate of FormA and I need this to fire? Am I doing something wrong? I hope this explanation is not confusing.

Thanks in advance

How To Trigger Activate Event Of A Form?
I have 2 exe programs.
prg1.exe = calling program
prg2.exe = program to be called

prg1 code to call prg2:

VB Code:
' Specifying vbNormalFocus as the second argument opens the application in ' normal size and gives it the focus.Dim RetValRetVal = Shell("C:WINDOWSprg.EXE 0001", vbNormalFocus)   ' Run prg2.  

prg2 code to unload, back to prg1:

VB Code:
'there is some others code before Unload Me'Function WriteInfoToINIFile()Unload Me

After prg2 Unload, the prg1 back its previous state and need to change some data depends on the written data from INI File by the prg2 upon the prg1 activate the program.

The Activate event of prg1 is not triggered upon activation.

The Activate event occurs when an object becomes the active window. But moving the focus to or from an object in another application doesn't trigger either event.

Favors to the group:
1) Please give a hints on how to trigger activate event switching between 2 applications.
2) If you have other way to meet the requirements, much better. Please teach me.
3) Also upon calling the prg2, the user should not able access prg1. Its like with calling other form using Show method with vbModal. But it is within the application.. How about between two applications. (maybe Hiding the prg1 first before calling the prg2 then show it again after prg2 unload.

Thank you very much.

DataReport Activate Event . . . ***RESOLVED!***
I can't seem to get the DataReport's activate event to fire.

I want to change the caption of my PageHeader at runtime. I put in the MsgBox "hi" so I would know if the event fired.

I have tried setting focus, resizing, etc. What am I missing?

I tried to change the caption during the Initialize event but that gave me a "Variable not defined" error on the lblAudit part. For some reason it can't reference the control when it initalizes .

VB Code:
Private Sub DataReport_Activate()    lblAudit.Caption = ""    DoEvents    rptROEA_Audit.Refresh    MsgBox "Hi"End Sub

Anyone ever changed the label caption on a DataReport at runtime??

(man, I hate VB reports!)

Can A LostFocus Event Be Selective? I.e Don&#039;t Activate If This Happens.
I'm trying to use the LostFocus on a couple of text boxes to auto-populate some other text boxes. Everything works ok as long as valid data is entered. But I'm trying to trap invalid input. Here's the gist of the program.

Text1 "Enter Warehouse Code".

When Text1 loses focus Text2, the warehouse name, is populated from a database.

Text3 "Enter Part Number"

When Text3 loses focus Text4, the part description, is populated from a database.

The problem is if an invalid warehouse code is entered. If the warehouse code doesn't exist in the database a message box pops up stating "Warehouse Code XXXXX Invalid". But the focus has moved to Text3 via the [TAB] key. When you back-tab to Text1 to correct the warehouse code, Text3 loses focus and tries to find a blank part number in the database. A message box pops up stating "Part Number Invalid".

Question 1: Can I make a losefocus event happen except if something else happens?

Question 2: Is there a better way of doing what I'm trying to do?


A computer is a tool, not a toy.
<A HREF=""></A>

SStab Click Event And Tab Activate
Hi all,
    I am using SStab control from the Microsfot tabbed controls. In my tab i
have 3 tabs. I have some controls in first tab. When I click tab 3  , some
validation has to happen with controls in the first tab. That is happening
when i click 3rd tab. But before the validation is over with success , the
3rd tab content should not be visible. If the validation fails the active
tab should not happen for the clicked tab. But what happening is when i
click 3rd tab, the 3rd tabs become active tab, then the click event of tab
is happening which is containing the validation code.

Is it possible to change this behaviour.

Thanks in advance for any help.....

Santhakumar B

Form Activate Event Not Firing
Well I'm facing a very peculiar problem with my MDI app. When the application starts the first time and I invoke any MDI child, the activate event of that MDI child does not fire. However, if I again reopen that MDI child or any other MDI child, the respective activate event starts firing. Can anyone explain this problem?

Activate Event Called Only When Program Is Compiled.
Greetings all!

I ran into a really weird problem that took me about one day of work to fix. Byt the thing is, I still don't understand why I got this weird behavior!?!?!?!?!? So I tought that maybe some of you could provide me with another plausible explaination than my computer is posessed!

I work with MDIforms. When I click a button, it is supposed to open a form. So, what I do is loading an MDIchild into a collection. After doing that, I call a my custom function "LoadData()" from the MDIchild to load some datas (duh! that really sounded like a bad help file I read once...).

Now, here is the funcky part: when I run from the .exe file, the sub "Form_Activate()" is called right after my function "LoadData()". BUT, if I run the program from the VB developpment (I call it debug mode...) environment, "Form_Activate()" is NOT called!!!!

If anybody could tell me why the behavior is different between compiled version of the app and the debug mode, that would be great!!! Or, at least, if someone have seen something like that, just tell me cuz I really think about calling a priest so he can exorcit my computer!!!!


How To Activate An Event Of A Form In A Function **Resolved**
Hi all,
I have a function. In this function I would like to call a form. the form has a text box and a command button.

The doubt is how to actuate the event procedure of a command button in the called form with in the function.

What Would Prevent A Form&#039;s Activate Event From Firing?
I have inhereted a MDI app here where I am observing strange behavior with a form. One child form (let's call it Form1) calls the Show method for another child form (let's call it Form2).
When Form2.Show is executed, the Load event for Form2 occurs, but the Activate event for Form2 does NOT fire as expected. The result is a partially visible Form2 (with controls missing, etc.) with Form1 behind it. If I click on Form1, then click back to Form2, Form2's Activate event fires and the program proceeds normally. I have coded a work-around that works, but I'm puzzled as what is going on.

My work-around code is:
(In Form1)

Any ideas?

Text1 Changes, Activate Code In Timer Event
When the contents of text1 change, I want my code underneath a timer to execute, so at x interval, the computer will emit a beep:
Private Sub timer1_timer()
End Sub

This is just the obvious code­.. now how would I go about the rest?

Error Occurs When Txtbox Has Setfocus Within Activate Event

I have a form with a txt box on in my code, I have placed
the setfocus on the txtbox within the activate event but this appears to return an error..."Invalid procedure call " - as anyone
any ideas?????


my code

VB Code:
'set the focus on the txtbox upon form activationPrivate Sub Form_Activate()    On Error GoTo Form_Activate_Error       txtinformation.SetFocus    On Error Resume Next          On Error GoTo 0   Exit Sub Form_Activate_Error:     MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_Activate of Form frmscan"End Sub


Activate ListBox Dbl_Click Event Without Clicking On An Added Item.
Is it possiple to activate the listbox double_click event without clicking on an added item. i.e. if the user dbl clicks anywhere in the listbox. I can only get the event if I dbl click on an added item.

How To Avoid Controls Click Events In Form Activate Event...
Is there any way to avoid the click event send that automatically Activate form event sends to all controls in the form???

Thanx in advance !!!!

Activate, Ye Stubborn Cell! ACTIVATE I SAY!!!
I'm glad to have one of my trademark needlessly complicated issues to present to you all. In my form is a combo box ('EventMenu'), two text boxes ('AskIt' and 'Moofus') and a button. Nice users will enter a string into the 'AskIt' box and my program will find the cell (all I really want is the row) where that string is found. Users also will have entered text into 'Moofus'; and this text will be entered into a cell on whichever row the AskIt string was found. Which cell, you ask; for there are many. Which cell the Moofus string ends up in depends on what the user selected from the EventMenu combo box.

Here is the script for when the button clicks:

Private Sub Findit_Click()
Loogit = Askit.Value
Hepcat = Moofus.Value
Set C = Worksheets(1).Cells.Find(Loogit, LookIn:=xlValues)
Showit.Value = C.Row
If EventMenu.SelText = "ONSITE" Then Cells(C.Row, 13).Activate
If EventMenu.SelText = "STARTUP" Then Cells(C.Row, 14).Activate
If EventMenu.SelText = "LOAD" Then Cells(C.Row, 15).Activate
If EventMenu.SelText = "MKEY" Then Cells(C.Row, 16).Activate
If EventMenu.SelText = "PROD" Then Cells(C.Row, 17).Activate
ActiveCell.Font.Bold = False
ActiveCell.Font.Size = 10
ActiveCell.Value = Hepcat
End Sub

In my dream world, they enter 1234A into AskIt and the program finds 1234A on row 11; the user selected "MKEY" from the Menu and thus the cell at R11C16 is activated and populated with Moofus.Value.

But all that happens instead is that the Moofus.Value ends up in whichever cell was active when I ran the macro.

Wha happened?

Deactivate Right Click
Hi I need to deactivate de Right click menu, Copy paste etc.
Someone knows how.

I know that with the mousedown event I can know wich button I click but I can´t deactivate the menu.

Thank´s a lot

Deactivate AutoSave

I have a huge Problem and unfotunately I think there wouldn´t be an answer for it. But if there is one, so I´m sure, you´ll tell me... :-)

I want to deactivate the AutoRecover Function for my Excel-VBA Application. OK, that seems easy! But no, not for WindowsNT!!

For WindowsXP I can use this Statement: "Application.AutoRecover.Enabled = False"

For WindowsNT I can only try to hack the Registry... --and God knows I don´t wanna do that :-)

Thanks for your help!!


Deactivate An Application
I would like to know if there is any thing like appactivate to deactivate an application any insight would be of help


Form Deactivate
I'm creating a program, with one main form, and one option-form. But I want that when you are on the option-form, you can't do anything on the main form. Does anyone know how I can do that??
Grtz and Thx

Deactivate Networkadapter

I`m searching for a function with which I can (de)activate my networkadapter, but I haven`t found anything til now.
I want to make it from one of my programs.
Is there a special API which can to that (NdisOpenAdapter - NdisCloseAdapter or something else?).
Or are there any other methods to do that?


Deactivate Vs Lostfocus
that's about it...
simple question

Deactivate A Private Sub
Guys, I'm new to VBA and have been writing a program which opens an external workbook before copying data and importing into my workbook. The problem is, when the external workbook is opened and i select the requisite cells i wish to copy, my code appears to be overridden and it subsequently jumps to a private sub contained within the external workbook and stops running my code

Therefore my question would be is there any way i cn de-activate or skip the private subs contained within the external workbook?

Any help would be most appreciated

Key Deactivate Problem
Hi Guys

I would like to deactivate the windows & poppu menu key of the keyboard at a particular instance

Have you got any idea

I have used the API's setKeyBoardState, GetKeyboardState, but unable to get the result


Form - Deactivate
For eg:
I have form1 and form2. From form1 i load form2. In this case form1 's deactivate event gets fired. I don't want this to happen.
This doesn't happen when we open a VB MessageBox.

Deactivate Workbook
What is the code to deactivate a workbook while my Shelled program is running. Coz I need to prevent the user from doing any form of actions(eg.clicking the menu bar)while my shelled program is running.I need to put the codes in a module.Can anyone help?Thanks.

Deactivate A Form
Hi Friends

I have created a VBA form. In that I have a button. When that button is pressed, the selected text will become bold.

What I want is, once the button is pressed the form should get deactivated after making the text bold. This is because I want to continue to edit my document after pressing this button. Now what I do is, I use the mouse to click on the document so that the form get deactivated and the current selection becomes active. Can this be done programatically? Is there a way to make the form loose its focus? or Is there a way to make the selection active?

Please help me.


Copyright © 2005-08, All rights reserved