LoginSignup
0
1

More than 1 year has passed since last update.

UWPでマウスカーソルを変更する

Posted at

curファイルを用意する

例えば以下とかを使って作成する。

rcファイルを作成する

この123が後で指定するIDになる。

#define IDI_CURSOR1 123

IDI_CURSOR1 CURSOR "circle.cur"

rcファイルをコンパイルする。

Developer Command Prompt for VS xxxxを起動して

rc xxxx.rc

でxxxx.resファイルが作成される。

resファイルを配置する。

適当に取り込んで以下とかにしておく

項目 設定内容
Build Action None
Copy to Output Directory Copy always

uwp の.csprojファイルをテキストエディタで開いて
一番上のPropertyGroupの中に以下を入れる

    <Win32Resource>Resources\Cursors\circle.res</Win32Resource>

パスは上で配置したパスにする。

カーソルを適用する

rcファイルに記載したIDにする。

        private void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            Window.Current.CoreWindow.PointerCursor = new Windows.UI.Core.CoreCursor(Windows.UI.Core.CoreCursorType.Custom, 123);
        }

cursor_changed_uwp.png

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1