1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
/*
 * PROJECT:         ReactOS api tests
 * LICENSE:         GPL - See COPYING in the top level directory
 * PURPOSE:         Test for ExtCreatePen
 * PROGRAMMERS:     Timo Kreuzer
 */

#include "precomp.h"

#define ok_lasterror(err) \
    ok(GetLastError() == err, "expected last error " #err " but got 0x%lx\n", GetLastError());

#define ok_elp(hPen, elp, pstyle, width, bstyle, color, hatch, cstyle) \
    ok(GetObjectA(hPen, sizeof(elpBuffer), elp) != 0, "GetObject failed\n"); \
    ok((elp)->elpPenStyle == (pstyle), "Wrong elpPenStyle, expected 0x%lx, got 0x%lx\n", (DWORD)pstyle, (elp)->elpPenStyle); \
    ok((elp)->elpWidth == width, "Wrong elpWidth, expected %lu, got %lu\n", (DWORD)width, (elp)->elpWidth); \
    ok((elp)->elpBrushStyle == (bstyle), "Wrong elpBrushStyle, expected 0x%x, got 0x%x\n", bstyle, (elp)->elpBrushStyle); \
    ok((elp)->elpColor == color, "Wrong elpColor, expected 0x%lx, got 0x%lx\n", (COLORREF)color, (elp)->elpColor); \
    ok((elp)->elpHatch == hatch, "Wrong elpHatch, expected 0x%p, got 0x%p\n", (PVOID)hatch, (PVOID)(elp)->elpHatch); \
    ok((elp)->elpNumEntries == cstyle, "Wrong elpNumEntries, expected %lu got %lu\n", (DWORD)cstyle, (elp)->elpNumEntries);

void Test_ExtCreatePen_Params()
{
    HPEN hPen;
    LOGBRUSH logbrush;
    struct
    {
        EXTLOGPEN extlogpen;
        ULONG styles[16];
    } elpBuffer;
    PEXTLOGPEN pelp = &elpBuffer.extlogpen;

    DWORD adwStyles[17] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};

    /* Test NULL logbrush */
    SetLastError(0);
    _SEH2_TRY
    {
        hPen = ExtCreatePen(PS_COSMETIC, 1, NULL, 0, 0);<--- hPen is assigned
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
        SetLastError(0xdeadc0de);
    }
    _SEH2_END;
    ok_lasterror(0xdeadc0de);

    logbrush.lbStyle = BS_SOLID;
    logbrush.lbColor = RGB(1, 2, 3);
    logbrush.lbHatch = 0;
    hPen = ExtCreatePen(PS_COSMETIC, 1, &logbrush, 0, 0);<--- hPen is overwritten
    ok(hPen != NULL, "ExtCreatePen failed\n");
    ok_elp(hPen, pelp, PS_COSMETIC, 1, BS_SOLID, RGB(1,2,3), 0, 0);

    /* Test if we have an EXTPEN */
    ok(GDI_HANDLE_GET_TYPE(hPen) == GDI_OBJECT_TYPE_EXTPEN, "hPen=%p\n", hPen);
    DeleteObject(hPen);

    /* Test invalid style mask (0x0F) */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(9, 1, &logbrush, 0, 0);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test PS_ALTERNATE with PS_GEOMETRIC */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_ALTERNATE | PS_GEOMETRIC, 1, &logbrush, 0, NULL);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test invalid endcap mask (0xF00) */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(0x300, 1, &logbrush, 0, 0);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test invalid join mask (F000) */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(0x3000, 1, &logbrush, 0, 0);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test invalid type mask (F0000) */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(0x20000, 1, &logbrush, 0, 0);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test PS_COSMETIC with dwWidth != 1 */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_COSMETIC, -1, &logbrush, 0, 0);
    ok(hPen != NULL, "ExtCreatePen failed\n");
    ok_lasterror(0xdeadc0de);
    ok_elp(hPen, pelp, PS_COSMETIC, 1, BS_SOLID, RGB(1,2,3), 0, 0);
    DeleteObject(hPen);
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_COSMETIC, 2, &logbrush, 0, 0);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_COSMETIC, 0, &logbrush, 0, 0);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test PS_COSMETIC with PS_ENDCAP_SQUARE */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_COSMETIC | PS_ENDCAP_SQUARE, 1, &logbrush, 0, NULL);
    ok(hPen != NULL, "ExtCreatePen failed\n");
    ok_lasterror(0xdeadc0de);
    ok_elp(hPen, pelp, PS_COSMETIC | PS_ENDCAP_SQUARE, 1, BS_SOLID, RGB(1,2,3), 0, 0);
    DeleteObject(hPen);

    /* Test styles without PS_USERSTYLE */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_GEOMETRIC, 1, &logbrush, 16, adwStyles);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_GEOMETRIC, 1, &logbrush, 0, adwStyles);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_GEOMETRIC, 1, &logbrush, 16, NULL);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test PS_USERSTYLE */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 16, adwStyles);
    ok(hPen != NULL, "ExtCreatePen failed\n");
    ok_lasterror(0xdeadc0de);
    ok_elp(hPen, pelp, PS_GEOMETRIC | PS_USERSTYLE, 5, BS_SOLID, RGB(1,2,3), 0, 16);
    DeleteObject(hPen);

    /* Test PS_USERSTYLE with PS_COSMETIC */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_COSMETIC | PS_USERSTYLE, 5, &logbrush, 16, adwStyles);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test PS_USERSTYLE with 17 styles */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 17, adwStyles);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test PS_USERSTYLE with 1 style */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 5, &logbrush, 1, adwStyles);
    ok(hPen != NULL, "ExtCreatePen failed\n");
    ok_lasterror(0xdeadc0de);
    ok_elp(hPen, pelp, PS_GEOMETRIC | PS_USERSTYLE, 5, BS_SOLID, RGB(1,2,3), 0, 1);
    DeleteObject(hPen);

    /* Test PS_USERSTYLE with NULL lpStyles */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_GEOMETRIC | PS_USERSTYLE, 1, &logbrush, 2, NULL);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test PS_NULL */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_NULL, 1, &logbrush, 0, NULL);
    ok(hPen == GetStockObject(NULL_PEN), "ExtCreatePen should return NULL_PEN, but returned %p\n", hPen);
    ok_lasterror(0xdeadc0de);

    /* When the size is anything other than sizeof(EXTLOGPEN), we will get a LOGPEN! */
    ok(GetObjectA(hPen, sizeof(EXTLOGPEN) + 1, pelp) == sizeof(LOGPEN), "GetObject failed\n");

    /* ACHTUNG: special handling, we want sizeof(EXTLOGPEN) and nothing else */
    ok(GetObjectA(hPen, sizeof(EXTLOGPEN), pelp) == sizeof(EXTLOGPEN), "GetObject failed\n");
    ok(pelp->elpPenStyle == PS_NULL, "Wrong elpPenStyle, expected PS_NULL, got 0x%lx\n", pelp->elpPenStyle);
    ok(pelp->elpWidth == 0, "Wrong elpWidth, expected 0, got %lu\n", pelp->elpWidth);
    ok(pelp->elpBrushStyle == BS_SOLID, "Wrong elpBrushStyle, expected BS_SOLID, got 0x%x\n", pelp->elpBrushStyle);
    ok(pelp->elpColor == 0, "Wrong elpColor, expected 0, got 0x%lx\n", pelp->elpColor);
    ok(pelp->elpHatch == 0, "Wrong elpHatch, expected 0, got 0x%lx\n", pelp->elpHatch);
    ok(pelp->elpNumEntries == 0, "Wrong elpNumEntries, expected %u got %lu\n", 0, pelp->elpNumEntries);

    /* Test PS_NULL with styles */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_NULL, 1, &logbrush, 1, adwStyles);
    ok(hPen == NULL, "ExtCreatePen should fail\n");
    ok_lasterror(ERROR_INVALID_PARAMETER);

    /* Test 0 width */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_GEOMETRIC, 0, &logbrush, 0, 0);
    ok(hPen != NULL, "ExtCreatePen failed\n");
    ok_lasterror(0xdeadc0de);
    ok_elp(hPen, pelp, PS_GEOMETRIC, 0, BS_SOLID, RGB(1,2,3), 0, 0);
    DeleteObject(hPen);

    /* Test negative width */
    SetLastError(0xdeadc0de);
    hPen = ExtCreatePen(PS_GEOMETRIC, -7942, &logbrush, 0, 0);
    ok(hPen != NULL, "ExtCreatePen failed\n");
    ok_lasterror(0xdeadc0de);
    ok_elp(hPen, pelp, PS_GEOMETRIC, 7942, BS_SOLID, RGB(1,2,3), 0, 0);
    DeleteObject(hPen);

}

