SDC C-Project CF Review 프로그램
LYW
2021-11-12 039bde2990b5b015232b5da9ff4df0cf1d88ddac
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
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
///////////////////////////////////////////////////////////////////////////////////////////////////
// Copyright 2012 Advanced Software    Engineering    Limited
//
// You may use and modify the code in this file    in your    application, provided the code and
// its modifications are used only in conjunction with ChartDirector. Usage    of this    software
// is subjected    to the terms and condition of the ChartDirector    license.
///////////////////////////////////////////////////////////////////////////////////////////////////
 
///////////////////////////////////////////////////////////////////////////////////////////////////
// CChartViewer    Implementation
//
// The CChartViewer    is a subclass of CStatic for displaying    chart images. It extends CStatic 
// to support to support image maps, clickable hot spots with tool tips, zooming and scrolling
// support and image update    rate control.
//
// To use CChartViewer,    create the layout template using the Resource Editor with CStatic 
// (Picture) controls configured to    display    bitmaps. Remember to check the "Notify"    check 
// box for the control.    Create member variables    for    them using the ClassWizard as usual. 
// Then    edit the header    file to    include    "ChartViewer.h"    and    change CStatic to CChartViewer.
///////////////////////////////////////////////////////////////////////////////////////////////////
 
#include "stdafx.h"
#include "ChartViewer.h"
 
#ifdef _DEBUG
#define    new    DEBUG_NEW
#endif
 
/////////////////////////////////////////////////////////////////////////////
// CChartViewer
 
//
// Build in    mouse cursors for zooming and scrolling    support
//
static HCURSOR getZoomInCursor();
static HCURSOR getZoomOutCursor();
static HCURSOR getNoZoomCursor();
static HCURSOR getNoMove2DCursor();
static HCURSOR getNoMoveHorizCursor();
static HCURSOR getNoMoveVertCursor();
 
//
// Constants used in m_delayChartUpdate
//
enum DelayNeedType    { NO_DELAY, NEED_DELAY, NEED_UPDATE };
enum UpdateViewType { UPDATE_VIEW_PORT_TIMER = 1, DELAYED_MOUSE_MOVE_TIMER = 2 };
 
 
//
// Constructor
//
CChartViewer::CChartViewer()
{
    // current chart and hot spot tester
    m_currentChart = 0;
    m_hotSpotTester    = 0;
 
    // create the tool tip control
    m_ToolTip.Create(this);
    m_ToolTip.Activate(TRUE);
    m_ToolTip.ModifyStyle(0, TTS_NOPREFIX);
    m_toolTipHasAttached = false;
 
    // initialize chart    configuration
    m_selectBoxLineColor = RGB(0, 0, 0);
    m_selectBoxLineWidth = 2;
    m_mouseUsage = Chart::MouseUsageDefault;
    m_zoomDirection    = Chart::DirectionHorizontal;
    m_zoomInRatio =    2;
    m_zoomOutRatio = 0.5;
    m_scrollDirection =    Chart::DirectionHorizontal;
    m_minDragAmount    = 5;
    m_updateInterval = 20;
 
    // current state of    the    mouse
    m_isOnPlotArea = false;
    m_isPlotAreaMouseDown =    false;
    m_isDragScrolling =    false;
    m_currentHotSpot = -1;
    m_isClickable =    false;
    m_isMouseTracking = false;
    m_isInMouseMove = false;
 
    // chart update    rate support
    m_needUpdateChart =    false;
    m_needUpdateImageMap = false;
    m_holdTimerActive =    false;
    m_delayUpdateChart = NO_DELAY;
    m_delayedChart = 0;
    m_lastMouseMove = 0;
    m_hasDelayedMouseMove = false;
 
    // track cursor support
    m_autoHideMsg = 0;
    m_currentMouseX = 0;
    m_currentMouseY = 0;
    m_isInMouseMovePlotArea = false;
}
 
BEGIN_MESSAGE_MAP(CChartViewer,    CStatic)
    //{{AFX_MSG_MAP(CChartViewer)
    ON_WM_MOUSEMOVE()
    ON_MESSAGE(WM_MOUSELEAVE, OnMouseLeave)
    ON_WM_SETCURSOR()
    ON_WM_DESTROY()
    ON_WM_LBUTTONDOWN()
    ON_WM_LBUTTONUP()
    ON_WM_TIMER()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
// CChartViewer    message    handlers
 
//
// Free    resources
//
void CChartViewer::OnDestroy() 
{
    CStatic::OnDestroy();
    
    // Free    HBITMAP
    HBITMAP    b =    SetBitmap(0);
    if (0 != b)
        DeleteObject(b);
 
    // Free    hot    spot tester
    if (0 != m_hotSpotTester)
        delete m_hotSpotTester;
    m_hotSpotTester    = 0;
}
 
