|
kabe さん、こん**は。Hidemi Oya です。
「20 回に1回」という表現は適切でなかったですね。プログレスバーを 20 分割したときの切れ目だけ表示するということです。
>kabe です。
>右クリックでのカレントセルの変更がうまくいかず、まだ修正版をアップできない状態です。(ポップアップメニューが出るタイミングによるのかカレントセルを変更できない場合がある)
StringGrid の PopupMenu プロパティを空にして、OnMouseUp イベントでセル選択とメニューのポップアップを実行するってのじゃダメでしょうか? ついでに、OnKeyUp イベントでコンテキストメニューキーも処理する必要がありますが…。
procedure TForm1.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
var
c, r:longint;
p: TPoint;
begin
if Button <> mbRight then Exit; // 右ボタン以外は無視
StringGrid1.MouseToCell(X, Y, c, r); // マウスカーソル下のセル位置取得
StringGrid1.Col := c; // 選択セル桁位置設定
StringGrid1.Row := r; // 選択セル行位置設定
// 選択セル右下位置をスクリーン座標に変換
p := StringGrid1.ClientToScreen(StringGrid1.CellRect(c, r).BottomRight);
PopupMenu1.Popup(p.X, p.Y); // マウス位置にメニューをポップアップ
end;
procedure TForm1.StringGrid1KeyUp(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
p: TPoint;
begin
if Key <> VK_APPS then Exit; // コンテキストメニューキー以外は無視
// 選択セル右下位置をスクリーン座標に変換
p := StringGrid1.ClientToScreen(StringGrid1.CellRect(StringGrid1.Col, StringGrid1.Row).BottomRight);
PopupMenu1.Popup(p.X, p.Y); // マウス位置にメニューをポップアップ
end;
|
|