ReactOS 0.4.16-dev-297-gc569aee
carets.c File Reference
#include <windows.h>
#include <stdio.h>
#include "resource.h"
Include dependency graph for carets.c:

Go to the source code of this file.

Functions

ULONG __cdecl DbgPrint (IN PCH Format, IN ...)
 
LRESULT WINAPI MainWndProc (HWND, UINT, WPARAM, LPARAM)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
 

Variables

static int CaretWidth = 2
 
static int CaretHeight = 16
 
static int CharWidth = 10
 
static int CharHeight = 16
 
static HBITMAP CaretBitmap
 

Function Documentation

◆ DbgPrint()

ULONG __cdecl DbgPrint ( IN PCH  Format,
IN ...   
)

◆ MainWndProc()

LRESULT WINAPI MainWndProc ( HWND  hWnd,
UINT  msg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 73 of file carets.c.

74{
75 POINT pt;
76 switch(msg)
77 {
78 case WM_ACTIVATE:
79 switch(LOWORD(wParam))
80 {
81 case WA_ACTIVE:
82 case WA_CLICKACTIVE:
83 if(!ShowCaret(hWnd))
84 DbgPrint("ShowCaret(0x%x)\n", hWnd);
85 break;
86 case WA_INACTIVE:
87 if(!HideCaret(hWnd))
88 DbgPrint("HideCaret(0x%x)\n", hWnd);
89 break;
90 }
91 break;
92
93 case WM_KEYDOWN:
94 if(!GetCaretPos(&pt))
95 {
96 DbgPrint("GetCaretPos() failed!\n");
97 break;
98 }
99 switch(wParam)
100 {
101 case VK_LEFT:
102 pt.x -= CharWidth;
103 break;
104 case VK_UP:
105 pt.y -= CharHeight;
106 break;
107 case VK_RIGHT:
108 pt.x += CharWidth;
109 break;
110 case VK_DOWN:
111 pt.y += CharHeight;
112 break;
113 }
114 if(!SetCaretPos(pt.x, pt.y))
115 DbgPrint("SetCaretPos() failed!\n");
116 break;
117
118 case WM_RBUTTONDOWN:
119 if(!CreateCaret(hWnd, CaretBitmap, 0, 0))
120 DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd);
121 else
122 if(!ShowCaret(hWnd))
123 DbgPrint("ShowCaret(0x%x)\n", hWnd);
124 break;
125
126 case WM_LBUTTONDOWN:
128 DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd);
129 else
130 if(!ShowCaret(hWnd))
131 DbgPrint("ShowCaret(0x%x)\n", hWnd);
132 break;
133
134 case WM_CREATE:
136 DbgPrint("CreateCaret() for window 0x%x failed!\n", hWnd);
137 else
138 if(!SetCaretPos(1, 1))
139 DbgPrint("SetCaretPos(%i, %i) failed!\n", 1, 1);
140 break;
141
142 case WM_DESTROY:
143 if(!DestroyCaret())
144 DbgPrint("DestroyCaret() failed!\n");
146 break;
147
148 default:
150 }
151 return 0;
152}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
static int CaretHeight
Definition: carets.c:6
static int CharWidth
Definition: carets.c:7
static int CharHeight
Definition: carets.c:8
static int CaretWidth
Definition: carets.c:5
static HBITMAP CaretBitmap
Definition: carets.c:9
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define pt(x, y)
Definition: drawing.c:79
#define DbgPrint
Definition: hal.h:12
static HBITMAP
Definition: button.c:44
#define LOWORD(l)
Definition: pedump.c:82
#define DefWindowProc
Definition: ros2win.h:31
BOOL WINAPI ShowCaret(_In_opt_ HWND)
#define WM_CREATE
Definition: winuser.h:1611
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define VK_UP
Definition: winuser.h:2228
#define WA_INACTIVE
Definition: winuser.h:2625
#define WM_LBUTTONDOWN
Definition: winuser.h:1779
#define WM_ACTIVATE
Definition: winuser.h:1615
#define WM_RBUTTONDOWN
Definition: winuser.h:1782
BOOL WINAPI GetCaretPos(_Out_ LPPOINT)
#define WA_ACTIVE
Definition: winuser.h:2626
#define VK_LEFT
Definition: winuser.h:2227
#define VK_RIGHT
Definition: winuser.h:2229
#define VK_DOWN
Definition: winuser.h:2230
#define WA_CLICKACTIVE
Definition: winuser.h:2627
#define WM_DESTROY
Definition: winuser.h:1612
#define WM_KEYDOWN
Definition: winuser.h:1718
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)
BOOL WINAPI CreateCaret(_In_ HWND, _In_opt_ HBITMAP, _In_ int, _In_ int)
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35
BOOL WINAPI HideCaret(_In_opt_ HWND)

