Groups
Groups
Sign in
Groups
Groups
Japan RAD Studio User Group
Conversations
About
Send feedback
Help
Delphiでマウス・キーボード操作をスルーする方法はありますか?
180 views
Skip to first unread message
ooe....@gmail.com
unread,
Aug 17, 2023, 5:59:08 AM
8/17/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to radstu...@googlegroups.com
環境 Delphi 10.2 Tokyo
VCLフォームアプリケーション
Windows 10
こんばんは。
フォームを透明化して常に最前面に表示させた状態で、
マウスやキーボード操作の影響を受けない状態にしたいのですが、
そのようなことは可能でしょうか。
このアプリでは枠だけ表示させて最前面に置いて、
背面のアプリを普段通りに使いたいのです。
最前面表示とフォームの透明化は下記コードでできましたが、
当たり前ですがこのフォーム上でクリックすると、
このアプリがマウスに反応し背面のアプリはクリックされません。
やはり、そんなことはできないでしょうか。
procedure TForm1.FormCreate(Sender: TObject);
begin
Form1.BorderStyle := bsDialog;
Form1.Color := clInfoBk;
Form1.TransparentColor := True;
Form1.TransparentColorValue := clInfoBk;
SetWindowPos(handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE Or SWP_NOSIZE or
SWP_NOACTIVATE);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
SetWindowpos(handle,HWND_NOTOPMOST,0,0,0,0,SWP_NOMOVE Or SWP_NOSIZE
or SWP_NOACTIVATE);
end;
end.
mam
unread,
Aug 17, 2023, 8:06:06 PM
8/17/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Japan RAD Studio User Group
mamと申します。
ご投稿されているソースコードをそのまま
Delphi XE10.2 TOKYOに貼り付けて動かしましたが、
このフォームの上でクリックすると、背面側のアプリが応答しました。
御所望の通りに動作しているように思えるのですが。
2023年8月17日木曜日 18:59:08 UTC+9
ooe....@gmail.com
:
ooe....@gmail.com
unread,
Aug 18, 2023, 2:42:10 AM
8/18/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to radstu...@googlegroups.com
mam さま
ありがとうございました。
確かにあのコードのままで動作を確認できました。
ただ、私がうまくいかなかったのは、
フォーム上にTLabelを配置していたからでした。
お恥ずかしい。
---------------
関連した新しい質問です。
下記コードにて「フォームを非アクティブで最前面」は
できることを確認できたのですが、
そのフォーム上に配置したTLabelもマウス操作を無視させて、
背面側のアプリを応答させたいと思っています。
そもそも可能なのかが分かりませんが、
もし可能なら方法を知りたいです。
よろしくお願いいたします。
> --
> このメールは Google グループのグループ「Japan RAD Studio User Group」に
> 登録しているユーザーに送られています。
> このグループから退会し、グループからのメールの配信を停止するには
>
radstudio-jp...@googlegroups.com
> <mailto:
radstudio-jp...@googlegroups.com
> にメールを送信してく
> ださい。
> このディスカッションをウェブ上で閲覧するには
>
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com
<
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com?utm_medium=email&utm_source=footer
> にアクセスしてください。
mam
unread,
Aug 18, 2023, 3:34:29 AM
8/18/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Japan RAD Studio User Group
あまり内容がわからずにお答えするので意図が間違っていたらすいません。
Label1.Transparent:=True;
又は
Label1.Color:=clInfoBk;
ではだめなのでしょうか。
Label上の文字自体も透過したいのであれば、
Label1.Font.Color:=clInfoBk;
として文字自体も透明にしてしまうしかないと思います。
Form1.TransparentColor := True;
Form1.TransparentColorValue := clInfoBk;
としているので、フォーム上のコントロール含む全てのclInfoBk色は透過となります。
2023年8月18日金曜日 15:42:10 UTC+9
ooe....@gmail.com
:
mam
unread,
Aug 18, 2023, 3:54:55 AM
8/18/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Japan RAD Studio User Group
ご参考まで
https://mam-mam.net/delphi/vcl_clock_widget.html
では、
self.TransparentColor:=true; self.TransparentColorValue:=Self.Color; self.BorderStyle:=bsNone;
とフォームを透明化して、フォームのcanvasに描画してガジェットを作っています。
2023年8月18日金曜日 16:34:29 UTC+9 mam:
ooe....@gmail.com
unread,
Aug 18, 2023, 4:24:42 AM
8/18/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to radstu...@googlegroups.com
「アナログ時計ガジェットの作り方」サイトのご紹介ありがとうございます。
実際に動かしてみました。これもとても面白いですね。
細かい部分がとても良い参考になります。
いえいえ、私のやりたいことが一般的でないと思うので、
こちらこそすみません。
このアプリを使って説明させていただきますと…
このアプリは「短針長針をドラッグして移動可能」ですが、
私は「この短針長針をマウスには無反応にしたい」
そして「常に背面側のアプリが応答して欲しい」のです。
どこかで「画面上に半透明で表示されていて、マウスの影響を
全くうけないアプリ」というのをどこかで見た気がするので、
何か方法があるんだと思うのですが、、、。
いろいろ検索してますが、見つけられずにいます。
>
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com
<
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com
> <
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com?utm_medium=email&utm_source=footer
<
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com?utm_medium=email&utm_source=footer
>> にアクセスしてください。
>
> --
> このメールは Google グループのグループ「Japan RAD Studio User Group」に
> 登録しているユーザーに送られています。
> このグループから退会し、グループからのメールの配信を停止するには
>
radstudio-jp...@googlegroups.com
> <mailto:
radstudio-jp...@googlegroups.com
> にメールを送信してく
> ださい。
> このディスカッションをウェブ上で閲覧するには
>
https://groups.google.com/d/msgid/radstudio-jp/bb383eed-15fe-4c58-8ce5-3335be8f1ab1n%40googlegroups.com
<
https://groups.google.com/d/msgid/radstudio-jp/bb383eed-15fe-4c58-8ce5-3335be8f1ab1n%40googlegroups.com?utm_medium=email&utm_source=footer
> にアクセスしてください。
mam
unread,
Aug 18, 2023, 4:47:50 AM
8/18/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Japan RAD Studio User Group
>「この短針長針をマウスには無反応にしたい」
>そして「常に背面側のアプリが応答して欲しい」のです。
なるほどです。
作成するアプリのウィンドウは完全に非表示にして、
デスクトップのウィンドウハンドルから
デスクトップのデバイスコンテキストに対してタイマーなどで直接定期的に描画するしかないような気がしますね。
procedure TForm1.Timer1Timer(Sender: TObject);
var h:HWND;
d:HDC;
c:TCanvas;
begin
h:=GetDesktopWindow;
d:=GetDC(h);
c:=TCanvas.Create;
c.Handle:=d;
c.Font.Color:=clRed;
c.TextOut(0,0,FormatDateTime('hh:nn:ss',now()));
ReleaseDC(h,d);
end;
2023年8月18日金曜日 17:24:42 UTC+9
ooe....@gmail.com
:
mam
unread,
Aug 18, 2023, 4:49:00 AM
8/18/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Japan RAD Studio User Group
すいません、canvasの破棄を忘れていました。
procedure TForm1.Timer1Timer(Sender: TObject);
var h:HWND;
d:HDC;
c:TCanvas;
begin
h:=GetDesktopWindow;
d:=GetDC(h);
c:=TCanvas.Create;
c.Handle:=d;
c.Font.Color:=clRed;
c.TextOut(0,0,FormatDateTime('hh:nn:ss',now()));
c.Free;
ReleaseDC(h,d);
end;
2023年8月18日金曜日 17:47:50 UTC+9 mam:
ooe....@gmail.com
unread,
Aug 18, 2023, 9:34:48 PM
8/18/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to radstu...@googlegroups.com
mam さま
描けました。
点滅してしまうのは仕方ないと諦めて、
これでやってみようと思います。
ありがとうございました。
>
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com
<
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com
> <
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com
<
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com
>> <
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com?utm_medium=email&utm_source=footer
<
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com?utm_medium=email&utm_source=footer
> <
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com?utm_medium=email&utm_source=footer
<
https://groups.google.com/d/msgid/radstudio-jp/47820fc3-15c8-49ef-a903-d628af6c5522n%40googlegroups.com?utm_medium=email&utm_source=footer
>>> にアクセスしてください。
> >
> > --
> > このメールは Google グループのグループ「Japan RAD Studio User
> Group」に
> > 登録しているユーザーに送られています。
> > このグループから退会し、グループからのメールの配信を停止するには
> >
radstudio-jp...@googlegroups.com
> > <mailto:
radstudio-jp...@googlegroups.com
> にメールを送信してく
> > ださい。
> > このディスカッションをウェブ上で閲覧するには
> >
>
https://groups.google.com/d/msgid/radstudio-jp/bb383eed-15fe-4c58-8ce5-3335be8f1ab1n%40googlegroups.com
<
https://groups.google.com/d/msgid/radstudio-jp/bb383eed-15fe-4c58-8ce5-3335be8f1ab1n%40googlegroups.com
> <
https://groups.google.com/d/msgid/radstudio-jp/bb383eed-15fe-4c58-8ce5-3335be8f1ab1n%40googlegroups.com?utm_medium=email&utm_source=footer
<
https://groups.google.com/d/msgid/radstudio-jp/bb383eed-15fe-4c58-8ce5-3335be8f1ab1n%40googlegroups.com?utm_medium=email&utm_source=footer
>> にアクセスしてください。
>
> --
> このメールは Google グループのグループ「Japan RAD Studio User Group」に
> 登録しているユーザーに送られています。
> このグループから退会し、グループからのメールの配信を停止するには
>
radstudio-jp...@googlegroups.com
> <mailto:
radstudio-jp...@googlegroups.com
> にメールを送信してく
> ださい。
> このディスカッションをウェブ上で閲覧するには
>
https://groups.google.com/d/msgid/radstudio-jp/e923d623-0e7f-4a61-99ce-3ae5842e60dan%40googlegroups.com
<
https://groups.google.com/d/msgid/radstudio-jp/e923d623-0e7f-4a61-99ce-3ae5842e60dan%40googlegroups.com?utm_medium=email&utm_source=footer
> にアクセスしてください。
細川淳
unread,
Aug 20, 2023, 2:07:55 AM
8/20/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to radstu...@googlegroups.com
ooe.riku さん
こんにちは。
細川です。
こんな感じでクリック透過できます。
■プロパティ
BorderStyle: bsNone // クリックが透過してしまうためタイトルバーがあっても無意味
FormStyle: fsStayOnTop // 必要であれば最前面表示 (WS_EX_TOPMOST)
TransparentColor: True // Layer Window 化 (WS_EX_LAYERED)
TransparentColorValue: clBtnFace // フォームの背景色を指定
■コード
type
TForm1 = class(TForm)
Label1: TLabel; // FontSize: 128, Caption = 'Hello, Wolrd!' を設定
protected
procedure CreateParams(var Params: TCreateParams); override;
end;
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.ExStyle :=
Params.ExStyle
or WS_EX_TRANSPARENT // 透明化
or WS_EX_NOACTIVATE // アクティブにならない
;
end;
よろしければ、コードのシンタックスハイライト表示や画像を添付したりできる Discrod もご利用ください。
↓Delphi Discord サーバのご案内
https://gist.github.com/freeonterminate/928ccd3ad64c5762315c069afd72e51e
2023年8月18日(金) 17:24
ooe....@gmail.com
<
ooe....@gmail.com
>:
> このメールは Google グループのグループ「Japan RAD Studio User Group」の登録者に送られています。
> このグループから退会し、グループからのメールの配信を停止するには
radstudio-jp...@googlegroups.com
にメールを送信してください。
> このディスカッションをウェブ上で閲覧するには、
https://groups.google.com/d/msgid/radstudio-jp/61b2e6e2-3228-47c3-c1b2-bd0f4ee26b2d%40gmail.com
にアクセスしてください。
細川淳
unread,
Aug 21, 2023, 7:05:49 AM
8/21/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to radstu...@googlegroups.com
細川です。
補足です。
フォームを半透明にする場合は、プロパティを下記の様に設定してみてください。
TransparentColor: False // True にしてあったら False に戻す
AlphaBrend: True
AlphaBrendValue: 0~255
2023年8月20日(日) 15:07 細川淳 <
j...@serialgames.co.jp
>:
> このディスカッションをウェブ上で閲覧するには、
https://groups.google.com/d/msgid/radstudio-jp/CAEcB0P5_B6OMEtoyHaKq%2BUH6jTZYaS0QY%3DUsqUF0VhYAMuVe0w%40mail.gmail.com
にアクセスしてください。
ooe....@gmail.com
unread,
Aug 21, 2023, 7:50:23 PM
8/21/23
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to radstu...@googlegroups.com
細川さま
教えていただいた方法でできました。
ありがとうございました。
CreateParams って初めて知ったので、
FormCreateから呼び出されてないのに動くの?と思ったんですが、
このメソッド(?)は書けば自動実行されるんですね。
これを使うことで、付箋紙アプリのようなタイトルバーが無く
サイズ変更可能なフォームも作れると分かり、
新しいことが色々できそうで楽しくなりました。
ありがとうございました。
Reply all
Reply to author
Forward
0 new messages