ReactOS 0.4.16-dev-338-g34e76ad
lineclip.c File Reference
#include <windows.h>
#include <stdio.h>
Include dependency graph for lineclip.c:

Go to the source code of this file.

Functions

LRESULT WINAPI MainWndProc (HWND, UINT, WPARAM, LPARAM)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
 
static void DrawLines (HDC hDC)
 

Function Documentation

◆ DrawLines()

static void DrawLines ( HDC  hDC)
static

Definition at line 63 of file lineclip.c.

64{
65 static struct
66 {
67 int fromx;
68 int fromy;
69 int tox;
70 int toy;
71 }
72 points[ ] =
73 {
74 { 50, 99, 125, 99 },
75 { 160, 99, 190, 99 },
76 { 300, 99, 225, 99 },
77 { 50, 100, 125, 100 },
78 { 160, 100, 190, 100 },
79 { 300, 100, 225, 100 },
80 { 50, 125, 300, 125 },
81 { 50, 149, 125, 149 },
82 { 160, 149, 190, 149 },
83 { 300, 149, 225, 149 },
84 { 50, 150, 125, 150 },
85 { 160, 150, 190, 150 },
86 { 300, 150, 225, 150 },
87 { 160, 249, 190, 249 },
88 { 160, 250, 190, 250 },
89 { 149, 50, 149, 125 },
90 { 149, 160, 149, 190 },
91 { 149, 300, 149, 225 },
92 { 150, 50, 150, 125 },
93 { 150, 160, 150, 190 },
94 { 150, 300, 150, 225 },
95 { 199, 50, 199, 125 },
96 { 199, 160, 199, 190 },
97 { 199, 300, 199, 225 },
98 { 200, 50, 200, 125 },
99 { 200, 160, 200, 190 },
100 { 200, 300, 200, 225 },
101 { 175, 50, 175, 300 },
102 { 50, 55, 300, 290 },
103 { 300, 295, 50, 60 },
104 { 50, 290, 300, 55 },
105 { 300, 60, 50, 295 },
106 { 55, 50, 290, 300 },
107 { 295, 300, 60, 50 },
108 { 55, 300, 290, 50 },
109 { 295, 50, 60, 300 }
110 };
111 int i;
112
113 for (i = 0; i < sizeof(points) / sizeof(points[0]); i++)
114 {
115 MoveToEx(hDC, points[i].fromx, points[i].fromy, NULL);
116 LineTo(hDC, points[i].tox, points[i].toy);
117 }
118}
static HDC hDC
Definition: 3dtext.c:33
#define NULL
Definition: types.h:112
GLsizei const GLfloat * points
Definition: glext.h:8112
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)

Referenced by MainWndProc().

◆ MainWndProc()

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

Definition at line 120 of file lineclip.c.

121{
122 PAINTSTRUCT ps;
123 HDC hDC;
124 RECT clr;
125 HRGN ClipRgn, ExcludeRgn;
126 RECT Rect;
127
128 switch(msg)
129 {
130 case WM_PAINT:
131 GetClientRect(hWnd, &clr);
132 ClipRgn = CreateRectRgnIndirect(&clr);
133 hDC = BeginPaint(hWnd, &ps);
134 Rect.left = 100;
135 Rect.top = 100;
136 Rect.right = 250;
137 Rect.bottom = 150;
138 FillRect(hDC, &Rect, CreateSolidBrush(RGB(0xFF, 0x00, 0x00)));
139 ExcludeRgn = CreateRectRgnIndirect(&Rect);
140 CombineRgn(ClipRgn, ClipRgn, ExcludeRgn, RGN_DIFF);
141 DeleteObject(ExcludeRgn);
142 Rect.left = 150;
143 Rect.top = 150;
144 Rect.right = 200;
145 Rect.bottom = 250;
146 FillRect(hDC, &Rect, CreateSolidBrush(RGB(0xFF, 0x00, 0x00)));
147 SelectObject(hDC, CreatePen(PS_SOLID, 0, RGB(0xFF, 0xFF, 0x00)));
148 DrawLines(hDC);
149 SelectObject(hDC, CreatePen(PS_SOLID, 0, RGB(0x00, 0x00, 0xFF)));
150 ExcludeRgn = CreateRectRgnIndirect(&Rect);
151 CombineRgn(ClipRgn, ClipRgn, ExcludeRgn, RGN_DIFF);
152 DeleteObject(ExcludeRgn);
153 SelectClipRgn(hDC, ClipRgn);
154 DrawLines(hDC);
155 EndPaint(hWnd, &ps);
156 break;
157
158 case WM_DESTROY:
160 break;
161
162 default:
164 }
165 return 0;
166}
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define RGB(r, g, b)
Definition: precomp.h:71
pKey DeleteObject()
static void DrawLines(HDC hDC)
Definition: lineclip.c:63
static HDC
Definition: imagelist.c:88
#define DefWindowProc
Definition: ros2win.h:31
#define RGN_DIFF
Definition: wingdi.h:358
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HRGN WINAPI CreateRectRgnIndirect(_In_ LPCRECT)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define PS_SOLID
Definition: wingdi.h:586
#define WM_PAINT
Definition: winuser.h:1623
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define WM_DESTROY
Definition: winuser.h:1612
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)

Referenced by WinMain().

◆ WinMain()

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

Definition at line 7 of file lineclip.c.

11{
12 WNDCLASS wc;
13 MSG msg;
14 HWND hWnd;
15
16 wc.lpszClassName = "ClipClass";
23 wc.lpszMenuName = NULL;
24 wc.cbClsExtra = 0;
25 wc.cbWndExtra = 0;
26 if (RegisterClass(&wc) == 0)
27 {
28 fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
29 GetLastError());
30 return(1);
31 }
32
33 hWnd = CreateWindow("ClipClass",
34 "Line clipping test",
36 0,
37 0,
40 NULL,
41 NULL,
43 NULL);
44 if (hWnd == NULL)
45 {
46 fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
47 GetLastError());
48 return(1);
49 }
50
51 ShowWindow(hWnd, nCmdShow);
52
53 while(GetMessage(&msg, NULL, 0, 0))
54 {
57 }
58
59 return msg.wParam;
60}
HINSTANCE hInstance
Definition: charmap.c:19
#define stderr
Definition: stdio.h:100
_Check_return_opt_ _CRTIMP int __cdecl fprintf(_Inout_ FILE *_File, _In_z_ _Printf_format_string_ const char *_Format,...)
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: lineclip.c:120
#define WS_OVERLAPPEDWINDOW
Definition: pedump.c:637
#define WS_VSCROLL
Definition: pedump.c:627
#define WS_HSCROLL
Definition: pedump.c:628
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
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define GRAY_BRUSH
Definition: wingdi.h:898
#define CS_VREDRAW
Definition: winuser.h:658
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#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 CW_USEDEFAULT
Definition: winuser.h:225
#define RegisterClass
Definition: winuser.h:5848
#define DispatchMessage
Definition: winuser.h:5777
const CHAR * LPCTSTR
Definition: xmlstorage.h:193