Silverfrost Forums

Welcome to our forums

Child window handles

4 Apr 2020 2:12 #25140

I ran across this while building a set of child windows for %ps. I had intended to use the handle for the %sh that builds the 'tab' to enable or disable the tab using its handle. But, the handles don't seem to be valid.

Specifically, the handles returned when building the %sh is -1, as well as after the %ps has been built and the tabs active.

The code that shows this is:

	winapp
    program cmain
	use mswin
    integer:: i,j=2,k=10,l=30
    integer,external:: button1
    integer:: ps(3)
    common/sheet_test/ps
    i = winio@('%sh&',ps(1))
    i = winio@('%ca[First]%rd',j)
    i = winio@('%sh&',ps(2))
    i = winio@('%ca[Second]%rd',k)
    i = winio@('%sh&',ps(3))
    i = winio@('%ca[Third]%rd',l)
    print *,ps
    i = winio@('%3ps&',ps(1),ps(2),ps(3))
    i = winio@('%^bt[print_handles]',button1)
    end
	INTEGER(KIND=7) FUNCTION BUTTON1()
    integer:: ps(3)
    common/sheet_test/ps
	BUTTON1= -1
    print *,'Button_press=',ps
	RETURN
	END

This prints the handles assigned to the array element (named ps) before the parent window is created, and after the button press. I would have expected that at least the button press would show window handles. Alas, still -1.

My (perhaps faulty) remembrance is that after the %sh has closed the building of the child window, the control associated with the %sh then contains a handle.

4 Apr 2020 3:03 #25141

The 'handles' referred to in the documentation for %ps are not Windows HWND handles. They are variables whose addresses connect the %ps to its sheets.

You can get the Windows HWND of a sheet via %hw as in

    i = winio@('%sh&',ps(1))
    i = winio@('%hw&',h(1))
    i = winio@('%ca[First]%rd',j)

where h is INTEGER(7) h(3).

4 Apr 2020 5:16 #25143

Paul, this makes sense.

I had mused to myself before submitting the post that it must be the address of the control that is being used for %sh since everything seemed to work just fine.

It does leave one with a more complex solution to the EnableWindows way of displaying or hiding content.

Bill

Please login to reply.