structures, and tabitem right-click hittest
- Posted by "danielmoyer" <danielmoyer at prodigy.net> Dec 05, 2003
- 628 views
Jordah, Derek, Euman, etc: Not knowing what I was doing, I tried to modify Jordah's example2.exw (using his llrtns.ew), to indicate which tabitem is right-clicked on, with the following tacked on at the end of example2.exw, just before WinMain, but it doesn't work. Fails trying to read memory at FFFFFFFF. (I made "htFlags" = 0 because it failed at the store without something there as a value, not for any other reason.) Relevant structure info(?) is after code. Without the tabitem hittest part, the mouse rightclick on tab position is returned just fine. Can anyone make this work right? It tacks onto end of Jordah's Example2.exw, which can be found with his llrtns.ew low level routines library at: http://www.rapideuphoria.com/llrtns.zip Dan Moyer -------------------[ POINT STRUCTURE ???]------------------- sequence POINT POINT = defineStructure({ {"x" ,C_LONG}, {"y" ,C_LONG} }) -------------------[ HITTESTINFO STRUCTURE ??? ]------------------- sequence HITTESTINFOSTRUCT HITTESTINFOSTRUCT = defineStructure({ {"mousePoint" , POINT}, {"htFlags" ,C_UINT} }) function rtClickedTab(atom Tab, integer x, integer y) Store(HITTESTINFOSTRUCT, {{"mousePoint" ,{x,y}},{"htFlags", 0}}) junk = sendMessage(Tab, TCM_HITTEST, 0, addressOf(HITTESTINFOSTRUCT)) return junk end function ----- mouse handler ------------- procedure Tab_onMouse (integer self, integer event, sequence params) --params is ( int event, int x, int y, int shift ) integer aTab if equal(params[1], RIGHT_DOWN) then setText({status,1}, "right down: " & sprint(params[2])) aTab = rtClickedTab(Tab, params[2], params[3]) setText({status,2}, sprint(aTab)) else setText(status, " ") end if end procedure setHandler( Tab, w32HMouse, routine_id("Tab_onMouse")) 1. TCM_HITTEST Message ---- Determines which tab, if any, is at a specified screen position. You can send this message explicitly or by using the TabCtrl_HitTest macro. Syntax To send this message, call the SendMessage function as follows. lResult = SendMessage( // returns LRESULT in lResult (HWND) hWndControl, // handle to destination control (UINT) TCM_HITTEST, // message ID (WPARAM) wParam, // = 0; not used, must be zero (LPARAM) lParam // = (LPARAM) (LPTCHITTESTINFO) pinfo; ); Parameters wParam Must be zero. pinfo Pointer to a TCHITTESTINFO structure that specifies the screen position to test. Return Value Returns the index of the tab, or -1 if no tab is at the specified position. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2. TCHITTESTINFO Structure ---- Contains information about a hit test. This structure supersedes the TC_HITTESTINFO structure. Syntax typedef struct tagTCHITTESTINFO { POINT pt; UINT flags; } TCHITTESTINFO, *LPTCHITTESTINFO; Members pt Position to hit test, in client coordinates. flags Variable that receives the results of a hit test. The tab control sets this member to one of the following values: TCHT_NOWHERE The position is not over a tab. TCHT_ONITEM The position is over a tab but not over its icon or its text. For owner-drawn tab controls, this value is specified if the position is anywhere over a tab. TCHT_ONITEMICON The position is over a tab's icon. TCHT_ONITEMLABEL The position is over a tab's text. TCHT_ONITEM is a bitwise-OR operation on TCHT_ONITEMICON and TCHT_ONITEMLABEL. Dan Moyer