1. Previous control
- Posted by Mike777 <anon4321 at ?ma?l.com> May 10, 2008
- 786 views
I have two separate top-level windows. I want window 2 to be aware of what the last control that was touched on window 1 was. Is there an easy way for a command button on window2 to interrogate "something" and find out what control has the focus on window1? The reason I'm asking is that the controls are being built with newUIObj and therefore they depend on user input at the time. I have been successful at registering a callback for check boxes and radio buttons, but I have not been able to make a callback work for other controls (edit boxes and combo boxes, mostly). If I could make the callback work for all controls that can have focus, I would have no problem manipulating a global variable for inter-window communication. So, either way would work for me (1: make the callback work for edit and combo boxes; 2: find some other way to send information (or retrieve information)). Here is my code for the callback that works for check boxes and radio buttons: global procedure MyCheckClick (integer self, integer event, sequence params) -- previousCheckBox is a global variable, so I always know what the last -- checkbox (or radio button) that was clicked was previousCheckBox = self end procedure procedure AppCallback(integer self, integer event, sequence params) sequence mySeq mySeq = getIdName(self) -- All of my checkboxes have names that begin with "chk" -- All of my radioboxes have names that begin with "opt" if event = w32HGetHandler and compare("Click",params[1][1..5]) = 0 and ((compare(mySeq[1..3],"chk") = 0) or (compare(mySeq[1..3],"opt") = 0)) then returnValue(routine_id("MyCheckClick")) end if end procedure prevValue = setCallback(routine_id("AppCallback")) I suppose the edit boxes and combo boxes don't really have a Click event, so I'm supposed to use a different event for w32HGetHandler. Any guidance would be appreciated. Thanks Mike
2. Re: Previous control
- Posted by CChris <christian.cuvier at agric?ltu?e.gouv.fr> May 10, 2008
- 738 views
- Last edited May 11, 2008
Mike777 wrote: > > I have two separate top-level windows. I want window 2 to be aware of what > the last control that was touched on window 1 was. Is there an easy way for > a command button on window2 to interrogate "something" and find out what > control > has the focus on window1? > > The reason I'm asking is that the controls are being built with newUIObj and > therefore they depend on user input at the time. > > I have been successful at registering a callback for check boxes and radio > buttons, > but I have not been able to make a callback work for other controls (edit > boxes > and combo boxes, mostly). > > If I could make the callback work for all controls that can have focus, I > would > have no problem manipulating a global variable for inter-window communication. > > So, either way would work for me (1: make the callback work for edit and combo > boxes; 2: find some other way to send information (or retrieve information)). > > Here is my code for the callback that works for check boxes and radio buttons: > > global procedure MyCheckClick (integer self, integer event, sequence params) > -- previousCheckBox is a global variable, so I always know what the last > -- checkbox (or radio button) that was clicked was > previousCheckBox = self > end procedure > > procedure AppCallback(integer self, integer event, sequence params) > sequence mySeq > mySeq = getIdName(self) > -- All of my checkboxes have names that begin with "chk" > -- All of my radioboxes have names that begin with "opt" > if event = w32HGetHandler and > compare("Click",params[1][1..5]) = 0 and > ((compare(mySeq[1..3],"chk") = 0) > or (compare(mySeq[1..3],"opt") = 0)) then > returnValue(routine_id("MyCheckClick")) > end if > end procedure > prevValue = setCallback(routine_id("AppCallback")) > > I suppose the edit boxes and combo boxes don't really have a Click event, so > I'm supposed to use a different event for w32HGetHandler. > > Any guidance would be appreciated. > > Thanks > > Mike Why not simply add an w32HGotFocus event handler to all the controls you are interested in? The common handler would save in a variable you define the id of the control for which it is called (or stack them if you need more), and then you retrieve them. Doesn't work? CChris
3. Re: Previous control
- Posted by Mike777 <anon4321 at g?ail?com> May 12, 2008
- 736 views
CChris wrote: > > Mike777 wrote: > > > > I suppose the edit boxes and combo boxes don't really have a Click event, so > > I'm supposed to use a different event for w32HGetHandler. > > > > Any guidance would be appreciated. > > > > Thanks > > > > Mike > > Why not simply add an w32HGotFocus event handler to all the controls you are > interested in? > The common handler would save in a variable you define the id of the control > for which it is called (or stack them if you need more), and then you retrieve > them. > Doesn't work? Almost. w32HGotFocus doesn't fire when the mouse is clicked into a combobox. I tried w32HEvent, but then just passing the mouse over the control activates the event procedure, undoing what I've done by clicking in the cbo. It works for Text Boxes, Radio Buttons and Check Boxes. Is there a substitute for w32HGotFocus that works on combo boxes? [Yes, I've looked but I haven't found one, yet.] Mike
4. Re: Previous control
- Posted by CChris <christian.cuvier at agricultur?.gouv.?r> May 12, 2008
- 740 views
- Last edited May 13, 2008
Mike777 wrote: > > CChris wrote: > > > > Mike777 wrote: > > > > > > I suppose the edit boxes and combo boxes don't really have a Click event, > > > so > > > I'm supposed to use a different event for w32HGetHandler. > > > > > > Any guidance would be appreciated. > > > > > > Thanks > > > > > > Mike > > > > Why not simply add an w32HGotFocus event handler to all the controls you are > > interested in? > > The common handler would save in a variable you define the id of the control > > for which it is called (or stack them if you need more), and then you > > retrieve > > them. > > Doesn't work? > > Almost. w32HGotFocus doesn't fire when the mouse is clicked into a combobox. > I tried w32HEvent, but then just passing the mouse over the control activates > the event procedure, undoing what I've done by clicking in the cbo. > > It works for Text Boxes, Radio Buttons and Check Boxes. > > Is there a substitute for w32HGotFocus that works on combo boxes? [Yes, I've > looked but I haven't found one, yet.] > > Mike I didn't have time to check (busy documenting sets.e and adding more tests, and I certainly type 10x slower than Jeremy). I don't see why combo boxes wouldn't fire w32HGotFocus. If I can confirm this I'll fix it, Bill forbid. CChris
5. Re: Previous control
- Posted by Mike777 <anon4321 at gma?l.co?> May 13, 2008
- 722 views
CChris wrote: > > Mike777 wrote: > > > > CChris wrote: > > > > > > Mike777 wrote: > > > > > > > > I suppose the edit boxes and combo boxes don't really have a Click > > > > event, so > > > > I'm supposed to use a different event for w32HGetHandler. > > > > > > > > Any guidance would be appreciated. > > > > > > > > Thanks > > > > > > > > Mike > > > > > > Why not simply add an w32HGotFocus event handler to all the controls you > > > are > > > interested in? > > > The common handler would save in a variable you define the id of the > > > control > > > for which it is called (or stack them if you need more), and then you > > > retrieve > > > them. > > > Doesn't work? > > > > Almost. w32HGotFocus doesn't fire when the mouse is clicked into a > > combobox. > > I tried w32HEvent, but then just passing the mouse over the control > > activates > > the event procedure, undoing what I've done by clicking in the cbo. > > > > It works for Text Boxes, Radio Buttons and Check Boxes. > > > > Is there a substitute for w32HGotFocus that works on combo boxes? [Yes, > > I've > > looked but I haven't found one, yet.] > > > > Mike > > I didn't have time to check (busy documenting sets.e and adding more tests, > and I certainly type 10x slower than Jeremy). I don't see why combo boxes > wouldn't > fire w32HGotFocus. If I can confirm this I'll fix it, Bill forbid. I think it has something to do with the fact that the combo box is really two controls tied up together. In any event, my travels lead me to the following: 1) The GotFocus() event fires if the combo box is entered via a tab (either a regular tab or a shift tab) 2) The GotFocus() event does not fire if the mouse is used to select the combo box 3) I haven't tested whether a SetFocus command has the effect of firing the GotFocus event (not that I would be using this, anyway). My application requires that the comboboxes be empty at the moment. I'm wondering if that makes a difference. That is, I could load an item into each combobox and that would enable the dropdown event to fire. I don't think it can right how, because there aren't any items. But this is just a bad workaround anyway, so I'll use this only as a backup plan at the moment. Mike
6. Re: Previous control
- Posted by Mike777 <anon4321 at gmail.c?m> May 13, 2008
- 744 views
Mike777 wrote: > > CChris wrote: > > > > Mike777 wrote: > > > > > > CChris wrote: > > > > > > > > Mike777 wrote: > > > > > > > > > > I suppose the edit boxes and combo boxes don't really have a Click > > > > > event, > so</font></i> > > > > > I'm supposed to use a different event for w32HGetHandler. > > > > > > > > > > Any guidance would be appreciated. > > > > > > > > > > Thanks > > > > > > > > > > Mike > > > > > > > > Why not simply add an w32HGotFocus event handler to all the controls you > > > > are > > > > interested in? > > > > The common handler would save in a variable you define the id of the > > > > control > > > > for which it is called (or stack them if you need more), and then you > > > > retrieve > > > > them. > > > > Doesn't work? > > > > > > Almost. w32HGotFocus doesn't fire when the mouse is clicked into a > > > combobox. > > > I tried w32HEvent, but then just passing the mouse over the control > > > activates > > > the event procedure, undoing what I've done by clicking in the cbo. > > > > > > It works for Text Boxes, Radio Buttons and Check Boxes. > > > > > > Is there a substitute for w32HGotFocus that works on combo boxes? [Yes, > > > I've > > > looked but I haven't found one, yet.] > > > > > > Mike > > > > I didn't have time to check (busy documenting sets.e and adding more tests, > > and I certainly type 10x slower than Jeremy). I don't see why combo boxes > > wouldn't > > fire w32HGotFocus. If I can confirm this I'll fix it, Bill forbid. I have a workaround. For those controls that have a GotFocus event, as per your suggestion. For those that don't, params[1]=273 seems to execute only once when the control is selected with the mouse, so I added the w32HEvent but filtered on params[1]=273. Seems to work for now. I attempted to find someplace which would identify the parameter codes (and the other parameters, for that matter) to no avail. So, for now, it was trial and error (thank you pretty_print) and search for a code that occurs exactly once each time a control is selected. Not at all elegant, but functional. Mike
7. Re: Previous control
- Posted by CChris <christian.cuvier at ?gricul?ure.gouv.fr> May 13, 2008
- 757 views
Mike777 wrote: > > Mike777 wrote: > > > > CChris wrote: > > > > > > Mike777 wrote: > > > > > > > > CChris wrote: > > > > > > > > > > Mike777 wrote: > > > > > > > > > > > > I suppose the edit boxes and combo boxes don't really have a Click > > > > > > event, > > so</font></i> > > > > > > I'm supposed to use a different event for w32HGetHandler. > > > > > > > > > > > > Any guidance would be appreciated. > > > > > > > > > > > > Thanks > > > > > > > > > > > > Mike > > > > > > > > > > Why not simply add an w32HGotFocus event handler to all the controls > > > > > you > are</font></i> > > > > > interested in? > > > > > The common handler would save in a variable you define the id of the > > > > > control > > > > > for which it is called (or stack them if you need more), and then you > > > > > retrieve > > > > > them. > > > > > Doesn't work? > > > > > > > > Almost. w32HGotFocus doesn't fire when the mouse is clicked into a > > > > combobox. > > > > I tried w32HEvent, but then just passing the mouse over the control > > > > activates > > > > the event procedure, undoing what I've done by clicking in the cbo. > > > > > > > > It works for Text Boxes, Radio Buttons and Check Boxes. > > > > > > > > Is there a substitute for w32HGotFocus that works on combo boxes? [Yes, > > > > I've > > > > looked but I haven't found one, yet.] > > > > > > > > Mike > > > > > > I didn't have time to check (busy documenting sets.e and adding more > > > tests, > > > and I certainly type 10x slower than Jeremy). I don't see why combo boxes > > > wouldn't > > > fire w32HGotFocus. If I can confirm this I'll fix it, Bill forbid. > > I have a workaround. For those controls that have a GotFocus event, as per > your suggestion. For those that don't, params[1]=273 seems to execute only > once when the control is selected with the mouse, so I added the w32HEvent but > filtered on params[1]=273. > > Seems to work for now. > > I attempted to find someplace which would identify the parameter codes (and > the other parameters, for that matter) to no avail. So, for now, it was trial > and error (thank you pretty_print) and search for a code that occurs exactly > once each time a control is selected. > > Not at all elegant, but functional. > > Mike The list is called winuser.h, and it is fairly easy to get. There are holes in that list, and I found other references that were filling some of the holes. I'm not sure, however, whether these messages are very helpful: * some come from older versions of Windows (typically WM_TESTING or WM_COMPACTING) * some are probably specific to Wine, Windows CE or such variants * and for some I don't have a clue (like WM_SIZEWAIT). This one is not bad: http://wiki.winprog.org/wiki/Windows_messages but it has holes too. Some other pages do fill these gaps, but then not the others. There is no such list on MSDN - shame on them! CChris
8. Re: Previous control
- Posted by CChris <christian.cuvier at ag?iculture.gouv?fr> May 13, 2008
- 748 views
Mike777 wrote: > > Mike777 wrote: > > > > CChris wrote: > > > > > > Mike777 wrote: > > > > > > > > CChris wrote: > > > > > > > > > > Mike777 wrote: > > > > > > > > > > > > I suppose the edit boxes and combo boxes don't really have a Click > > > > > > event, > > so</font></i> > > > > > > I'm supposed to use a different event for w32HGetHandler. > > > > > > > > > > > > Any guidance would be appreciated. > > > > > > > > > > > > Thanks > > > > > > > > > > > > Mike > > > > > > > > > > Why not simply add an w32HGotFocus event handler to all the controls > > > > > you > are</font></i> > > > > > interested in? > > > > > The common handler would save in a variable you define the id of the > > > > > control > > > > > for which it is called (or stack them if you need more), and then you > > > > > retrieve > > > > > them. > > > > > Doesn't work? > > > > > > > > Almost. w32HGotFocus doesn't fire when the mouse is clicked into a > > > > combobox. > > > > I tried w32HEvent, but then just passing the mouse over the control > > > > activates > > > > the event procedure, undoing what I've done by clicking in the cbo. > > > > > > > > It works for Text Boxes, Radio Buttons and Check Boxes. > > > > > > > > Is there a substitute for w32HGotFocus that works on combo boxes? [Yes, > > > > I've > > > > looked but I haven't found one, yet.] > > > > > > > > Mike > > > > > > I didn't have time to check (busy documenting sets.e and adding more > > > tests, > > > and I certainly type 10x slower than Jeremy). I don't see why combo boxes > > > wouldn't > > > fire w32HGotFocus. If I can confirm this I'll fix it, Bill forbid. > > I have a workaround. For those controls that have a GotFocus event, as per > your suggestion. For those that don't, params[1]=273 seems to execute only > once when the control is selected with the mouse, so I added the w32HEvent but > filtered on params[1]=273. > > Seems to work for now. > > I attempted to find someplace which would identify the parameter codes (and > the other parameters, for that matter) to no avail. So, for now, it was trial > and error (thank you pretty_print) and search for a code that occurs exactly > once each time a control is selected. > > Not at all elegant, but functional. > > Mike In its unfathomable wisdom, Windows does not send WM_SETFOCUS to a combo box when clicked. That's why w32HGotFocus doesn't fire. It is not related to the combo being empty. What you get is an old style notification message (CBN_SETFOCUS) through WM_COMMAND (the ubiquitous 273). I'll add code to fire w32HGotFocus on this notification tonight. Not difficult, but not a one liner either, I need to add a test to wmCommand() for that. CChris PS: Judith, I didn't forget about ColoredButtons! but I wanted to get the tax forms done, and am busy documenting and unit-testing sets.e for inclusion in the new standard lib. Will look into it ASAP. Derek: if you need more time, could you email me, so that I post a later date for releasing 70.4a?