Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Shared memory
#1
Using the share function, how do you get the share address into variables that don't assign by "=", like a POINT variable for example.
Function Function72
Code:
Copy      Help
int hwnd=win("Program Manager" "Progman")
int hlv=id(1 "Program Manager")
int n=SendMessage(hlv LVM_GETITEMCOUNT 0 0)
ARRAY(POINT) p.create(n)
for int'i 0 n
,lock _share
,SendMessage(hlv LVM_GETITEMPOSITION i share(hwnd))
,p[i]=+share
,lock- _share
#2
Macro
Code:
Copy      Help
int hwnd=win("Program Manager" "Progman")
int hlv=id(1 "Program Manager")
int n=SendMessage(hlv LVM_GETITEMCOUNT 0 0)
ARRAY(POINT) p.create(n)
lock _share
for int'i 0 n
,SendMessage(hlv LVM_GETITEMPOSITION i share(hwnd))
,memcpy &p[i] share sizeof(POINT)
lock- _share

for i 0 p.len
,out "%i %i" p[i].x p[i].y
,

or

Macro
Code:
Copy      Help
int hwnd=win("Program Manager" "Progman")
int hlv=id(1 "Program Manager")
int n=SendMessage(hlv LVM_GETITEMCOUNT 0 0)
ARRAY(POINT) p.create(n)
lock _share
POINT& pqm=share
for int'i 0 n
,SendMessage(hlv LVM_GETITEMPOSITION i share(hwnd))
,p[i]=pqm
lock- _share

for i 0 p.len
,out "%i %i" p[i].x p[i].y
,
#3
Both work perfectly, thanks!
#4
will be faster if you call share(hwnd) not in for.

Macro
Code:
Copy      Help
int hwnd=win("Program Manager" "Progman")
int hlv=id(1 "Program Manager")
int n=SendMessage(hlv LVM_GETITEMCOUNT 0 0)
ARRAY(POINT) p.create(n)
lock _share
POINT& pqm=share
POINT& pe=share(hwnd)
for int'i 0 n
,SendMessage(hlv LVM_GETITEMPOSITION i &pe)
,p[i]=pqm
lock- _share

for i 0 p.len
,out "%i %i" p[i].x p[i].y
,


Forum Jump:


Users browsing this thread: 1 Guest(s)