#include "apdefap.
h"
void OnLButtonDown(char* lpszPictureName, char* lpszObjectName, char*
lpszPropertyName, UINT nFlags, int x, int y)
{
// WINCC:TAGNAME_SECTION_START
// syntax: #define TagNameInAction "DMTagName"
// next TagID : 1
// WINCC:TAGNAME_SECTION_END
// WINCC:PICNAME_SECTION_START
// syntax: #define PicNameInAction "PictureName"
// next PicID : 1
// WINCC:PICNAME_SECTION_END
#pragma code ("[Link]")
BOOL PlaySound(LPCSTR pszSound,HMODULE hMod,DWORD fdwSound);
#define SND_FILENAME 0x00020000L
#define SND_ASYNC 0x0001
#pragma code ()
char szProjectName[MAX_PATH];
CMN_ERROR Error;
char szSoundFilePath[MAX_PATH] = "";
char szSoundFile[MAX_PATH] = "[Link]";
int iResult;
//get current language
switch (GetLanguage())
{
//set message text
//german
case 0x407: iResult=MessageBox(NULL,
"Wollen Sie Ihre Arbeit mit Project_WinCCEditors\r\n"
"wirklich beenden?\r\n",
"Runtime beenden",
MB_OKCANCEL|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
break;
//english
case 0x409: iResult=MessageBox(NULL,
"This ends your work with WinCC Runtime.\r\n",
"Shutdown Runtime",
MB_OKCANCEL|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
break;
//french
case 0x40C: iResult=MessageBox(NULL,
"Voulez-vous vraiment terminer votre\r\n"
"travail sur Project_WinCCEditors?\r\n",
"Terminer runtime",
MB_OKCANCEL|MB_ICONQUESTION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
break;
}//switch
if (iResult==IDOK) {
//DeactivateRTProject();
//DMExitWinCCEx (DM_SDMODE_SYSTEM);
DeactivateRTProject ();
PlaySound(NULL,NULL,SND_FILENAME|SND_ASYNC);
}
}
Sub Write2TextFile
Option Explicit
Dim objFSO, objFolder, objShell, objTextFile, objFile
Dim strDirectory, strFile, strText
strDirectory = "D:\HngBatchHouse\Reports"
strFile = "\[Link]"
strText = "Book Another Holiday"
' Create the File System Object
Set objFSO = CreateObject("[Link]")
' Check that the strDirectory folder exists
If [Link](strDirectory) Then
Set objFolder = [Link](strDirectory)
Else
Set objFolder = [Link](strDirectory)
[Link] "Just created " & strDirectory
End If
If [Link](strDirectory & strFile) Then
Set objFolder = [Link](strDirectory)
Else
Set objFile = [Link](strDirectory & strFile)
[Link] "Just created " & strDirectory & strFile
End If
set objFile = nothing
set objFolder = nothing
' OpenTextFile Method needs a Const value
' ForAppending = 8 ForReading = 1, ForWriting = 2
Const ForAppending = 8
Set objTextFile = [Link] _
(strDirectory & strFile, ForAppending, True)
' Writes strText every time you run this VBScript
[Link](strText)
[Link]
' Bonus or cosmetic section to launch explorer to check file
If [Link] = vbEmpty then
Set objShell = CreateObject("[Link]")
[Link] ("Explorer" &" " & strDirectory & "\" )
Else [Link] "VBScript Error: " & [Link]
End If
[Link]
End Sub