//
// MouseMove event handler
//
void CChartViewer::OnMouseMove(UINT    nFlags,    CPoint point) 
{
    // Enable mouse tracking to detect mouse leave events
    if (!m_isMouseTracking)
    {
        TRACKMOUSEEVENT e;        
        e.cbSize = sizeof(e);        
        e.dwFlags = TME_LEAVE;        
        e.hwndTrack = this->m_hWnd;
        m_isMouseTracking = (0 != TrackMouseEvent(&e));
    }
 
    // On Windows, mouse events can by-pass the event queue. If there are too many mouse events,
    // the event queue may not get processed, preventing other controls from updating. If two mouse
    // events are less than 10ms apart, there is a risk of too many mouse events. So we repost the
    // mouse event as a timer event that is queued up normally, allowing the queue to get processed.
    unsigned int timeBetweenMouseMove = GetTickCount() - m_lastMouseMove;
    if ((m_hasDelayedMouseMove && (timeBetweenMouseMove < 250)) || (timeBetweenMouseMove < 10))
    {
        m_delayedMouseMoveFlag = nFlags;
        m_delayedMouseMovePoint = point;
        if (!m_hasDelayedMouseMove)
        {
            m_hasDelayedMouseMove = true;
            SetTimer(DELAYED_MOUSE_MOVE_TIMER, 1, 0);
        }
    }
    else
        commitMouseMove(nFlags, point);
}
 
//
// The method that actually performs MouseMove event processing
//
void CChartViewer::commitMouseMove(UINT nFlags, CPoint point)
{
    // Cancel the delayed mouse event if any
    if (m_hasDelayedMouseMove)
    {
        KillTimer(DELAYED_MOUSE_MOVE_TIMER);
        m_hasDelayedMouseMove = false;
    }
 
    // Remember the mouse coordinates for later use
    m_currentMouseX = point.x;
    m_currentMouseY = point.y;
 
    // The chart can be updated more than once during mouse move. For example, it can update due to
    // drag to scroll, and also due to drawing track cursor. So we delay updating the display until
    // all all events has occured.
    m_delayUpdateChart = NEED_DELAY;
    m_isInMouseMove = true;
 
    // Check if mouse is dragging on the plot area
    m_isOnPlotArea = m_isPlotAreaMouseDown || inPlotArea(point.x, point.y);
    if (m_isPlotAreaMouseDown)
        OnPlotAreaMouseDrag(nFlags,    point);
 
    // Send CVN_MouseMoveChart
    GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CVN_MouseMoveChart), 
        (LPARAM)m_hWnd);
 
    if (inExtendedPlotArea(point.x, point.y))
    {
        // Mouse is in extended plot area, send CVN_MouseMovePlotArea
        m_isInMouseMovePlotArea = true;
        GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CVN_MouseMovePlotArea), 
            (LPARAM)m_hWnd);
    }
    else if (m_isInMouseMovePlotArea)
    {
        // Mouse was in extended plot area, but is not in it now, so send CVN_MouseLeavePlotArea
        m_isInMouseMovePlotArea = false;
        GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CVN_MouseLeavePlotArea), 
            (LPARAM)m_hWnd);
        applyAutoHide(CVN_MouseLeavePlotArea);
    }
 
    // Can update chart now
    commitUpdateChart();
    m_isInMouseMove = false;
 
    //
    // Show    hot    spot tool tips if necessary
    //
    if (!m_toolTipHasAttached)
    {
        m_toolTipHasAttached = true;
 
        // Connects    the    CChartViewer to    the    CToolTipCtrl control
        m_ToolTip.AddTool(this);
        m_ToolTip.SendMessage(TTM_SETMAXTIPWIDTH, 0, SHRT_MAX);
    }
 
    if (nFlags != 0)
    {
        // Hide    tool tips if mouse button is pressed.
        m_ToolTip.UpdateTipText(_T(""),    this);
    }
    else
    {
        // Use the ChartDirector ImageMapHandler to    determine if the mouse is over a hot spot
        int    hotSpotNo =    0;
        if (0 != m_hotSpotTester)
            hotSpotNo =    m_hotSpotTester->getHotSpot(point.x, point.y);
 
        // If the mouse    is in the same hot spot    since the last mouse move event, there is no need
        // to update the tool tip.
        if (hotSpotNo != m_currentHotSpot)
        {
            // Hot spot    has    changed    - update tool tip text
            m_currentHotSpot = hotSpotNo;
 
            if (hotSpotNo == 0)
            {
                // Mouse is    not    actually on    hanlder    hot    spot - use default tool    tip    text and reset
                // the clickable flag.
                m_ToolTip.UpdateTipText(m_defaultToolTip, this);
                m_isClickable =    false;
            }
            else
            {
                // Mouse is    on a hot spot. In this implementation, we consider the hot spot    as 
                // clickable if    its    href ("path") parameter    is not empty.
                const char *path = m_hotSpotTester->getValue("path");
                m_isClickable =    ((0    != path) &&    (0 != *path));
 
                // Use the title attribute as the tool tip.    Note that ChartDirector    uses UTF8, 
                // while MFC uses TCHAR, so    we use the utility UTF8toTCHAR for conversion.
                m_ToolTip.UpdateTipText(UTF8toTCHAR(m_hotSpotTester->getValue("title")), this);
            }
        }
    }
 
    m_lastMouseMove = GetTickCount();
    CStatic::OnMouseMove(nFlags, point);
}
 
//
// Delayed MouseMove event handler
//
void CChartViewer::OnDelayedMouseMove() 
{
    if (m_hasDelayedMouseMove)
        commitMouseMove(m_delayedMouseMoveFlag, m_delayedMouseMovePoint);
}
 
//
// MouseLeave event handler
//
LRESULT CChartViewer::OnMouseLeave(WPARAM wParam, LPARAM lParam) 
{
    // Process delayed mouse move, if any
    OnDelayedMouseMove();
 
    // Mouse tracking is no longer active
    m_isMouseTracking = false;
 
    if (m_isInMouseMovePlotArea)
    {
        // Mouse was in extended plot area, but is not in it now, so send CVN_MouseLeavePlotArea
        m_isInMouseMovePlotArea = false;
        GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CVN_MouseLeavePlotArea), 
            (LPARAM)m_hWnd);
        applyAutoHide(CVN_MouseLeavePlotArea);
    }
 
    // Send CVN_MouseLeaveChart
    GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(), CVN_MouseLeaveChart), 
        (LPARAM)m_hWnd);
    applyAutoHide(CVN_MouseLeaveChart);
 
    return TRUE;
}
 
