Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OSD grid lines
#2
Macro OSD grid
Code:
Copy      Help
int hwnd=OnScreenGrid(0 0 ScreenWidth ScreenHeight 32 1 ColorFromRGB(255 200 0) 160)
wait 2

;if need to change grid properties at run time, use hwnd
OnScreenGrid(0 0 ScreenWidth ScreenHeight 100 4 ColorFromRGB(0 200 0) 50 hwnd)
wait 2

;if need to remove the grid before the thread ends
OnScreenDrawEnd hwnd

Function OnScreenGrid
Code:
Copy      Help
;/
function# x y width height gridSize [lineThickness] [lineColor] [transparency] [hwnd]

;Shows grid on screen.
;Returns grid window handle. It can be used with OnScreenDrawEnd, or with another OnScreenGrid call (to change grid properties).
;The thread must then wait.

;x, y, width, height - where to show grid.
;gridSize - width and height of grid cells.
;lineThickness, lineColor - properties of grid lines.
;transparency - transparency of grid lines. Can be 1 (almost transparent) to 255 (opaque). If 0, does not cange.
;hwnd - handle of grid window, returned by previous OnScreenGrid call. Use if you want to dynamically change grid properties.


type OSDGRID gridSize lineThickness lineColor

if(transparency and hwnd) Transparent hwnd transparency GetSysColor(COLOR_BTNFACE) ;;OnScreenDraw doesn't change it

ret OnScreenDraw(x y width height &OSD_ProcGrid &gridSize transparency 1 sizeof(OSDGRID) hwnd)

Function OSD_ProcGrid
Code:
Copy      Help
;/
function hwnd hdc cx cy OSDGRID&g

int hpen oldpen

hpen=CreatePen(0 g.lineThickness g.lineColor); oldpen=SelectObject(hdc hpen)

ARRAY(int) ai
ARRAY(POINT) a
int i k

;horz lines

ai.create(cy/g.gridSize)
a.create(ai.len*2)
k=0
for i 0 a.len
,ai[i/2]=2
,k+g.gridSize
,a[i].y=k
,i+1
,a[i].y=k
,a[i].x=cx

PolyPolyline(hdc &a[0] &ai[0] ai.len)

;vert lines

ai.create(cx/g.gridSize)
a.create(ai.len*2)
k=0
for i 0 a.len
,ai[i/2]=2
,k+g.gridSize
,a[i].x=k
,i+1
,a[i].x=k
,a[i].y=cy

PolyPolyline(hdc &a[0] &ai[0] ai.len)

DeleteObject SelectObject(hdc oldpen)


Also you will need on-screen draw functions.
If don't have, download Archive.qml from
Collected QM apps, functions, samples
and import 'On-screen draw' folder. It is in folder 'Samples - other'.


Messages In This Thread

Forum Jump:


Users browsing this thread: 5 Guest(s)