View previous topic :: View next topic |
Author |
Message |
ljfarrugia
Joined: 06 Jun 2016 Posts: 37
|
Posted: Thu Oct 28, 2021 11:51 am Post subject: handle to window created using create_window |
|
|
I use the following code to create a window to accept text written to the standard output from Fortran. I do this so that I can control the size and caption for the Window (rather than using the default output window of Clearwin).
My question is : is it possible to obtain a handle for this window, such that another process can detect if this window is still open. Similar to the way that setting a class using %nc allows other procesess to detect whether that window is still open (using FindWindowA), in other words can a second instance of a program detect that a previous instance is still running?
integer function CreateWindow(caption,x0,y0,x1,y1)
C ---- creates a window for I/O with caption "caption"
C_EXTERNAL CREATE_WINDOW '__create_window' (INSTRING,VAL,VAL, &
&VAL,VAL):INTEGER*4
character*(*) caption
integer x0,y0,x1,y1
CreateWindow = create_window(caption,x0,y0,x1,y1)
end function CreateWindow |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8037 Location: Salford, UK
|
Posted: Fri Oct 29, 2021 7:22 am Post subject: |
|
|
ljfarrugia
The library function __create_window returns the Windows handle (HWND) of the created window. It calls the Microsoft API function CreateWindow and returns its return value. So you can use it with FindWindowA etc.
For a 64 bit application, the return value has type INTEGER(7). |
|
Back to top |
|
|
ljfarrugia
Joined: 06 Jun 2016 Posts: 37
|
Posted: Mon Dec 06, 2021 7:47 pm Post subject: |
|
|
Thanks
is the caption argument for create_window the same as thing as lpClassName? In other words could another application use that name with FindWindowsA to see if the created windows is still open? I don't see how another application can use this Window handle in FindWindowsA ?
Excuse my ignorance of Windows API, I primarily work with Clearwin
Louis |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8037 Location: Salford, UK
|
Posted: Mon Dec 06, 2021 7:54 pm Post subject: |
|
|
Use lpWindowName for the caption and NULL (zero) for lpClassName.
If you want to know the lpClassName, Plato has a "Spy" tool that is accessed from the Tools menu. Drag the target icon over the window that you have created and the name will appear in the box labelled "Class". |
|
Back to top |
|
|
ljfarrugia
Joined: 06 Jun 2016 Posts: 37
|
Posted: Tue Dec 07, 2021 1:32 am Post subject: |
|
|
Hello
I use the code below to try and see if a window created by another application using createWindow with the caption 'PLATON - Dialog Window'
exists, but the function always returns zero, even if such a window is open
program main
integer(7) :: wgxFindWindow,i
i = wgxFindWindow('PLATON - Dialog Window')
write(*,*) i
end
C
C----------------------------------------------------------------------C
C
integer function wgxFindWindow(window_name)
STDCALL FINDWINDOW 'FindWindowA' (STRING,STRING):INTEGER(7)
c Use MSWIN
character*(*) window_name
wgxFindWindow = FindWindow(0,window_name)
end |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 8037 Location: Salford, UK
|
Posted: Tue Dec 07, 2021 9:01 am Post subject: |
|
|
You need something like
STDCALL FINDWINDOW 'FindWindowA' (VAL7,STRING):INTEGER(7) |
|
Back to top |
|
|
ljfarrugia
Joined: 06 Jun 2016 Posts: 37
|
Posted: Tue Dec 07, 2021 9:03 pm Post subject: |
|
|
Thanks! that does the trick
Louis |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2877 Location: South Pole, Antarctica
|
Posted: Fri Dec 10, 2021 3:49 am Post subject: |
|
|
I did not understand what you are doing and why this way? Can you post the whole code or picture? |
|
Back to top |
|
|
|