How is the control handle of a control causing a callback determined?
control id in a callback
You may need to use %lc. If not then a short illustrative sample would help me to understand what you are looking for.
Paul,
I seem to have got it to work, I was originally confused by the result being some unknown window ID. It transpired that because the callback printed the result to an output window it perhaps returned the ID of that window instead. The subsequent callback results were correct. The solution was to open the output window before the winio@ calls and then the callback results were correct. Eventually I got it to work, and settled on using the 'focussed_window' value.
It would be useful if there was a clearwin_info@ parameter that just returned the 'CONTROL_ID', without the need for a focus_monitor.
Regards
Ian
The code is below.
winapp
include <windows.ins>
external icallback,ifw_cb,icw_cb
common/data_stuff/ival(3),ihandle(3),ifw,icw,ihw
call add_focus_monitor@(ifw_cb)
call add_cursor_monitor@(icw_cb)
!first callback event gives wrong result if the output window is not activated first - see line below
print *,'started output window'
ival=0
i=winio@('%ca[Control id]&')
i=winio@('%ff%8^rd%lc&',ival(1),icallback,ihandle(1))
i=winio@('%ff%8^rd%lc&',ival(2),icallback,ihandle(2))
i=winio@('%ff%^`rb[Press me]%lc&',ival(3),icallback,ihandle(3))
i=winio@('%ff%bt[End]%hw&',ihw)
!don't really need the line below
i=winio@('%sc','+',ifw_cb,icw_cb)
!alternative version to output focus and cursor IDs every 5 seconds
!i=winio@('%sc%dl','+',ifw_cb,icw_cb,5d0,icallback)
call remove_focus_monitor@(ifw_cb)
call remove_cursor_monitor@(icw_cb)
end
integer*4 function icallback()
include <windows.ins>
common/data_stuff/ival(3),ihandle(3),ifw,icw,ihw
print *,ihandle,ihw
print *,'focussed_window',ifw
print *,'cursor_window ',icw
icallback=2
end
integer*4 function ifw_cb()
include <windows.ins>
common/data_stuff/ival(3),ihandle(3),ifw,icw,ihw
ifw=clearwin_info@('focussed_window')
ifw_cb=2
end
integer*4 function icw_cb()
include <windows.ins>
common/data_stuff/ival(3),ihandle(3),ifw,icw,ihw
icw=clearwin_info@('cursor_window')
icw_cb=2
end
It is not clear from your sample why you need the focus window hwnd. Why not have a different callback for each control?
Because I'm writing something that allows the windows to be tailored by a list of commands in a text file, and currently one window is up to about 350 controls, shortly to be over 400. A lot of these controls have the same callback and I have an array defining the appropriate callback for each control; I just needed to find which control, to know which callback.
Regards
Ian
I have added a new clearwin_info@ parameter 'CURRENT_CONTROL' that gives the hwnd directly in the callback function icallback. It works fine with your sample. I can send you a salflibc.dll to try if you wish.
Paul,
Thanks, that would be great if you could send me the dll
Regards
Ian
I'm not sure if I have correctly understood the problem. I once wrote an app where I was grappling with what I *think *is the same problem. The way I tackled it was to use two Clear Win+ standard callbacks, '+' and 'SET'. Everywhere I used a callback, I actually invoked the sequence of callbacks:
'+', 'SET', flag, flagval, mycallback
and checked flagval inside mycallback to find which control was responsible for firing it.
Does that help?
Andy