(7)アイコン(アイコン)の形をクロールする
新しいform3を作成し、capture3.pasとして保存します。属性ボーダリコンの4つのプロパティをfalseに設定します。
BorderStyleはBSNONEに設定されており、FormStyleはFSSTAYONTOPに設定されています。
1つのプライベート変数:FDRaging:Boolean;
ユニットCapture3;
インタフェース
用途
窓、メッセージ、sysutils、バリアント、クラス、グラフィック、コントロール、フォーム、
ダイアログ;
タイプ
tform3 = class(tform)
手順formcreate(sender:tobject);
手順FormMousedown(送信者:tobject; button:tmousebutton;
シフト:tshiftState; x、integer);
手順formmousemove(sender:tobject; shift:tshiftstate;
x、y:整数);
手順formmouseup(sender:tobject; button:tmousebutton;
シフト:tshiftState; x、integer);
手順formactivate(sender:tobject);
手順formdestroy(送信者:tobject);
手順フォームペイント(送信者:tobject);
プライベート
fdragging:boolean;
公共
FRECT:TRECT;
FBMP:tbitmap;
終わり;
var
Form3:tform3;
実装
{$ r *.dfm}
//新しいカスタムカーソルcursor_2を作成し、capture3.resリソースに配置します
//ファイルには、キャプチャの範囲を示すために32*32の白い長方形の境界があります。
手順tform3.formcreate(sender:tobject);
var ADC:HDC;
const crbox = -19;
始める
screen.cursors [crbox]:= loadcursor(hinstance、 'cursor_2');
カーソル:= crbox;
fbmp:= tbitmap.create;
fbmp.width:= screen.width;
fbmp.height:= screen.height;
ADC:= getDC(0);
bitblt(fbmp.canvas.handle、0,0、screen.width、screen.height、adc、0,0、srccopy);
releasec(0、adc);
setbounds(0,0、screen.width、screen.height);
終わり;
手順tform3.formmousedown(sender:tobject; button:tmousebutton;
シフト:tshiftState; x、integer);
始める
mbleft =ボタンの場合、開始します
fdragging:= true;
setRect(FRECT、X、Y、X+32、Y+32);
canvas.drawfocusRect(FRECT);
終わり;
終わり;
手順tform3.formmousemove(sender:tobject; shift:tshiftstate;
x、y:整数);
始める
fdraggingの場合、開始します
canvas.drawfocusRect(FRECT);
frect.left:= x;
frect.top:= y;
frect.right:= x+32;
frect.bottom:= y+32;
canvas.drawfocusRect(FRECT);
終わり;
終わり;
手順tform3.formmouseup(sender:tobject; button:tmousebutton;
シフト:tshiftState; x、integer);
始める
ModalResult:= mrok;
終わり;
手順tform3.formactivate(sender:tobject);
const crhand = -18;
始める
screen.cursors [crhand]:= loadcursor(hinstance、pchar( 'cursor_1'));
カーソル:= crhand;
終わり;
手順tform3.formdestroy(sender:tobject);
始める
fbmp.free;
screen.cursor:= crdefault;
終わり;
手順tform3.formpaint(sender:tobject);
始める
canvas.draw(0,0、fbmp);
終わり;
終わり。