📄 graph.c
字号:
// if(tim == 0) continue; // if(tim >=HqTime[GraphData.jys].pm_min_start) // tim =HqTime[GraphData.jys].am_min_count // +(tim-HqTime[GraphData.jys].pm_min_start); // else tim -=HqTime[GraphData.jys].am_min_start; // LineTo(hDC, (int)(fwdt*tim), -(int)(fhdj*fplus/ma)); //} /////////////////////////////////////////////////////////// //以下为平均线 for(i=0,j=1,fplus=0;i<GraphData.minCount;i++) { if(GraphData.lpGraData[GraphData.lpMinPos[i]].tim==0) continue; fplus +=GraphData.lpGraData[GraphData.lpMinPos[i]].zjjg; tim =GraphData.lpGraData[GraphData.lpMinPos[i]].tim; if(tim>HqTime[GraphData.jys].pm_min_start+HqTime[GraphData.jys].pm_min_count) break; if(i==0) MoveTo(hDC, (int)(fwdt*COOR(tim)), -(int)(fhdj*fplus/j++)); else LineTo(hDC, (int)(fwdt*COOR(tim)), -(int)(fhdj*fplus/j++)); } SelectObject(hDC, GetStockObject(WHITE_PEN)); DeleteObject(hPen); } return 0;}int DrawJlt(HDC hDC, LPRECT rc){ int i; //int ma; //long lplus; double fhdj, fwdt, zjjg, lastjg; long l, val, oldval; HPEN hPen, hPenRed, hPenGreen; int tim; char tmp[20]; int ll; //画X坐标及Y坐标 hPen =CreatePen(PS_SOLID, 2, RGB(255, 255, 255)); SelectObject(hDC, hPen); MoveTo(hDC,rc->left,0); LineTo(hDC,rc->left,rc->bottom+1); LineTo(hDC,rc->right, rc->bottom+1); SelectObject(hDC,GetStockObject(WHITE_PEN)); DeleteObject(hPen); if(GraphData.minEnd <=0 || GraphData.minCount <=0) return -1; SelectObject(hDC, GetStockObject(WHITE_PEN)); fwdt =(double)(rc->right-rc->left)/(HqTime[HqPaintData.jys].am_min_count +HqTime[HqPaintData.jys].pm_min_count+R_DOTS); if(GraphData.GraHead.zglc ==0) return -1; fhdj =(double)(rc->bottom-rc->top)/GraphData.GraHead.zglc; SetTextColor(hDC, RGB(255, 255, 0)); SetTextAlign(hDC, TA_RIGHT|TA_TOP); val =0; if(IsZsRec(GraphData.jys, GraphData.recNum)) ll =100; else ll =1; hPen =CreatePen(PS_SOLID, 1, RGB(80, 80, 80)); SelectObject(hDC, hPen); if(fhdj) { oldval =val; if(GraphData.GraHead.zglc <100) { for(i =1; i<5; i++) { val =GraphData.GraHead.zglc*i/5; wsprintf(tmp, "%ld", val); MoveTo(hDC, rc->right-2, rc->bottom-(int)(fhdj*val)); LineTo(hDC, rc->left, rc->bottom-(int)(fhdj*val)); TextOut(hDC, rc->left-4, rc->bottom-(int)(fhdj*val)-4, tmp, strlen(tmp)); } } else for(l =GraphData.GraHead.zglc/5; l >=0 && l<=GraphData.GraHead.zglc; l+=GraphData.GraHead.zglc/5) { wsprintf(tmp, "%ld", l); i =strlen(tmp)-2; if(i>0) { val =1; while(i-->0) val *=10; val =l -l%val; if(oldval ==val) continue; wsprintf(tmp, "%ld", val); } else val =l; MoveTo(hDC, rc->right-2, rc->bottom-(int)(fhdj*val)); LineTo(hDC, rc->left, rc->bottom-(int)(fhdj*val)); TextOut(hDC, rc->left-4, rc->bottom-(int)(fhdj*val)-4, tmp, strlen(tmp)); if(val >GraphData.GraHead.zglc) break; oldval =val; } } SelectObject(hDC, GetStockObject(WHITE_PEN)); DeleteObject(hPen); hPenRed =CreatePen(PS_SOLID, 1, RGB(255, 0, 255)); hPenGreen =CreatePen(PS_SOLID, 1, RGB(0, 255, 255)); zjjg =GraphData.lpGraData[GraphData.lpMinPos[0]].zjjg; lastjg =GraphData.GraHead.zrsp; for(i =0; i<GraphData.minCount; i++) { tim =GraphData.lpGraData[GraphData.lpMinPos[i]].tim; if(tim>HqTime[GraphData.jys].pm_min_start+HqTime[GraphData.jys].pm_min_count) break; if(tim ==0) continue; zjjg =GraphData.lpGraData[GraphData.lpMinPos[i]].zjjg; if(zjjg>lastjg) SelectObject(hDC, hPenRed); else if(zjjg<lastjg) SelectObject(hDC, hPenGreen); else SelectObject(hDC, hPenRed); l =GraphData.lpMinLc[i]; MoveTo(hDC, rc->left+(int)(fwdt*COOR(tim)), rc->bottom); LineTo(hDC, rc->left+(int)(fwdt*COOR(tim)), rc->bottom-(int)(fhdj*l)); lastjg =zjjg; } SelectObject(hDC, GetStockObject(WHITE_PEN)); DeleteObject(hPenGreen); DeleteObject(hPenRed); //分时平均线 /* ma =GraphData.jlt.ma[0]; if(GraphData.minCount <ma) return 0; hPen =CreatePen(PS_SOLID, 0, GraphData.color[0]); SelectObject(hDC, hPen); lplus =0L; for(i =0; i<ma; i++) lplus +=GraphData.lpMinLc[i]; tim =GraphData.lpGraData[GraphData.lpMinPos[i-1]].tim; MoveTo(hDC, rc->left+(int)(fwdt*COOR(tim)), rc->bottom-(int)(fhdj*(lplus/ma))); for(; i<GraphData.minCount; i++) { lplus-=GraphData.lpMinLc[i-ma]; lplus +=GraphData.lpMinLc[i]; tim =GraphData.lpGraData[GraphData.lpMinPos[i-1]].tim; if(tim>HqTime[GraphData.jys].pm_min_start+HqTime[GraphData.jys].pm_min_count) break; if(tim ==0) continue; LineTo(hDC, rc->left+(int)(fwdt*COOR(tim)), rc->bottom-(int)(fhdj*(lplus/ma))); } SelectObject(hDC, GetStockObject(WHITE_PEN)); DeleteObject(hPen); */ return 0;}int DrawTimeLines(HWND hWnd,HDC hDC, LPRECT rc, BOOL fDrawText){ int i, j; char tmp[50]; HPEN hPen; double fwdt; int top; if(hWnd ==ghWndJlt) top =0; else top =rc->top+1; j = HqTime[HqPaintData.jys].am_min_count +HqTime[HqPaintData.jys].pm_min_count+R_DOTS; fwdt =(double)(rc->right-rc->left)/j; hPen =CreatePen(PS_SOLID, 0, RGB(80, 80, 80)); SelectObject(hDC, hPen); SetTextAlign(hDC, TA_LEFT|TA_TOP); SelectObject(hDC, GraphData.hFont); for(i=0;i<=j;i=i+30) { if(i>0) { MoveTo(hDC, rc->left+(int)(fwdt*i), top); LineTo(hDC, rc->left+(int)(fwdt*i), rc->bottom); } if(fDrawText) { wsprintf(tmp, "%d:%02d",TIME(i)/60,TIME(i)%60); TextOut(hDC, rc->left+(int)(fwdt*i), rc->bottom+2, tmp,strlen(tmp)); } } SelectObject(hDC, GetStockObject(WHITE_PEN)); DeleteObject(hPen); return 0;}BOOL fVLineDrawed =FALSE;extern int graphTop;extern HBITMAP getImage(HDC, LPRECT);extern int putImage(HDC, HBITMAP, LPRECT);extern int CapHig;int DrawVLine(int pos){ static int minNum =0; RECT rc, rc1, rc2; float fwdt, fhdj; HDC hDC; char tmp[100]; static int slen =0; int ll; int timPos =0; static RECT rcJg; if(GraphData.minCount <=0 || GraphData.minEnd <=0) return 0; GetWindowRect(ghWndXlt, &rc1); SetRect(&rc, 0, graphTop, rc1.right-rc1.left, rc1.bottom-rc1.top-1); fwdt =(float)(rc1.right-rc1.left-80)/(HqTime[HqPaintData.jys].am_min_count +HqTime[HqPaintData.jys].pm_min_count+R_DOTS); fhdj =(float)(rc.bottom-rc.top-10)/(GraphData.GraHead.zgjg*2); hDC =GetDC(NULL); SetROP2(hDC, R2_NOT); if(minNum+pos <0) pos =GraphData.minCount-1 -minNum; if(minNum >=GraphData.minCount) minNum =GraphData.minCount-1; if(minNum+pos >=GraphData.minCount) pos =-minNum; GetWindowRect(ghWndJlt, &rc2); rc2.bottom -=10; timPos =GraphData.lpGraData[GraphData.lpMinPos[minNum]].tim; MoveTo(hDC, rc1.left+50+(int)(fwdt*COOR(timPos)), rc1.top+graphTop+2); LineTo(hDC, rc1.left+50+(int)(fwdt*COOR(timPos)), rc2.bottom-20); if(pos && fVLineDrawed) { do { minNum +=pos; timPos =GraphData.lpGraData[GraphData.lpMinPos[minNum]].tim; }while(timPos ==0); if(timPos >=HqTime[GraphData.jys].pm_min_start) timPos =HqTime[GraphData.jys].am_min_count+(timPos-HqTime[GraphData.jys].pm_min_start); else timPos -=HqTime[GraphData.jys].am_min_start; MoveTo(hDC, rc1.left+50+(int)(fwdt*timPos), rc1.top+graphTop+2); LineTo(hDC, rc1.left+50+(int)(fwdt*timPos), rc2.bottom-20); } fVLineDrawed =TRUE; if(IsZsRec(GraphData.jys, GraphData.recNum)) ll =100; else ll =1; sprintf(tmp, "时间:%2d:%02d 价格:%6.2f 量差:%5ld 总量:%8ld", GraphData.lpGraData[GraphData.lpMinPos[minNum]].tim/60, GraphData.lpGraData[GraphData.lpMinPos[minNum]].tim%60, GraphData.lpGraData[GraphData.lpMinPos[minNum]].zjjg+GraphData.GraHead.zrsp, GraphData.lpMinLc[minNum], GraphData.lpGraData[GraphData.lpMinPos[minNum]].zl); if(GraphData.lpGraData[GraphData.lpMinPos[minNum]].zjjg<0) SetTextColor(hDC, RGB(0, 255, 0)); else SetTextColor(hDC, RGB(255, 0, 0)); SetROP2(hDC, R2_COPYPEN); SelectObject(hDC,GetStockObject(BLACK_BRUSH)); ReleaseDC(NULL, hDC); GetWindowRect(ghWndMain,&rc); GetWindowRect(ghWndXlt,&rc1); GetWindowRect(ghWndMsg,&rc2); if(pos&& fVLineDrawed) Msg(tmp,MSG_VERT|MSG_TIME); else Msg(tmp,MSG_HIDE); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -