On 21 Jan 2011, at 10:14, Norman Dunbar wrote: > > I've written a small demo program to show the things that happen when an > application sub-window is hit in a PE program. The program has a window > containing a single application sub-window. > > The hit routine does nothing more than this: > > ahit0 movem.l d1/d3/d5-d7/a0/a4,-(a7) ; Save the workers > moveq #0,d1 ; D1.W = Application sub window number > moveq #0,d2 ; D2.W = Ink colour > ; A4 already set to Working definition > jsr wm_swapp(a2) ; Set channel id (A0) to the subwindow > > movem.l a1-a2,-(a7) ; A1 gets corrupted > lea hit,a1 ; Text string to print > move.w ut_mtext,a2 ; Print string vector > jsr (a2) ; Print the message > > lea hitter,a1 ; Hit counter location > move.w (a1),d1 ; Hit counter value > addq.w #1,d1 ; Increment counter > move.w d1,(a1) ; Save counter > move.w ut_mint,a2 ; Print integer vector > jsr (a2) ; Print it > > movem.l (a7)+,a1-a2 ; Restore > > movem.l (a7)+,d1/d3/d5-d7/a0/a4 ; Restore the workers > moveq #0,d0 ; No errors > rts > > ; Strings and things go here > > hitter dc.w 0 ; How many times have I been hit? > > hit dc.w hit_e-hit-2 ; Hit message > dc.b 'HIT: ' > hit_e equ * > > Now, when run I notice the following "foibles": > > 1. The hit code is called when the pointer enters the sub-window, and > each time it moves within the sub-window. > > 2. Pressing the TAB key, which activates the sub-window, the counter > increases by TWO and not one. > > 3. Pressing the F1 key also increases the count by two. > > 4. Other keys, I have not tested everything, increment the counter by one. > > There are no menus or anything in the sub-window, it is used simply as a > display area by the program, aub-window menus come in a later article! >
The hit routine is called by PE in many cases. For example the manual says "If there is no keystroke, or the keystroke is not the selection keystroke for a loose menu item or an application sub-window, then, if the pointer is within a sub-window, the hit routine is called, or else the loose menu item list is searched to find a new current item". F1 causes an event and so will cause the hit routine to be called. > Another question, I only have a single sub-window. If I comment out the > call to WM_SWAPP in the hit routine, I still see my output in the > sub-window, but it is not cleared before hand. (I can live with this) > but when I was writing PE stuff using SuperBasic and EasyPTR 3, I always > had to set the channel to the sub-window (or info window or whatever) > before I could write to it. > Commenting out WM_SWAPP is not a good idea. When I tried this program, or something very like it, HIT appeared in the main window. However, accessing the application window by a selection key caused HIT to appear in the application window. Obviously, the PE redefines the window area depending on where it finds the pointer. > So, My further queries are: > > 1. Do I need to call WM_SWAPP if I only have one sub-window or can I > assume that the channel id always refers to the sub-window regardless > unless I explicitly set it to a loose item or whatever? > You have to use WM_SWAPP > 2. If I have two or more sub-windows, does the channel id, by default, > point at the first - I haven't tested this yet - If I don't call WM_SWAPP? > No George _______________________________________________ QL-Users Mailing List http://www.q-v-d.demon.co.uk/smsqe.htm