BOOL
Test_ExtCreatePen_Expect(
    DWORD dwPenStyle,
    DWORD dwWidth,
    DWORD dwStyleCount,
    PDWORD pdwStyles,
    UINT lbStyle,
    ULONG_PTR lbHatch,
    PBOOL pbExpectException,
    PEXTLOGPEN pelpExpect)
{
    *pbExpectException = FALSE;

    if ((dwPenStyle & PS_STYLE_MASK) == PS_USERSTYLE)
    {
        if (pdwStyles == NULL)
        {
            return FALSE;
        }
    }
    else
    {
        if ((dwStyleCount != 0) || (pdwStyles != NULL))
        {
            return FALSE;
        }
    }

    if (lbStyle == BS_PATTERN)
    {
        if (lbHatch == 0) return FALSE;
    }

    if (lbStyle == BS_DIBPATTERNPT)
    {
        if (lbHatch == 0) return FALSE;
        if (lbHatch < 0xFFFF)
        {
            *pbExpectException = TRUE;
            return FALSE;
        }
    }

    if (lbStyle == BS_DIBPATTERN)
    {
        return FALSE;
    }

    if ((dwPenStyle & PS_STYLE_MASK) == PS_USERSTYLE)
    {
        if (dwStyleCount == 0)
        {
            return FALSE;
        }

        if (dwStyleCount > 16)
        {
            return FALSE;
        }

        if ((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC)
        {
            if (pdwStyles[0] == 0)
            {
                return FALSE;
            }
        }
        else
        {
            if ((pdwStyles[0] == 0) && (dwStyleCount == 1))
            {
                return FALSE;
            }
        }
    }

    if ((dwPenStyle & PS_STYLE_MASK) == PS_NULL)
    {
        pelpExpect->elpPenStyle = PS_NULL;
        pelpExpect->elpWidth = 0;
        pelpExpect->elpBrushStyle = BS_SOLID;
        pelpExpect->elpColor = 0;
        pelpExpect->elpHatch = 0;
        pelpExpect->elpNumEntries = 0;
        return TRUE;
    }


    if (((dwPenStyle & PS_STYLE_MASK) >> 0) > PS_ALTERNATE) return FALSE;
    if (((dwPenStyle & PS_ENDCAP_MASK) >> 8) > 2) return FALSE;
    if (((dwPenStyle & PS_JOIN_MASK) >> 12) > 2) return FALSE;
    if (((dwPenStyle & PS_TYPE_MASK) >> 16) > 1) return FALSE;

    dwWidth = abs(((LONG)dwWidth));

    if ((dwPenStyle & PS_TYPE_MASK) == PS_COSMETIC)
    {
        if (dwWidth != 1) return FALSE;

        if ((lbStyle != BS_SOLID) &&
            (lbStyle != BS_HATCHED))
        {
            return FALSE;
        }

        if (lbStyle == BS_HATCHED)
        {
            if ((lbHatch != 8) &&
                (lbHatch != 10) &&
                (lbHatch != 12))
            {
                return FALSE;
            }

            if (lbHatch >= HS_API_MAX)
            {
                return FALSE;
            }
        }

        if ((dwPenStyle & PS_STYLE_MASK) == PS_INSIDEFRAME)
        {
            return FALSE;
        }
    }
    else
    {
        if ((dwPenStyle & PS_STYLE_MASK) == PS_ALTERNATE)
        {
            return FALSE;
        }

        if (((dwPenStyle & PS_STYLE_MASK) != PS_SOLID) &&
            ((dwPenStyle & PS_STYLE_MASK) != PS_INSIDEFRAME) &&
            ((dwPenStyle & PS_STYLE_MASK) != PS_USERSTYLE))
        {
            if (dwWidth == 0)
            {
                return FALSE;
            }
        }

        if (lbStyle == BS_NULL)
        {
            pelpExpect->elpPenStyle = PS_NULL;
            pelpExpect->elpWidth = 0;
            pelpExpect->elpBrushStyle = BS_SOLID;
            pelpExpect->elpColor = 0;
            pelpExpect->elpHatch = 0;
            pelpExpect->elpNumEntries = 0;
            return TRUE;
        }

        if (lbStyle > BS_HATCHED)
        {
            return FALSE;
        }

        if (lbStyle == BS_HATCHED)
        {
            if (lbHatch >= HS_API_MAX)
            {
                return FALSE;
            }
        }

    }

    pelpExpect->elpPenStyle = dwPenStyle;
    pelpExpect->elpWidth = dwWidth;
    pelpExpect->elpBrushStyle = lbStyle;
    pelpExpect->elpColor = RGB(1,2,3);
    pelpExpect->elpHatch = lbHatch;
    pelpExpect->elpNumEntries = dwStyleCount;
    //pelpExpect->elpStyleEntry[1];

    return TRUE;
}

void
Test_ExtCreatePen_Helper(
    DWORD dwPenStyle,
    DWORD dwWidth,
    DWORD dwStyleCount,
    PDWORD pdwStyles,
    UINT lbStyle,
    ULONG_PTR lbHatch)
{
    LOGBRUSH lb;
    HPEN hpen;
    BOOL bExpectSuccess, bExpectException, bGotException = FALSE;
    struct
    {
        EXTLOGPEN extlogpen;
        ULONG styles[16];
    } elpBuffer;
    PEXTLOGPEN pelp = &elpBuffer.extlogpen;
    EXTLOGPEN elpExpect;

    lb.lbStyle = lbStyle;
    lb.lbColor = RGB(1,2,3);
    lb.lbHatch = lbHatch;

    bExpectSuccess = Test_ExtCreatePen_Expect(
                             dwPenStyle,
                             dwWidth,
                             dwStyleCount,
                             pdwStyles,
                             lbStyle,
                             lbHatch,
                             &bExpectException,
                             &elpExpect);

    _SEH2_TRY
    {
        hpen = ExtCreatePen(dwPenStyle, dwWidth, &lb, dwStyleCount, pdwStyles);
    }
    _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
    {
        bGotException = TRUE;
    }
    _SEH2_END;

#define ok2(expression, text, expected, got) \
    ok(expression, text \
       "(dwPenStyle=0x%lx, dwWidth=%lu, dwStyleCount=%lu, pdwStyles=%p, lbStyle=%u, lbHatch=%p)\n", \
       expected, got, dwPenStyle, dwWidth, dwStyleCount, pdwStyles, lbStyle, (PVOID)lbHatch);

    //ok(bGotException == bExpectException, "ExtCreatePen expected exception=%lu for "
    //   "dwPenStyle=0x%lx, dwWidth=%lu, dwStyleCount=%lu, pdwStyles=%p, lbStyle=%lu, lbHatch=%p\n",
    //   bExpectException, dwPenStyle, dwWidth, dwStyleCount, pdwStyles, lbStyle, (PVOID)lbHatch);

    ok2(bGotException == bExpectException, "ExtCreatePen expception, expected %u, got %u", bExpectException, bGotException);

    if (!bExpectSuccess)
    {
        ok(hpen == NULL, "ExtCreatePen should fail for "
           "dwPenStyle=0x%lx, dwWidth=%lu, dwStyleCount=%lu, pdwStyles=%p, lbStyle=%u, lbHatch=%p\n",
           dwPenStyle, dwWidth, dwStyleCount, pdwStyles, lbStyle, (PVOID)lbHatch);
    }
    else
    {
        ok(hpen != NULL, "ExtCreatePen failed for "
           "dwPenStyle=0x%lx, dwWidth=%lu, dwStyleCount=%lu, pdwStyles=%p, lbStyle=%u, lbHatch=%p\n",
           dwPenStyle, dwWidth, dwStyleCount, pdwStyles, lbStyle, (PVOID)lbHatch);
        if (hpen != NULL)
        {
            if (GetObjectA(hpen, sizeof(elpBuffer), pelp) < sizeof(EXTLOGPEN))
            {
                if (!GetObjectA(hpen, sizeof(EXTLOGPEN), pelp))
                {
                    ok(0, "failed again?\n");
                    return;
                }
            }

            ok2(pelp->elpPenStyle == elpExpect.elpPenStyle, "elpPenStyle, expected 0x%lx, got 0x%lx\n", elpExpect.elpPenStyle, pelp->elpPenStyle);
            ok2(pelp->elpWidth == elpExpect.elpWidth, "elpWidth, expected 0x%lx, got 0x%lx\n", elpExpect.elpWidth, pelp->elpWidth);
            ok2(pelp->elpBrushStyle == elpExpect.elpBrushStyle, "elpBrushStyle, expected 0x%x, got 0x%x\n", elpExpect.elpBrushStyle, pelp->elpBrushStyle);
            ok2(pelp->elpColor == elpExpect.elpColor, "elpColor, expected 0x%lx, got 0x%lx\n", elpExpect.elpColor, pelp->elpColor);
            ok2(pelp->elpHatch == elpExpect.elpHatch, "elpHatch, expected 0x%lx, got 0x%lx\n", elpExpect.elpHatch, pelp->elpHatch);
            ok2(pelp->elpNumEntries == elpExpect.elpNumEntries, "elpNumEntries, expected 0x%lx, got 0x%lx\n", elpExpect.elpNumEntries, pelp->elpNumEntries);
            //for (i = 0; i < pelp->elpNumEntries; i++)
            //{
            //    ok2(pelp->elpStyleEntry[i] == elpExpect.elpStyleEntry[i], "elpHatch, expected 0x%lx, got 0x%lx\n", elpExpect.elpStyleEntry[i], pelp->elpStyleEntry[i]);
            //}
        }
    }

}

void Test_ExtCreatePen_Params2()
{
    ULONG aflPenType[] = {PS_COSMETIC, PS_GEOMETRIC, 0x20000};
    ULONG iType, iStyle, iEndCap, iJoin, iWidth, iStyleCount, iStyles, iBrushStyle, iHatch;
    DWORD adwStyles[17] = {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};
    DWORD adwStyles2[17] = {0,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17};

    printf("adwStyles=%p, adwStyles2=%p\n", adwStyles, adwStyles2);

    //for (iType = 0; iType < sizeof(aflPenType) / sizeof(aflPenType[0]); iType++)
    for (iType = 0; iType < 3; iType++)
    {
        ULONG aflPenStyle[] = {PS_SOLID, PS_DASH, PS_DOT, PS_DASHDOT, PS_DASHDOTDOT, PS_NULL, PS_INSIDEFRAME, PS_USERSTYLE, PS_ALTERNATE, 9};
        //for (iStyle = 0; iStyle < sizeof(aflPenStyle) / sizeof(aflPenStyle[0]); iStyle++)
        for (iStyle = 0; iStyle < 10; iStyle++)
        {
            ULONG aflEndCap[] = {PS_ENDCAP_ROUND, PS_ENDCAP_SQUARE, PS_ENDCAP_FLAT, 0x300, 0x400};
            for (iEndCap = 0; iEndCap < sizeof(aflEndCap) / sizeof(aflEndCap[0]); iEndCap++)
            {
                ULONG aflJoin[] = {PS_JOIN_ROUND, PS_JOIN_BEVEL, PS_JOIN_MITER, 0x3000, 0x4000};
                for (iJoin = 0; iJoin < sizeof(aflJoin) / sizeof(aflJoin[0]); iJoin++)
                {
                    DWORD adwWidth[] = {0, 1, 2};
                    ULONG flPenStyle = aflPenType[iType] | aflPenStyle[iStyle] | aflEndCap[iEndCap] | aflJoin[iJoin];

                    for (iWidth = 0; iWidth < sizeof(adwWidth) / sizeof(adwWidth[0]); iWidth++)
                    {
                        ULONG adwStyleCount[] = {0, 1, 2, 16, 17};
                        for (iStyleCount = 0; iStyleCount < sizeof(adwStyleCount) / sizeof(adwStyleCount[0]); iStyleCount++)
                        {
                            PULONG apdwStyles[] = {NULL, adwStyles, adwStyles2};
                            for (iStyles = 0; iStyles < sizeof(apdwStyles) / sizeof(apdwStyles[0]); iStyles++)
                            {
                                UINT albStyle[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
                                for (iBrushStyle = 0; iBrushStyle < sizeof(albStyle) / sizeof(albStyle[0]); iBrushStyle++)
                                {
                                    ULONG_PTR alHatch[] = {0, 1, 6, 7, 8, 9, 10, 11, 12, 13};

                                    for (iHatch = 0; iHatch < sizeof(alHatch) / sizeof(alHatch[0]); iHatch++)
                                    {
                                        Test_ExtCreatePen_Helper(flPenStyle,
                                                                 adwWidth[iWidth],
                                                                 adwStyleCount[iStyleCount],
                                                                 apdwStyles[iStyles],
                                                                 albStyle[iBrushStyle],
                                                                 alHatch[iHatch]);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

}

START_TEST(ExtCreatePen)
{
    Test_ExtCreatePen_Params();
    //Test_ExtCreatePen_Params2();
}