473,468 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Activating program with windows class name

553 Contributor
Hi

I am trying to activate a program using its Windows Class Name. Here is the code. :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2. Dim rVal As Integer
  3.     rVal = AppActivateClass("SciCalc")
  4. End Sub
  5.  
  6. Function AppActivateClass(lpclassname$)
  7.       Dim hWnd As Integer       'the application's window handle
  8.       Dim dummy As Integer      'Dummy variable
  9.  
  10.       'Get the Window Handle
  11.       hWnd = alias_FindWindow("lpclassname$", 0&)
  12.  
  13.       'Activate the Application
  14.       dummy = alias_SetActiveWindow(hWnd)
  15.       dummy = alias_ShowWindow(hWnd, SW_SHOW)
  16.  
  17.       'Return True if Application Running, or False if not.
  18.       AppActivateClass = hWnd
  19.  
  20. End Function
  21.  
In module:
Expand|Select|Wrap|Line Numbers
  1. Declare Function alias_ShowWindow Lib "User" Alias "ShowWindow" _
  2.      (ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
  3.  
  4.     Declare Function alias_FindWindow Lib "User" Alias "FindWindow" _
  5.      (ByVal lpclassname As String, ByVal lpCaption As Any) As Integer
  6.  
  7.     Declare Function alias_SetActiveWindow Lib "User" Alias _
  8.       "SetActiveWindow" (ByVal hWnd As Integer) As Integer
  9.  
  10.     Const SW_SHOW = 9
  11.  
I am keep getting error 53: File not Found 'User'

I have no idea what this error means and what file error has to do with this program?

Any ideas?

Thanks
Qi
Aug 30 '07 #1
6 4680
ADezii
8,834 Recognized Expert Expert
Hi

I am trying to activate a program using its Windows Class Name. Here is the code. :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2. Dim rVal As Integer
  3.     rVal = AppActivateClass("SciCalc")
  4. End Sub
  5.  
  6. Function AppActivateClass(lpclassname$)
  7.       Dim hWnd As Integer       'the application's window handle
  8.       Dim dummy As Integer      'Dummy variable
  9.  
  10.       'Get the Window Handle
  11.       hWnd = alias_FindWindow("lpclassname$", 0&)
  12.  
  13.       'Activate the Application
  14.       dummy = alias_SetActiveWindow(hWnd)
  15.       dummy = alias_ShowWindow(hWnd, SW_SHOW)
  16.  
  17.       'Return True if Application Running, or False if not.
  18.       AppActivateClass = hWnd
  19.  
  20. End Function
  21.  
In module:
Expand|Select|Wrap|Line Numbers
  1. Declare Function alias_ShowWindow Lib "User" Alias "ShowWindow" _
  2.      (ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
  3.  
  4.     Declare Function alias_FindWindow Lib "User" Alias "FindWindow" _
  5.      (ByVal lpclassname As String, ByVal lpCaption As Any) As Integer
  6.  
  7.     Declare Function alias_SetActiveWindow Lib "User" Alias _
  8.       "SetActiveWindow" (ByVal hWnd As Integer) As Integer
  9.  
  10.     Const SW_SHOW = 9
  11.  
I am keep getting error 53: File not Found 'User'

I have no idea what this error means and what file error has to do with this program?

Any ideas?

Thanks
Qi
To the best of my knowledge, the AppActivateClass() Function has not been supported by Access since Version 2.0. Use the AppActivate Statement instead.
Aug 30 '07 #2
dima69
181 Recognized Expert New Member
Hi

I am trying to activate a program using its Windows Class Name. Here is the code. :

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2. Dim rVal As Integer
  3.     rVal = AppActivateClass("SciCalc")
  4. End Sub
  5.  
  6. Function AppActivateClass(lpclassname$)
  7.       Dim hWnd As Integer       'the application's window handle
  8.       Dim dummy As Integer      'Dummy variable
  9.  
  10.       'Get the Window Handle
  11.       hWnd = alias_FindWindow("lpclassname$", 0&)
  12.  
  13.       'Activate the Application
  14.       dummy = alias_SetActiveWindow(hWnd)
  15.       dummy = alias_ShowWindow(hWnd, SW_SHOW)
  16.  
  17.       'Return True if Application Running, or False if not.
  18.       AppActivateClass = hWnd
  19.  
  20. End Function
  21.  
In module:
Expand|Select|Wrap|Line Numbers
  1. Declare Function alias_ShowWindow Lib "User" Alias "ShowWindow" _
  2.      (ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
  3.  
  4.     Declare Function alias_FindWindow Lib "User" Alias "FindWindow" _
  5.      (ByVal lpclassname As String, ByVal lpCaption As Any) As Integer
  6.  
  7.     Declare Function alias_SetActiveWindow Lib "User" Alias _
  8.       "SetActiveWindow" (ByVal hWnd As Integer) As Integer
  9.  
  10.     Const SW_SHOW = 9
  11.  
I am keep getting error 53: File not Found 'User'

I have no idea what this error means and what file error has to do with this program?

Any ideas?

Thanks
Qi
Your API functions declarations are wrong.
It should be "Lib User32" instead of "Lib User". See full declarations HERE
Aug 30 '07 #3
questionit
553 Contributor
dima69

I changed it to user32 from user, but now i get this error:

Cant find DLL entry point FindWindow in user32.

Adezii,

"AppActivateClass" that i use is a function that i have defined in the code - not a VB pre-defined function! What did you mean when you said this is not in the new versions?

Qi


Your API functions declarations are wrong.
It should be "Lib User32" instead of "Lib User". See full declarations HERE
Aug 30 '07 #4
dima69
181 Recognized Expert New Member
dima69

I changed it to user32 from user, but now i get this error:

Cant find DLL entry point FindWindow in user32.

Adezii,

"AppActivateClass" that i use is a function that i have defined in the code - not a VB pre-defined function! What did you mean when you said this is not in the new versions?

Qi
This is the correct declaration for FindWindow:
Expand|Select|Wrap|Line Numbers
  1. Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
See the link in my previous post for the rest.
Aug 30 '07 #5
Scott Price
1,384 Recognized Expert Top Contributor
It looks like you are already using some copy'n'pasted code from this link: have a look at the bottom of the page, and you will see this applies to Microsoft Access 1.0, 1.1, and 2.0... If you are using another version of Access you'll have to update the code to fit the different version of VBA.

http://support.microsoft.com/?scid=k...4710&x=21&y=15

Regards,
Scott
Aug 30 '07 #6
ADezii
8,834 Recognized Expert Expert
dima69

I changed it to user32 from user, but now i get this error:

Cant find DLL entry point FindWindow in user32.

Adezii,

"AppActivateClass" that i use is a function that i have defined in the code - not a VB pre-defined function! What did you mean when you said this is not in the new versions?

Qi
You are starting gto retrofit outdated Code and Declarations into a newer Version of Access and Windows. Start from scratch with the correct Function Declarations.
Aug 30 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Brian Worth | last post by:
I have just upgraded from VB 4.0 to VB .NET 2002. One program under VB 4.0 was able to shut down or restart the (windows XP) machine using a series of API calls. (Getlasterror, GetCurrentProcess,...
6
by: Alice | last post by:
Hi -- I am trying to code a "mad libs" style program, in which the user puts in nouns, adjectives, etc., into text boxes. Then the user clicks on a button which opens a message box. Inside the...
1
by: Michael D. Reed | last post by:
I am using the help class to display a simple help file. I generated the help file using Word and saving it as a single page Web page (.mht extension). I show the help file with the following...
1
by: dabassguy1 | last post by:
frmFinApp instantiates, shows, and activates frmSoldLeads, by clicking btnSoldLead. The btnMakeDeal instantiates, shows and activates frmInputDeal and then closes frmSoldLeads btnSaveDeal on...
0
by: Robert Rotstein | last post by:
I want to write a SOAP extension that gets activated from both the client and the server. From whast I have read, this should be quite easy to do. Yet I can only activate it from the server. I...
0
by: Robert Rotstein | last post by:
I want to write a SOAP extension that gets activated from both the client and the server. But so far, I have only been able to activate from the server. I have a service (.asmx file) which...
2
by: simchajoy2000 | last post by:
Hi, Let me see if I can explain this, I have noticed that when I create new windows forms (within my larger window form which serves as the primary interface with dropdown menus etc) that...
19
by: mohammaditraders | last post by:
a program which consists of a class named Student, the class should consists of three data members Name, Ob_marks, Total_marks and two member functions Cal_percentage() which calculate the...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.