ReactOS 0.4.15-dev-5667-ged97270
gradient.c File Reference
#include <windows.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for gradient.c:

Go to the source code of this file.

Functions

BOOL WINAPI GdiGradientFill (HDC hdc, TRIVERTEX *vert_array, ULONG nvert, void *grad_array, ULONG ngrad, ULONG mode)
 
LRESULT WINAPI MainWndProc (HWND, UINT, WPARAM, LPARAM)
 
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpszCmdLine, int nCmdShow)
 

Function Documentation

◆ GdiGradientFill()

BOOL WINAPI GdiGradientFill ( HDC  hdc,
TRIVERTEX vert_array,
ULONG  nvert,
void grad_array,
ULONG  ngrad,
ULONG  mode 
)

◆ MainWndProc()

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

Definition at line 71 of file gradient.c.

72{
73 HDC hDC;
74
75 switch(msg)
76 {
77 case WM_PAINT:
78 {
79 PAINTSTRUCT ps;
80 TRIVERTEX vert [5] ;
81 GRADIENT_TRIANGLE gTRi[3];
82 GRADIENT_RECT gRect[2];
83 hDC = BeginPaint(hWnd, &ps);
84
85 vert [0] .x = 0;
86 vert [0] .y = 0;
87 vert [0] .Red = 0xff00;
88 vert [0] .Green = 0xff00;
89 vert [0] .Blue = 0xff00;
90 vert [0] .Alpha = 0x0000;
91
92 vert [1] .x = 300;
93 vert [1] .y = 20;
94 vert [1] .Red = 0x0000;
95 vert [1] .Green = 0x0000;
96 vert [1] .Blue = 0xff00;
97 vert [1] .Alpha = 0x0000;
98
99 vert [2] .x = 100;
100 vert [2] .y = 200;
101 vert [2] .Red = 0xff00;
102 vert [2] .Green = 0x0000;
103 vert [2] .Blue = 0x0000;
104 vert [2] .Alpha = 0x0000;
105
106 vert [3] .x = 250;
107 vert [3] .y = 300;
108 vert [3] .Red = 0x8000;
109 vert [3] .Green = 0x8000;
110 vert [3] .Blue = 0x0000;
111 vert [3] .Alpha = 0x0000;
112
113 vert [4] .x = 325;
114 vert [4] .y = 300;
115 vert [4] .Red = 0x0000;
116 vert [4] .Green = 0xff00;
117 vert [4] .Blue = 0x0000;
118 vert [4] .Alpha = 0x0000;
119
120 gTRi[0].Vertex1 = 0;
121 gTRi[0].Vertex2 = 1;
122 gTRi[0].Vertex3 = 2;
123
124 gTRi[1].Vertex1 = 1;
125 gTRi[1].Vertex2 = 2;
126 gTRi[1].Vertex3 = 3;
127
128 gTRi[2].Vertex1 = 1;
129 gTRi[2].Vertex2 = 3;
130 gTRi[2].Vertex3 = 4;
131
132 GdiGradientFill(hDC,vert,5,&gTRi,3,GRADIENT_FILL_TRIANGLE);
133
134
135 vert [0] .x = 5;
136 vert [0] .y = 200;
137 vert [0] .Red = 0x0000;
138 vert [0] .Green = 0x0000;
139 vert [0] .Blue = 0x0000;
140 vert [0] .Alpha = 0x0000;
141
142 vert [1] .x = 90;
143 vert [1] .y = 240;
144 vert [1] .Red = 0x0000;
145 vert [1] .Green = 0x0000;
146 vert [1] .Blue = 0xff00;
147 vert [1] .Alpha = 0x0000;
148
149 vert [2] .x = 5;
150 vert [2] .y = 245;
151 vert [2] .Red = 0x0000;
152 vert [2] .Green = 0x0000;
153 vert [2] .Blue = 0x0000;
154 vert [2] .Alpha = 0x0000;
155
156 vert [3] .x = 90;
157 vert [3] .y = 300;
158 vert [3] .Red = 0x0000;
159 vert [3] .Green = 0x0000;
160 vert [3] .Blue = 0xff00;
161 vert [3] .Alpha = 0x0000;
162
163 gRect[0].UpperLeft = 0;
164 gRect[0].LowerRight = 1;
165
166 gRect[1].UpperLeft = 2;
167 gRect[1].LowerRight = 3;
168
169 GdiGradientFill(hDC,vert,4,&gRect[0],1,GRADIENT_FILL_RECT_H);
170 GdiGradientFill(hDC,vert,4,&gRect[1],1,GRADIENT_FILL_RECT_V);
171
172 EndPaint(hWnd, &ps);
173 break;
174 }
175
176 case WM_DESTROY:
178 break;
179
180 default:
182 }
183 return 0;
184}
static HDC hDC
Definition: 3dtext.c:33
#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
BOOL WINAPI GdiGradientFill(HDC hdc, TRIVERTEX *vert_array, ULONG nvert, void *grad_array, ULONG ngrad, ULONG mode)
static HDC
Definition: imagelist.c:92
#define DefWindowProc
Definition: ros2win.h:31
ULONG LowerRight
Definition: wingdi.h:2806
ULONG UpperLeft
Definition: wingdi.h:2805
COLOR16 Red
Definition: wingdi.h:2786
LONG y
Definition: wingdi.h:2785
COLOR16 Green
Definition: wingdi.h:2787
COLOR16 Alpha
Definition: wingdi.h:2789
COLOR16 Blue
Definition: wingdi.h:2788
LONG x
Definition: wingdi.h:2784
#define WM_PAINT
Definition: winuser.h:1610
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define WM_DESTROY
Definition: winuser.h:1599
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 11 of file gradient.c.

