Hi,
I'm looking for some help to get the below code to work.
I have a button, when you click on it, it loads the calculator application. If it's already open it brings it to the front and if its minimized it shows the window.
The issue i'm having is with the minimized window side of things. I'm getting errors with this section of the code.
StrPtr shows as not declared and a few other problems. Any ideas will be a massive help.
Here is the full code.
I'm looking for some help to get the below code to work.
I have a button, when you click on it, it loads the calculator application. If it's already open it brings it to the front and if its minimized it shows the window.
The issue i'm having is with the minimized window side of things. I'm getting errors with this section of the code.
StrPtr shows as not declared and a few other problems. Any ideas will be a massive help.
Code:
hWndCalc = FindWindowW(StrPtr("SciCalc"), StrPtr("Calculator"))
If hWndCalc Then
SetForegroundWindow hWndCalc
If IsIconic(hWndCalc) Then ShowWindow(hWndCalc, SW_RESTORE)
Else
Here is the full code.
Code:
#If True Then
Private Const SW_RESTORE As Long = 9
Private Declare Function FindWindowW Lib "user32.dll" (Optional ByVal lpClassName As Long, Optional ByVal lpWindowName As Long) As Long
Private Declare Function IsIconic Lib "user32.dll" (ByVal hWnd As Long) As Long
Private Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hWnd As Long) As Long
Private Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Long, ByVal nCmdShow As Long) As Long
Private Sub cmdOpenCalc_Click()
Dim hWndCalc As Long
hWndCalc = FindWindowW(StrPtr("SciCalc"), StrPtr("Calculator"))
If hWndCalc Then
SetForegroundWindow hWndCalc
If IsIconic(hWndCalc) Then ShowWindow hWndCalc, SW_RESTORE
Else
Shell "calc.exe"
End If
End Sub
#Else
Private Sub cmdOpenCalc_Click()
On Error Resume Next
AppActivate "Calculator"
If Err Then Shell "calc.exe"
End Sub
#End If