GetCaretPosでキャレットの位置を取得する。
GetCaretPos 関数 (winuser.h) - Win32 apps | Microsoft Learn
メニューリソースに、
Item2-2を追加。
GetCaretPos.cppでは、
Item2-2が選択されたら、GetCaretPosでキャレット位置を取得して表示。
渡したPOINT構造体変数ptにエディットボックス上のどこの位置座標かが格納される。
(ドット単位でキャレットの棒の一番上の点の座標かな。)
![キャレットを一番左に](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20221209/20221209162607.png)
キャレットを一番左に。
![Item2-2を選択](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20221209/20221209162659.png)
Item2-2を選択。
![(0, 0)の位置](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20221209/20221209162742.png)
(0, 0)の位置。
![1文字目の後ろ](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20221209/20221209162818.png)
1文字目の後ろ。
![(15, 0)の位置](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20221209/20221209162853.png)
(15, 0)の位置。
![一番右、5文字目の後ろ。](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20221209/20221209162933.png)
一番右、5文字目の後ろ。
![(75, 0)の位置](https://cdn-ak.f.st-hatena.com/images/fotolife/B/BG1/20221209/20221209163014.png)
(75, 0)の位置。
Sample/winapi/GetCaretPos/GetCaretPos/src/GetCaretPos at master · bg1bgst333/Sample · GitHub