//
// Intercept WM_SETCURSOR to change    the    mouse cursor.
//
BOOL CChartViewer::OnSetCursor(CWnd* pWnd, UINT    nHitTest, UINT message)    
{
    if (m_isOnPlotArea)
    {
        switch (m_mouseUsage)
        {
        case Chart::MouseUsageZoomIn:
            if (canZoomIn(m_zoomDirection))
                ::SetCursor(getZoomInCursor());
            else
                ::SetCursor(getNoZoomCursor());
            return TRUE;
        case Chart::MouseUsageZoomOut:
            if (canZoomOut(m_zoomDirection))
                ::SetCursor(getZoomOutCursor());
            else
                ::SetCursor(getNoZoomCursor());
            return TRUE;
        }
    }
 
    if (m_isClickable)
    {
        // Hand    cursor = IDC_HAND =    32649
        HCURSOR    h =    AfxGetApp()->LoadStandardCursor(MAKEINTRESOURCE(32649));
        if (NULL !=    h)
            ::SetCursor(h);
        return TRUE;
    }
 
    return CStatic::OnSetCursor(pWnd, nHitTest,    message);
}
 
//
// Mouse left button down event.
//
void CChartViewer::OnLButtonDown(UINT nFlags, CPoint point)    
{
    OnDelayedMouseMove();
 
    if (inPlotArea(point.x,    point.y) &&    (m_mouseUsage != Chart::MouseUsageDefault))
    {
        // Mouse usage is for drag to zoom/scroll. Capture the mouse to    prepare    for    dragging and 
        // save    the    mouse down position    to draw    the    selection rectangle.
        SetCapture();
        m_isPlotAreaMouseDown =    true;
        m_plotAreaMouseDownXPos    = point.x;
        m_plotAreaMouseDownYPos    = point.y;
        startDrag();
    }
    else
        CStatic::OnLButtonDown(nFlags, point);
}
 
//
// Mouse left button up    event.
//
void CChartViewer::OnLButtonUp(UINT    nFlags,    CPoint point) 
{
    OnDelayedMouseMove();
 
    if (m_isPlotAreaMouseDown)
    {
        // Release the mouse capture.
        ReleaseCapture();
        m_isPlotAreaMouseDown =    false;
        setRectVisible(false);
        bool hasUpdate = false;
 
        switch (m_mouseUsage)
        {
        case Chart::MouseUsageZoomIn :
            if (canZoomIn(m_zoomDirection))
            {
                if (isDrag(m_zoomDirection,    point))
                    // Zoom    to the drag    selection rectangle.
                    hasUpdate =    zoomTo(m_zoomDirection,    
                        m_plotAreaMouseDownXPos, m_plotAreaMouseDownYPos, point.x, point.y);
                else
                    // User    just click on a    point. Zoom-in around the mouse    cursor position.
                    hasUpdate =    zoomAt(m_zoomDirection,    point.x, point.y, m_zoomInRatio);
            }
            break;
        case Chart::MouseUsageZoomOut:
            // Zoom    out    around the mouse cursor    position.
            if (canZoomOut(m_zoomDirection))
                hasUpdate =    zoomAt(m_zoomDirection,    point.x, point.y, m_zoomOutRatio);
            break;
        default    :
            if (m_isDragScrolling)
                // Drag    to scroll. We can update the image map now as scrolling    has    finished.
                updateViewPort(false, true);
            else
                // Is not zooming or scrolling,    so is just a normal    click event.
                GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(),    BN_CLICKED), (LPARAM)m_hWnd);
            break;
        }
 
        m_isDragScrolling =    false;
        if (hasUpdate)
            // View    port has changed - update it.
            updateViewPort(true, true);
    }
    else
        CStatic::OnLButtonUp(nFlags, point);
}
 
//
// Chart hold timer.
//
void CChartViewer::OnTimer(UINT_PTR nIDEvent)    
{
    if (nIDEvent == DELAYED_MOUSE_MOVE_TIMER)
    {
        // Is a delayed mouse move event
        OnDelayedMouseMove();
    }
    else
    {    
        // Is a delayed view port update
        m_holdTimerActive =    false;
 
        // Reset the timer
        KillTimer(nIDEvent);
        
        // If has pending chart    view port update request, handles them now.
        if (m_needUpdateChart || m_needUpdateImageMap)
            updateViewPort(m_needUpdateChart, m_needUpdateImageMap);
    }
}
 
/////////////////////////////////////////////////////////////////////////////
// CChartViewer    overrides
 
BOOL CChartViewer::PreTranslateMessage(MSG*    pMsg) 
{
    // Remember    to forward mouse messages to the CToolTipCtrl
    BOOL res = CStatic::PreTranslateMessage(pMsg);
    m_ToolTip.RelayEvent(pMsg);
    return res;
}
 
/////////////////////////////////////////////////////////////////////////////
// CChartViewer    properties
 
