お知らせ

電子会議

ライブラリ

パレット

Delphi FAQ検索

Delphi FAQ一覧

サンプル蔵





FDelphi FAQ
16番会議室「玉石混淆みんなで作るSample蔵」に寄せられたサンプル

"マウスドラッグでクロックメニュー"

この発言に対し以下のコメントが寄せられています
#01054 兵藤 隆志 さん RE:マウスドラッグでクロックメニュー

JW_CAD for Windows のマウスドラッグによるクロックメニューをDELPHIで ユニット化しました。 unit JwwClock; interface uses Classes, Controls; function JWW_MouseDown(Button: TMouseButton;X,Y:Integer):ShortString; function JWW_MouseMove(Shift: TShiftState;X,Y: Integer):ShortString; function JWW_MouseUp(Button: TMouseButton;X,Y: Integer):ShortString; var MsDX,MsDY:Integer; implementation var LButtonDown, RButtonDown, LeftClock, RightClock, BothButton, AMTimeZone: boolean ; ClockTime:String[8]; ClockTimeList: array[1..48] of String = ( 'C左AM0','C左AM1','C左AM2','C左AM3','C左AM4','C左AM5', 'C左AM6','C左AM7','C左AM8','C左AM9','C左AMa','C左AMb', 'C左PM0','C左PM1','C左PM2','C左PM3','C左PM4','C左PM5', 'C左PM6','C左PM7','C左PM8','C左PM9','C左PMa','C左PMb', 'C右AM0','C右AM1','C右AM2','C右AM3','C右AM4','C右AM5', 'C右AM6','C右AM7','C右AM8','C右AM9','C右AMa','C右AMb', 'C右PM0','C右PM1','C右PM2','C右PM3','C右PM4','C右PM5', 'C右PM6','C右PM7','C右PM8','C右PM9','C右PMa','C右PMb'); MsHX,MsHY,Circle,JWWSin:Integer; I,J,K,L,M : ShortInt; MsHYP: boolean = False; function JWW_MouseDown(Button: TMouseButton;X,Y:Integer):ShortString; begin if Button = mbLeft then //1.左釦を押した場合 begin LButtonDown := True; if RbuttonDown then //1-1.右釦が既に押されていた場合 begin if ClockTime = '' then //1-1-1.両釦クリックの場合 begin ClockTime := 'B移動'; Result := ClockTime; BothButton := True; end; if ClockTime[1] = 'C' then //1-1-2.AM⇔PM切替の場合 begin AMTimeZone := not AMTimeZone; if ClockTime[4] ='A' then ClockTime[4] := 'P' else Clocktime[4] := 'A'; Result := Clocktime ; end; if ClockTime[1] = 'B' then //1-1-3.両釦ドラッグ中 begin Result := ClockTime; end; end else //1-2.右釦が押されていない場合 begin AMTimeZone := True; Result := ''; MsDX := X; MsDY := Y; end; end; if Button = mbRight then //2.右釦を押した場合 begin RButtonDown := True; if LbuttonDown then //2-1.左釦が既に押されていた場合 begin if CLockTime = '' then //2-1-1.両釦クリックの場合 begin ClockTime := 'B移動'; Result := ClockTime; BothButton := True; end; if ClockTime[1] = 'C' then //2-1-2.AM⇔PM切替の場合 begin AMTimeZone := not AMTimeZone; if ClockTime[4] ='A' then ClockTime[4] := 'P' else Clocktime[4] := 'A'; Result := Clocktime ; end; if ClockTime[1] = 'B' then //2-1-3.両釦ドラッグ中 begin Result := Clocktime; end; end else //2-2.左釦が押されていない場合 begin AMTimeZone := True; Result := ''; MsDX := X; MsDY := Y; end; end; end; function JWW_MouseUp(Button: TMouseButton;X,Y: Integer):ShortString; begin if Button = mbLeft then //1.左釦を離した場合 begin LButtonDown := False; if RButtonDown then //1-1.右釦を押している場合 begin if BothButton then Result := '' //1-1-1.両釦クリックの場合 else begin //1-1-2.両釦クリックではない場合 if LeftClock then begin LeftClock := False; RightClock := False; RButtonDown := False; Result := ClockTime; ClockTime := ''; end; end; end else begin //1-2.右釦が押されていない場合 if LeftClock then begin //1-2-1.左クロック表示中 LeftClock := False; Result := ClockTime; BothButton := False; RightClock := False; end; if BothButton then //1-2-2.両釦クリックの場合 begin Result := ClockTime; BothButton := False; end; end; end; if Button = mbRight then //2.右釦を離した場合 begin RButtonDown := False; if LButtonDown then //2-1.左釦を押している場合 begin if BothButton then Result := '' //2-1-1.両釦クリックの場合 else begin //2-1-2.両釦クリックではない場合 if RightClock then begin RightClock := False; LeftClock := False; LButtonDown := False; Result := ClockTime; ClockTime := ''; end; end; end else begin //2-2.左釦が既に押されていない場合 if RightClock then begin //2-2-1.右クロック表示中 Result := ClockTime; BothButton := False; LeftClock := False; RightClock := False; end; if BothButton then //2-2-2.両釦クリック表示中 begin Result := ClockTime; BothButton := False; end; end; end; end; function JWW_MouseMove(Shift: TShiftState;X,Y: Integer):ShortString; begin MsHX := X - MsDX ; MsHY := MsDY - Y; Circle := sqr(MsHX)+sqr(MsHY); ClockTime := ''; if BothButton then //1.両釦ドラッグ中の場合 begin if Circle < 400 then ClockTime := 'B移動' else begin if MsHX >= 0 then if MsHY > 0 then ClockTime := 'B全体' else ClockTime := 'B拡大' else if MsHY > 0 then ClockTime := 'B縮小' else ClockTime := 'B前率'; end; end else begin //2.両釦ドラッグでない場合 if Circle > 900 then //クロックサークル外の場合 begin if MsHX = 0 then if MsHY > 0 then begin MsHYP := True; I := 7; end else begin MsHYP := False; I := 1; end else begin JWWSin := Round(MsHY*1000/MsHX); if (JWWSin > 3732) then I := 1; if (JWWSin > 1000) and (JWWSin <= 3732) then I := 2; if (JWWSin > 268) and (JWWSin <= 1000) then I := 3; if (JWWSin > -268) and (JWWSin <= 268) then I := 4; if (JWWSin >-1000) and (JWWSin <= -268) then I := 5; if (JWWSin >-3732) and (JWWSin <=-1000) then I := 6; if (JWWSin <=-3732) then I := 7; end; if LButtonDown and not RightClock then //2-1.左釦クロックの場合 begin LeftClock := True; L := 0; if AMTimeZone = True then K := 0 else K := 1; if MsHX > 0 then J := I else if I = 7 then J := 1 else J := 6+ I; Clocktime := ClockTimeList[J+12*K+24*L]; end; if RButtonDown and not LeftClock then //2-2.右釦クロックの場合 begin RightClock := True; L := 1; if AMTimeZone = True then K := 0 else K := 1; if MsHX > 0 then J := I else if I = 7 then J := 1 else J := 6+ I; Clocktime := ClockTimeList[J+12*K+24*L]; end; end else begin if LeftClock then if AMTimeZone then ClockTime :='C左ACA' else ClockTime := 'C左PCA'; if RightClock then if AMTimeZone then ClockTime :='C右ACA' else ClockTime := 'C右PCA'; end; end; Result := ClockTime; end; end. YRB03356 居残り君 こと 兵藤 隆志 使い方はこれにコメントとして繋げます。 Original document by 兵藤 隆志 氏 ID:(YRB03356)



ここにあるドキュメントは NIFTY SERVEの Delphi Users' Forum の16番会議室「玉石混淆みんなで作るSample蔵」に投稿されたサンプルです。これらのサンプルはボーランド株式会社がサポートする公式のものではありません。また、必ずしも動作が検証されているものではありません。これらのサンプルを使用したことに起因するいかなる損害も投稿者、およびフォーラムスタッフはその責めを負いません。使用者のリスクの範疇でご使用下さい。

Copyright 1996-2002 Delphi Users' Forum