Mercurial > hg > Members > nobuyasu > SampleSource
view WindowsOnly/WinScript2/main.txt @ 0:db40c85cad7a default tip
upload sample source
author | nobuyasu <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 09 May 2011 03:11:59 +0900 |
parents | |
children |
line wrap: on
line source
// テストスクリプト // グローバル変数 int xpos[1000], ypos[1000]; int xlast, ylast; int start, count; int drag; // 直線の追加 void AddLine(int x, int y) { xpos[start] = x; ypos[start] = y; start += 1; if (start >= 1000) start = 0; if (count < 1000) count += 1; xlast = x; ylast = y; } // WM_PAINTの処理 int OnPaint(int dc) { int i; int pos; if (count > 0) { pos = start - count; if (pos < 0) pos += 1000; SetColor(dc, 0, 0, 0); MoveTo(dc, xpos[pos], ypos[pos]); for (i=1; i<count; i+=1) { pos += 1; if (pos >= 1000) pos -= 1000; LineTo(dc, xpos[pos], ypos[pos]); } } return 0; } // WM_LBUTTONDOWNの処理 int OnLButtonDown(int x, int y) { count = 0; start = 0; drag = 1; AddLine(x, y); return 0; } // WM_MOUSEMOVEの処理 int OnMouseMove(int x, int y) { if (drag) { int dc; dc = GetDC(); SetColor(dc, 0, 0, 0); MoveTo(dc, xlast, ylast); LineTo(dc, x, y); ReleaseDC(dc); AddLine(x, y); } return 0; } // WM_LBUTTONDOWNの処理 int OnLButtonUp(int x, int y) { OnMouseMove(x, y); drag = 0; return 0; }