#include "stdafx.h" #include "common.h" LRESULT CALLBACK RulerProc(HWND hwnd,UINT message,WPARAM wParam,LPARAM lParam){ switch(message){ case WM_PAINT: CRuler *pobj_Ruler; pobj_Ruler=(CRuler *)GetWindowLongPtr(hwnd,GWLP_USERDATA); HDC hdc; PAINTSTRUCT ps; hdc=BeginPaint(hwnd,&ps); pobj_Ruler->draw(hdc); EndPaint(hwnd,&ps); break; } return DefWindowProc(hwnd,message,wParam,lParam); } CRuler::CRuler(HWND hParent,MDIINFO *pMdiInfo) : pMdiInfo( pMdiInfo ) { hRulerWnd=CreateWindowEx(0,"Ruler","Ruler", WS_CHILD|WS_CLIPCHILDREN|WS_VISIBLE, 0,0,0,0, hParent,0,hInst,0); SetWindowLongPtr(hRulerWnd,GWLP_USERDATA,(long)this); HDC hdc; hdc=GetDC(hRulerWnd); memdc=CreateCompatibleDC(hdc); hMemBmp=CreateCompatibleBitmap(hdc,ScreenX,HEIGHT_RULER); SelectObject(memdc,hMemBmp); ReleaseDC(hRulerWnd,hdc); } CRuler::~CRuler(){ DeleteDC(memdc); DeleteObject(hMemBmp); DestroyWindow(hRulerWnd); } void CRuler::resize(int x,int y,int cx,int cy){ MoveWindow(hRulerWnd,x,y,cx,cy,1); } void CRuler::draw(HDC hdc){ int i; //スクロールバーによるベースポジションを取得 int BaseX,BaseY; BaseX=0; BaseY=0; GetScrollBaseCaretPos(this->pMdiInfo,&BaseX,&BaseY); int iControlTabSpace; iControlTabSpace=this->pMdiInfo->pMdiTextEdit->iWidth_ControlTabSpace; HBRUSH hBrush,hOldBrush; hBrush=CreateSolidBrush(RGB(230,230,230)); HPEN hPen,hOldPen; hPen=CreatePen(PS_SOLID,0,RGB(60,60,60)); //背景色を塗りつぶす hOldBrush=(HBRUSH)SelectObject(memdc,hBrush); PatBlt(memdc,0,0,ScreenX,HEIGHT_RULER,PATCOPY); SelectObject(memdc,hOldBrush); extern HFONT hRulerFont; HFONT hOldFont; hOldFont=(HFONT)SelectObject(memdc,hRulerFont); hOldPen=(HPEN)SelectObject(memdc,hPen); //ラインを描画 extern int font_width; int x; for(x=iControlTabSpace,i=-BaseX;x