-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMainFrm.cpp
1261 lines (1052 loc) · 35.9 KB
/
MainFrm.cpp
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
/////////////////////////////////////////////////////////////////////////////
// Copyright (c) 2005-2011 Association Homecinema Francophone. All rights reserved.
/////////////////////////////////////////////////////////////////////////////
//
// This file is subject to the terms of the GNU General Public License as
// published by the Free Software Foundation. A copy of this license is
// included with this software distribution in the file COPYING.htm. If you
// do not have a copy, you may obtain a copy by writing to the Free
// Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
//
// This software is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details
/////////////////////////////////////////////////////////////////////////////
// Author(s):
// François-Xavier CHABOUD
// Georges GALLERAND
/////////////////////////////////////////////////////////////////////////////
// MainFrm.cpp : implementation of the CMainFrame class
//
#include "stdafx.h"
#include "ColorHCFR.h"
#include "DataSetDoc.h"
#include "MainView.h"
#include "MainFrm.h"
#include "MultiFrm.h"
#include "NewDocPropertyPages.h"
#include "LangSelection.h"
#include "PatternDisplay.h"
//#include "WebUpdate.h"
#include "CWebUpdate.h"
#include <dde.h>
#include <afxpriv.h>
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
// This define must be the same than in ColorHCFRConfig.cpp
#define LANG_PREFIX "CHCFR21_"
extern CPtrList gOpenedFramesList; // Implemented in MultiFrm.cpp
extern BOOL g_bNewDocUseDDEInfo; // Implemented in Datasetdoc.cpp
extern CString g_NewDocName;
extern CString g_ThcFileName;
extern int g_NewDocGeneratorID;
extern int g_NewDocSensorID;
extern Matrix g_NewDocSensorMatrix;
extern BOOL g_bNewDocIsDuplication; // Implemented in Datasetdoc.cpp
extern CDataSetDoc * g_DocToDuplicate; // Implemented in Datasetdoc.cpp
/////////////////////////////////////////////////////////////////////////////
// CMainFrame
IMPLEMENT_DYNAMIC(CMainFrame, CNewMDIFrameWnd)
BEGIN_MESSAGE_MAP(CMainFrame, CNewMDIFrameWnd)
//{{AFX_MSG_MAP(CMainFrame)
ON_WM_CREATE()
ON_COMMAND(IDM_DUPLICATEDOC, OnDuplicateDoc)
ON_COMMAND(ID_VIEW_VIEW_BAR, OnViewViewBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_VIEW_BAR, OnUpdateViewViewBar)
ON_COMMAND(ID_VIEW_TOOLBAR, OnViewToolbar)
ON_UPDATE_COMMAND_UI(ID_VIEW_TOOLBAR, OnUpdateViewToolbar)
ON_WM_SYSCOLORCHANGE()
ON_COMMAND(IDM_VIEW_TESTCOLOR, OnViewTestColor)
ON_UPDATE_COMMAND_UI(IDM_VIEW_TESTCOLOR, OnUpdateViewTestColor)
ON_WM_DROPFILES()
ON_COMMAND(IDM_GENERAL_CONFIG, OnGeneralConfig)
ON_COMMAND(ID_HELP, OnHelp)
ON_COMMAND(IDM_HELP_FORUM, OnHelpForum)
ON_COMMAND(IDM_HELP_INSTALL, OnHelpInstall)
ON_COMMAND(IDM_HELP_SUPPORT, OnHelpSupport)
ON_COMMAND(IDM_LANGUAGE, OnLanguage)
ON_COMMAND(IDM_UPDATE_SOFT, OnUpdateSoft)
ON_COMMAND(IDM_PATTERN_DISP_ROOT, OnPatternDisplay)
ON_COMMAND(IDM_REFRESH_LUX, OnRefreshLux)
ON_COMMAND(IDM_VIEW_LUMINANCE, OnViewLuminance)
ON_UPDATE_COMMAND_UI(IDM_VIEW_LUMINANCE, OnUpdateViewLuminance)
ON_COMMAND(ID_VIEW_MEASURE_BAR, OnViewMeasureBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_MEASURE_BAR, OnUpdateViewMeasureBar)
ON_COMMAND(ID_VIEW_MEASURE_EXT_BAR, OnViewMeasureExBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_MEASURE_EXT_BAR, OnUpdateViewMeasureExBar)
ON_COMMAND(IDM_HELP, OnHelp)
ON_COMMAND(IDM_PATTERN_DISPLAY, OnPatternDisplay)
ON_COMMAND(ID_VIEW_MEASURE_SAT_BAR, OnViewMeasureSatBar)
ON_UPDATE_COMMAND_UI(ID_VIEW_MEASURE_SAT_BAR, OnUpdateViewMeasureSatBar)
//}}AFX_MSG_MAP
ON_MESSAGE(WM_DDE_INITIATE, OnDDEInitiate)
ON_MESSAGE(WM_DDE_EXECUTE, OnDDEExecute)
ON_MESSAGE(WM_DDE_REQUEST, OnDDERequest)
ON_MESSAGE(WM_DDE_POKE, OnDDEPoke)
ON_MESSAGE(WM_DDE_TERMINATE, OnDDETerminate)
ON_MESSAGE(WM_BKGND_MEASURE_READY, OnBkgndMeasureReady)
ON_MESSAGE(WM_TOOLBAR_RBUTTONDOWN, OnRightButton)
ON_MESSAGE(WM_TOOLBAR_MBUTTONDOWN, OnMiddleButton)
ON_MESSAGE(WM_SETMESSAGESTRING, OnSetMessageString)
END_MESSAGE_MAP()
static UINT indicators[] =
{
ID_SEPARATOR, // status line indicator
ID_LUX_VALUE,
ID_INDICATOR_CAPS,
ID_INDICATOR_NUM,
ID_INDICATOR_SCRL,
};
/////////////////////////////////////////////////////////////////////////////
// CMainFrame construction/destruction
CMainFrame::CMainFrame()
{
p_wndPatternDisplay = NULL;
m_mainToolbarID = IDR_MEDIUMTOOLBAR_MAIN;
m_viewToolbarID = IDR_MEDIUMTOOLBAR_VIEWS;
m_measureToolbarID = IDR_MEDIUMTOOLBAR_MEASURES;
m_measureexToolbarID = IDR_MEDIUMTOOLBAR_MEASURES_EX;
m_measuresatToolbarID = IDR_MEDIUMTOOLBAR_MEASURES_SAT;
// m_strPane0StatusMsg.SetString("this is a test");
}
CMainFrame::~CMainFrame()
{
}
BOOL CMainFrame::LoadToolbars()
{
// GGA TODO: very slow, need to be optimized: maybe create a LoadToolBar with no useless internal call to LoadHiColor.
// TODO: dpi aware set of toolbars?
if(!m_wndToolBar.LoadToolBar(m_mainToolbarID))
return FALSE;
if(!m_wndToolBar.LoadHiColor(MAKEINTRESOURCE(IDB_MEDIUMTOOLBAR_MAIN_HICOL),RGB(0,0,0)))
return FALSE;
if(!m_wndToolBarViews.LoadToolBar(m_viewToolbarID))
return FALSE;
if(!m_wndToolBarViews.LoadHiColor(MAKEINTRESOURCE(IDB_MEDIUMTOOLBAR_VIEW_HICOL),RGB(0,0,0)))
return FALSE;
if(!m_wndToolBarMeasures.LoadToolBar(m_measureToolbarID))
return FALSE;
if(!m_wndToolBarMeasures.LoadHiColor(MAKEINTRESOURCE(IDB_MEDIUMTOOLBAR_MEASURE_HICOL),RGB(0,0,0)))
return FALSE;
if(!m_wndToolBarMeasuresEx.LoadToolBar(m_measureexToolbarID))
return FALSE;
if(!m_wndToolBarMeasuresEx.LoadHiColor(MAKEINTRESOURCE(IDB_MEDIUMTOOLBAR_MEAS_EX_HICOL),RGB(0,0,0)))
return FALSE;
if(!m_wndToolBarMeasuresSat.LoadToolBar(m_measuresatToolbarID))
return FALSE;
if(!m_wndToolBarMeasuresSat.LoadHiColor(MAKEINTRESOURCE(IDB_MEDIUMTOOLBAR_MEAS_SAT_HICOL),RGB(0,0,0)))
return FALSE;
return TRUE;
}
int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CMDIFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1;
// Subclass m_hWndMDIClient
m_LogoWnd.SubclassWindow ( m_hWndMDIClient );
DragAcceptFiles ();
if (!m_wndMenuBar.Create(this,WS_CHILD | WS_VISIBLE | CBRS_ALIGN_TOP|CBRS_SIZE_DYNAMIC|CBRS_TOOLTIPS
|CBRS_GRIPPER) )
{
TRACE0("Failed to create menu bar\n");
return -1; // fail to create
}
if (!m_wndToolBar.CreateEx(this, TBSTYLE_AUTOSIZE | TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0,0,0,0), IDC_MAINTOOLBAR) )
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBarMeasures.CreateEx(this, TBSTYLE_AUTOSIZE | TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0,0,0,0), IDC_MEASURETOOLBAR) )
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBarMeasuresEx.CreateEx(this, TBSTYLE_AUTOSIZE | TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0,0,0,0), IDC_MEASUREEXTOOLBAR) )
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBarMeasuresSat.CreateEx(this, TBSTYLE_AUTOSIZE | TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0,0,0,0), IDC_MEASURESATTOOLBAR) )
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndToolBarViews.CreateEx(this, TBSTYLE_AUTOSIZE | TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP
| CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC, CRect(0,0,0,0), IDC_VIEWTOOLBAR) )
{
TRACE0("Failed to create toolbar\n");
return -1; // fail to create
}
if (!m_wndStatusBar.Create(this) ||
!m_wndStatusBar.SetIndicators(indicators,
sizeof(indicators)/sizeof(UINT)))
{
TRACE0("Failed to create status bar\n");
return -1; // fail to create
}
m_wndMenuBar.SetWindowText(_T("Menu standard"));
m_wndToolBar.SetWindowText(_T("Toolbar standard"));
m_wndToolBarViews.SetWindowText(_T("Toolbar views"));
m_wndToolBarViews.SetSizes(CSize(32+7,32+6), CSize(32,32));
m_wndToolBarMeasures.SetWindowText(_T("Toolbar measures"));
m_wndToolBarMeasuresEx.SetWindowText(_T("Toolbar measures ext"));
m_wndToolBarMeasuresSat.SetWindowText(_T("Toolbar measures sat"));
m_wndToolBarMeasures.SetSizes(CSize(32+7,32+6), CSize(32,32));
if(!LoadToolbars())
{
TRACE0("Failed to load toolbars\n");
return -1; // fail to create
}
m_wndTestColorWnd.Create(CTestColorWnd::IDD, this);
m_tooltip.Create(this);
m_tooltip.AddToolBar(&m_wndToolBar);
m_tooltip.AddToolBar(&m_wndToolBarMeasures);
m_tooltip.AddToolBar(&m_wndToolBarMeasuresEx);
m_tooltip.AddToolBar(&m_wndToolBarMeasuresSat);
m_tooltip.AddToolBar(&m_wndToolBarViews);
m_tooltip.SetColorBk(RGB(255,165,0),RGB(0,128,128));
m_tooltip.SetEffectBk(CPPDrawManager::EFFECT_HGRADIENT);
m_tooltip.SetBorder(::CreateSolidBrush(RGB(212,175,55)),1,1);
m_wndMenuBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarMeasures.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarMeasuresEx.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarMeasuresSat.EnableDocking(CBRS_ALIGN_ANY);
m_wndToolBarViews.EnableDocking(CBRS_ALIGN_ANY);
// Enable docking
// EnableDocking(CBRS_ALIGN_ANY);
EnableDocking(CBRS_ALIGN_TOP); // Use this to make bottom bar expanding only to left bar right side
EnableDocking(CBRS_ALIGN_LEFT);
EnableDocking(CBRS_ALIGN_RIGHT);
EnableDocking(CBRS_ALIGN_BOTTOM);
// Used by CControlBar to change bar visual aspect
#ifdef _SCB_REPLACE_MINIFRAME
m_pFloatingFrameClass = RUNTIME_CLASS(CSCBMiniDockFrameWnd);
#endif //_SCB_REPLACE_MINIFRAME
DockControlBar(&m_wndMenuBar);
DockControlBar(&m_wndToolBar);
DockControlBarNextTo(&m_wndToolBarMeasures,&m_wndToolBar);
DockControlBarNextTo(&m_wndToolBarViews,&m_wndToolBarMeasures);
DockControlBar(&m_wndToolBarMeasuresEx);
DockControlBarNextTo(&m_wndToolBarMeasuresSat,&m_wndToolBarMeasuresEx);
// Restore previous bar state
CString sProfile = _T("MeasureBarState");
if (VerifyBarState(sProfile))
{
CDockState state;
state.LoadState(sProfile);
if ( state.m_arrBarInfo.GetSize() == 0 )
{
ShowControlBar ( &m_wndToolBarMeasuresEx, FALSE, TRUE );
ShowControlBar ( &m_wndToolBarMeasuresSat, FALSE, TRUE );
}
else
{
CSizingControlBar::GlobalLoadState(this, sProfile);
LoadBarState(sProfile);
}
}
m_DefaultNewMenu.LoadToolBar(IDR_MENUBARGRAPH);
RecalcLayout(FALSE);
// Clear initial lux value
m_wndStatusBar.SetPaneText ( m_wndStatusBar.CommandToIndex ( ID_LUX_VALUE ), "" );
return 0;
}
BOOL CMainFrame::DestroyWindow()
{
if ( p_wndPatternDisplay )
{
p_wndPatternDisplay->DestroyWindow ();
delete p_wndPatternDisplay;
p_wndPatternDisplay = NULL;
}
CString sProfile = _T("MeasureBarState");
CSizingControlBar::GlobalSaveState(this, sProfile);
SaveBarState(sProfile);
return CMDIFrameWnd::DestroyWindow();
}
/////////////////////////////////////////////////////////////////////////////
// CMainFrame diagnostics
#ifdef _DEBUG
void CMainFrame::AssertValid() const
{
CMDIFrameWnd::AssertValid();
}
void CMainFrame::Dump(CDumpContext& dc) const
{
CMDIFrameWnd::Dump(dc);
}
#endif //_DEBUG
/////////////////////////////////////////////////////////////////////////////
// CMainFrame message handlers
// This function is Copyright (c) 2000, Cristi Posea.
// See www.datamekanix.com for more control bars tips&tricks.
BOOL CMainFrame::VerifyBarState(LPCTSTR lpszProfileName)
{
CDockState state;
state.LoadState(lpszProfileName);
for (int i = 0; i < state.m_arrBarInfo.GetSize(); i++)
{
CControlBarInfo* pInfo = (CControlBarInfo*)state.m_arrBarInfo[i];
ASSERT(pInfo != NULL);
int nDockedCount = pInfo->m_arrBarID.GetSize();
if (nDockedCount > 0)
{
// dockbar
for (int j = 0; j < nDockedCount; j++)
{
UINT nID = (UINT) pInfo->m_arrBarID[j];
if (nID == 0) continue; // row separator
if (nID > 0xFFFF)
nID &= 0xFFFF; // placeholder - get the ID
if (GetControlBar(nID) == NULL)
return FALSE;
}
}
if (!pInfo->m_bFloating) // floating dockbars can be created later
if (GetControlBar(pInfo->m_nBarID) == NULL)
return FALSE; // invalid bar ID
}
return TRUE;
}
void CMainFrame::DockControlBarNextTo(CControlBar* pBar,CControlBar* pTargetBar)
{
ASSERT(pBar != NULL);
ASSERT(pTargetBar != NULL);
ASSERT(pBar != pTargetBar);
// the neighbour must be already docked
CDockBar* pDockBar = pTargetBar->m_pDockBar;
ASSERT(pDockBar != NULL);
UINT nDockBarID = pTargetBar->m_pDockBar->GetDlgCtrlID();
ASSERT(nDockBarID != AFX_IDW_DOCKBAR_FLOAT);
bool bHorz = (nDockBarID == AFX_IDW_DOCKBAR_TOP ||
nDockBarID == AFX_IDW_DOCKBAR_BOTTOM);
// dock normally (inserts a new row)
DockControlBar(pBar, nDockBarID);
// delete the new row (the bar pointer and the row end mark)
pDockBar->m_arrBars.RemoveAt(pDockBar->m_arrBars.GetSize() - 1);
pDockBar->m_arrBars.RemoveAt(pDockBar->m_arrBars.GetSize() - 1);
// find the target bar
for (int i = 0; i < pDockBar->m_arrBars.GetSize(); i++)
{
void* p = pDockBar->m_arrBars[i];
if (p == pTargetBar) // and insert the new bar after it
pDockBar->m_arrBars.InsertAt(i + 1, pBar);
}
// move the new bar into position
CRect rBar;
pTargetBar->GetWindowRect(rBar);
rBar.OffsetRect(bHorz ? 1 : 0, bHorz ? 0 : 1);
pBar->MoveWindow(rBar);
}
LRESULT CMainFrame::OnSetMessageString(WPARAM wParam, LPARAM lParam)
{
if (!lParam && (wParam == AFX_IDS_IDLEMESSAGE) &&
m_strPane0StatusMsg.GetLength ())
{ // override the idle message
// save off last message ID, so can return
UINT nIDLast = m_nIDLastMessage;
m_nFlags &= ~WF_NOPOPMSG;
m_wndStatusBar.SetWindowText (m_strPane0StatusMsg);
// new ID -and- so F1 on toolbar buttons work
m_nIDTracking = m_nIDLastMessage = (UINT) wParam;
// return last message ID to simulate success
return (nIDLast);
}
// no override requested, do normal things from WinFrm.cpp
return (CFrameWnd::OnSetMessageString (wParam, lParam));
}
void CMainFrame::OnViewTestColor()
{
BOOL bShow = m_wndTestColorWnd.IsWindowVisible();
m_wndTestColorWnd.ShowWindow ( bShow ? SW_HIDE : SW_SHOW );
}
void CMainFrame::OnUpdateViewTestColor(CCmdUI* pCmdUI)
{
pCmdUI->Enable();
pCmdUI->SetCheck(m_wndTestColorWnd.IsWindowVisible());
}
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
m_tooltip.RelayEvent(pMsg);
if(m_wndMenuBar.TranslateFrameMessage(pMsg))
return TRUE;
return CMDIFrameWnd::PreTranslateMessage(pMsg);
}
BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)
{
cs.style |= WS_HSCROLL | WS_VSCROLL;
return CMDIFrameWnd::PreCreateWindow(cs);
}
void CMainFrame::OnViewViewBar()
{
BOOL bShow = m_wndToolBarViews.IsVisible();
ShowControlBar(&m_wndToolBarViews, !bShow, FALSE);
}
void CMainFrame::OnUpdateViewViewBar(CCmdUI* pCmdUI)
{
pCmdUI->Enable();
pCmdUI->SetCheck(m_wndToolBarViews.IsVisible());
}
void CMainFrame::OnViewMeasureBar()
{
BOOL bShow = m_wndToolBarMeasures.IsVisible();
ShowControlBar(&m_wndToolBarMeasures, !bShow, FALSE);
}
void CMainFrame::OnUpdateViewMeasureBar(CCmdUI* pCmdUI)
{
pCmdUI->Enable();
pCmdUI->SetCheck(m_wndToolBarMeasures.IsVisible());
}
void CMainFrame::OnViewMeasureExBar()
{
BOOL bShow = m_wndToolBarMeasuresEx.IsVisible();
ShowControlBar(&m_wndToolBarMeasuresEx, !bShow, FALSE);
}
void CMainFrame::OnUpdateViewMeasureExBar(CCmdUI* pCmdUI)
{
pCmdUI->Enable();
pCmdUI->SetCheck(m_wndToolBarMeasuresEx.IsVisible());
}
void CMainFrame::OnViewMeasureSatBar()
{
BOOL bShow = m_wndToolBarMeasuresSat.IsVisible();
ShowControlBar(&m_wndToolBarMeasuresSat, !bShow, FALSE);
}
void CMainFrame::OnUpdateViewMeasureSatBar(CCmdUI* pCmdUI)
{
pCmdUI->Enable();
pCmdUI->SetCheck(m_wndToolBarMeasuresSat.IsVisible());
}
void CMainFrame::OnViewToolbar()
{
BOOL bShow = m_wndToolBar.IsVisible();
ShowControlBar(&m_wndToolBar, !bShow, FALSE);
}
void CMainFrame::OnUpdateViewToolbar(CCmdUI* pCmdUI)
{
pCmdUI->Enable();
pCmdUI->SetCheck(m_wndToolBar.IsVisible());
}
void CMainFrame::OnGeneralConfig()
{
GetConfig()->ChangeSettings(0);
}
void CMainFrame::OnSysColorChange()
{
CNewMDIFrameWnd::OnSysColorChange();
// reload toolbar to re-create grayed icons with correct color
// m_wndToolBar.LoadHiColor(MAKEINTRESOURCE(IDB_MEDIUMTOOLBAR_MAIN),RGB(0,0,0));
// m_wndToolBarViews.LoadToolBar(m_viewToolbarID);
LoadToolbars();
// Redraw all toolbars including non-client areas
m_wndMenuBar.RedrawWindow(NULL,NULL,RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME );
m_wndToolBar.RedrawWindow(NULL,NULL,RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME );
m_wndToolBarViews.RedrawWindow(NULL,NULL,RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME );
m_wndToolBarMeasures.RedrawWindow(NULL,NULL,RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME );
m_wndStatusBar.RedrawWindow(NULL,NULL,RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_FRAME );
Invalidate(TRUE); // redraw window
}
void CMainFrame::OnDropFiles(HDROP hDropInfo)
{
// Default implementation is OK.
CNewMDIFrameWnd::OnDropFiles(hDropInfo);
}
void DdeParseString ( LPCSTR lpszString, CString & strCmd, CStringList & CmdParams );
extern "C" __declspec (dllexport) const char g_szShortApplicationName [] = "COLORH~1";
extern "C" __declspec (dllexport) const char g_szLongApplicationName [] = "COLORHCFR";
static const char * g_szDDETopicName = "General";
LRESULT CMainFrame::OnDDEInitiate(WPARAM wParam, LPARAM lParam)
{
LRESULT lResult = -1;
BOOL bOk = FALSE;
POSITION pos;
HWND hWndClient = (HWND) wParam;
ATOM nAtomAppli = (ATOM) LOWORD(lParam);
ATOM nAtomTopic = (ATOM) HIWORD(lParam);
ATOM nAtomSrvAppli;
ATOM nAtomSrvTopic;
char szBuf [ 256 ];
if ( nAtomAppli )
{
if ( nAtomAppli != AfxGetApp () -> m_atomApp )
{
GlobalGetAtomName ( nAtomAppli, szBuf, sizeof ( szBuf ) );
if ( _stricmp ( szBuf, g_szShortApplicationName ) == 0 || _stricmp ( szBuf, g_szLongApplicationName ) == 0 )
{
// Received good name, compressed or not. Get good atom name
nAtomAppli = AfxGetApp () -> m_atomApp;
lParam = MAKELONG ( nAtomAppli, nAtomTopic );
}
}
if ( nAtomAppli == AfxGetApp () -> m_atomApp )
{
if ( nAtomTopic )
{
GlobalGetAtomName ( nAtomTopic, szBuf, sizeof ( szBuf ) );
if ( _stricmp ( szBuf, g_szDDETopicName ) == 0 )
bOk = TRUE;
}
else
{
bOk = TRUE;
}
}
}
if ( bOk )
{
// Accept DDE conversation
nAtomSrvAppli = AfxGetApp () -> m_atomApp;
nAtomSrvTopic = GlobalAddAtom ( g_szDDETopicName );
lParam = MAKELPARAM ( nAtomSrvAppli, nAtomSrvTopic );
::SendMessage ( hWndClient, WM_DDE_ACK, (WPARAM) m_hWnd, lParam );
lResult = 0;
}
if ( lResult == -1 )
{
// Transfer initiate to all opened views
pos = gOpenedFramesList.GetHeadPosition ();
while ( pos && lResult == -1 )
{
CMultiFrame * pFrame = ( CMultiFrame * ) gOpenedFramesList.GetNext ( pos );
lResult = pFrame -> OnDDEInitiate(wParam, lParam);
}
}
if (lResult != -1)
{
}
else
{
// Transfer initiate command to MFC file open handler
CNewMDIFrameWnd::OnDDEInitiate(CWnd::FromHandle(hWndClient), LOBYTE(lParam), HIBYTE(lParam));
}
return 0;
}
LRESULT CMainFrame::OnDDEExecute(WPARAM wParam, LPARAM lParam)
{
int i;
int nRow, nCol;
int nCount;
char c;
Matrix SensorMatrix ( 0.0, 3, 3 );
BOOL bOk = FALSE;
BOOL bSomethingDone = FALSE;
LRESULT lRes = -1;
HWND hWndClient = (HWND) wParam;
HGLOBAL hMem = (HGLOBAL) lParam;
LPCSTR lpszCommand;
LPCSTR lpStr;
LPCSTR lpStr2;
LPCSTR lpStart = NULL;
char szBuf [ 256 ];
CString strCommand;
CString strCmd;
CString strParam;
CStringList CmdList;
CStringList CmdParams;
POSITION pos, pos2;
DDEACK Ack;
// Parse commands
lpszCommand = (LPCSTR) GlobalLock ( hMem );
lpStr = lpszCommand;
while ( (c=lpStr[0]) != '\0' )
{
if ( lpStart == NULL )
{
if ( c == '[' )
{
lpStr ++;
if ( lpStr [ 0 ] != '[' )
{
lpStart = lpStr;
nCount = 1;
}
}
}
else
{
if ( c == '[' )
nCount ++;
if ( c == ']' )
{
if ( lpStr [ 1 ] == ']' && nCount == 1 )
lpStr ++;
else
{
nCount --;
if ( nCount == 0 )
{
i = lpStr - lpStart;
strncpy_s ( szBuf, lpStart, i );
szBuf [ i ] = '\0';
CmdList.AddTail ( szBuf );
bOk = TRUE;
lpStart = NULL;
}
}
}
}
lpStr ++;
}
GlobalUnlock ( hMem );
if ( bOk )
{
pos = CmdList.GetHeadPosition ();
while ( pos && bOk )
{
strCommand = CmdList.GetNext ( pos );
bOk = FALSE;
DdeParseString ( (LPCSTR) strCommand, strCmd, CmdParams );
if ( _stricmp ( (LPCSTR) strCmd, "OpenColorDataSet" ) == 0 || _stricmp ( (LPCSTR) strCmd, "Open" ) == 0 )
{
lRes = 0;
nCount = CmdParams.GetCount ();
if ( nCount == 1 )
{
bOk = TRUE;
bSomethingDone = TRUE;
// First param is the file name to open
strParam = CmdParams.GetHead ();
if ( ! AfxGetApp () -> OpenDocumentFile ( strParam ) )
bOk = FALSE;
}
}
else if ( _stricmp ( (LPCSTR) strCmd, "NewColorDataSet" ) == 0 )
{
nCount = CmdParams.GetCount ();
if ( nCount == 4 )
{
bOk = TRUE;
bSomethingDone = TRUE;
pos2 = CmdParams.GetHeadPosition ();
// Retrieve Document name
strParam = CmdParams.GetNext ( pos2 );
g_NewDocName = strParam;
// Retrieve Generator ID
strParam = CmdParams.GetNext ( pos2 );
g_NewDocGeneratorID = atoi ( (LPCSTR) strParam );
// Retrieve Sensor ID
strParam = CmdParams.GetNext ( pos2 );
g_NewDocSensorID = atoi ( (LPCSTR) strParam );
// Retrieve Matrix
strParam = CmdParams.GetNext ( pos2 );
lpStr2 = strtok ( strParam.GetBuffer(1), "," );
if ( lpStr2 )
lpStr2 ++;
for ( nRow = 0; nRow < 3 && lpStr2 ; nRow ++ )
{
for ( nCol = 0; nCol < 3 && lpStr2 ; nCol ++ )
{
SensorMatrix [nRow] [nCol] = atof(lpStr2);
lpStr2 = strtok ( NULL, "," );
}
}
if ( nRow == 3 && nCol == 3 && lpStr2 == NULL )
{
g_bNewDocUseDDEInfo = TRUE;
g_ThcFileName.Empty ();
g_NewDocSensorMatrix = SensorMatrix;
GetColorApp() -> OnFileNew ();
g_bNewDocUseDDEInfo = FALSE;
}
else
{
// Invalid parameters
bOk = FALSE;
}
}
lRes = 0;
}
else if ( _stricmp ( (LPCSTR) strCmd, "NewColorDataSetWithThc" ) == 0 )
{
nCount = CmdParams.GetCount ();
if ( nCount == 4 )
{
bOk = TRUE;
bSomethingDone = TRUE;
pos2 = CmdParams.GetHeadPosition ();
// Retrieve Document name
strParam = CmdParams.GetNext ( pos2 );
g_NewDocName = strParam;
// Retrieve Generator ID
strParam = CmdParams.GetNext ( pos2 );
g_NewDocGeneratorID = atoi ( (LPCSTR) strParam );
// Retrieve Generator ID
strParam = CmdParams.GetNext ( pos2 );
g_NewDocSensorID = atoi ( (LPCSTR) strParam );
// Retrieve thc file name
strParam = CmdParams.GetNext ( pos2 );
if ( ! strParam.IsEmpty () )
{
CString strPath, strSubDir;
g_bNewDocUseDDEInfo = TRUE;
strPath = GetConfig () -> m_ApplicationPath;
strSubDir = CSensorSelectionPropPage::GetThcFileSubDir ( g_NewDocSensorID );
if ( ! strSubDir.IsEmpty () )
{
strPath += strSubDir;
strPath += '\\';
}
g_ThcFileName = strPath + strParam + ".thc";
GetColorApp() -> OnFileNew ();
g_bNewDocUseDDEInfo = FALSE;
}
else
{
// Invalid parameters
bOk = FALSE;
}
}
lRes = 0;
}
else if ( _stricmp ( (LPCSTR) strCmd, "SetLogFileName" ) == 0 )
{
nCount = CmdParams.GetCount ();
if ( nCount == 1 )
{
bOk = TRUE;
bSomethingDone = TRUE;
// Retrieve log file name
strParam = CmdParams.GetHead ();
strcpy_s ( GetConfig () -> m_logFileName, (LPCSTR) strParam );
}
}
}
if ( bSomethingDone )
{
Ack.bAppReturnCode = 0;
Ack.fAck = bOk;
Ack.fBusy = FALSE;
lParam = PackDDElParam ( WM_DDE_ACK, *(UINT*)(&Ack), lParam );
::PostMessage ( hWndClient, WM_DDE_ACK, (WPARAM) m_hWnd, lParam );
}
else
{
lRes = -1;
}
}
if ( lRes != -1 )
return lRes;
else
CNewMDIFrameWnd::OnDDEExecute(CWnd::FromHandle(hWndClient), hWndClient);
return 0;
}
LRESULT CMainFrame::OnDDERequest(WPARAM wParam, LPARAM lParam)
{
LRESULT lRes = -1;
if ( lRes != -1 )
return lRes;
else
return Default ();
}
LRESULT CMainFrame::OnDDEPoke(WPARAM wParam, LPARAM lParam)
{
LRESULT lRes = -1;
if ( lRes != -1 )
return lRes;
else
return Default ();
}
LRESULT CMainFrame::OnDDETerminate(WPARAM wParam, LPARAM lParam)
{
LRESULT lRes = -1;
if (lRes != -1)
{
}
else
CNewMDIFrameWnd::OnDDETerminate(CWnd::FromHandle((HWND)wParam));
return 0;
}
LRESULT CMainFrame::OnBkgndMeasureReady(WPARAM wParam, LPARAM lParam)
{
CDataSetDoc * pDoc = (CDataSetDoc *) wParam;
pDoc -> OnBkgndMeasureReady();
return 0;
}
void CMainFrame::OnDuplicateDoc()
{
g_bNewDocIsDuplication = TRUE;
CDataSetDoc * pDoc =(CDataSetDoc*)MDIGetActive()->GetActiveDocument();
g_DocToDuplicate = pDoc;
GetColorApp() -> OnFileNew ();
g_bNewDocIsDuplication = FALSE;
}
LRESULT CMainFrame::OnRightButton(WPARAM wParam, LPARAM lParam)
{
CDataSetDoc * pCurrentDocument = NULL;
CMDIChildWnd * pMDIFrameWnd = MDIGetActive();
if (pMDIFrameWnd != NULL)
{
pCurrentDocument = (CDataSetDoc *) pMDIFrameWnd->GetActiveDocument();
if ( pMDIFrameWnd -> IsKindOf ( RUNTIME_CLASS(CMultiFrame) ) )
( (CMultiFrame *) pMDIFrameWnd ) -> OnRightToolbarButton ( wParam );
}
return 0;
}
LRESULT CMainFrame::OnMiddleButton(WPARAM wParam, LPARAM lParam)
{
CDataSetDoc * pCurrentDocument = NULL;
CMDIChildWnd * pMDIFrameWnd = MDIGetActive();
if (pMDIFrameWnd != NULL)
{
pCurrentDocument = (CDataSetDoc *) pMDIFrameWnd->GetActiveDocument();
if ( pMDIFrameWnd -> IsKindOf ( RUNTIME_CLASS(CMultiFrame) ) )
( (CMultiFrame *) pMDIFrameWnd ) -> OnMiddleToolbarButton ( wParam );
}
return 0;
}
BEGIN_MESSAGE_MAP(CMDIClientWithLogo, CWnd)
//{{AFX_MSG_MAP(CMDIClientWithLogo)
ON_WM_SIZE()
ON_WM_ERASEBKGND()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CMDIClientWithLogo::CMDIClientWithLogo ()
{
m_LogoBitmap.LoadBitmap ( IDB_LOGO );
}
CMDIClientWithLogo::~CMDIClientWithLogo ()
{
m_LogoBitmap.DeleteObject ();
}
void CMDIClientWithLogo::OnSize(UINT nType, int cx, int cy)
{
InvalidateRect ( NULL, TRUE );
Default ();
}
BOOL CMDIClientWithLogo::OnEraseBkgnd(CDC* pDC)
{
// TODO: Add your message handler code here and/or call default
RECT Rect;
RECT ClientRect;
CDC BmpDC;
CBitmap * pOldBmp;
CBrush Brush ( RGB ( 56, 76, 104 ) );
BITMAP bm;
GetClientRect ( & ClientRect );
m_LogoBitmap.GetBitmap ( & bm );