forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

handle to window created using create_window

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
ljfarrugia



Joined: 06 Jun 2016
Posts: 35

PostPosted: Thu Oct 28, 2021 11:51 am    Post subject: handle to window created using create_window Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Fri Oct 29, 2021 7:22 am    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
ljfarrugia



Joined: 06 Jun 2016
Posts: 35

PostPosted: Mon Dec 06, 2021 7:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Mon Dec 06, 2021 7:54 pm    Post subject: Reply with quote

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
View user's profile Send private message AIM Address
ljfarrugia



Joined: 06 Jun 2016
Posts: 35

PostPosted: Tue Dec 07, 2021 1:32 am    Post subject: Reply with quote

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
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 7916
Location: Salford, UK

PostPosted: Tue Dec 07, 2021 9:01 am    Post subject: Reply with quote

You need something like

STDCALL FINDWINDOW 'FindWindowA' (VAL7,STRING):INTEGER(7)
Back to top
View user's profile Send private message AIM Address
ljfarrugia



Joined: 06 Jun 2016
Posts: 35

PostPosted: Tue Dec 07, 2021 9:03 pm    Post subject: Reply with quote

Thanks! that does the trick
Louis
Back to top
View user's profile Send private message
DanRRight



Joined: 10 Mar 2008
Posts: 2813
Location: South Pole, Antarctica

PostPosted: Fri Dec 10, 2021 3:49 am    Post subject: Reply with quote

I did not understand what you are doing and why this way? Can you post the whole code or picture?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
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