|
-
May 29th, 2001, 03:13 PM
#1
What do i do?????
Take alook at this code first:
' This code is supposed to, when you select an item and click show, it should open calculator
' if you click calculator
Dim run as string
private Sub show_Click()
If List1.text = "Word Processor" then
Form2.Show
ElseIf List1.text = "Calculator" then
run = Shell("C:\WINDOWS\CALC.EXE", 1)
End If
End Sub
' That works
' This code is supposed to exit the program when you click on calculator
private Sub close_Click()
If List1.text = "Word Processor" then
Form2.Hide
ElseIf List1.text = "Calculator" then
End If
End Sub
' And then there's the rest
private Sub Exit_Click()
End
End Sub
private Sub Form_Load()
List1.AddItem "Word Processor"
List1.AddItem "Calculator"
End Sub
' My question is: how do you make it close calculator when you select it from the list box and 'click close?
--Ant
-
May 29th, 2001, 07:40 PM
#2
Re: What do i do?????
Declare this
Const WM_DESTROY = &H2
Const WM_CLOSE = &H10
private Declare Function FindWindowA Lib "user32" (byval lpClassName as Any, byval lpWindowName as Any) as Integer
private Declare Function SendMessageA Lib "user32" (byval hWnd as Integer, byval wMsg as Integer, byval wParam as Integer, lParam as Any) as Long
For close Calculator
Dim hWnd&, Res&
hWnd = FindWindowA(vbNullString, "Calculator")
Res = SendMessageA(hWnd, WM_CLOSE, 0, 0)
Res = SendMessageA(hWnd, WM_DESTROY, 0, 0)
Andy Tower
-
May 30th, 2001, 06:41 AM
#3
Re: What do i do?????
refer http://vblib.virtualave.net, there should be a function ShutDownApp in vbSystem of the activeX DLL.
HTH
-
May 30th, 2001, 08:31 AM
#4
Re: What do i do?????
This should work:
Declare your run variable as an integer
' Activate the calculator
AppActivate run
' Close the Calculator
SendKeys "%{F4}, true"
-
May 30th, 2001, 12:21 PM
#5
Re: What do i do?????
Add the following:
dim run as string
dim runid as long ' ID returned by Shell()
.
.
private Sub show_Click()
If List1.text = "Word Processor" then
Form2.Show
ElseIf List1.text = "Calculator" then
runid = Shell("C:\WINDOWS\CALC.EXE", 1) ' save the ID
End If
End Sub
.
.
.
private Sub close_Click()
If List1.text = "Word Processor" then
Form2.Hide
ElseIf List1.text = "Calculator" then
AppActivate runid
SendKeys "%{F4}, true"
End If
End Sub
....
-Cool Bizs
Good Luck,
-Cool Bizs
-
May 30th, 2001, 01:41 PM
#6
Re: What do i do?????
Thanks every1.
I got it working right
now
--Ant
------------------------------------------------------------------------------------------------------------------------
Want Free Software?
E-mail me @: [email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|