ReactOS  0.4.14-dev-98-gb0d4763
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 ...   
)

Referenced by MainWndProc().

◆ 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");
145  PostQuitMessage(0);
146  break;
147 
148  default:
149  return DefWindowProc(hWnd, msg, wParam, lParam);
150  }
151  return 0;
152 }
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
#define pt(x, y)
Definition: drawing.c:79
static int CaretHeight
Definition: carets.c:6
HWND hWnd
Definition: settings.c:17
#define VK_LEFT
Definition: winuser.h:2199
#define VK_DOWN
Definition: winuser.h:2202
static int CaretWidth
Definition: carets.c:5
WPARAM wParam
Definition: combotst.c:138
static HBITMAP CaretBitmap
Definition: carets.c:9
#define VK_UP
Definition: winuser.h:2200
BOOL WINAPI HideCaret(_In_opt_ HWND)
BOOL WINAPI CreateCaret(_In_ HWND, _In_opt_ HBITMAP, _In_ int, _In_ int)
#define WM_KEYDOWN
Definition: winuser.h:1697
ULONG __cdecl DbgPrint(IN PCH Format, IN ...)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
#define WM_RBUTTONDOWN
Definition: winuser.h:1761
static int CharHeight
Definition: carets.c:8
#define WA_ACTIVE
Definition: winuser.h:2598
#define WA_CLICKACTIVE
Definition: winuser.h:2599
static int CharWidth
Definition: carets.c:7
#define VK_RIGHT
Definition: winuser.h:2201
#define WM_ACTIVATE
Definition: winuser.h:1594
BOOL WINAPI DestroyCaret(void)
Definition: caret.c:35
#define msg(x)
Definition: auth_time.c:54
#define WM_CREATE
Definition: winuser.h:1590
BOOL WINAPI GetCaretPos(_Out_ LPPOINT)
BOOL WINAPI ShowCaret(_In_opt_ HWND)
#define WA_INACTIVE
Definition: winuser.h:2597
static HBITMAP
Definition: button.c:44
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
BOOL WINAPI SetCaretPos(_In_ int, _In_ int)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)

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";
30  wc.hInstance = hInstance;
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,
53  hInstance,
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 }
#define DispatchMessage
Definition: winuser.h:5666
BOOL WINAPI TranslateMessage(_In_ const MSG *)
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define CreateWindow
Definition: winuser.h:5655
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hWnd
Definition: settings.c:17
int cbClsExtra
Definition: winuser.h:3139
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3145
#define IDI_APPLICATION
Definition: winuser.h:699
HBRUSH hbrBackground
Definition: winuser.h:3144
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define COLOR_WINDOW
Definition: winuser.h:908
static HBITMAP CaretBitmap
Definition: carets.c:9
int cbWndExtra
Definition: winuser.h:3140
HINSTANCE hInstance
Definition: charmap.c:20
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
HCURSOR hCursor
Definition: winuser.h:3143
smooth NULL
Definition: ftsmooth.c:416
#define LoadBitmap
Definition: winuser.h:5712
#define CS_VREDRAW
Definition: winuser.h:653
#define IDB_CARET
Definition: resource.h:1
LPCSTR lpszClassName
Definition: winuser.h:3146
#define LoadCursor
Definition: winuser.h:5713
UINT style
Definition: winuser.h:3137
HINSTANCE hInstance
Definition: winuser.h:3141
#define GetMessage
Definition: winuser.h:5691
WNDPROC lpfnWndProc
Definition: winuser.h:3138
#define msg(x)
Definition: auth_time.c:54
#define IDC_ARROW
Definition: winuser.h:682
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
FILE * stderr
#define RegisterClass
Definition: winuser.h:5737
#define LoadIcon
Definition: winuser.h:5714
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: carets.c:73
HICON hIcon
Definition: winuser.h:3142

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 FontSizeChange(), GetFontCellSize(), MainWndProc(), and UpdateFontPreview().

◆ CharWidth

int CharWidth = 10
static

Definition at line 7 of file carets.c.

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