5 static int CaretWidth
= 2;
6 static int CaretHeight
= 16;
7 static int CharWidth
= 10;
8 static int CharHeight
= 16;
9 static HBITMAP CaretBitmap
;
11 LRESULT WINAPI
MainWndProc(HWND
, UINT
, WPARAM
, LPARAM
);
14 WinMain(HINSTANCE hInstance
,
15 HINSTANCE hPrevInstance
,
23 CaretBitmap
= LoadBitmap(hInstance
, (LPCTSTR
)IDB_CARET
);
25 wc
.lpszClassName
= "CaretTestClass";
26 wc
.lpfnWndProc
= MainWndProc
;
27 wc
.style
= CS_VREDRAW
| CS_HREDRAW
;
28 wc
.hInstance
= hInstance
;
29 wc
.hIcon
= LoadIcon(NULL
, (LPCTSTR
)IDI_APPLICATION
);
30 wc
.hCursor
= LoadCursor(NULL
, (LPCTSTR
)IDC_ARROW
);
31 wc
.hbrBackground
= (HBRUSH
)COLOR_WINDOW
;
32 wc
.lpszMenuName
= NULL
;
35 if (RegisterClass(&wc
) == 0)
37 fprintf(stderr
, "RegisterClass failed (last error 0x%lX)\n",
42 hWnd
= CreateWindow(wc
.lpszClassName
,
55 fprintf(stderr
, "CreateWindow failed (last error 0x%lX)\n",
60 ShowWindow(hWnd
, nCmdShow
);
62 while(GetMessage(&msg
, NULL
, 0, 0))
64 TranslateMessage(&msg
);
65 DispatchMessage(&msg
);
71 LRESULT CALLBACK
MainWndProc(HWND hWnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
77 switch(LOWORD(wParam
))
82 DbgPrint("ShowCaret(0x%x)\n", hWnd
);
86 DbgPrint("HideCaret(0x%x)\n", hWnd
);
94 DbgPrint("GetCaretPos() failed!\n");
112 if(!SetCaretPos(pt
.x
, pt
.y
))
113 DbgPrint("SetCaretPos() failed!\n");
117 if(!CreateCaret(hWnd
, CaretBitmap
, 0, 0))
118 DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd
);
121 DbgPrint("ShowCaret(0x%x)\n", hWnd
);
125 if(!CreateCaret(hWnd
, (HBITMAP
)0, CaretWidth
, CaretHeight
))
126 DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd
);
129 DbgPrint("ShowCaret(0x%x)\n", hWnd
);
133 if(!CreateCaret(hWnd
, (HBITMAP
)0, CaretWidth
, CaretHeight
))
134 DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd
);
136 if(!SetCaretPos(1, 1))
137 DbgPrint("SetCaretPos(%i, %i) failed!\n", 1, 1);
142 DbgPrint("DestroyCaret() failed!\n");
147 return DefWindowProc(hWnd
, msg
, wParam
, lParam
);