Applies To:
  • CitectSCADA 1.00 1.01 1.10 1.11 1.20 2.00 2.01 3.00

Question: I have found that when calling PageInfo() from a cicode function which is executed at startup in an endless while loop, PageInfo does not always correspond to the correct page. For instance, if a page was activated via a Page command (PageDisplay() etc) then the function returns the correct page name. If however a popup is called via WinNew, then PageInfo does not acknowledge the popup as the current window and interestingly, if you call the function from a command, such as a button or keyboard command, then the correct page name is always returned. 

PageInfo is infact working correctly. When you create a cicode thread, that thread is attached to a particular window. Any output from that thread will be sent to that window and any information returned from that window. If you create another window the original cicode thread is still attached to the first window and is not effected by the new window. This allows each cicode thread to be not effected by other windows. This is normally what you want to happen so that a cicode thread can display to the correct window. If the cicode thread displayed to the current window then you would get all threads displaying to the current window and their output would get mixed together.

You may change the window each cicode thread is attached by calling the function WinSelect(). This allows you to control which window the thread will send its output and get its input. You may also find which window has the keyboard focus via the function WinGetFocus(). With these two functions I think you can get what you want to do. For example:

   nWin = WinGetFocus(); ! get window number of focus window
   WinSelect(nWin); ! make thread look at focus window
   sName = PageInfo(0); ! get page name of focus window

The function WinGetFocus() is available in version 1.20 and later.