15{
16 WNDCLASS wc;
17 MSG msg;
18 HWND hWnd;
19
20 wc.lpszClassName = "GradientClass";
27 wc.lpszMenuName = NULL;
28 wc.cbClsExtra = 0;
29 wc.cbWndExtra = 0;
30 if (RegisterClass(&wc) == 0)
31 {
32 fprintf(stderr, "RegisterClass failed (last error 0x%lX)\n",
33 GetLastError());
34 return(1);
35 }
36
37 hWnd = CreateWindow("GradientClass",
38 "GradientFill Test",
40 0,
41 0,
44 NULL,
45 NULL,
47 NULL);
48 if (hWnd == NULL)
49 {
50 fprintf(stderr, "CreateWindow failed (last error 0x%lX)\n",
51 GetLastError());
52 return(1);
53 }
54
55 //tf = CreateFontA(14, 0, 0, TA_BASELINE, FW_NORMAL, FALSE, FALSE, FALSE,
56 // ANSI_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
57 // DEFAULT_QUALITY, FIXED_PITCH|FF_DONTCARE, "Timmons");
58
59 ShowWindow(hWnd, nCmdShow);
60
61 while(GetMessage(&msg, NULL, 0, 0))
62 {
65 }
66
67 //DeleteObject(tf);
68
69 return msg.wParam;
70}
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,...)
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: gradient.c:71
#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:3160
HICON hIcon
Definition: winuser.h:3158
HINSTANCE hInstance
Definition: winuser.h:3157
HCURSOR hCursor
Definition: winuser.h:3159
int cbWndExtra
Definition: winuser.h:3156
UINT style
Definition: winuser.h:3153
LPCSTR lpszMenuName
Definition: winuser.h:3161
LPCSTR lpszClassName
Definition: winuser.h:3162
WNDPROC lpfnWndProc
Definition: winuser.h:3154
int cbClsExtra
Definition: winuser.h:3155
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
DWORD WINAPI GetLastError(void)
Definition: except.c:1040
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define GRAY_BRUSH
Definition: wingdi.h:898
#define CS_VREDRAW
Definition: winuser.h:653
BOOL WINAPI TranslateMessage(_In_ const MSG *)
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define CS_HREDRAW
Definition: winuser.h:648
#define IDC_ARROW
Definition: winuser.h:682
#define IDI_APPLICATION
Definition: winuser.h:699
#define CreateWindow
Definition: winuser.h:5744
#define GetMessage
Definition: winuser.h:5780
#define LoadIcon
Definition: winuser.h:5803
#define LoadCursor
Definition: winuser.h:5802
#define CW_USEDEFAULT
Definition: winuser.h:225
#define RegisterClass
Definition: winuser.h:5826
#define DispatchMessage
Definition: winuser.h:5755
const CHAR * LPCTSTR
Definition: xmlstorage.h:193