//
// Set the chart to    the    control
//
void CChartViewer::setChart(BaseChart *c)
{
    // In case the user    forgets    to check the "Notify" check    box    in the Dialog editor, we set it
    // ourselves so    the    CChartViewer control can receive mouse events.
    if ((GetStyle()    & SS_NOTIFY) ==    0)
        ModifyStyle(0, SS_NOTIFY);
 
    m_currentChart = c;
    setImageMap(0);
 
    if (0 != c)
    {
        commitPendingSyncAxis(c);
        if (m_delayUpdateChart != NO_DELAY)
            c->makeChart();
    }
 
    updateDisplay();
}
 
//
// Get back    the    same BaseChart pointer provided    by the previous    setChart call.
//
BaseChart *CChartViewer::getChart()
{
    return m_currentChart;
}
 
//
// Set image map used by the chart
//
void CChartViewer::setImageMap(const char *imageMap)
{
    //delete the existing ImageMapHandler
    if (0 != m_hotSpotTester)
        delete m_hotSpotTester;
    m_currentHotSpot = -1;
    m_isClickable =    false;
    
    //create a new ImageMapHandler to represent    the    image map
    if ((0 == imageMap)    || (0 == *imageMap))
        m_hotSpotTester    = 0;
    else
        m_hotSpotTester    = new ImageMapHandler(imageMap);
}
 
//
// Get the image map handler for the chart
//
ImageMapHandler    *CChartViewer::getImageMapHandler()
{
    return m_hotSpotTester;
}
 
//
// Set the default tool    tip    to use
//
void CChartViewer::setDefaultToolTip(LPCTSTR text)
{
    m_defaultToolTip = text;
}
 
//
// Get the CToolTipCtrl    for    managing tool tips.
//
CToolTipCtrl *CChartViewer::getToolTipCtrl()
{
    return &m_ToolTip;
}
 
//
// Set the border width    of the selection box
//
void CChartViewer::setSelectionBorderWidth(int width)
{
    m_selectBoxLineWidth = width;
}
 
//
// Get the border with of the selection    box.
//
int    CChartViewer::getSelectionBorderWidth()
{
    return m_selectBoxLineWidth;
}
 
//
// Set the border color    of the selection box
//
void CChartViewer::setSelectionBorderColor(COLORREF    c)
{
    m_selectBoxLineColor = c;
    if (m_TopLine.m_hWnd !=    0)
    {
        m_TopLine.SetColor(c);
        m_LeftLine.SetColor(c);
        m_BottomLine.SetColor(c);
        m_RightLine.SetColor(c);
    }
}
 
//
// Get the border color    of the selection box.
//
COLORREF CChartViewer::getSelectionBorderColor()
{
    return m_selectBoxLineColor;
}
 
//
// Set the mouse usage mode
//
void CChartViewer::setMouseUsage(int mouseUsage)
{
    m_mouseUsage = mouseUsage;
}
 
//
// Get the mouse usage mode
//
int    CChartViewer::getMouseUsage()
{
    return m_mouseUsage;
}
 
//
// Set the zoom    direction
//
void CChartViewer::setZoomDirection(int    direction)
{
    m_zoomDirection    = direction;
}
 
//
// Get the zoom    direction
//
int    CChartViewer::getZoomDirection()
{
    return m_zoomDirection;
}
 
//
// Set the scroll direction
//
void CChartViewer::setScrollDirection(int direction)
{
    m_scrollDirection =    direction;
}
 
//
// Get the scroll direction
//
int    CChartViewer::getScrollDirection()
{
    return m_scrollDirection;
}
 
//
// Set the zoom-in ratio for mouse click zoom-in
//
void CChartViewer::setZoomInRatio(double ratio)
{
    m_zoomInRatio =    ratio;
}
 
//
// Get the zoom-in ratio for mouse click zoom-in
//
double CChartViewer::getZoomInRatio()
{
    return m_zoomInRatio;
}
 
//
// Set the zoom-out    ratio
//
void CChartViewer::setZoomOutRatio(double ratio)
{
    m_zoomOutRatio = ratio;
}
 
//
// Get the zoom-out    ratio
//
double CChartViewer::getZoomOutRatio()
{
    return m_zoomOutRatio;    
}
 
//
// Set the minimum mouse drag before the dragging is considered    as real. This is to    avoid small    
// mouse vibrations    triggering a mouse drag.
//
void CChartViewer::setMinimumDrag(int offset)
{
    m_minDragAmount    = offset;
}
 
//
// Get the minimum mouse drag before the dragging is considered    as real.
//
int    CChartViewer::getMinimumDrag()
{
    return m_minDragAmount;
}
 
//
// Set the minimum interval    between    ViewPortChanged    events.    This is    to avoid the chart being 
// updated too frequently. (Default    is 20ms    between    chart updates.)    Multiple update    events
// arrived during the interval will    be merged into one chart update    and    executed at    the    end
// of the interval.
//
void CChartViewer::setUpdateInterval(int interval)
{
    m_updateInterval = interval;
}
 
//
// Get the minimum interval    between    ViewPortChanged    events.    
//
int    CChartViewer::getUpdateInterval()
{
    return m_updateInterval;
}
 
//
// Check if    there is a pending chart update    request. 
//
bool CChartViewer::needUpdateChart()
{
    return m_needUpdateChart;
}
 
//
// Check if    there is a pending image map update    request. 
//
bool CChartViewer::needUpdateImageMap()
{
    return m_needUpdateImageMap;
}
 
//
// Get the current mouse x coordinate when used in a mouse move event handler
//
int CChartViewer::getChartMouseX()
{
    return m_currentMouseX;
}
 
