Re: Win32dib?
- Posted by doncole2009 Jul 24, 2009
- 842 views
Here's the code I finally used in my CrossHairs. It's in the Archives
include win32dib.ew procedure re_instate(sequence dib,sequence oldPos) drawDib(WndMain,dib,oldPos[1], oldPos[2], 0, 0, dib[DibWidth], dib[DibHeight]) killDib(dib) end procedure procedure WndMain_onMouse (integer self, integer event, sequence params)--params is ( int event, int x, int y, int shift, int wheelmove ) sequence pos,c integer hPos,vPos,eLeft,eTop,eRight,eBot,eWidth,eHeight,diff,day atom price re_instate(hLineDib,oldHpos)------re-instate last horz line dib-------- re_instate(hRectDib,oldHRectPos)--re-instate last horz rect dib------- re_instate(vLineDib,oldVpos)------re_instate last vert line------ re_instate(vRectDib,oldVRectPos)--re-instate last vert rect------ ----------------------------------get temp constants------------------------------------ c=getClientRect(WndMain) pos = getPointerPos()--on the screen hPos=pos[1]-HPOS_OFFSET vPos=pos[2]-VPOS_OFFSET--vert position on CHART if vPos<CHART_TOP or vPos>CHART_BOT or hPos<CHART_LEFT or hPos>CHART_RIGHT then return end if eLeft=0 --window part left eTop=vPos-8--window part top eRight=c[5]--window part right eBot=vPos+8--window part bot eWidth=c[3]--window width eHeight=c[4]--window height diff=WIN_BOT-CHART_BOT oldHpos={eLeft,vPos}--HORZ_LINE oldVpos={hPos,CHART_TOP+1}--**--VERT LINE oldHRectPos={CHART_RIGHT,vPos-8}--***--HORZ RECT oldVRectPos={hPos-8,CHART_BOT}--*****--[VERT RECT]--MUST BE CHART_BOT -------------------------create dib------------------------------------------ hLineDib=newDib(eWidth,1) --****--HORZ LINE working hRectDib=newDib(eWidth,16) --***--HORZ RECT working vLineDib=newDib(1,eHeight) --VERT LINE working vRectDib=newDib(17,diff)--*****--[5] VERT RECT working at last ---------------------------------copy window portion to dib----------------------- copyToDib(hLineDib,WndMain,0,0,eLeft,vPos,eRight,vPos)--HORZ LINE working copyToDib(hRectDib,WndMain,0,0,CHART_RIGHT,vPos-8,eRight+10,vPos+8)--***--HORZ RECT working copyToDib(vRectDib,WndMain,0,0,hPos-8,CHART_BOT,hPos+8,eHeight)--*****--[5]--VERT RECT copyToDib(vLineDib,WndMain,0,0,hPos,CHART_TOP+1,hPos,eHeight)--****--VERT LINE --------------------------print the lines------------------------------- setPenColor(WndMain,White) drawHorzLine(WndMain,CHART_LEFT,CHART_RIGHT-1,vPos)------THE HORTZ LINE---- drawVertLine(WndMain,CHART_TOP+1,CHART_BOT,hPos)-- THE VERT LINE-- ------------------------print rectangles---------------------------- setPenColor(WndMain,White) -- drawRoundRect ( window, filled, x1, y1, x2, y2, xc, yc ) drawRoundRect(WndMain,1,CHART_RIGHT+3,vPos-8,CHART_RIGHT+40,vPos+8,5,5)--THE HORZ RECT *** drawRoundRect(WndMain,1,hPos-7,--left CHART_BOT,--top hPos+7,--right WIN_BOT,--bot 5,5)--THE VERT RECT *****[5] working RECT AT END OF VERT LINE -----------------------------print the text in rectangles------------------------------- setTextColor(WndMain,Black) price=getValue(vPos) day=getNum(hPos) mPutsTextHorzCent(WndMain,CHART_RIGHT+3,vPos,special(price))--print TEXT in horz rect mPutsTextVertCent(WndMain,hPos,CHART_BOT,sprintf("%d",day))--print TEXT in vert rect --draw_xy_pos(pos) end procedure setHandler( WndMain, w32HMouse, routine_id("WndMain_onMouse")) Don Cole