Silverfrost Forums

Welcome to our forums

handle to window created using create_window

28 Oct 2021 10:51 #28396

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):INTEGER4 character(*) caption integer x0,y0,x1,y1

  CreateWindow = create_window(caption,x0,y0,x1,y1)
  end function CreateWindow
29 Oct 2021 6:22 #28403

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).

6 Dec 2021 6:47 #28571

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

6 Dec 2021 6:54 #28573

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'.

7 Dec 2021 12:32 #28577

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
7 Dec 2021 8:01 #28580

You need something like

STDCALL FINDWINDOW 'FindWindowA' (VAL7,STRING):INTEGER(7)

7 Dec 2021 8:03 #28591

Thanks! that does the trick Louis

10 Dec 2021 2:49 #28606

I did not understand what you are doing and why this way? Can you post the whole code or picture?

Please login to reply.