|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Fri Dec 05, 2008 10:28 am Post subject: control id in a callback |
|
|
How is the control handle of a control causing a callback determined? |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Dec 05, 2008 12:30 pm Post subject: |
|
|
You may need to use %lc. If not then a short illustrative sample would help me to understand what you are looking for. |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Fri Dec 05, 2008 2:28 pm Post subject: |
|
|
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.
Code: |
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
|
|
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Fri Dec 05, 2008 3:49 pm Post subject: |
|
|
It is not clear from your sample why you need the focus window hwnd.
Why not have a different callback for each control? |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Mon Dec 08, 2008 4:31 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7927 Location: Salford, UK
|
Posted: Mon Dec 08, 2008 7:16 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
IanLambley
Joined: 17 Dec 2006 Posts: 490 Location: Sunderland
|
Posted: Tue Dec 09, 2008 3:05 pm Post subject: |
|
|
Paul,
Thanks, that would be great if you could send me the dll
Regards
Ian |
|
Back to top |
|
|
sparge
Joined: 11 Apr 2005 Posts: 371
|
Posted: Fri Dec 12, 2008 12:32 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
|
|
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
|