/
CementBD.cpp
184 lines (160 loc) · 5.36 KB
/
CementBD.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
#include "stdafx.h"
#include "KRS.h"
#include "MainFrm.h"
#include "CementDoc.h"
#include "CementView.h"
#include "resource.h"
#include "CementBD.h"
IMPLEMENT_DYNCREATE(CCementBD, CCementView)
CCementBD::CCementBD() : CCementView()
{
type_view = t_cement_db;
}
CCementBD::~CCementBD()
{
}
void CCementBD::DoDataExchange(CDataExchange* pDX)
{
CFormView::DoDataExchange(pDX);
}
BEGIN_MESSAGE_MAP(CCementBD, CCementView)
ON_WM_SETFOCUS()
ON_WM_TIMER()
ON_WM_CREATE()
END_MESSAGE_MAP()
CMenu* CCementBD::SetModulesExtern()
{
if(gListModuleExternal.GetCount() == 0) return 0;
//---------------------------------------------------
//Ôîðìèðóåì ìåíþ âíåøíèõ ìîäóëåé
CCementDoc* pDoc = (CCementDoc*)GetDocument();
HINSTANCE hInst = AfxGetResourceHandle();
pDoc->m_DefaultMenu =
::LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_KRSCEMENTTYPE));
if (pDoc->m_DefaultMenu == NULL)
return 0;
CMenu* menu = CMenu::FromHandle(pDoc->GetDefaultMenu());
if(menu)
{
int iPos;
CMenu* pPopup = NULL;
for(iPos = 0; iPos < (int)menu->GetMenuItemCount(); iPos++)
{
if(menu->GetSubMenu(iPos)->GetMenuItemID(0) == ID_NASTROIKA_MODULES)
{
pPopup = menu->GetSubMenu(iPos);
int ii = (int)pPopup->GetMenuItemCount();
break;
}
}
if(pPopup == NULL) return 0;
CMenu *submenu = menu->GetSubMenu(iPos);
if(submenu == NULL) return 0;
int ii = (int)submenu->GetMenuItemCount();
int cx = ::GetSystemMetrics(SM_CXMENUCHECK);
int cy = ::GetSystemMetrics(SM_CYMENUCHECK);
if(pPopup != NULL && gListModuleExternal.GetCount() > 0)
{
pPopup->AppendMenu(MF_SEPARATOR, 0, LPCTSTR(0));
for(int i = 0; i < gListModuleExternal.GetCount(); i++)
{
HICON hIconLarge, hIcon;
// ExtractIconEx(gListModuleExternal.GetName2(i), 0, &hIconLarge, &hIcon, 1);
CString Name2 = gListModuleExternal.GetName2txe(i);
if(Name2.GetLength() == 0) continue;
ExtractIconEx(Name2, 0, &hIconLarge, &hIcon, 1);
//HICON hIcon = ExtractIcon(pApp->m_hInstance, gListModuleExternal.GetName2(i), 0);
if(hIcon != NULL)
{
ICONINFO iconinfo;
GetIconInfo(hIcon, &iconinfo);
HANDLE hLoad = CopyImage(HANDLE(iconinfo.hbmColor), IMAGE_BITMAP, cx+1, cy+1, LR_COPYFROMRESOURCE);
CBitmap *pBmp = CBitmap::FromHandle(HBITMAP(hLoad));
CString str;
str.Format(" %d", i);
str += ". " + gListModuleExternal.GetName(i);
BOOL flg = pPopup->AppendMenu(MF_STRING | MF_ENABLED, ID_MENU_MODULE_EXTERNAL + i, str);
pPopup->SetMenuItemBitmaps(i+2, MF_BYPOSITION, pBmp, pBmp);
//BOOL res = menu->SetMenuItemBitmaps(2, MF_BYPOSITION, pBmp, pBmp);
//int zzz = 0;
}
}
}
CMDIFrameWnd* frame = ((CMDIChildWnd *) GetParent())->GetMDIFrame();
frame->MDISetMenu(menu, NULL);
frame->DrawMenuBar();
}
//-------------------------------------------------------------------------
return menu;
}
void CCementBD::RenameMenuItem(UINT ID_menu_item, CString new_name)
{
//---------------------------------------------------
//Ôîðìèðóåì ìåíþ âíåøíèõ ìîäóëåé
CCementDoc* pDoc = (CCementDoc*)GetDocument();
pDoc->m_DefaultMenu =
::LoadMenu(AfxGetResourceHandle(), MAKEINTRESOURCE(IDR_KRSCEMENTTYPE));
if (pDoc->m_DefaultMenu == NULL)
return;
CMenu* menu = CMenu::FromHandle(pDoc->GetDefaultMenu());
if(menu)
{
int iPos, iMaxPos, jPos, jMaxPos;
CMenu *submenu = NULL;
iMaxPos = (int)menu->GetMenuItemCount();
for(iPos = 0; iPos < iMaxPos; iPos++)
{
submenu = menu->GetSubMenu(iPos);
jMaxPos = (int)submenu->GetMenuItemCount();
for(jPos = 0; jPos < jMaxPos; jPos++)
{
if(submenu->GetMenuItemID(jPos) == ID_menu_item)
break;
}
if (jPos < jMaxPos)
break;
}
if(submenu == NULL || jPos >= jMaxPos || new_name.GetLength() == 0)
return;
BOOL flg = submenu->ModifyMenu(jPos, MF_BYPOSITION, ID_menu_item, new_name);
//BOOL flg = submenu->ModifyMenu(ID_menu_item, MF_BYCOMMAND, ID_menu_item, new_name);
CMDIFrameWnd* frame = ((CMDIChildWnd *) GetParent())->GetMDIFrame();
frame->MDISetMenu(menu, NULL);
frame->DrawMenuBar();
}
}
void CCementBD::OnInitialUpdate()
{
// if(m_flag_init) return;//çàõîäèò íåñêîëüêî ðàç
// m_flag_init = true;
m_ptmData = pgtmDataDB;
m_pcurGlub = pgcurGlubDB;
CCementView::OnInitialUpdate();
// KRS_CheckFinishInitialization();
}
void CCementBD::OnSetFocus(CWnd* pOldWnd)
{
CFormView::OnSetFocus(pOldWnd);
ASSERT(pFrm);
CheckRegim();
CheckGrf();
pFrm->ChangeTypeView((int)type_view, 3);
SetVisibilityPanelEtap();
SetModulesExtern();
}
void CCementBD::OnTimer(UINT_PTR nIDEvent)
{
if (nIDEvent == 10 && gflgDataReaded != 0)
{
// SetModulesExtern();
KillTimer(nIDEvent);
}
CCementView::OnTimer(nIDEvent);
}
int CCementBD::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CCementView::OnCreate(lpCreateStruct) == -1)
return -1;
SetTimer(10, 30, NULL); // äëÿ íîðìàëüíîé óñòàíîâêè ìåíþ âíåøíèõ ìîäóëåé
return 0;
}