Oxygen Basic
Programming => Problems & Solutions => Topic started by: Aurel on May 17, 2012, 07:41:16 AM
-
Hmmm...
I try use method which Peter use in window.inc that i can on simple way
draw text on window and that this text or primitive graphics stay all the time visible.
when you move your window across the screen or you minimize then maximize window.
For example like function:
PrintAT (hwnd,x,y,text,color)
Because when you want create more then one window hwnd parameter is important.
I don't know why i cannot replicate Peter function to do this properly?
-
Here is peter Text():
Sub Text( sys x, y, string txt, sys r,g,b)
color = r + g*256 + b*65536
SetTextColor bHdc, color
TextOut bHdc,x,y,txt,Len(txt)
End Sub
And here is mine TextOn():
Sub TextOn( int wnd,sys x, y, string txt, sys r,g,b)
'sys_hdc=GetDC(wnd)
'bHnd = CreateCompatibleBitmap(sys_hdc,128,24)
'bHdc = CreateCompatibleDC(sys_hdc)
'SelectObject bHdc, bHnd
SetBkMode tHdc,1
color = r + g*256 + b*65536
SetTextColor bHdc, color
TextOut bHdc,x,y,txt,Len(txt)
ReleaseDC(bhdc)
End Sub
It looks that work...hmmm
is this right way to properly add permanent text to window.
I test this function on example Sunflower:
include "win64.inc"
sys win
win=Window "SUN FLOWER",640,480,2
'TextOn(win,0,0,"PrintMe",200,0,0)
single r0=7.21,r1=2.11,r2=1.55,fc=30,st=.005,i
single inic=0,fi=80,pi=3.141592,x2,y2,a0,a1,x1,y1
x0 = 8*fc
y0 = 8*fc
ClsColor 200,200,248
For i=inic to fi step st
a0=(i/r0)*(2*pi)
a1=((i/r1)*(2*pi))*-1
x1=x0+(sin(a0)*((r0-r1)*fc))
y1=y0+(cos(a0)*((r0-r1)*fc))
x2=x1+(sin(a1)*((r2)*fc))
y2=y1+(cos(a1)*((r2)*fc))
Poke x2+80,y2-12,0,0,0
Next
TextOn(win,0,0,"PrintMe",200,0,0)
Oval 210,120,220,220,255,255,0
Pause
WinEnd
How work for you ?
-
Peter ...
heh why is bad?
explain little bit if is no problem.
From what i see only difference is because you add font,right?
And of course you include flipbuffer.
But you miss one important thing what if you create more windows ,what then?
Your window handler don't exists,right?
-
By the way, TextOn is not your idea, it is a copy of mine.
You are destroying my holy works!
;D
Hey maybe is this your idea to .. ;)
Procedure Text(_tx,_ty,_ttext.s)
TextOut(_drw_out_,_tx,_ty,_ttext,Len(_ttext))
EndProcedure
Procedure TextColor(_tc1,_tc2)
_textc1_=_tc1
_textc2_=_tc2
If _drw_out_
SetTextColor(_drw_out_,_textc1_)
SetBkColor(_drw_out_,_textc2_)
EndIf
EndProcedure
Procedure TransparentDraw(_did,xp,yp,BMPWidth,BMPHeight,trx,try,borg,horg)
Declare TransColor,obj,BmpBackOld,BmpObjectOld,BmpMemOld,BmpSaveOld,HdcMem,HdcBack,HdcObject
Declare HdcSave,HdcTemp,hzwischen,BmPAndBack,BmPAndObject,BmPAndMem,BmPSave,_source,hdc
_source=_drwbitmap(_did,1):hdc=_drw_out_
hzwischen=CreateCompatibleBitmap(hdc,BMPWidth,BMPHeight)
HdcTemp=CreateCompatibleDC(hdc)
obj=SelectObject(HdcTemp,hzwischen)
HdcBack=CreateCompatibleDC(hdc)
HdcObject=CreateCompatibleDC(hdc)
HdcMem=CreateCompatibleDC(hdc)
HdcSave=CreateCompatibleDC(hdc)
BmPAndBack=CreateBitmap(BMPWidth,BMPHeight,1,1,0)
BmPAndObject=CreateBitmap(BMPWidth,BMPHeight,1,1,0)
BmPAndMem=CreateCompatibleBitmap(hdc,BMPWidth,BMPHeight)
BmPSave=CreateCompatibleBitmap(hdc,BMPWidth,BMPHeight)
SetMapMode(HdcTemp,GetMapMode(hdc))
BmpBackOld=SelectObject(HdcBack,BmPAndBack)
BmpObjectOld=SelectObject(HdcObject,BmPAndObject)
BmpMemOld=SelectObject(HdcMem,BmPAndMem)
BmpSaveOld=SelectObject(HdcSave,BmPSave)
SetStretchBltMode(HdcTemp,#COLORONCOLOR)
StretchBlt(HdcTemp,0,0,BMPWidth,BMPHeight,_source, trx, try, borg, horg,#SRCCOPY)
TransColor=GetPixel(HdcTemp,Sub(BMPWidth,1),0)
SetMapMode(HdcTemp,GetMapMode(hdc))
BitBlt(HdcSave,0,0,BMPWidth,BMPHeight,HdcTemp,0,0,13369376)
SetBkColor(HdcTemp,TransColor)
BitBlt(HdcObject,0,0,BMPWidth,BMPHeight,HdcTemp,0,0,13369376)
SetBkColor(HdcTemp,16777215)
BitBlt(HdcBack,0,0,BMPWidth,BMPHeight,HdcObject,0,0,3342344)
BitBlt(HdcMem,0,0,BMPWidth,BMPHeight,_drw_out_,xp,yp,13369376)
BitBlt(HdcMem,0,0,BMPWidth,BMPHeight,HdcObject,0,0,8913094)
BitBlt(HdcTemp,0,0,BMPWidth,BMPHeight,HdcBack,0,0,8913094)
BitBlt(HdcMem,0,0,BMPWidth,BMPHeight,HdcTemp,0,0,15597702)
BitBlt(HdcTemp,0,0,BMPWidth,BMPHeight,HdcMem,0,0,13369376)
BitBlt(_drw_out_,xp,yp,BMPWidth,BMPHeight,HdcTemp,0,0,13369376)
DeleteObject(obj)
DeleteObject(BmpBackOld)
DeleteObject(BmpObjectOld)
DeleteObject(BmpMemOld)
DeleteObject(BmpSaveOld)
DeleteDC(HdcMem)
DeleteDC(HdcBack)
DeleteDC(HdcObject)
DeleteDC(HdcSave)
DeleteDC(HdcTemp)
DeleteObject(hzwischen)
DeleteObject(BmPAndBack)
DeleteObject(BmPAndObject)
DeleteObject(BmPAndMem)
DeleteObject(BmPSave)
EndProcedure
-
I can easy say same for all your work to... ;)
Hey put the pipe down... ;D
-
I can easy say same for all your work to... ;)
Hey put the pipe down... ;D
Seems Casper made a big impression on you. :D