-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCKPEquilibrium_PhasesPg1.cpp
755 lines (637 loc) · 19.1 KB
/
CKPEquilibrium_PhasesPg1.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
// CKPEquilibrium_PhasesPg1.cpp : implementation file
//
// $Id$
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "resource.h"
#include "CKPEquilibrium_PhasesPg1.h"
#include "RichDocIn.h"
#include "Database.h"
#include "Util.h"
#include "DDX_DDV.h"
#ifdef _DEBUG
#undef THIS_FILE
static char BASED_CODE THIS_FILE[] = __FILE__;
#endif
IMPLEMENT_DYNCREATE(CCKPEquilibrium_PhasesPg1, baseCKPEquilibrium_PhasesPg1)
/////////////////////////////////////////////////////////////////////////////
// CCKPEquilibrium_PhasesPg1 property page
CCKPEquilibrium_PhasesPg1::CCKPEquilibrium_PhasesPg1()
: baseCKPEquilibrium_PhasesPg1(CCKPEquilibrium_PhasesPg1::IDD)
, m_glDoc(&m_ctrlPhaseEditGrid, &m_ctrlPhaseCheckList, 1)
// COMMENT: {8/28/2001 1:29:00 PM} , m_bComboFilledOnce(false)
{
//{{AFX_DATA_INIT(CCKPEquilibrium_PhasesPg1)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
CCKPEquilibrium_PhasesPg1::~CCKPEquilibrium_PhasesPg1()
{
}
void CCKPEquilibrium_PhasesPg1::DoDataExchange(CDataExchange* pDX)
{
baseCKPEquilibrium_PhasesPg1::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CCKPEquilibrium_PhasesPg1)
DDX_Control(pDX, IDC_CL_PHASE, m_ctrlPhaseCheckList);
DDX_Control(pDX, IDC_MSHFG_PHASE, m_ctrlPhaseEditGrid);
//}}AFX_DATA_MAP
DDX_PurePhaseList(pDX, IDC_MSHFG_PHASE);
}
BEGIN_MESSAGE_MAP(CCKPEquilibrium_PhasesPg1, baseCKPEquilibrium_PhasesPg1)
//{{AFX_MSG_MAP(CCKPEquilibrium_PhasesPg1)
ON_NOTIFY(NM_SETFOCUS, IDC_CL_PHASE, OnSetfocusClPhase)
ON_WM_CONTEXTMENU()
ON_NOTIFY(LVN_ITEMCHANGED, IDC_CL_PHASE, OnItemchangedClPhase)
ON_WM_SIZE()
ON_WM_HELPINFO()
//}}AFX_MSG_MAP
// custom edit grid notifications
ON_MESSAGE(EGN_BEGINCELLEDIT, OnBeginCellEdit)
ON_MESSAGE(EGN_ENDCELLEDIT, OnEndCellEdit)
ON_MESSAGE(EGN_SETFOCUS, OnSetfocusGrid)
// custom check list notifications
ON_COMMAND_RANGE(ID_VIEW_AS_LIST, ID_LIST_CLEAR_ALL, OnViewChange)
END_MESSAGE_MAP()
BEGIN_EVENTSINK_MAP(CCKPEquilibrium_PhasesPg1, baseCKPEquilibrium_PhasesPg1)
//{{AFX_EVENTSINK_MAP(CCKPEquilibrium_PhasesPg1)
ON_EVENT(CCKPEquilibrium_PhasesPg1, IDC_MSHFG_NUM_DESC, 71 /* EnterCell */, OnEnterCellMshfgNumDesc, VTS_NONE)
ON_EVENT(CCKPEquilibrium_PhasesPg1, IDC_MSHFG_PHASE, 71 /* EnterCell */, OnEnterCellMshfgPhase, VTS_NONE)
ON_EVENT(CCKPEquilibrium_PhasesPg1, IDC_MSHFG_PHASE, -602 /* KeyDown */, OnKeyDownMshfgPhase, VTS_PI2 VTS_I2)
//}}AFX_EVENTSINK_MAP
END_EVENTSINK_MAP()
BOOL CCKPEquilibrium_PhasesPg1::OnInitDialog()
{
baseCKPEquilibrium_PhasesPg1::OnInitDialog();
// Add extra initialization here
// set layout
CreateRoot(VERTICAL, 5, 6)
<< item(IDC_MSHFG_NUM_DESC, ABSOLUTE_VERT)
<< item(IDC_S_DEF_PHASE, NORESIZE | ALIGN_BOTTOM)
<< item(IDC_CL_PHASE, GREEDY)
<< item(IDC_MSHFG_PHASE, GREEDY)
<< ( paneCtrl(IDC_S_DESC_INPUT, HORIZONTAL, GREEDY, nDefaultBorder, 10, 10)
<< item(IDC_E_DESC_INPUT, ABSOLUTE_VERT)
);
UpdateLayout();
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
BOOL CCKPEquilibrium_PhasesPg1::InitPhaseCheckList()
{
CUtil::InsertPhases(&m_ctrlPhaseCheckList, GetDatabase());
m_ctrlPhaseCheckList.SetItemState(0, LVIS_SELECTED | LVIS_FOCUSED, LVIS_SELECTED | LVIS_FOCUSED);
return TRUE;
}
BOOL CCKPEquilibrium_PhasesPg1::InitPhaseEditGrid()
{
m_ctrlPhaseEditGrid.SetCols(0, 8);
// set column titles
m_ctrlPhaseEditGrid.SetTextMatrix(0, 1, _T("Name"));
m_ctrlPhaseEditGrid.SetTextMatrix(0, 2, _T("Sat. index"));
m_ctrlPhaseEditGrid.SetTextMatrix(0, 3, _T("Amount (moles)"));
m_ctrlPhaseEditGrid.SetTextMatrix(0, 4, _T("[Alt. formula]"));
m_ctrlPhaseEditGrid.SetTextMatrix(0, 5, _T("[Dissolve only]"));
m_ctrlPhaseEditGrid.SetTextMatrix(0, 6, _T("[Precip. only]"));
m_ctrlPhaseEditGrid.SetTextMatrix(0, 7, _T("[Force equal.]"));
// set alignment
m_ctrlPhaseEditGrid.SetColAlignment(1, flexAlignLeftCenter);
// set bold titles
m_ctrlPhaseEditGrid.SetRow(0), m_ctrlPhaseEditGrid.SetCol(1);
m_ctrlPhaseEditGrid.SetCellFontBold(TRUE);
m_ctrlPhaseEditGrid.SetRow(0), m_ctrlPhaseEditGrid.SetCol(2);
m_ctrlPhaseEditGrid.SetCellFontBold(TRUE);
m_ctrlPhaseEditGrid.SetRow(0), m_ctrlPhaseEditGrid.SetCol(3);
m_ctrlPhaseEditGrid.SetCellFontBold(TRUE);
// center align the column headers
m_ctrlPhaseEditGrid.SetFillStyle(flexFillRepeat);
m_ctrlPhaseEditGrid.SetRow(0);
m_ctrlPhaseEditGrid.SetCol(1);
m_ctrlPhaseEditGrid.SetColSel(m_ctrlPhaseEditGrid.GetCols(0) - 1);
m_ctrlPhaseEditGrid.SetCellAlignment(flexAlignCenterCenter);
m_ctrlPhaseEditGrid.SetFillStyle(flexFillSingle);
// set column widths
m_ctrlPhaseEditGrid.SetColWidth(0, 0, 500);
m_ctrlPhaseEditGrid.SetColWidth(1, 0, 1240);
m_ctrlPhaseEditGrid.SetColWidth(2, 0, 1240);
m_ctrlPhaseEditGrid.SetColWidth(3, 0, 1440);
m_ctrlPhaseEditGrid.SetColWidth(4, 0, 1300);
m_ctrlPhaseEditGrid.SetColWidth(5, 0, 1300);
m_ctrlPhaseEditGrid.SetColWidth(6, 0, 1300);
m_ctrlPhaseEditGrid.SetColWidth(7, 0, 1300);
// set row titles
m_ctrlPhaseEditGrid.AddRowHeaders();
// center align row titles
m_ctrlPhaseEditGrid.SetColAlignmentFixed(0, flexAlignCenterCenter);
// scroll to top of grid
m_ctrlPhaseEditGrid.SetTopRow(1); m_ctrlPhaseEditGrid.SetLeftCol(1);
// set initial cell
m_ctrlPhaseEditGrid.SetRow(1); m_ctrlPhaseEditGrid.SetCol(1);
return TRUE;
}
void CCKPEquilibrium_PhasesPg1::OnEnterCellMshfgNumDesc()
{
CString strRes;
switch (m_egNumDesc.GetRow())
{
case 0 :
AfxFormatString1(strRes, IDS_N_USER_140, _T("phase assemblage"));
break;
case 1 :
AfxFormatString1(strRes, IDS_N_USER_END_141, _T("phase"));
break;
case 2 :
AfxFormatString1(strRes, IDS_DESC_STR_142, _T("phase assemblage"));
break;
default :
ASSERT(FALSE);
break;
}
m_eInputDesc.SetWindowText(strRes);
}
void CCKPEquilibrium_PhasesPg1::OnEnterCellMshfgPhase()
{
CString strRes;
CString strRes2;
switch (m_ctrlPhaseEditGrid.GetCol())
{
case 1 :
strRes.LoadString(IDS_EQ_PH_1_143);
break;
case 2 :
strRes.LoadString(IDS_EQ_PH_2_144);
break;
case 3 :
strRes.LoadString(IDS_EQ_PH_3_145);
break;
case 4 :
strRes.LoadString(IDS_EQ_PH_4A_146);
strRes2.LoadString(IDS_EQ_PH_4B_147);
strRes += strRes2;
break;
case 5:
strRes.LoadString(IDS_STRING615);
break;
case 6:
strRes.LoadString(IDS_STRING695);
break;
case 7:
strRes.LoadString(IDS_STRING696);
break;
default :
ASSERT(FALSE);
break;
}
m_eInputDesc.SetWindowText(strRes);
}
void CCKPEquilibrium_PhasesPg1::OnSetfocusClPhase(NMHDR* pNMHDR, LRESULT* pResult)
{
ASSERT(pNMHDR->hwndFrom == m_ctrlPhaseCheckList.m_hWnd);
UNUSED(pNMHDR); // unused in release builds
CString strRes;
strRes.LoadString(IDS_EQ_PH_CL_148);
m_eInputDesc.SetWindowText(strRes);
*pResult = 0;
}
LRESULT CCKPEquilibrium_PhasesPg1::OnSetfocusGrid(WPARAM wParam, LPARAM lParam)
{
UINT nID = wParam;
UNUSED_ALWAYS(lParam);
switch (nID)
{
case IDC_MSHFG_NUM_DESC :
OnEnterCellMshfgNumDesc();
break;
case IDC_MSHFG_PHASE :
OnEnterCellMshfgPhase();
break;
}
return 0;
}
void CCKPEquilibrium_PhasesPg1::OnContextMenu(CWnd* pWnd, CPoint point)
{
if (pWnd == &m_ctrlPhaseCheckList)
{
if (point.x == -1 && point.y == -1)
{
//keystroke invocation
CRect rect;
pWnd->GetClientRect(rect);
pWnd->ClientToScreen(rect);
point = rect.TopLeft();
point.Offset(5, 5);
}
CMenu menu;
VERIFY(menu.LoadMenu(IDR_CHECKLIST));
CMenu* pPopup = menu.GetSubMenu(0);
ASSERT(pPopup != NULL);
pPopup->CheckMenuRadioItem(ID_VIEW_AS_LIST, ID_VIEW_AS_REPORT,
(m_ctrlPhaseCheckList.GetStyle() & LVS_TYPEMASK) == LVS_LIST ? ID_VIEW_AS_LIST : ID_VIEW_AS_REPORT,
MF_BYCOMMAND );
pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
this/*pWndPopupOwner*/);
}
}
void CCKPEquilibrium_PhasesPg1::OnViewChange(UINT uID)
{
CWaitCursor wait;
int i, nElements;
switch (uID)
{
case ID_VIEW_AS_LIST :
m_ctrlPhaseCheckList.ModifyStyle(LVS_REPORT, LVS_LIST);
break;
case ID_VIEW_AS_REPORT :
m_ctrlPhaseCheckList.ModifyStyle(LVS_LIST, LVS_REPORT);
m_ctrlPhaseCheckList.SetColumnWidth(0, LVSCW_AUTOSIZE_USEHEADER);
m_ctrlPhaseCheckList.SetColumnWidth(1, LVSCW_AUTOSIZE_USEHEADER);
m_ctrlPhaseCheckList.SetColumnWidth(2, LVSCW_AUTOSIZE_USEHEADER);
m_ctrlPhaseCheckList.RedrawWindow();
break;
case ID_LIST_CLEAR_ALL :
nElements = m_ctrlPhaseCheckList.GetItemCount();
for (i = 0; i < nElements; ++i)
{
if (m_ctrlPhaseCheckList.GetCheckBox(i) == BST_CHECKED)
{
m_ctrlPhaseCheckList.SetCheckBox(i, BST_UNCHECKED);
}
}
break;
default :
ASSERT(FALSE);
break;
}
}
LRESULT CCKPEquilibrium_PhasesPg1::OnBeginCellEdit(WPARAM wParam, LPARAM lParam)
{
NMEGINFO* pInfo = (NMEGINFO*)lParam;
UINT nID = wParam;
BOOL bDenyEdit = FALSE; // allow edit
if ( nID == IDC_MSHFG_PHASE )
{
switch ( pInfo->item.iCol )
{
case 1:
// set to phase list
pInfo->item.bUseCombo = (CUtil::InsertPhases(pInfo->item.hWndCombo, GetDatabase()) > 0);
break;
case 5: case 6: case 7:
if (pInfo->item.hWndCombo)
{
CComboBox* pCombo = (CComboBox*)CWnd::FromHandle(pInfo->item.hWndCombo);
ASSERT_KINDOF(CComboBox, pCombo); // must be combobox
if (pCombo)
{
// remove prev items
pCombo->ResetContent();
pCombo->AddString(_T(""));
pCombo->AddString(_T("true"));
// set drop width
CDC* pDC = pCombo->GetDC();
CSize size = pDC->GetTextExtent(_T("true"));
pCombo->SetDroppedWidth(size.cx);
pInfo->item.bUseCombo = (pCombo->GetCount() > 0);
}
}
else
{
pInfo->item.bUseCombo = TRUE;
}
break;
default :
break;
}
}
return bDenyEdit;
}
LRESULT CCKPEquilibrium_PhasesPg1::OnEndCellEdit(WPARAM wParam, LPARAM lParam)
{
NMEGINFO* pInfo = (NMEGINFO*)lParam;
UINT nID = wParam;
UNUSED(pInfo);
BOOL bMakeChange = TRUE;
// ignore if edit is cancelled
if ( pInfo->item.pszText == NULL ) return bMakeChange;
switch ( nID )
{
case IDC_MSHFG_PHASE :
if (_tcslen(pInfo->item.pszText))
{
// fill in defaults
if (m_ctrlPhaseEditGrid.GetTextMatrix(pInfo->item.iRow, 2).IsEmpty())
{
m_ctrlPhaseEditGrid.SetTextMatrix(pInfo->item.iRow, 2, _T("0.0"));
}
if (m_ctrlPhaseEditGrid.GetTextMatrix(pInfo->item.iRow, 3).IsEmpty())
{
m_ctrlPhaseEditGrid.SetTextMatrix(pInfo->item.iRow, 3, _T("10.0"));
}
}
return m_glDoc.OnEndCellEdit(wParam, lParam);
break;
case IDC_MSHFG_NUM_DESC :
break;
}
return bMakeChange;
}
void CCKPEquilibrium_PhasesPg1::OnItemchangedClPhase(NMHDR* pNMHDR, LRESULT* pResult)
{
// do default
long row = m_glDoc.OnItemChanged(pNMHDR, pResult);
if (row != -1)
{
if (m_ctrlPhaseEditGrid.GetTextMatrix(row, 2).IsEmpty())
m_ctrlPhaseEditGrid.SetTextMatrix(row, 2, _T("0.0"));
if (m_ctrlPhaseEditGrid.GetTextMatrix(row, 3).IsEmpty())
m_ctrlPhaseEditGrid.SetTextMatrix(row, 3, _T("10.0"));
}
}
void CCKPEquilibrium_PhasesPg1::OnKeyDownMshfgPhase(short FAR* KeyCode, short Shift)
{
// mustn't have any disabled cells
m_glDoc.OnKeyDown(KeyCode, Shift);
}
void CCKPEquilibrium_PhasesPg1::DDX_PurePhaseList(CDataExchange *pDX, int nIDC)
{
ASSERT(nIDC == IDC_MSHFG_PHASE);
// do only on initialization
if (m_bFirstSetActive)
{
InitPhaseCheckList();
InitPhaseEditGrid();
}
if (pDX->m_bSaveAndValidate)
{
std::list<CPurePhase> listPurePhase;
CString strDummy;
for (long nRow = 1; nRow < m_ctrlPhaseEditGrid.GetRows(); ++nRow)
{
CPurePhase purePhase;
// phase name
DDX_GridText(pDX, nIDC, nRow, 1, purePhase.m_strName);
if (purePhase.m_strName.IsEmpty())
continue;
// saturation index
DDX_GridText(pDX, nIDC, nRow, 2, purePhase.m_dSI);
// alternative formula or phase
DDX_GridText(pDX, nIDC, nRow, 4, purePhase.m_strAlt);
// amount
DDX_GridText(pDX, nIDC, nRow, 3, purePhase.m_dAmount);
// dissolve only
DDX_GridText(pDX, nIDC, nRow, 5, strDummy);
strDummy.TrimLeft();
if (!strDummy.IsEmpty())
{
switch (strDummy[0])
{
case _T('T') : case _T('t') : case _T('Y') : case _T('y') :
purePhase.m_bDissolveOnly = true;
break;
case _T('F') : case _T('f') : case _T('N') : case _T('n') :
purePhase.m_bDissolveOnly = false;
break;
default :
::AfxMessageBox(_T("The dissolve only option should be \"true\", \"false\" or empty."));
pDX->Fail();
break;
}
}
// precip only
DDX_GridText(pDX, nIDC, nRow, 6, strDummy);
strDummy.TrimLeft();
if (!strDummy.IsEmpty())
{
switch (strDummy[0])
{
case _T('T') : case _T('t') : case _T('Y') : case _T('y') :
purePhase.m_bPrecipOnly = true;
break;
case _T('F') : case _T('f') : case _T('N') : case _T('n') :
purePhase.m_bPrecipOnly = false;
break;
default :
::AfxMessageBox(_T("The precipitate only option should be \"true\", \"false\" or empty."));
pDX->Fail();
break;
}
}
// force_equality
DDX_GridText(pDX, nIDC, nRow, 7, strDummy);
strDummy.TrimLeft();
if (!strDummy.IsEmpty())
{
switch (strDummy[0])
{
case _T('T') : case _T('t') : case _T('Y') : case _T('y') :
purePhase.m_bForceEquality = true;
break;
case _T('F') : case _T('f') : case _T('N') : case _T('n') :
purePhase.m_bForceEquality = false;
break;
default :
::AfxMessageBox(_T("The force equality option should be \"true\", \"false\" or empty."));
pDX->Fail();
break;
}
}
if (purePhase.m_bDissolveOnly && purePhase.m_bPrecipOnly)
{
::AfxMessageBox(_T("The \"dissolve only\" and \"precipitate only\" are mutually exclusive options."));
pDX->Fail();
}
if (purePhase.m_bDissolveOnly && !purePhase.m_strAlt.IsEmpty())
{
::AfxMessageBox(_T("The dissolve only option cannot be used when adding an alternative reaction."));
pDX->Fail();
}
if (purePhase.m_bPrecipOnly && !purePhase.m_strAlt.IsEmpty())
{
::AfxMessageBox(_T("The precipitate only option cannot be used when adding an alternative reaction."));
pDX->Fail();
}
// if here no exception has occured so add to list
listPurePhase.push_back(purePhase);
}
// if here listPurePhase is valid and can be assigned to the member variable
m_listPurePhase.empty();
m_listPurePhase.assign(listPurePhase.begin(), listPurePhase.end());
}
else
{
std::list<CPurePhase>::const_iterator iter = m_listPurePhase.begin();
for (; iter != m_listPurePhase.end(); ++iter)
{
// phase name [saturation index [(alternative formula or alternative phase) [amount]]]
CPurePhase purePhase(*iter);
// phase name
// add to grid list doc
int nRow = m_glDoc.AddItem(purePhase.m_strName).m_nRow;
// saturation index
DDX_GridText(pDX, nIDC, nRow, 2, purePhase.m_dSI);
// alternative formula or phase
if ( !(*iter).m_strAlt.IsEmpty() )
{
DDX_GridText(pDX, nIDC, nRow, 4, purePhase.m_strAlt);
}
// amount
DDX_GridText(pDX, nIDC, nRow, 3, purePhase.m_dAmount);
// dissolve only
if (purePhase.m_bDissolveOnly)
{
CString str = _T("true");
DDX_GridText(pDX, nIDC, nRow, 5, str);
}
// precip only
if (purePhase.m_bPrecipOnly)
{
CString str = _T("true");
DDX_GridText(pDX, nIDC, nRow, 6, str);
}
// force_equality
if (purePhase.m_bForceEquality)
{
CString str = _T("true");
DDX_GridText(pDX, nIDC, nRow, 7, str);
}
}
}
}
void CCKPEquilibrium_PhasesPg1::OnSize(UINT nType, int cx, int cy)
{
baseCKPEquilibrium_PhasesPg1::OnSize(nType, cx, cy);
// Add your message handler code here
if (::GetKeyState(VK_CONTROL) < 0)
{
}
}
BOOL CCKPEquilibrium_PhasesPg1::OnHelpInfo(HELPINFO* pHelpInfo)
{
// Declare the popup structure and initialize it.
HH_POPUP myPopup;
memset(&myPopup, 0, sizeof(HH_POPUP));
// Fill in the popup structure
myPopup.cbStruct = sizeof(HH_POPUP);
myPopup.rcMargins.top = 5;
myPopup.rcMargins.bottom = 5;
myPopup.rcMargins.left = 5;
myPopup.rcMargins.right = 5;
myPopup.clrForeground = (COLORREF)-1; // use default
myPopup.clrBackground = (COLORREF)-1; // use default
myPopup.idString = 0; // set the ID string to 0
if (IsContextHelp())
{
myPopup.pt.x = pHelpInfo->MousePos.x;
myPopup.pt.y = pHelpInfo->MousePos.y;
}
else
{
if (pHelpInfo->hItemHandle)
{
// Center pt of window w/ offset
CRect rc;
::GetWindowRect((HWND)pHelpInfo->hItemHandle, &rc);
myPopup.pt = rc.CenterPoint();
myPopup.pt.y += 10;
}
}
CString strRes;
CString strResEx;
switch (pHelpInfo->iCtrlId)
{
case IDC_CL_PHASE: case IDC_S_DEF_PHASE:
strRes.LoadString(IDS_EQ_PH_CL_148);
break;
case IDC_MSHFG_PHASE:
if (!IsContextHelp())
{
if (!(m_ctrlPhaseEditGrid.GetRowIsVisible(m_ctrlPhaseEditGrid.GetRow()) && m_ctrlPhaseEditGrid.GetColIsVisible(m_ctrlPhaseEditGrid.GetCol())))
{
::MessageBeep((UINT)-1);
return TRUE;
}
// modify placement
CDC* pDC = m_ctrlPhaseEditGrid.GetDC();
int m_nLogX = pDC->GetDeviceCaps(LOGPIXELSX);
int m_nLogY = pDC->GetDeviceCaps(LOGPIXELSY);
long nLeft = ::MulDiv(m_ctrlPhaseEditGrid.GetCellLeft(), m_nLogX, TWIPS_PER_INCH);
long nTop = ::MulDiv(m_ctrlPhaseEditGrid.GetCellTop(), m_nLogY, TWIPS_PER_INCH);
CRect rc;
m_ctrlPhaseEditGrid.GetWindowRect(rc);
myPopup.pt.x = rc.left + nLeft;
myPopup.pt.y = rc.top + nTop + 10;
}
switch (IsContextHelp() ? m_ctrlPhaseEditGrid.GetMouseCol() : m_ctrlPhaseEditGrid.GetCol())
{
case 1 :
strRes.LoadString(IDS_EQ_PH_1_143);
break;
case 2 :
strRes.LoadString(IDS_EQ_PH_2_144);
break;
case 3 :
strRes.LoadString(IDS_EQ_PH_3_145);
break;
case 4 :
strRes.LoadString(IDS_EQ_PH_4A_146);
strResEx.LoadString(IDS_EQ_PH_4B_147);
strRes += strResEx;
break;
case 5:
strRes.LoadString(IDS_STRING615);
break;
case 6:
strRes.LoadString(IDS_STRING695);
break;
case 7:
strRes.LoadString(IDS_STRING696);
break;
default :
// No help topic is associated with this item.
strRes.LoadString(IDS_STRING441);
break;
}
break;
case IDC_MSHFG_NUM_DESC:
if (!IsContextHelp())
{
if (!(m_egNumDesc.GetRowIsVisible(m_egNumDesc.GetRow()) && m_egNumDesc.GetColIsVisible(m_egNumDesc.GetCol())))
{
::MessageBeep((UINT)-1);
return TRUE;
}
// modify placement
CDC* pDC = m_egNumDesc.GetDC();
int m_nLogX = pDC->GetDeviceCaps(LOGPIXELSX);
int m_nLogY = pDC->GetDeviceCaps(LOGPIXELSY);
long nLeft = ::MulDiv(m_egNumDesc.GetCellLeft(), m_nLogX, TWIPS_PER_INCH);
long nTop = ::MulDiv(m_egNumDesc.GetCellTop(), m_nLogY, TWIPS_PER_INCH);
CRect rc;
m_egNumDesc.GetWindowRect(rc);
myPopup.pt.x = rc.left + nLeft;
myPopup.pt.y = rc.top + nTop + 10;
}
switch (IsContextHelp() ? m_egNumDesc.GetMouseRow() : m_egNumDesc.GetRow())
{
case 0 :
AfxFormatString1(strRes, IDS_N_USER_140, _T("phase assemblage"));
break;
case 1 :
AfxFormatString1(strRes, IDS_N_USER_END_141, _T("phase"));
break;
case 2 :
AfxFormatString1(strRes, IDS_DESC_STR_142, _T("phase assemblage"));
break;
default :
// No help topic is associated with this item.
strRes.LoadString(IDS_STRING441);
break;
}
break;
default:
// No help topic is associated with this item.
strRes.LoadString(IDS_STRING441);
break;
}
myPopup.pszText = strRes;
return ::HtmlHelp(NULL, NULL, HH_DISPLAY_TEXT_POPUP, (DWORD)&myPopup) != NULL;
}