//
// Get the current mouse y coordinate when used in a mouse move event handler
//
int CChartViewer::getChartMouseY()
{
    return m_currentMouseY;
}
 
//
// Get the current mouse x coordinate bounded to the plot area when used in a mouse event handler
//
int CChartViewer::getPlotAreaMouseX()
{
    int ret = getChartMouseX();
    if (ret < getPlotAreaLeft())
        ret = getPlotAreaLeft();
    if (ret > getPlotAreaLeft() + getPlotAreaWidth())
        ret = getPlotAreaLeft() + getPlotAreaWidth();
    return ret;
}
 
//
// Get the current mouse y coordinate bounded to the plot area when used in a mouse event handler
//
int CChartViewer::getPlotAreaMouseY()
{
    int ret = getChartMouseY();
    if (ret < getPlotAreaTop())
        ret = getPlotAreaTop();
    if (ret > getPlotAreaTop() + getPlotAreaHeight())
        ret = getPlotAreaTop() + getPlotAreaHeight();
    return ret;
}
 
//
// Check if mouse is on the extended plot area
//
bool CChartViewer::isMouseOnPlotArea()
{
    if (this->m_isMouseTracking)
        return inExtendedPlotArea(getChartMouseX(), getChartMouseY());
    else
        return false;
}
 
//
// Check if is currently processing a mouse move event
//
bool CChartViewer::isInMouseMoveEvent()
{
    return m_isInMouseMove;
}
 
/////////////////////////////////////////////////////////////////////////////
// CChartViewer    methods
 
//
// Update the display
//
void CChartViewer::updateDisplay()
{
    if (m_delayUpdateChart == NO_DELAY)
        commitUpdateChart();
    else
    {
        m_delayUpdateChart = NEED_UPDATE;
        delete m_delayedChart;
        m_delayedChart = (0 != m_currentChart) ? new BaseChart(m_currentChart) : 0;
    }
}
 
//
// Commit chart to display
//
void CChartViewer::commitUpdateChart()
{
    if (m_delayUpdateChart == NEED_DELAY)
    {
        // No actual update occur
        m_delayUpdateChart = NO_DELAY;
        return;
    }
 
    // Get the HBITMAP and metrics for the chart
    BaseChart *c = (m_delayUpdateChart == NEED_UPDATE) ? m_delayedChart : m_currentChart;
    HBITMAP    chartBMP = 0;
    const char *chartMetrics = 0;
 
    if (0 != c)
    {
        // Output chart    as Device Indpendent Bitmap    with file headers
        MemBlock m = c->makeChart(Chart::BMP);
 
        // MFC expects HBITMAP,    so convert from    DIB    to HBITMAP.    
        CDC    *cdc = GetDC();
        chartBMP = CreateDIBitmap(
            cdc->m_hDC,    
            (const struct tagBITMAPINFOHEADER *)(m.data    + 14), 
            CBM_INIT, 
            m.data + *(int *)(m.data + 10),    
            (const struct tagBITMAPINFO    *)(m.data +    14),
            DIB_RGB_COLORS);
        ReleaseDC(cdc);
 
        // Get chart metrics
        chartMetrics = c->getChartMetrics();
    }
 
    // Set the HBITMAP for display
    if (0 != (chartBMP = SetBitmap(chartBMP)))
        DeleteObject(chartBMP);
 
    // Set the chart metrics and clear the image map
    setChartMetrics(chartMetrics);
 
    // Remember to update the selection rectangle
    if ((0 != m_TopLine.m_hWnd) && m_TopLine.IsWindowVisible())
    {
        m_TopLine.Invalidate();
        m_LeftLine.Invalidate();
        m_RightLine.Invalidate();
        m_BottomLine.Invalidate();
        m_TopLine.UpdateWindow();
        m_LeftLine.UpdateWindow();
        m_RightLine.UpdateWindow();
        m_BottomLine.UpdateWindow();
    }
 
    // Any delayed chart has been committed
    m_delayUpdateChart = NO_DELAY;
    delete m_delayedChart;
    m_delayedChart = 0;
}
 
//
// Set the message used to remove the dynamic layer
//
void CChartViewer::removeDynamicLayer(int msg)
{
    m_autoHideMsg = msg;
    if (msg == -1)
        applyAutoHide(msg);
}
 
//
// Attempt to hide the dynamic layer using the specified message
//
void CChartViewer::applyAutoHide(int msg)
{
    if (m_autoHideMsg == msg)
    {
        if (0 != m_currentChart)
            m_currentChart->removeDynamicLayer();
        m_autoHideMsg = 0;
 
        updateDisplay();
    }
}
 
//
// Create the edges    for    the    selection rectangle
//
void CChartViewer::initRect()
{
    m_TopLine.Create(GetParent(), m_selectBoxLineColor);
    m_LeftLine.Create(GetParent(), m_selectBoxLineColor);
    m_BottomLine.Create(GetParent(), m_selectBoxLineColor);
    m_RightLine.Create(GetParent(),    m_selectBoxLineColor);
}
 
