 |
plc.myforum.ro PLCs users www.plc.myforum.ro!
|
| View previous topic :: View next topic |
| Author |
Message |
valz Member 3


Joined: 26 Jul 2015 Posts: 771
|
Posted: 18/10/2022 18:44 Post subject: Windows dialog box with WinCC |
|
|
How do you create a Windows dialog box with WinCC and evaluate the response of the operator?
https://support.industry.siemens.com/cs/document/268859/
A C script that uses the Windows API function "MessageBox()" creates a standard Windows dialog box. The return value of the function contains the code of the button selected by the operator.
Programming the MessageBox() in the Windows API
Script example
Special feature "Independent picture windows"
Note
An alternative to the Windows dialog box are the picture windows that you can configure directly in WinCC.
https://support.industry.siemens.com/cs/ww/en/view/109736220/52924528395
Unlike the dialog box, a picture window does not stop processing of Runtime. Information about this is available under How to insert a picture windowin the WinCC V7.4 System Manual "Working with WinCC" in
https://support.industry.siemens.com/cs/attachments/109736220/WinCC_Working_with_WinCC_en-US_en-US.pdf
Programming the MessageBox() in the Windows API
The Microsoft Developer Network includes detailed instructions for programming a Windows dialog box, including a description of parameters and return values.
Note the following in conjunction with WinCC:
For hWnd the Window handle must be transferred by PDLRT.
In uType the flags "MB_SETFOREGROUND" and "MB_SYSTEMMODAL" must be set, because otherwise the dialog box does not appear in the picture foreground and the system might be made inoperable.
Script example
The following script shows how to use the "MessageBox()" function and evaluate the return value.
The text file below includes the script shown above:
https://support.industry.siemens.com/cs/attachments/268859/268859_wincc_messageboxuse.txt
| Code: | #include "apdefap.h"
void OnClick(char* lpszPictureName, char* lpszObjectName, char* lpszPropertyName)
{
int iRet = 0;
HWND WindowClassHandle_PDLRT = NULL;
WindowClassHandle_PDLRT = FindWindow ("PDLRTisAliveAndWaitsForYou",NULL);
if(WindowClassHandle_PDLRT)
{
iRet = MessageBox(WindowClassHandle_PDLRT, "The message text!", "Title", MB_YESNOCANCEL|MB_ICONEXCLAMATION|MB_SETFOREGROUND|MB_SYSTEMMODAL);
switch (iRet){
case IDYES:
printf ("#I101: lpszObjectName=\"%s\" - MessageBox() iRet=%d (Button \"YES\") \r\n",lpszObjectName, iRet);
break;
case IDNO:
printf ("#I102: lpszObjectName=\"%s\" - MessageBox() iRet=%d (Button \"NO\") \r\n",lpszObjectName, iRet);
break;
case IDCANCEL:
printf ("#I103: lpszObjectName=\"%s\" - MessageBox() iRet=%d (Button \"CANCEL\") \r\n",lpszObjectName, iRet);
break;
default:
printf ("#I100: lpszObjectName=\"%s\" - MessageBox() iRet=%d (Error!) \r\n",lpszObjectName, iRet);
break;
}
}
else
printf ("PDLRT-Handle not found\r\n");
}
|
Special feature "Independent picture windows"
If the dialog box is called from an independent picture window, you must link this dialog box to the picture window.
Otherwise, the dialog box may disappear in the background if you do not close it immediately or lose the focus. Since in this case the associated script is still waiting for a return value, the C scripts are blocked for this long.
Procedure
1. Define a static header (PictureWindowHeader) for the picture window under Properties > Miscellaneous.
2. Adjust the script line with the command FindWindow
WindowClassHandle_PDLRT = FindWindow ("PDLRTisAliveAndWaitsForYou",NULL);
accordingly as follows:
WindowClassHandle_PDLRT = FindWindow (NULL, "PictureWindowHeader");
Notes
The operating system language set before the Runtime starts is also used for the texts on the buttons of the Windows MessageBox. To have multiple languages you need a multi-language version of the operating system (MUI). Further information about this is available in Entry
https://support.industry.siemens.com/cs/document/21923800/how-can-i-change-the-languages-of-the-texts-in-the-wincc-message-box
You have to configure switching the languages for the message text and headline manually.
Entry
https://support.industry.siemens.com/cs/document/22907359/how-can-you-configure-language-switchover-for-the-message-text-and-caption-of-the-windows-messagebox
shows how to configure switching languages for the message text and headline. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group Fa-ti si tu propriul forum GRATUIT, pe www.myforum.ro
|