03-19-2020, 12:42 PM
In the example which it follows I have experienced that I had to use a different RECT [r1] to display the second label of text (Counts). I wonder whether this is reasonable or is it likely that I could re-use the previous RECT [r] ? Furthermore, I wonder whether there exists any simple way to draw the second label (Counts) vertically. Any advice is mostly welcome.
Function Bov_On
Function OSD_Bov
Function Bov_On
;---> Comment 19-03-2020 11:57:56 :
;str si.getmacro(getopt(itemid) 1)
;str caller.getmacro(getopt(itemid 1) 1);err caller=si
;if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : <open>%s</open>%s" NowT si _error.place si caller
int xini yini xsc ysc
xini=50; yini=40; xsc=0.8*xres; ysc=0.7*yres
int hBov
hBov=OnScreenDraw(xini yini xsc ysc &OSD_Bov 0 0 0 0 hBov)
;int rad=5
;x0=x0+10 ; y0=y0+10
;OnScreenDraw(x0+0 y0+10 rad rad &OSD_Proc_Red_Light)
;OnScreenDraw(155 140 rad rad &OSD_Proc_Red_Light)
;OnScreenDraw(160 150 rad rad &OSD_Proc_Red_Light)
;h1=OnScreenLine(250 250 400 400 175 2)
2
;OnScreenDrawEnd hBov
Function OSD_Bov
function hwnd hdc cx cy param
;---> Comment 19-03-2020 12:10:24 :
;str si.getmacro(getopt(itemid) 1)
;str caller.getmacro(getopt(itemid 1) 1);err caller=si
;if ideb; min 0; err out "<>%s : <open ''%s /%i''>%s</open> - Called by : <open>%s</open>%s" NowT si _error.place si caller
int hpen oldpen hbrush oldbrush oldfont
int xini yini ipen x00 y00 dx dy
ipen=8
xini=5; yini=5
dx=cx-(2*xini)-ipen ; dy=cy-(2*yini)-ipen
;create/select pen and draw rectangle
hpen=CreatePen(0 ipen 0xff0000); oldpen=SelectObject(hdc hpen)
RoundRect hdc xini yini cx-(2*xini) cy-(2*yini) 20 20 ;;rounded corners
;create/select brush and pen, and draw internal rectangle - background
hbrush=CreateSolidBrush(14614245); oldbrush=SelectObject(hdc hbrush)
hpen=CreatePen(0 ipen 14614245); oldpen=SelectObject(hdc hpen)
RoundRect hdc xini+ipen yini+ipen dx dy 3 3
DeleteObject SelectObject(hdc oldbrush)
DeleteObject SelectObject(hdc oldpen)
;create/select brush and pen, and draw ellipse - points - Αρχή των Αξόνων
hbrush=CreateSolidBrush(0xFF0000); oldbrush=SelectObject(hdc hbrush)
hpen=CreatePen(0 1 0xFF0000); oldpen=SelectObject(hdc hpen)
int rad=10 ;; point size
x00=50
y00=dy-40
Ellipse hdc x00 y00 x00+rad y00+rad
DeleteObject SelectObject(hdc oldbrush)
DeleteObject SelectObject(hdc oldpen)
;draw text - Label under x axis
str txt="Channel"
;create font. To create fonts easily, download CFont class from the forum
#ifdef CFont
CFont hfont.Create("Tahoma" 11 0)
oldfont=SelectObject(hdc hfont)
#endif
;set text color and transparent background
SetTextColor(hdc 0xff0000)
SetBkMode(hdc TRANSPARENT)
;set rectangle
RECT r
DrawText hdc txt -1 &r DT_CALCRECT
OffsetRect &r x00+dx-150 y00+15
;draw
DrawText hdc txt -1 &r 0
txt="Counts"
RECT r1
DrawText hdc txt -1 &r1 DT_CALCRECT
OffsetRect &r1 x00+dx-150 y00-150
;draw
DrawText hdc txt -1 &r1 0
#ifdef CFont
SelectObject hdc oldfont
#endif