//
// Set selection rectangle position    and    size
//
void CChartViewer::drawRect(int    x, int y, int width, int height)
{
    // Create the edges    of the rectangle if    not    already    created
    if (m_TopLine.m_hWnd ==    0)
        initRect();
 
    // width < 0 is    interpreted    as the rectangle extends to    the    left or    x.
    // height <0 is    interpreted    as the rectangle extends to    above y.
    if (width <    0)
        x -= (width    = -width);
    if (height < 0)
        y -= (height = -height);
 
    // Compute the position    of the selection rectangle as relative to the parent window
    RECT rect;
    rect.left =    x;
    rect.top = y;
    rect.right = x + width;
    rect.bottom    = y    + height;
    MapWindowPoints(m_TopLine.GetParent(), &rect);
 
    // Put the edges along the sides of    the    rectangle
    m_TopLine.MoveWindow(rect.left,    rect.top, rect.right - rect.left, m_selectBoxLineWidth);
    m_LeftLine.MoveWindow(rect.left, rect.top, m_selectBoxLineWidth, rect.bottom - rect.top);
    m_BottomLine.MoveWindow(rect.left, rect.bottom - m_selectBoxLineWidth +    1, 
        rect.right - rect.left,    m_selectBoxLineWidth);
    m_RightLine.MoveWindow(rect.right -    m_selectBoxLineWidth + 1, rect.top,    
        m_selectBoxLineWidth, rect.bottom -    rect.top);
}
 
//
// Show/hide selection rectangle
//
void CChartViewer::setRectVisible(bool b)
{
    // Create the edges    of the rectangle if    not    already    created
    if (b && (m_TopLine.m_hWnd == 0)) 
        initRect();
 
    // Show/hide the edges
    if (m_TopLine.m_hWnd != 0)
    {
        int    state =    b ?    SW_SHOW    : SW_HIDE;
        m_TopLine.ShowWindow(state);
        m_LeftLine.ShowWindow(state);
        m_BottomLine.ShowWindow(state);
        m_RightLine.ShowWindow(state);
    }
}
 
//
// Determines if the mouse is dragging.
//
bool CChartViewer::isDrag(int direction, CPoint    point)
{
    // We only consider    the    mouse is dragging it is    has    dragged    more than m_minDragAmount. This    is
    // to avoid    small mouse    vibrations triggering a    mouse drag.
    int    spanX =    abs(point.x    - m_plotAreaMouseDownXPos);
    int    spanY =    abs(point.y    - m_plotAreaMouseDownYPos);
    return ((direction != Chart::DirectionVertical)    && (spanX >= m_minDragAmount)) ||
        ((direction    != Chart::DirectionHorizontal) && (spanY >=    m_minDragAmount));
}
 
//
// Process mouse dragging over the plot    area
//
void CChartViewer::OnPlotAreaMouseDrag(UINT    /* nFlags */, CPoint point)
{
    switch (m_mouseUsage)
    {
        case Chart::MouseUsageZoomIn :
        {
            //
            // Mouse is    used for zoom in. Draw the selection rectangle if necessary.
            //
 
            bool isDragZoom    = canZoomIn(m_zoomDirection) &&    isDrag(m_zoomDirection,    point);
            if (isDragZoom)
            {
                int    spanX =    m_plotAreaMouseDownXPos    - point.x;
                int    spanY =    m_plotAreaMouseDownYPos    - point.y;
 
                switch (m_zoomDirection)
                {
                case Chart::DirectionHorizontal:
                    drawRect(point.x, getPlotAreaTop(),    spanX, getPlotAreaHeight());
                    break;
                case Chart::DirectionVertical:
                    drawRect(getPlotAreaLeft(),    point.y, getPlotAreaWidth(), spanY);
                    break;
                default:
                    drawRect(point.x, point.y, spanX, spanY);
                    break;
                }
            }
            setRectVisible(isDragZoom);
            break;
        }
        case Chart::MouseUsageScroll :
        {
            //
            // Mouse is    used for drag scrolling. Scroll    and    update the view    port.
            //
 
            if (m_isDragScrolling || isDrag(m_scrollDirection, point))
            {
                m_isDragScrolling =    true;
                switch (m_scrollDirection)
                {
                case Chart::DirectionHorizontal:
                    ::SetCursor(getNoMoveHorizCursor());
                    break;
                case Chart::DirectionVertical:
                    ::SetCursor(getNoMoveVertCursor());
                    break;
                default    :
                    ::SetCursor(getNoMove2DCursor());
                    break;
                }
                                
                if (dragTo(m_scrollDirection, 
                    point.x    - m_plotAreaMouseDownXPos, point.y - m_plotAreaMouseDownYPos))
                    updateViewPort(true, false);
            }
        }
    }
}
 
//
// Trigger the ViewPortChanged event
//
void CChartViewer::updateViewPort(bool needUpdateChart,    bool needUpdateImageMap)
{
    // Merge the current update    requests with any pending requests.
    m_needUpdateChart =    m_needUpdateChart || needUpdateChart;
    m_needUpdateImageMap = needUpdateImageMap;
 
    // Hold    timer has not expired, so do not update    chart immediately. Keep    the    requests pending.
    if (m_holdTimerActive)
        return;
 
    // The chart can be updated more than once during mouse move. For example, it can update due to
    // drag to scroll, and also due to drawing track cursor. So we delay updating the display until
    // all all updates has occured.
    int hasDelayUpdate = (m_delayUpdateChart != NO_DELAY);
    if (!hasDelayUpdate)
        m_delayUpdateChart = NEED_DELAY;
    
    // Can trigger the ViewPortChanged event.
    validateViewPort();
    GetParent()->SendMessage(WM_COMMAND, MAKEWPARAM(GetDlgCtrlID(),    CVN_ViewPortChanged), 
        (LPARAM)m_hWnd);
    
    // Can update chart now
    if (!hasDelayUpdate)
        commitUpdateChart();
 
    // Clear any pending updates.
    m_needUpdateChart =    false;
    m_needUpdateImageMap = false;
 
    // Set hold    timer to prevent multiple chart    updates    within a short period.
    if (m_updateInterval > 0)
    {
        m_holdTimerActive = true;
        SetTimer(UPDATE_VIEW_PORT_TIMER, m_updateInterval, 0);
    }
}
 
