PtInRect Parameters
Posted: Fri Feb 24, 2012 10:06 am
This code, by netmaestro, posted in an earlier thread, demonstrated the use of the PtInRect API:In the discussion, it was said that the PtInRect API required 3 parameters, the RECT, and the X & Y points. However, the code doesn't work, yielding to an error of [PtInRect_(): Incorrect number of parameters]. Further searching on the forum resulted in an alternative solution which works, where the X & Y points have somehow been merged:Is the earlier declaration with 3 parameters no longer supported by PureBasic? And what does this equation (click\y<<32+click\x) actually do?
Thank you.
Code: Select all
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ListIconGadget(0,0,0,320,240,"Name",160)
AddGadgetColumn(0,1,"Type",80)
AddGadgetColumn(0,1,"Size",60)
header = SendMessage_(GadgetID(0),#LVM_GETHEADER,0,0)
Repeat
ev = WaitWindowEvent(1)
GetWindowRect_(header, @wr.rect)
If PtInRect_(wr, DesktopMouseX(),DesktopMouseY())
ShowWindow_(header, #SW_HIDE)
dc = GetDC_(GadgetID(0))
TextOut_(dc, 100,0, PeekS(?begin), 15)
ReleaseDC_(GadgetID(0),dc)
Else
ShowWindow_(header, #SW_SHOW)
EndIf
Until ev = #WM_CLOSE
DataSection
begin:
Data.q 7453301692552738114,9400190730641523
Code: Select all
Define click.Point
OpenWindow(0,0,0,320,240,"void",#PB_Window_SystemMenu | #PB_Window_ScreenCentered)
CreateGadgetList(WindowID(0))
ListIconGadget(0,0,0,320,240,"Name",160)
AddGadgetColumn(0,1,"Type",80)
AddGadgetColumn(0,1,"Size",60)
header = SendMessage_(GadgetID(0),#LVM_GETHEADER,0,0)
Repeat
ev = WaitWindowEvent(1)
GetWindowRect_(header, @wr.rect)
click\x = DesktopMouseX()
click\y = DesktopMouseY()
If PtInRect_(wr, click\y<<32+click\x)
ShowWindow_(header, #SW_HIDE)
dc = GetDC_(GadgetID(0))
TextOut_(dc, 100,0, PeekS(?begin), 16)
ReleaseDC_(GadgetID(0),dc)
Else
ShowWindow_(header, #SW_SHOW)
EndIf
Until ev = #WM_CLOSE
DataSection
begin:
Data.q 7598523934101894480,2410381742072537187
Thank you.