ReactOS  0.4.15-dev-1206-g731eddf
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:
177  PostQuitMessage(0);
178  break;
179 
180  default:
181  return DefWindowProc(hWnd, msg, wParam, lParam);
182  }
183  return 0;
184 }
ULONG UpperLeft
Definition: wingdi.h:2804
ULONG LowerRight
Definition: wingdi.h:2805
static HDC
Definition: imagelist.c:92
HWND hWnd
Definition: settings.c:17
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
WPARAM wParam
Definition: combotst.c:138
LONG y
Definition: wingdi.h:2784
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define DefWindowProc
Definition: ros2win.h:31
#define WM_DESTROY
Definition: winuser.h:1591
LONG x
Definition: wingdi.h:2783
#define WM_PAINT
Definition: winuser.h:1602
static HDC hDC
Definition: 3dtext.c:33
COLOR16 Alpha
Definition: wingdi.h:2788
BOOL WINAPI GdiGradientFill(HDC hdc, TRIVERTEX *vert_array, ULONG nvert, void *grad_array, ULONG ngrad, ULONG mode)
#define msg(x)
Definition: auth_time.c:54
COLOR16 Red
Definition: wingdi.h:2785
COLOR16 Blue
Definition: wingdi.h:2787
COLOR16 Green
Definition: wingdi.h:2786
LPARAM lParam
Definition: combotst.c:139
__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 11 of file gradient.c.

15 {
16  WNDCLASS wc;
17  MSG msg;
18  HWND hWnd;
19 
20  wc.lpszClassName = "GradientClass";
23  wc.hInstance = hInstance;
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,
46  hInstance,
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 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define DispatchMessage
Definition: winuser.h:5740
BOOL WINAPI TranslateMessage(_In_ const MSG *)
const CHAR * LPCTSTR
Definition: xmlstorage.h:193
#define CreateWindow
Definition: winuser.h:5729
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
HWND hWnd
Definition: settings.c:17
int cbClsExtra
Definition: winuser.h:3140
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1044
#define CS_HREDRAW
Definition: winuser.h:648
LPCSTR lpszMenuName
Definition: winuser.h:3146
#define IDI_APPLICATION
Definition: winuser.h:699
HBRUSH hbrBackground
Definition: winuser.h:3145
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LRESULT WINAPI MainWndProc(HWND, UINT, WPARAM, LPARAM)
Definition: gradient.c:71
int cbWndExtra
Definition: winuser.h:3141
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:3144
#define CW_USEDEFAULT
Definition: winuser.h:225
smooth NULL
Definition: ftsmooth.c:416
#define GRAY_BRUSH
Definition: wingdi.h:897
#define CS_VREDRAW
Definition: winuser.h:653
#define WS_HSCROLL
Definition: pedump.c:628
LPCSTR lpszClassName
Definition: winuser.h:3147
#define LoadCursor
Definition: winuser.h:5787
UINT style
Definition: winuser.h:3138
HINSTANCE hInstance
Definition: winuser.h:3142
#define WS_VSCROLL
Definition: pedump.c:627
#define GetMessage
Definition: winuser.h:5765
WNDPROC lpfnWndProc
Definition: winuser.h:3139
#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:5811
#define LoadIcon
Definition: winuser.h:5788
HICON hIcon
Definition: winuser.h:3143