/////////////////////////////////////////////////////////////////////////////
// CRectCtrl
//
// A rectangle with    a background color.    Use    as thick edges for the selection
// rectangle.
//
 
//
// Create control with a given color
//
BOOL CRectCtrl::Create(CWnd    *pParentWnd, COLORREF c)
{
    SetColor(c);
 
    RECT r;
    r.left = r.top = r.right = r.bottom    = 0;
    return CStatic::Create(0, WS_CHILD,    r, pParentWnd);
}
 
BEGIN_MESSAGE_MAP(CRectCtrl, CStatic)
    //{{AFX_MSG_MAP(CRectCtrl)
    ON_WM_CTLCOLOR_REFLECT()
    //}}AFX_MSG_MAP
END_MESSAGE_MAP()
 
/////////////////////////////////////////////////////////////////////////////
// CRectCtrl message handlers
 
HBRUSH CRectCtrl::CtlColor(CDC*    /* pDC */, UINT    /* nCtlColor */) 
{
    return (HBRUSH)m_Color.m_hObject;
}
 
/////////////////////////////////////////////////////////////////////////////
// CRectCtrl proporties
 
//
// Set the background color
//
void CRectCtrl::SetColor(COLORREF c)
{
    m_Color.CreateSolidBrush(c);
}
 
/////////////////////////////////////////////////////////////////////////////
// Build in    mouse cursors for zooming and scrolling    support
//
 
static const int zoomInCursorA[] = 
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xff3ff8ff,
0xff0fe0ff,
0xff07c0ff,
0xff07c0ff,
0xff0380ff,
0xff0380ff,
0xff0380ff,
0xff0380ff,
0xff0380ff,
0xff07c0ff,
0xff07c0ff,
0xff01e0ff,
0xff30f8ff,
0x7ff0ffff,
0x3ff8ffff,
0x1ffcffff,
0x0ffeffff,
0x0fffffff,
0x9fffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff
};
 
static const int zoomInCursorB[] = 
{
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00c00700,
0x00f01f00,
0x00f01e00,
0x00f83e00,
0x00f83e00,
0x00183000,
0x00f83e00,
0x00f83e00,
0x00f01e00,
0x00f01f00,
0x00c00700,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000
};
 
static const int zoomOutCursorA[] =    
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xff3ff8ff,
0xff0fe0ff,
0xff07c0ff,
0xff07c0ff,
0xff0380ff,
0xff0380ff,
0xff0380ff,
0xff0380ff,
0xff0380ff,
0xff07c0ff,
0xff07c0ff,
0xff01e0ff,
0xff30f8ff,
0x7ff0ffff,
0x3ff8ffff,
0x1ffcffff,
0x0ffeffff,
0x0fffffff,
0x9fffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff
};
 
static const int zoomOutCursorB[] =    
{
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00c00700,
0x00f01f00,
0x00f01f00,
0x00f83f00,
0x00f83f00,
0x00183000,
0x00f83f00,
0x00f83f00,
0x00f01f00,
0x00f01f00,
0x00c00700,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000
};
 
static const int noZoomCursorA[] = 
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xff3ff8ff,
0xff0fe0ff,
0xff07c0ff,
0xff07c0ff,
0xff0380ff,
0xff0380ff,
0xff0380ff,
0xff0380ff,
0xff0380ff,
0xff07c0ff,
0xff07c0ff,
0xff01e0ff,
0xff30f8ff,
0x7ff0ffff,
0x3ff8ffff,
0x1ffcffff,
0x0ffeffff,
0x0fffffff,
0x9fffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff
};
 
static const int noZoomCursorB[] = 
{
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00c00700,
0x00f01f00,
0x00f01f00,
0x00f83f00,
0x00f83f00,
0x00f83f00,
0x00f83f00,
0x00f83f00,
0x00f01f00,
0x00f01f00,
0x00c00700,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000
};
 
static int noMove2DCursorA[] =
{
0xffffffff,
0xffffffff,
0xffffffff,
0xff7ffeff,
0xff3ffcff,
0xff1ff8ff,
0xff0ff0ff,
0xff07e0ff,
0xff03c0ff,
0xff03c0ff,
0xfffc3fff,
0x7ffc3ffe,
0x3ffc3ffc,
0x1f7c3ef8,
0x0f3c3cf0,
0x071c38e0,
0x071c38e0,
0x0f3c3cf0,
0x1f7c3ef8,
0x3ffc3ffc,
0x7ffc3ffe,
0xfffc3fff,
0xff03c0ff,
0xff03c0ff,
0xff07e0ff,
0xff0ff0ff,
0xff1ff8ff,
0xff3ffcff,
0xff7ffeff,
0xffffffff,
0xffffffff,
0xffffffff
};
 
static int noMove2DCursorB[] =
{
0x00000000,
0x00000000,
0x00000000,
0x00800100,
0x00400200,
0x00200400,
0x00100800,
0x00081000,
0x00042000,
0x00fc3f00,
0x0003c000,
0x80024001,
0x40024002,
0x20824104,
0x10424208,
0x08224410,
0x08224410,
0x10424208,
0x20824104,
0x40024002,
0x80024001,
0x0003c000,
0x00fc3f00,
0x00042000,
0x00081000,
0x00100800,
0x00200400,
0x00400200,
0x00800100,
0x00000000,
0x00000000,
0x00000000
};
 
