Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!feeder.news-service.com!216.196.110.142.MISMATCH!border3.nntp.ams.giganews.com!Xl.tags.giganews.com!border1.nntp.ams.giganews.com!nntp.giganews.com!local2.nntp.ams.giganews.com!nntp.bt.com!news.bt.com.POSTED!not-for-mail NNTP-Posting-Date: Fri, 13 May 2011 19:14:00 -0500 Date: Sat, 14 May 2011 00:58:39 +0100 From: Rik Griffin Newsgroups: comp.sys.acorn.programmer Subject: Re: Toolbox Mouse position Message-ID: <79a2fad251.rik@iyonix.hell> References: <88a93ecb-a883-48c6-abd2-76ab95f20cc7@cu4g2000vbb.googlegroups.com> Organization: None User-Agent: Messenger-Pro/1.00c (MsgServe/1.00a) (RISC-OS/5.17) NewsHound/v1.50-32 Lines: 43 X-Usenet-Provider: http://www.giganews.com X-AuthenticatedUsername: NoAuthUser X-Trace: sv3-qFuYrKzOp5XJs/neyzxRq0Vc1QUGwMDLRGyPutzGNFFrt3Ah+dixJ9ExBRzBG7YE6Aq0ks98+j0Ufgq!gFLeDrHBJRMoezdIHOT3jLV9MzThlqkt5wd1cOfCCjB6V0S1bzKzUj3rD+Q= X-Complaints-To: abuse@btinternet.com X-DMCA-Complaints-To: abuse@btinternet.com X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2840 Xref: x330-a1.tempe.blueboxinc.net comp.sys.acorn.programmer:299 In message <88a93ecb-a883-48c6-abd2-76ab95f20cc7@cu4g2000vbb.googlegroups.com> Mister Ron wrote: > > Thanks guys for the info. > I tried Martin's method then Rik's. > I'm now saving the position of the click in the click event. Then in > the menu_click event find the ComponentId. > > However some of my displayfields are greyed out and > window_wimp_to_toolbox seem to return -1 for these icons. Hmm, yes, I just tested it in ResTest and greyed out gadgets return an icon number of -1 in the mouse click event. I never knew that, or probably I did and I've forgotten it :) By the way, I was wrong originally, you don't need to set your window's background to button type 3 to see Menu clicks, it seems they are always returned. > I'm now trying to calculate the window position again so I can work > out which icon i'm over with the following: > > /* Find window Y coords */ > WimpGetWindowInfoBlock block; > block.window_handle = mouse_click_position.window_handle; > e=wimp_get_window_info( &block ); if(e) raise_error(e); > > This doesn't seem to error but crashes later with an ** unrecoverable > error in run time system : free failed > > Does this look right or is there a better method to use. Wimp_GetWindowInfo returns a block for the window AND all the icons in it. So it'll overrun the end of the WimpGetWindowInfoBlock. You can stop the icon information being written to your block by setting bit 1 of r0. But if all you want is the window position, it'd be simpler to use wimp_get_window_state which uses a WimpGetWindowStateBlock, which just basically gives you the position of the window and its flags. -- Rik Griffin