Is there a way to get the x and y coordinates of individual lines of text within a gadget?
Just 2D in Windows. I want to determine on which entry within a list box the user did a right-click without having to select it first with a left-click.
coordinates of text
coordinates of text
Last edited by k3pto on Sun Mar 30, 2025 9:18 pm, edited 1 time in total.
Re: coordinates of text
I wonder if you mean in 3D…
-
- Addict
- Posts: 2344
- Joined: Mon Jun 02, 2003 9:16 am
- Location: Germany
- Contact:
Re: coordinates of text
Which OS? This will be highly OS specific.k3pto wrote: Sun Mar 23, 2025 10:52 pm Is there a way to get the x and y coordinates of individual lines of text within a gadget?
bye,
Daniel
Daniel
Re: coordinates of text
I'm not sure how you could get text width in purebasic but y is pretty simple. It's just font size. If you want to get the height of multiple lines then it's just font size multiplied by the number of new lines in your string
▓▓▓▓▓▒▒▒▒▒░░░░░
Re: coordinates of text
Try this out:
(heavily based on old code by Rashad!)
(heavily based on old code by Rashad!)
Code: Select all
Procedure WndProc(hWnd, uMsg, wParam, lParam)
itemh = SendMessage_(GadgetID(6), #LB_GETITEMHEIGHT, 0, 0)
Select uMsg
Case #WM_CONTEXTMENU
Select wParam
Case GadgetID(6)
GetCursorPos_(p.POINT)
ScreenToClient_ (GadgetID(6), @p)
Debug "x: " + p\x
Debug "y: " + p\y
index = Int(p\y/itemh)
Debug "Gadget 6 Item "+Str(index)
EndSelect
EndSelect
ProcedureReturn #PB_ProcessPureBasicEvents
EndProcedure
OpenWindow( 0, 0, 0, 620, 510, "TEST", #PB_Window_SystemMenu | #PB_Window_ScreenCentered )
ListViewGadget( 6, 20, 90, 280, 260, #PB_ListView_MultiSelect )
For x = 0 To 4
AddGadgetItem(6, -1, "TEST")
Next
SetWindowCallback(@WndProc())
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
SetWindowCallback(0)