Referenced by WinMain().

◆ WinMain()

int WINAPI WinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPSTR  lpszCmdLine,
int  nCmdShow 
)

Definition at line 16 of file carets.c.

20{
21 WNDCLASS wc;
22 MSG msg;
23 HWND hWnd;
24
26
27 wc.lpszClassName = "CaretTestClass";
33 wc.hbrBackground = (HBRUSH)COLOR_WINDOW;
34 wc.lpszMenuName = NULL;
35 wc.cbClsExtra = 0;
36 wc.cbWndExtra = 0;
37 if (RegisterClass(&wc) == 0)
38 {
39 fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
40 GetLastError());
41 return(1);
42 }
43
45 "Caret Test",
47 0,
48 0,
49 200,
50 250,
51 NULL,
52 NULL,
54 NULL);
55 if (hWnd == NULL)
56 {
57 fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
58 GetLastError());
59 return(1);
60 }
61
62 ShowWindow(hWnd, nCmdShow);
63
64 while(GetMessage(&msg, NULL, 0, 0))
65 {
68 }
69
70 return msg.wParam;
71}
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: carets.c:73
HINSTANCE hInstance
Definition: charmap.c:19
#define NULL
Definition: types.h:112
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
#define IDB_CARET
Definition: resource.h:1
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
HBRUSH hbrBackground
Definition: winuser.h:3173
HICON hIcon
Definition: winuser.h:3171
HINSTANCE hInstance
Definition: winuser.h:3170
HCURSOR hCursor
Definition: winuser.h:3172
int cbWndExtra
Definition: winuser.h:3169
UINT style
Definition: winuser.h:3166
LPCSTR lpszMenuName
Definition: winuser.h:3174
LPCSTR lpszClassName
Definition: winuser.h:3175
WNDPROC lpfnWndProc
Definition: winuser.h:3167
int cbClsExtra
Definition: winuser.h:3168
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define COLOR_WINDOW
Definition: winuser.h:921
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define LoadBitmap
Definition: winuser.h:5823
#define CS_HREDRAW
Definition: winuser.h:653
#define IDC_ARROW
Definition: winuser.h:687
#define IDI_APPLICATION
Definition: winuser.h:704
#define CreateWindow
Definition: winuser.h:5766
#define GetMessage
Definition: winuser.h:5802
#define LoadIcon
Definition: winuser.h:5825
#define LoadCursor
Definition: winuser.h:5824
#define RegisterClass
Definition: winuser.h:5848
#define DispatchMessage
Definition: winuser.h:5777
const CHAR * LPCTSTR
Definition: xmlstorage.h:193

Variable Documentation

◆ CaretBitmap

HBITMAP CaretBitmap
static

Definition at line 9 of file carets.c.

Referenced by MainWndProc(), and WinMain().

◆ CaretHeight

int CaretHeight = 16
static

Definition at line 6 of file carets.c.

Referenced by MainWndProc().

◆ CaretWidth

int CaretWidth = 2
static

Definition at line 5 of file carets.c.

Referenced by MainWndProc().

◆ CharHeight

int CharHeight = 16
static

Definition at line 8 of file carets.c.

Referenced by _Success_(), FontSizeChange(), MainWndProc(), and UpdateFontPreview().

◆ CharWidth

int CharWidth = 10
static

Definition at line 7 of file carets.c.

Referenced by _Success_(), FontSizeChange(), MainWndProc(), and UpdateFontPreview().