static int noMoveHorizCursorA[]    =
{
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xfffc3fff,
0x7ffc3ffe,
0x3ffc3ffc,
0x1f7c3ef8,
0x0f3c3cf0,
0x071c38e0,
0x071c38e0,
0x0f3c3cf0,
0x1f7c3ef8,
0x3ffc3ffc,
0x7ffc3ffe,
0xfffc3fff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff,
0xffffffff
};
 
static int noMoveHorizCursorB[]    =
{
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x0003c000,
0x80024001,
0x40024002,
0x20824104,
0x10424208,
0x08224410,
0x08224410,
0x10424208,
0x20824104,
0x40024002,
0x80024001,
0x0003c000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000,
0x00000000
};
 
static int noMoveVertCursorA[] =
{
0xffffffff,
0xffffffff,
0xffffffff,
0xff7ffeff,
0xff3ffcff,
0xff1ff8ff,
0xff0ff0ff,
0xff07e0ff,
0xff03c0ff,
0xff03c0ff,
0xffffffff,
0xffffffff,
0xffffffff,
0xff7ffeff,
0xff3ffcff,
0xff1ff8ff,
0xff1ff8ff,
0xff3ffcff,
0xff7ffeff,
0xffffffff,
0xffffffff,
0xffffffff,
0xff03c0ff,
0xff03c0ff,
0xff07e0ff,
0xff0ff0ff,
0xff1ff8ff,
0xff3ffcff,
0xff7ffeff,
0xffffffff,
0xffffffff,
0xffffffff
};
 
static int noMoveVertCursorB[] =
{
0x00000000,
0x00000000,
0x00000000,
0x00800100,
0x00400200,
0x00200400,
0x00100800,
0x00081000,
0x00042000,
0x00fc3f00,
0x00000000,
0x00000000,
0x00000000,
0x00800100,
0x00400200,
0x00200400,
0x00200400,
0x00400200,
0x00800100,
0x00000000,
0x00000000,
0x00000000,
0x00fc3f00,
0x00042000,
0x00081000,
0x00100800,
0x00200400,
0x00400200,
0x00800100,
0x00000000,
0x00000000,
0x00000000
};
 
static HCURSOR hZoomInCursor = 0;
static HCURSOR hZoomOutCursor =    0;
static HCURSOR hNoZoomCursor = 0;
static HCURSOR hNoMove2DCursor = 0;
static HCURSOR hNoMoveHorizCursor =    0;
static HCURSOR hNoMoveVertCursor = 0;
 
class FreeCursors
{
public:
    ~FreeCursors()
    {
        if (0 != hZoomInCursor)
            DestroyCursor(hZoomInCursor);
        if (0 != hZoomOutCursor)
            DestroyCursor(hZoomOutCursor);
        if (0 != hNoZoomCursor)
            DestroyCursor(hNoZoomCursor);
        if (0 != hNoMove2DCursor)
            DestroyCursor(hNoMove2DCursor);
        if (0 != hNoMoveHorizCursor)
            DestroyCursor(hNoMoveHorizCursor);
        if (0 != hNoMoveVertCursor)
            DestroyCursor(hNoMoveVertCursor);
    }
} dummyFreeCursorObj;
 
static HCURSOR getZoomInCursor()
{
    if (0 == hZoomInCursor)
    {
        hZoomInCursor =    CreateCursor(AfxGetApp()->m_hInstance, 15, 15, 32, 32, 
            zoomInCursorA, zoomInCursorB);
    }
    return hZoomInCursor;
}
 
static HCURSOR getZoomOutCursor()
{
    if (0 == hZoomOutCursor)
    {
        hZoomOutCursor = CreateCursor(AfxGetApp()->m_hInstance,    15,    15,    32,    32,    
            zoomOutCursorA,    zoomOutCursorB);
    }
    return hZoomOutCursor;
}
 
static HCURSOR getNoZoomCursor()
{
    if (0 == hNoZoomCursor)
    {
        hNoZoomCursor =    CreateCursor(AfxGetApp()->m_hInstance, 15, 15, 32, 32, 
            noZoomCursorA, noZoomCursorB);
    }
    return hNoZoomCursor;
}
 
static HCURSOR getNoMove2DCursor()
{
    if (0 == hNoMove2DCursor)
    {
        hNoMove2DCursor    = CreateCursor(AfxGetApp()->m_hInstance, 15, 15, 32, 32, 
            noMove2DCursorA, noMove2DCursorB);
    }
    return hNoMove2DCursor;
}
 
static HCURSOR getNoMoveHorizCursor()
{
    if (0 == hNoMoveHorizCursor)
    {
        hNoMoveHorizCursor = CreateCursor(AfxGetApp()->m_hInstance,    15,    15,    32,    32,    
            noMoveHorizCursorA,    noMoveHorizCursorB);
    }
    return hNoMoveHorizCursor;
}
 
static HCURSOR getNoMoveVertCursor()
{
    if (0 == hNoMoveVertCursor)
    {
        hNoMoveVertCursor =    CreateCursor(AfxGetApp()->m_hInstance, 15, 15, 32, 32, 
            noMoveVertCursorA, noMoveVertCursorB);
    }
    return hNoMoveVertCursor;
}