Windowsの機能を使ったクリップボード機能を実装。アプリケーションを再度起動した時に前回の設定を復帰できるようにする。
@@ -6,6 +6,8 @@ | ||
6 | 6 | class IBuffer2D; |
7 | 7 | } |
8 | 8 | |
9 | +#include "setting.h" | |
10 | + | |
9 | 11 | class CDataView : public CWindowImpl<CDataView> |
10 | 12 | { |
11 | 13 | public: |
@@ -17,9 +19,14 @@ | ||
17 | 19 | void ProcessData(); |
18 | 20 | |
19 | 21 | BOOL PreTranslateMessage(MSG* pMsg); |
20 | - struct ProcessSetting& GetSetting() { return *m_pSetting; } | |
21 | - void ReadData(const ProcessSetting& setting); | |
22 | - void ProcessData(const ProcessSetting& setting); | |
22 | + ProcessSetting& GetProcessSetting() { | |
23 | + return m_processSetting; | |
24 | + } | |
25 | + const IDataSetting* GetDataSetting() { | |
26 | + return m_pDataSetting.get(); | |
27 | + } | |
28 | + void ReadData(const ProcessSetting& setting, boost::shared_ptr<IDataSetting>& pDataSetting); | |
29 | + void ProcessData(const ProcessSetting& setting, boost::shared_ptr<IDataSetting>& pDataSetting); | |
23 | 30 | |
24 | 31 | void ZoomIn(); |
25 | 32 | void ZoomOut(); |
@@ -44,7 +51,8 @@ | ||
44 | 51 | END_MSG_MAP() |
45 | 52 | |
46 | 53 | private: |
47 | - boost::shared_ptr<struct ProcessSetting> m_pSetting; | |
54 | + ProcessSetting m_processSetting; | |
55 | + boost::shared_ptr<IDataSetting> m_pDataSetting; | |
48 | 56 | std::vector<char> m_data; |
49 | 57 | std::vector<double> m_values; |
50 | 58 |
@@ -9,6 +9,7 @@ | ||
9 | 9 | |
10 | 10 | #include "TwoWayMap.h" |
11 | 11 | #include "converter.h" |
12 | +#include "arrayutil.h" | |
12 | 13 | |
13 | 14 | #include "Setting.h" |
14 | 15 |
@@ -170,21 +171,21 @@ | ||
170 | 171 | |
171 | 172 | void CSettingDialog_2D::RetrieveSetting(boost::shared_ptr<IDataSetting>& pSetting) |
172 | 173 | { |
173 | - boost::shared_ptr<DataSetting2D> ps = boost::shared_ptr<DataSetting2D>(new DataSetting2D); | |
174 | - pSetting = ps; | |
174 | + DataSetting2D* ps = new DataSetting2D; | |
175 | + pSetting = boost::shared_ptr<DataSetting2D>(ps); | |
175 | 176 | |
176 | 177 | CString str; |
177 | 178 | m_wndCmbTargetStructureType.GetLBText(m_wndCmbTargetStructureType.GetCurSel(), str); |
178 | 179 | ps->targetStructureType = targetStructureTypeMapper[str]; |
179 | - m_wndEdtTargetStructureAddress.GetWindowText(ps->structureAddressFormula); | |
180 | - m_wndEdtWidth.GetWindowText(ps->widthFormula); | |
181 | - m_wndEdtHeight.GetWindowText(ps->heightFormula); | |
180 | + m_wndEdtTargetStructureAddress.GetWindowText(ps->structureAddressFormula, Count(ps->structureAddressFormula)); | |
181 | + m_wndEdtWidth.GetWindowText(ps->widthFormula, Count(ps->widthFormula)); | |
182 | + m_wndEdtHeight.GetWindowText(ps->heightFormula, Count(ps->heightFormula)); | |
182 | 183 | if (IsDlgButtonChecked(IDC_RAD_ADDRESSEDLINE_FIRST) == BST_CHECKED) { |
183 | 184 | ps->addressedLine = DataSetting2D::AddressedLine_First; |
184 | 185 | }else if (IsDlgButtonChecked(IDC_RAD_ADDRESSEDLINE_LAST) == BST_CHECKED) { |
185 | 186 | ps->addressedLine = DataSetting2D::AddressedLine_Last; |
186 | 187 | } |
187 | - m_wndEdtLineOffset.GetWindowText(ps->lineOffsetFormula); | |
188 | + m_wndEdtLineOffset.GetWindowText(ps->lineOffsetFormula, Count(ps->lineOffsetFormula)); | |
188 | 189 | m_wndCmbColorFormat.GetLBText(m_wndCmbColorFormat.GetCurSel(), str); |
189 | 190 | ps->colorFormat = colorFormatTypeMapper[str]; |
190 | 191 | } |
@@ -1,5 +1,7 @@ | ||
1 | 1 | #pragma once |
2 | 2 | |
3 | +#pragma pack(push,1) | |
4 | + | |
3 | 5 | enum DataSourceKeyType |
4 | 6 | { |
5 | 7 | DataSourceKeyType_ImageName, |
@@ -36,10 +38,10 @@ | ||
36 | 38 | DataSetting1D(); |
37 | 39 | |
38 | 40 | DataType dataType; |
39 | - CString countFormula; | |
41 | + TCHAR countFormula[128]; | |
40 | 42 | bool viewAuto; |
41 | - CString viewMinFormula; | |
42 | - CString viewMaxFormula; | |
43 | + TCHAR viewMinFormula[128]; | |
44 | + TCHAR viewMaxFormula[128]; | |
43 | 45 | |
44 | 46 | size_t GetTotalBytes() const; |
45 | 47 | size_t GetElementSize() const; |
@@ -78,11 +80,11 @@ | ||
78 | 80 | }; |
79 | 81 | |
80 | 82 | TargetStructureType targetStructureType; |
81 | - CString structureAddressFormula; | |
83 | + TCHAR structureAddressFormula[128]; | |
82 | 84 | |
83 | - CString widthFormula; | |
84 | - CString heightFormula; | |
85 | - CString lineOffsetFormula; | |
85 | + TCHAR widthFormula[128]; | |
86 | + TCHAR heightFormula[128]; | |
87 | + TCHAR lineOffsetFormula[128]; | |
86 | 88 | AddressedLine addressedLine; |
87 | 89 | ColorFormatType colorFormat; |
88 | 90 |
@@ -92,7 +94,7 @@ | ||
92 | 94 | |
93 | 95 | struct DataSettingTEXT : IDataSetting |
94 | 96 | { |
95 | - CString bytesFormula; | |
97 | + TCHAR bytesFormula[128]; | |
96 | 98 | size_t GetTotalBytes() const; |
97 | 99 | int GetAddressOffset() const; |
98 | 100 | }; |
@@ -102,12 +104,12 @@ | ||
102 | 104 | ProcessSetting(); |
103 | 105 | |
104 | 106 | DataSourceKeyType dataSourceKeyType; |
105 | - CString imageName; | |
107 | + TCHAR imageName[128]; | |
106 | 108 | DWORD pid; |
107 | - CString addressBaseFormula; | |
108 | - CString addressOffsetFormula; | |
109 | + TCHAR addressBaseFormula[128]; | |
110 | + TCHAR addressOffsetFormula[128]; | |
109 | 111 | int addressOffsetMultiplier; |
110 | 112 | |
111 | - boost::shared_ptr<IDataSetting> pDataSetting; | |
112 | 113 | }; |
113 | 114 | |
115 | +#pragma pack(pop) |
@@ -15,7 +15,7 @@ | ||
15 | 15 | _Module.AddMessageLoop(&theLoop); |
16 | 16 | |
17 | 17 | CMainFrame wndMain; |
18 | - CRect rec(0,0, 800,600); | |
18 | + CRect rec(0,0, 1024,768); | |
19 | 19 | if(wndMain.CreateEx(NULL,rec) == NULL) |
20 | 20 | { |
21 | 21 | ATLTRACE(_T("Main window creation failed!\n")); |
@@ -78,6 +78,8 @@ | ||
78 | 78 | #define ID_VIEW_ZOOMOUT 32780 |
79 | 79 | #define ID_VIEW_ZOOMRESET 32781 |
80 | 80 | #define ID_HAND 32782 |
81 | +#define ID_EDIT_COPY32783 32783 | |
82 | +#define ID_EDIT_PASTE32784 32784 | |
81 | 83 | |
82 | 84 | // Next default values for new objects |
83 | 85 | // |
@@ -84,7 +86,7 @@ | ||
84 | 86 | #ifdef APSTUDIO_INVOKED |
85 | 87 | #ifndef APSTUDIO_READONLY_SYMBOLS |
86 | 88 | #define _APS_NEXT_RESOURCE_VALUE 206 |
87 | -#define _APS_NEXT_COMMAND_VALUE 32783 | |
89 | +#define _APS_NEXT_COMMAND_VALUE 32789 | |
88 | 90 | #define _APS_NEXT_CONTROL_VALUE 1058 |
89 | 91 | #define _APS_NEXT_SYMED_VALUE 101 |
90 | 92 | #endif |
@@ -1,6 +1,7 @@ | ||
1 | 1 | #pragma once |
2 | 2 | |
3 | 3 | struct ProcessSetting; |
4 | +struct IDataSetting; | |
4 | 5 | |
5 | 6 | class CMainFrame |
6 | 7 | : |
@@ -22,9 +23,9 @@ | ||
22 | 23 | |
23 | 24 | HWND CreateClient(); |
24 | 25 | |
25 | - void ReadData(const ProcessSetting& setting); | |
26 | - void ProcessData(const ProcessSetting& setting); | |
27 | - void SetSettingView(const ProcessSetting& setting); | |
26 | + void ReadData(const ProcessSetting& setting, boost::shared_ptr<IDataSetting>& pDataSetting); | |
27 | + void ProcessData(const ProcessSetting& setting, boost::shared_ptr<IDataSetting>& pDataSetting); | |
28 | + void SetSettingView(const ProcessSetting& setting, const IDataSetting* pDataSetting); | |
28 | 29 | void updateUI(); |
29 | 30 | |
30 | 31 | virtual BOOL PreTranslateMessage(MSG* pMsg); |
@@ -51,6 +52,8 @@ | ||
51 | 52 | COMMAND_ID_HANDLER(ID_WINDOW_TILE_HORZ, OnWindowTile) |
52 | 53 | COMMAND_ID_HANDLER_EX(ID_HAND, OnHand) |
53 | 54 | COMMAND_ID_HANDLER_EX(ID_ZOOM, OnZoom) |
55 | + COMMAND_ID_HANDLER_EX(ID_EDIT_COPY, OnEditCopy) | |
56 | + COMMAND_ID_HANDLER_EX(ID_EDIT_PASTE, OnEditPaste) | |
54 | 57 | |
55 | 58 | // COMMAND_ID_HANDLER(ID_WINDOW_ARRANGE, OnWindowArrangeIcons) |
56 | 59 | CHAIN_MSG_MAP(CUpdateUI<CMainFrame>) |
@@ -78,4 +81,6 @@ | ||
78 | 81 | LRESULT OnWindowArrangeIcons(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); |
79 | 82 | LRESULT OnHand(WORD wNotifyCode, WORD wID, HWND hWndCtl); |
80 | 83 | LRESULT OnZoom(WORD wNotifyCode, WORD wID, HWND hWndCtl); |
84 | + LRESULT OnEditCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl); | |
85 | + LRESULT OnEditPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl); | |
81 | 86 | }; |
@@ -4,6 +4,7 @@ | ||
4 | 4 | |
5 | 5 | #include "converter.h" |
6 | 6 | #include "Setting.h" |
7 | +#include "arrayutil.h" | |
7 | 8 | |
8 | 9 | CSettingDialog_TEXT::CSettingDialog_TEXT() |
9 | 10 | { |
@@ -34,7 +35,7 @@ | ||
34 | 35 | { |
35 | 36 | try { |
36 | 37 | CString str; |
37 | - GetDlgItemText(IDC_EDT_BYTES, setting.bytesFormula); | |
38 | + GetDlgItemText(IDC_EDT_BYTES, setting.bytesFormula, Count(setting.bytesFormula)); | |
38 | 39 | }catch(...) { |
39 | 40 | ; |
40 | 41 | } |
@@ -43,8 +44,8 @@ | ||
43 | 44 | |
44 | 45 | void CSettingDialog_TEXT::RetrieveSetting(boost::shared_ptr<IDataSetting>& pSetting) |
45 | 46 | { |
46 | - boost::shared_ptr<DataSettingTEXT> ps = boost::shared_ptr<DataSettingTEXT>(new DataSettingTEXT); | |
47 | + DataSettingTEXT* ps = new DataSettingTEXT(); | |
47 | 48 | RetreiveSetting(*ps); |
48 | - pSetting = ps; | |
49 | + pSetting = boost::shared_ptr<DataSettingTEXT>(ps); | |
49 | 50 | } |
50 | 51 |
@@ -2,6 +2,7 @@ | ||
2 | 2 | |
3 | 3 | #include "resource.h" // main symbols |
4 | 4 | #include "AutoCombo.h" |
5 | +#include "Setting.h" | |
5 | 6 | |
6 | 7 | struct ProcessSetting; |
7 | 8 |
@@ -28,8 +29,6 @@ | ||
28 | 29 | COMMAND_HANDLER(IDC_BTN_READ, BN_CLICKED, OnBnClickedBtnRead) |
29 | 30 | COMMAND_HANDLER(IDC_CHK_READ_AUTO, BN_CLICKED, OnBnClickedChkReadAuto) |
30 | 31 | COMMAND_HANDLER(IDC_BTN_PROCESS, BN_CLICKED, OnBnClickedBtnProcess) |
31 | - COMMAND_HANDLER_EX(IDC_BTN_COPY, BN_CLICKED, OnBtnCopyBnClicked) | |
32 | - COMMAND_HANDLER_EX(IDC_BTN_PASTE, BN_CLICKED, OnBtnPasteBnClicked) | |
33 | 32 | NOTIFY_HANDLER_EX(IDC_TAB, TCN_SELCHANGE, OnTabTcnSelChange) |
34 | 33 | REFLECT_NOTIFICATIONS() |
35 | 34 | END_MSG_MAP() |
@@ -50,19 +49,19 @@ | ||
50 | 49 | LRESULT OnBnClickedChkReadAuto(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); |
51 | 50 | LRESULT OnBnClickedBtnProcess(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/); |
52 | 51 | LRESULT OnTabTcnSelChange(LPNMHDR pnmh); |
53 | - LRESULT OnBtnCopyBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl); | |
54 | - LRESULT OnBtnPasteBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl); | |
55 | 52 | |
56 | 53 | public: |
57 | - void SetSetting(const ProcessSetting& setting); | |
58 | - void RetrieveSetting(ProcessSetting& setting); | |
54 | + void SetSetting(const ProcessSetting& setting, const IDataSetting* pDataSetting); | |
55 | + void RetrieveSetting(ProcessSetting& setting, boost::shared_ptr<IDataSetting>& pDataSetting); | |
59 | 56 | |
60 | 57 | bool FetchProcessData(LPCVOID pTargetAddress, void* pWriteBuffer, size_t fetchSize); |
61 | 58 | |
62 | - fastdelegate::FastDelegate1<const ProcessSetting&> m_readDelegate; | |
63 | - fastdelegate::FastDelegate1<const ProcessSetting&> m_processDelegate; | |
59 | + fastdelegate::FastDelegate2<const ProcessSetting&, boost::shared_ptr<IDataSetting>& > m_readDelegate; | |
60 | + fastdelegate::FastDelegate2<const ProcessSetting&, boost::shared_ptr<IDataSetting>& > m_processDelegate; | |
61 | + | |
62 | + void CopyToClipboard(); | |
63 | + void PasteFromClipboard(); | |
64 | 64 | |
65 | - | |
66 | 65 | private: |
67 | 66 | CAutoCombo m_wndCmbImageName; |
68 | 67 | CTabCtrl m_wndTab; |
@@ -70,8 +69,6 @@ | ||
70 | 69 | boost::shared_ptr<class CSettingDialog_2D> m_pDlg2D; |
71 | 70 | boost::shared_ptr<class CSettingDialog_TEXT> m_pDlgTEXT; |
72 | 71 | |
73 | - boost::shared_ptr<ProcessSetting> m_pProcessSetting_Tmp; | |
74 | - | |
75 | 72 | void SetProcessImageNamesToComboBox(); |
76 | 73 | void ReadData(); |
77 | 74 | void ProcessData(); |
@@ -109,8 +109,7 @@ | ||
109 | 109 | gl::SetupSlopeCorrectionTable(g_slopeCorrTable, SLOPE_CORR_TABLE_SIZE); |
110 | 110 | gl::SetupFilterTable(g_filterTable, FILTER_TABLE_SIZE, 0.75); |
111 | 111 | |
112 | - m_pSetting = boost::shared_ptr<ProcessSetting>(new ProcessSetting); | |
113 | - m_pSetting->pDataSetting = boost::shared_ptr<DataSetting1D>(new DataSetting1D); | |
112 | + m_pDataSetting = boost::shared_ptr<DataSetting1D>(new DataSetting1D); | |
114 | 113 | m_scale = 1.0; |
115 | 114 | |
116 | 115 | return 0; |
@@ -167,7 +166,7 @@ | ||
167 | 166 | |
168 | 167 | void CDataView::Render(CPaintDC& dc) |
169 | 168 | { |
170 | - const type_info& ti = typeid(*m_pSetting->pDataSetting); | |
169 | + const type_info& ti = typeid(*m_pDataSetting); | |
171 | 170 | if (ti == typeid(DataSetting1D)) { |
172 | 171 | Render1D(dc); |
173 | 172 | }else if (ti == typeid(DataSetting2D)) { |
@@ -181,7 +180,7 @@ | ||
181 | 180 | { |
182 | 181 | if (m_data.size() == 0) |
183 | 182 | return; |
184 | - const type_info& ti = typeid(*m_pSetting->pDataSetting); | |
183 | + const type_info& ti = typeid(*m_pDataSetting); | |
185 | 184 | if (ti == typeid(DataSetting1D)) { |
186 | 185 | ProcessAs1D(); |
187 | 186 | }else if (ti == typeid(DataSetting2D)) { |
@@ -197,7 +196,7 @@ | ||
197 | 196 | { |
198 | 197 | size_t dataBytes = m_data.size(); |
199 | 198 | const char* pData = &m_data[0]; |
200 | - const DataSetting1D& dataSetting = dynamic_cast<DataSetting1D&>(*m_pSetting->pDataSetting); | |
199 | + const DataSetting1D& dataSetting = dynamic_cast<const DataSetting1D&>(*m_pDataSetting); | |
201 | 200 | DataReader<NumericT>::ReadDataAs(&dataSetting.GetTypeInfo(), m_values, pData, dataBytes); |
202 | 201 | } |
203 | 202 |
@@ -206,7 +205,7 @@ | ||
206 | 205 | size_t dataBytes = m_data.size(); |
207 | 206 | const char* pData = &m_data[0]; |
208 | 207 | |
209 | - const DataSetting2D& setting = dynamic_cast<DataSetting2D&>(*m_pSetting->pDataSetting); | |
208 | + const DataSetting2D& setting = dynamic_cast<const DataSetting2D&>(*m_pDataSetting); | |
210 | 209 | int width = EvalFormula(setting.widthFormula); |
211 | 210 | if (width <= 0) |
212 | 211 | return; |
@@ -324,7 +323,7 @@ | ||
324 | 323 | return; |
325 | 324 | } |
326 | 325 | const std::vector<double>& values = m_values; |
327 | - const DataSetting1D& dataSetting = dynamic_cast<DataSetting1D&>(*m_pSetting->pDataSetting); | |
326 | + const DataSetting1D& dataSetting = dynamic_cast<const DataSetting1D&>(*m_pDataSetting); | |
328 | 327 | size_t dataCount = dataSetting.GetTotalBytes() / dataSetting.GetElementSize(); |
329 | 328 | |
330 | 329 | double min = 0; |
@@ -461,7 +460,7 @@ | ||
461 | 460 | if (m_values.size() == 0) { |
462 | 461 | return; |
463 | 462 | } |
464 | - const DataSettingTEXT& dataSetting = dynamic_cast<DataSettingTEXT&>(*m_pSetting->pDataSetting); | |
463 | + const DataSettingTEXT& dataSetting = dynamic_cast<const DataSettingTEXT&>(*m_pDataSetting); | |
465 | 464 | // m_memDC.TextOut(10, 10, _T("test"), -1); |
466 | 465 | size_t nBytes = dataSetting.GetTotalBytes(); |
467 | 466 | size_t nLines = nBytes / 16 + ((nBytes % 16) ? 1 : 0); |
@@ -481,7 +480,7 @@ | ||
481 | 480 | |
482 | 481 | void CDataView::setScrollInfo(int hPos, int vPos) |
483 | 482 | { |
484 | - if (typeid(*m_pSetting->pDataSetting) == typeid(DataSetting2D) && m_pImage) { | |
483 | + if (typeid(*m_pDataSetting) == typeid(DataSetting2D) && m_pImage) { | |
485 | 484 | BOOL bRedraw = TRUE; |
486 | 485 | CSize Size; |
487 | 486 | CRect rec; |
@@ -520,9 +519,9 @@ | ||
520 | 519 | return 0; |
521 | 520 | } |
522 | 521 | |
523 | -bool FetchProcessData(const ProcessSetting& setting, std::vector<char>& data) | |
522 | +bool FetchProcessData(const ProcessSetting& setting, const boost::shared_ptr<IDataSetting>& pDataSetting, std::vector<char>& data) | |
524 | 523 | { |
525 | - size_t dataLength = setting.pDataSetting->GetTotalBytes(); | |
524 | + size_t dataLength = pDataSetting->GetTotalBytes(); | |
526 | 525 | if (dataLength == 0) |
527 | 526 | return false; |
528 | 527 | data.resize(dataLength); |
@@ -530,12 +529,12 @@ | ||
530 | 529 | |
531 | 530 | int addressBase = AddressHexStrToNum(setting.addressBaseFormula); |
532 | 531 | int addressOffset = EvalFormula(setting.addressOffsetFormula) * setting.addressOffsetMultiplier; |
533 | - addressOffset += setting.pDataSetting->GetAddressOffset(); | |
532 | + addressOffset += pDataSetting->GetAddressOffset(); | |
534 | 533 | LPCVOID pTarget = (LPVOID) (addressBase + addressOffset); |
535 | 534 | bool ret = false; |
536 | 535 | switch (setting.dataSourceKeyType) { |
537 | 536 | case DataSourceKeyType_ImageName: |
538 | - if (setting.imageName.IsEmpty()) { | |
537 | + if (_tcslen(setting.imageName) == 0) { | |
539 | 538 | return false; |
540 | 539 | } |
541 | 540 | ret = ReadProcessData(setting.imageName, pTarget, buffer, dataLength); |
@@ -547,10 +546,11 @@ | ||
547 | 546 | return ret; |
548 | 547 | } |
549 | 548 | |
550 | -void CDataView::ReadData(const ProcessSetting& setting) | |
549 | +void CDataView::ReadData(const ProcessSetting& setting, boost::shared_ptr<IDataSetting>& pDataSetting) | |
551 | 550 | { |
552 | - *m_pSetting = setting; | |
553 | - if (FetchProcessData(setting, m_data)) { | |
551 | + m_processSetting = setting; | |
552 | + m_pDataSetting = pDataSetting; | |
553 | + if (FetchProcessData(setting, pDataSetting, m_data)) { | |
554 | 554 | ProcessData(); |
555 | 555 | Invalidate(); |
556 | 556 | UpdateWindow(); |
@@ -557,9 +557,10 @@ | ||
557 | 557 | } |
558 | 558 | } |
559 | 559 | |
560 | -void CDataView::ProcessData(const ProcessSetting& setting) | |
560 | +void CDataView::ProcessData(const ProcessSetting& setting, boost::shared_ptr<IDataSetting>& pDataSetting) | |
561 | 561 | { |
562 | - *m_pSetting = setting; | |
562 | + m_processSetting = setting; | |
563 | + m_pDataSetting = pDataSetting; | |
563 | 564 | ProcessData(); |
564 | 565 | Invalidate(); |
565 | 566 | UpdateWindow(); |
@@ -0,0 +1,247 @@ | ||
1 | +// ISO C9x compliant stdint.h for Microsoft Visual Studio | |
2 | +// Based on ISO/IEC 9899:TC2 Committee draft (May 6, 2005) WG14/N1124 | |
3 | +// | |
4 | +// Copyright (c) 2006-2008 Alexander Chemeris | |
5 | +// | |
6 | +// Redistribution and use in source and binary forms, with or without | |
7 | +// modification, are permitted provided that the following conditions are met: | |
8 | +// | |
9 | +// 1. Redistributions of source code must retain the above copyright notice, | |
10 | +// this list of conditions and the following disclaimer. | |
11 | +// | |
12 | +// 2. Redistributions in binary form must reproduce the above copyright | |
13 | +// notice, this list of conditions and the following disclaimer in the | |
14 | +// documentation and/or other materials provided with the distribution. | |
15 | +// | |
16 | +// 3. The name of the author may be used to endorse or promote products | |
17 | +// derived from this software without specific prior written permission. | |
18 | +// | |
19 | +// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED | |
20 | +// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF | |
21 | +// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO | |
22 | +// EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |
23 | +// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, | |
24 | +// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; | |
25 | +// OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, | |
26 | +// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR | |
27 | +// OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF | |
28 | +// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | |
29 | +// | |
30 | +/////////////////////////////////////////////////////////////////////////////// | |
31 | + | |
32 | +#ifndef _MSC_VER // [ | |
33 | +#error "Use this header only with Microsoft Visual C++ compilers!" | |
34 | +#endif // _MSC_VER ] | |
35 | + | |
36 | +#ifndef _MSC_STDINT_H_ // [ | |
37 | +#define _MSC_STDINT_H_ | |
38 | + | |
39 | +#if _MSC_VER > 1000 | |
40 | +#pragma once | |
41 | +#endif | |
42 | + | |
43 | +#include <limits.h> | |
44 | + | |
45 | +// For Visual Studio 6 in C++ mode and for many Visual Studio versions when | |
46 | +// compiling for ARM we should wrap <wchar.h> include with 'extern "C++" {}' | |
47 | +// or compiler give many errors like this: | |
48 | +// error C2733: second C linkage of overloaded function 'wmemchr' not allowed | |
49 | +#ifdef __cplusplus | |
50 | +extern "C" { | |
51 | +#endif | |
52 | +# include <wchar.h> | |
53 | +#ifdef __cplusplus | |
54 | +} | |
55 | +#endif | |
56 | + | |
57 | +// Define _W64 macros to mark types changing their size, like intptr_t. | |
58 | +#ifndef _W64 | |
59 | +# if !defined(__midl) && (defined(_X86_) || defined(_M_IX86)) && _MSC_VER >= 1300 | |
60 | +# define _W64 __w64 | |
61 | +# else | |
62 | +# define _W64 | |
63 | +# endif | |
64 | +#endif | |
65 | + | |
66 | + | |
67 | +// 7.18.1 Integer types | |
68 | + | |
69 | +// 7.18.1.1 Exact-width integer types | |
70 | + | |
71 | +// Visual Studio 6 and Embedded Visual C++ 4 doesn't | |
72 | +// realize that, e.g. char has the same size as __int8 | |
73 | +// so we give up on __intX for them. | |
74 | +#if (_MSC_VER < 1300) | |
75 | + typedef signed char int8_t; | |
76 | + typedef signed short int16_t; | |
77 | + typedef signed int int32_t; | |
78 | + typedef unsigned char uint8_t; | |
79 | + typedef unsigned short uint16_t; | |
80 | + typedef unsigned int uint32_t; | |
81 | +#else | |
82 | + typedef signed __int8 int8_t; | |
83 | + typedef signed __int16 int16_t; | |
84 | + typedef signed __int32 int32_t; | |
85 | + typedef unsigned __int8 uint8_t; | |
86 | + typedef unsigned __int16 uint16_t; | |
87 | + typedef unsigned __int32 uint32_t; | |
88 | +#endif | |
89 | +typedef signed __int64 int64_t; | |
90 | +typedef unsigned __int64 uint64_t; | |
91 | + | |
92 | + | |
93 | +// 7.18.1.2 Minimum-width integer types | |
94 | +typedef int8_t int_least8_t; | |
95 | +typedef int16_t int_least16_t; | |
96 | +typedef int32_t int_least32_t; | |
97 | +typedef int64_t int_least64_t; | |
98 | +typedef uint8_t uint_least8_t; | |
99 | +typedef uint16_t uint_least16_t; | |
100 | +typedef uint32_t uint_least32_t; | |
101 | +typedef uint64_t uint_least64_t; | |
102 | + | |
103 | +// 7.18.1.3 Fastest minimum-width integer types | |
104 | +typedef int8_t int_fast8_t; | |
105 | +typedef int16_t int_fast16_t; | |
106 | +typedef int32_t int_fast32_t; | |
107 | +typedef int64_t int_fast64_t; | |
108 | +typedef uint8_t uint_fast8_t; | |
109 | +typedef uint16_t uint_fast16_t; | |
110 | +typedef uint32_t uint_fast32_t; | |
111 | +typedef uint64_t uint_fast64_t; | |
112 | + | |
113 | +// 7.18.1.4 Integer types capable of holding object pointers | |
114 | +#ifdef _WIN64 // [ | |
115 | + typedef signed __int64 intptr_t; | |
116 | + typedef unsigned __int64 uintptr_t; | |
117 | +#else // _WIN64 ][ | |
118 | + typedef _W64 signed int intptr_t; | |
119 | + typedef _W64 unsigned int uintptr_t; | |
120 | +#endif // _WIN64 ] | |
121 | + | |
122 | +// 7.18.1.5 Greatest-width integer types | |
123 | +typedef int64_t intmax_t; | |
124 | +typedef uint64_t uintmax_t; | |
125 | + | |
126 | + | |
127 | +// 7.18.2 Limits of specified-width integer types | |
128 | + | |
129 | +#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS) // [ See footnote 220 at page 257 and footnote 221 at page 259 | |
130 | + | |
131 | +// 7.18.2.1 Limits of exact-width integer types | |
132 | +#define INT8_MIN ((int8_t)_I8_MIN) | |
133 | +#define INT8_MAX _I8_MAX | |
134 | +#define INT16_MIN ((int16_t)_I16_MIN) | |
135 | +#define INT16_MAX _I16_MAX | |
136 | +#define INT32_MIN ((int32_t)_I32_MIN) | |
137 | +#define INT32_MAX _I32_MAX | |
138 | +#define INT64_MIN ((int64_t)_I64_MIN) | |
139 | +#define INT64_MAX _I64_MAX | |
140 | +#define UINT8_MAX _UI8_MAX | |
141 | +#define UINT16_MAX _UI16_MAX | |
142 | +#define UINT32_MAX _UI32_MAX | |
143 | +#define UINT64_MAX _UI64_MAX | |
144 | + | |
145 | +// 7.18.2.2 Limits of minimum-width integer types | |
146 | +#define INT_LEAST8_MIN INT8_MIN | |
147 | +#define INT_LEAST8_MAX INT8_MAX | |
148 | +#define INT_LEAST16_MIN INT16_MIN | |
149 | +#define INT_LEAST16_MAX INT16_MAX | |
150 | +#define INT_LEAST32_MIN INT32_MIN | |
151 | +#define INT_LEAST32_MAX INT32_MAX | |
152 | +#define INT_LEAST64_MIN INT64_MIN | |
153 | +#define INT_LEAST64_MAX INT64_MAX | |
154 | +#define UINT_LEAST8_MAX UINT8_MAX | |
155 | +#define UINT_LEAST16_MAX UINT16_MAX | |
156 | +#define UINT_LEAST32_MAX UINT32_MAX | |
157 | +#define UINT_LEAST64_MAX UINT64_MAX | |
158 | + | |
159 | +// 7.18.2.3 Limits of fastest minimum-width integer types | |
160 | +#define INT_FAST8_MIN INT8_MIN | |
161 | +#define INT_FAST8_MAX INT8_MAX | |
162 | +#define INT_FAST16_MIN INT16_MIN | |
163 | +#define INT_FAST16_MAX INT16_MAX | |
164 | +#define INT_FAST32_MIN INT32_MIN | |
165 | +#define INT_FAST32_MAX INT32_MAX | |
166 | +#define INT_FAST64_MIN INT64_MIN | |
167 | +#define INT_FAST64_MAX INT64_MAX | |
168 | +#define UINT_FAST8_MAX UINT8_MAX | |
169 | +#define UINT_FAST16_MAX UINT16_MAX | |
170 | +#define UINT_FAST32_MAX UINT32_MAX | |
171 | +#define UINT_FAST64_MAX UINT64_MAX | |
172 | + | |
173 | +// 7.18.2.4 Limits of integer types capable of holding object pointers | |
174 | +#ifdef _WIN64 // [ | |
175 | +# define INTPTR_MIN INT64_MIN | |
176 | +# define INTPTR_MAX INT64_MAX | |
177 | +# define UINTPTR_MAX UINT64_MAX | |
178 | +#else // _WIN64 ][ | |
179 | +# define INTPTR_MIN INT32_MIN | |
180 | +# define INTPTR_MAX INT32_MAX | |
181 | +# define UINTPTR_MAX UINT32_MAX | |
182 | +#endif // _WIN64 ] | |
183 | + | |
184 | +// 7.18.2.5 Limits of greatest-width integer types | |
185 | +#define INTMAX_MIN INT64_MIN | |
186 | +#define INTMAX_MAX INT64_MAX | |
187 | +#define UINTMAX_MAX UINT64_MAX | |
188 | + | |
189 | +// 7.18.3 Limits of other integer types | |
190 | + | |
191 | +#ifdef _WIN64 // [ | |
192 | +# define PTRDIFF_MIN _I64_MIN | |
193 | +# define PTRDIFF_MAX _I64_MAX | |
194 | +#else // _WIN64 ][ | |
195 | +# define PTRDIFF_MIN _I32_MIN | |
196 | +# define PTRDIFF_MAX _I32_MAX | |
197 | +#endif // _WIN64 ] | |
198 | + | |
199 | +#define SIG_ATOMIC_MIN INT_MIN | |
200 | +#define SIG_ATOMIC_MAX INT_MAX | |
201 | + | |
202 | +#ifndef SIZE_MAX // [ | |
203 | +# ifdef _WIN64 // [ | |
204 | +# define SIZE_MAX _UI64_MAX | |
205 | +# else // _WIN64 ][ | |
206 | +# define SIZE_MAX _UI32_MAX | |
207 | +# endif // _WIN64 ] | |
208 | +#endif // SIZE_MAX ] | |
209 | + | |
210 | +// WCHAR_MIN and WCHAR_MAX are also defined in <wchar.h> | |
211 | +#ifndef WCHAR_MIN // [ | |
212 | +# define WCHAR_MIN 0 | |
213 | +#endif // WCHAR_MIN ] | |
214 | +#ifndef WCHAR_MAX // [ | |
215 | +# define WCHAR_MAX _UI16_MAX | |
216 | +#endif // WCHAR_MAX ] | |
217 | + | |
218 | +#define WINT_MIN 0 | |
219 | +#define WINT_MAX _UI16_MAX | |
220 | + | |
221 | +#endif // __STDC_LIMIT_MACROS ] | |
222 | + | |
223 | + | |
224 | +// 7.18.4 Limits of other integer types | |
225 | + | |
226 | +#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS) // [ See footnote 224 at page 260 | |
227 | + | |
228 | +// 7.18.4.1 Macros for minimum-width integer constants | |
229 | + | |
230 | +#define INT8_C(val) val##i8 | |
231 | +#define INT16_C(val) val##i16 | |
232 | +#define INT32_C(val) val##i32 | |
233 | +#define INT64_C(val) val##i64 | |
234 | + | |
235 | +#define UINT8_C(val) val##ui8 | |
236 | +#define UINT16_C(val) val##ui16 | |
237 | +#define UINT32_C(val) val##ui32 | |
238 | +#define UINT64_C(val) val##ui64 | |
239 | + | |
240 | +// 7.18.4.2 Macros for greatest-width integer constants | |
241 | +#define INTMAX_C INT64_C | |
242 | +#define UINTMAX_C UINT64_C | |
243 | + | |
244 | +#endif // __STDC_CONSTANT_MACROS ] | |
245 | + | |
246 | + | |
247 | +#endif // _MSC_STDINT_H_ ] |
@@ -1,8 +1,5 @@ | ||
1 | 1 | #pragma once |
2 | 2 | |
3 | -#include <boost/cstdint.hpp> | |
4 | -using namespace boost; | |
5 | - | |
6 | 3 | template <typename T> |
7 | 4 | bool InArray(const T& val, const T arr[]) |
8 | 5 | { |
@@ -1,7 +1,6 @@ | ||
1 | 1 | #pragma once |
2 | 2 | |
3 | 3 | #include "buffer2D.h" |
4 | -#include <boost/cstdint.hpp> | |
5 | 4 | |
6 | 5 | namespace gl |
7 | 6 | { |
@@ -11,7 +10,7 @@ | ||
11 | 10 | class Buffer2D<bool> : public IBuffer2D |
12 | 11 | { |
13 | 12 | public: |
14 | - typedef boost::uint_fast32_t value_type; | |
13 | + typedef uint32_t value_type; | |
15 | 14 | private: |
16 | 15 | size_t width_; //!< 描画領域の横幅 |
17 | 16 | size_t height_; //!< 描画領域の縦幅 |
@@ -7,6 +7,9 @@ | ||
7 | 7 | { |
8 | 8 | dataType = DataType_Int; |
9 | 9 | viewAuto = true; |
10 | + _tcscpy(countFormula, _T("")); | |
11 | + _tcscpy(viewMinFormula, _T("")); | |
12 | + _tcscpy(viewMaxFormula, _T("")); | |
10 | 13 | } |
11 | 14 | |
12 | 15 | std::map<DataSetting1D::DataType, const std::type_info*> typeInfoMap; |
@@ -64,7 +67,9 @@ | ||
64 | 67 | ProcessSetting::ProcessSetting() |
65 | 68 | { |
66 | 69 | dataSourceKeyType = DataSourceKeyType_ImageName; |
67 | - imageName = ""; | |
70 | + _tcscpy(imageName, _T("")); | |
71 | + _tcscpy(addressBaseFormula, _T("")); | |
72 | + _tcscpy(addressOffsetFormula, _T("")); | |
68 | 73 | pid = 0; |
69 | 74 | addressOffsetMultiplier = 1; |
70 | 75 | } |
@@ -4,6 +4,7 @@ | ||
4 | 4 | |
5 | 5 | #include "converter.h" |
6 | 6 | #include "Setting.h" |
7 | +#include "arrayutil.h" | |
7 | 8 | |
8 | 9 | #include "TwoWayMap.h" |
9 | 10 |
@@ -67,10 +68,10 @@ | ||
67 | 68 | CString str; |
68 | 69 | m_wndCmbType.GetLBText(m_wndCmbType.GetCurSel(), str); |
69 | 70 | setting.dataType = dataTypeMapper[str]; |
70 | - GetDlgItemText(IDC_EDT_COUNT, setting.countFormula); | |
71 | + GetDlgItemText(IDC_EDT_COUNT, setting.countFormula, Count(setting.countFormula)); | |
71 | 72 | setting.viewAuto = (IsDlgButtonChecked(IDC_CHK_VIEWAUTO) == BST_CHECKED); |
72 | - GetDlgItemText(IDC_EDT_VIEW_MIN, setting.viewMinFormula); | |
73 | - GetDlgItemText(IDC_EDT_VIEW_MAX, setting.viewMaxFormula); | |
73 | + GetDlgItemText(IDC_EDT_VIEW_MIN, setting.viewMinFormula, Count(setting.viewMinFormula)); | |
74 | + GetDlgItemText(IDC_EDT_VIEW_MAX, setting.viewMaxFormula, Count(setting.viewMaxFormula)); | |
74 | 75 | }catch(...) { |
75 | 76 | ; |
76 | 77 | } |
@@ -79,9 +80,9 @@ | ||
79 | 80 | |
80 | 81 | void CSettingDialog_1D::RetrieveSetting(boost::shared_ptr<IDataSetting>& pSetting) |
81 | 82 | { |
82 | - boost::shared_ptr<DataSetting1D> ps = boost::shared_ptr<DataSetting1D>(new DataSetting1D); | |
83 | - RetreiveSetting(*ps); | |
84 | - pSetting = ps; | |
83 | + DataSetting1D* p = new DataSetting1D(); | |
84 | + RetreiveSetting(*p); | |
85 | + pSetting = boost::shared_ptr<DataSetting1D>(p); | |
85 | 86 | } |
86 | 87 | |
87 | 88 | LRESULT CSettingDialog_1D::OnBnClickedChkViewauto(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) |
@@ -57,7 +57,7 @@ | ||
57 | 57 | ::DrawMenuBar(GetMainFrame()); |
58 | 58 | |
59 | 59 | m_pMainFrame->m_pCurView = m_pView.get(); |
60 | - m_pMainFrame->SetSettingView(m_pView->GetSetting()); | |
60 | + m_pMainFrame->SetSettingView(m_pView->GetProcessSetting(), m_pView->GetDataSetting()); | |
61 | 61 | } |
62 | 62 | else if((HWND)lParam == NULL) { // last child has closed |
63 | 63 | m_pMainFrame->m_pCurView = NULL; |
@@ -192,27 +192,27 @@ | ||
192 | 192 | return 0; |
193 | 193 | } |
194 | 194 | |
195 | -void CMainFrame::SetSettingView(const ProcessSetting& setting) | |
195 | +void CMainFrame::SetSettingView(const ProcessSetting& setting, const IDataSetting* pDataSetting) | |
196 | 196 | { |
197 | - m_pSettingDlg->SetSetting(setting); | |
197 | + m_pSettingDlg->SetSetting(setting, pDataSetting); | |
198 | 198 | |
199 | 199 | } |
200 | 200 | |
201 | -void CMainFrame::ReadData(const ProcessSetting& setting) | |
201 | +void CMainFrame::ReadData(const ProcessSetting& setting, boost::shared_ptr<IDataSetting>& pDataSetting) | |
202 | 202 | { |
203 | 203 | if (!m_pCurView) |
204 | 204 | return; |
205 | 205 | |
206 | - m_pCurView->ReadData(setting); | |
206 | + m_pCurView->ReadData(setting, pDataSetting); | |
207 | 207 | |
208 | 208 | } |
209 | 209 | |
210 | -void CMainFrame::ProcessData(const ProcessSetting& setting) | |
210 | +void CMainFrame::ProcessData(const ProcessSetting& setting, boost::shared_ptr<IDataSetting>& pDataSetting) | |
211 | 211 | { |
212 | 212 | if (!m_pCurView) |
213 | 213 | return; |
214 | 214 | |
215 | - m_pCurView->ProcessData(setting); | |
215 | + m_pCurView->ProcessData(setting, pDataSetting); | |
216 | 216 | |
217 | 217 | } |
218 | 218 |
@@ -235,3 +235,15 @@ | ||
235 | 235 | updateUI(); |
236 | 236 | return 0; |
237 | 237 | } |
238 | + | |
239 | +LRESULT CMainFrame::OnEditCopy(WORD wNotifyCode, WORD wID, HWND hWndCtl) | |
240 | +{ | |
241 | + m_pSettingDlg->CopyToClipboard(); | |
242 | + return 0; | |
243 | +} | |
244 | + | |
245 | +LRESULT CMainFrame::OnEditPaste(WORD wNotifyCode, WORD wID, HWND hWndCtl) | |
246 | +{ | |
247 | + m_pSettingDlg->PasteFromClipboard(); | |
248 | + return 0; | |
249 | +} |
@@ -3,6 +3,7 @@ | ||
3 | 3 | |
4 | 4 | #include "converter.h" |
5 | 5 | #include "Setting.h" |
6 | +#include "arrayutil.h" | |
6 | 7 | |
7 | 8 | #include "SettingDialog_1D.h" |
8 | 9 | #include "SettingDialog_2D.h" |
@@ -23,8 +24,12 @@ | ||
23 | 24 | { |
24 | 25 | } |
25 | 26 | |
27 | +static UINT clipBoardFormat_; | |
28 | + | |
26 | 29 | LRESULT CSettingDialog::OnInitDialog(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled) |
27 | 30 | { |
31 | + clipBoardFormat_ = RegisterClipboardFormat(_T("beruponu DataViewer")); | |
32 | + | |
28 | 33 | DoDataExchange(); |
29 | 34 | // SetSetting(); |
30 | 35 |
@@ -91,7 +96,7 @@ | ||
91 | 96 | return FALSE; |
92 | 97 | } |
93 | 98 | |
94 | -void CSettingDialog::SetSetting(const ProcessSetting& setting) | |
99 | +void CSettingDialog::SetSetting(const ProcessSetting& setting, const IDataSetting* pDataSetting) | |
95 | 100 | { |
96 | 101 | switch (setting.dataSourceKeyType) { |
97 | 102 | case DataSourceKeyType_ImageName: |
@@ -111,18 +116,18 @@ | ||
111 | 116 | SetDlgItemText(IDC_EDT_ADDRESS_OFFSET, setting.addressOffsetFormula); |
112 | 117 | convert(setting.addressOffsetMultiplier, str); SetDlgItemText(IDC_EDT_ADDRESS_OFFSET_MULTIPLIER, str); |
113 | 118 | |
114 | - assert (setting.pDataSetting); | |
115 | - const type_info& dataType = typeid(*setting.pDataSetting); | |
119 | + assert (pDataSetting); | |
120 | + const type_info& dataType = typeid(*pDataSetting); | |
116 | 121 | if (dataType == typeid(DataSetting1D)) { |
117 | - m_pDlg1D->SetSetting(dynamic_cast<const DataSetting1D&>(*setting.pDataSetting)); | |
122 | + m_pDlg1D->SetSetting(dynamic_cast<const DataSetting1D&>(*pDataSetting)); | |
118 | 123 | m_wndTab.SetCurSel(0); |
119 | 124 | OnSelTab(0); |
120 | 125 | }else if (dataType == typeid(DataSetting2D)) { |
121 | - m_pDlg2D->SetSetting(dynamic_cast<const DataSetting2D&>(*setting.pDataSetting)); | |
126 | + m_pDlg2D->SetSetting(dynamic_cast<const DataSetting2D&>(*pDataSetting)); | |
122 | 127 | m_wndTab.SetCurSel(1); |
123 | 128 | OnSelTab(1); |
124 | 129 | }else { |
125 | - m_pDlgTEXT->SetSetting(dynamic_cast<const DataSettingTEXT&>(*setting.pDataSetting)); | |
130 | + m_pDlgTEXT->SetSetting(dynamic_cast<const DataSettingTEXT&>(*pDataSetting)); | |
126 | 131 | m_wndTab.SetCurSel(2); |
127 | 132 | OnSelTab(2); |
128 | 133 | } |
@@ -150,7 +155,7 @@ | ||
150 | 155 | } |
151 | 156 | } |
152 | 157 | |
153 | -void CSettingDialog::RetrieveSetting(ProcessSetting& setting) | |
158 | +void CSettingDialog::RetrieveSetting(ProcessSetting& setting, boost::shared_ptr<IDataSetting>& pDataSetting) | |
154 | 159 | { |
155 | 160 | try { |
156 | 161 |
@@ -162,22 +167,22 @@ | ||
162 | 167 | setting.dataSourceKeyType = DataSourceKeyType_PID; |
163 | 168 | } |
164 | 169 | |
165 | - m_wndCmbImageName.GetWindowText(setting.imageName); | |
170 | + m_wndCmbImageName.GetWindowText(setting.imageName, Count(setting.imageName)); | |
166 | 171 | GetDlgItemText(IDC_EDT_PID, str); |
167 | 172 | convert(str, setting.pid); |
168 | 173 | |
169 | - GetDlgItemText(IDC_EDT_ADDRESS_BASE, setting.addressBaseFormula); | |
170 | - GetDlgItemText(IDC_EDT_ADDRESS_OFFSET, setting.addressOffsetFormula); | |
174 | + GetDlgItemText(IDC_EDT_ADDRESS_BASE, setting.addressBaseFormula, Count(setting.addressBaseFormula)); | |
175 | + GetDlgItemText(IDC_EDT_ADDRESS_OFFSET, setting.addressOffsetFormula, Count(setting.addressOffsetFormula)); | |
171 | 176 | |
172 | 177 | GetDlgItemText(IDC_EDT_ADDRESS_OFFSET_MULTIPLIER, str); |
173 | 178 | convert(str, setting.addressOffsetMultiplier); |
174 | 179 | |
175 | 180 | if (m_pDlg1D->IsWindowVisible()) { |
176 | - m_pDlg1D->RetrieveSetting(setting.pDataSetting); | |
181 | + m_pDlg1D->RetrieveSetting(pDataSetting); | |
177 | 182 | }else if (m_pDlg2D->IsWindowVisible()) { |
178 | - m_pDlg2D->RetrieveSetting(setting.pDataSetting); | |
183 | + m_pDlg2D->RetrieveSetting(pDataSetting); | |
179 | 184 | }else { |
180 | - m_pDlgTEXT->RetrieveSetting(setting.pDataSetting); | |
185 | + m_pDlgTEXT->RetrieveSetting(pDataSetting); | |
181 | 186 | } |
182 | 187 | |
183 | 188 | }catch(...) { |
@@ -257,21 +262,6 @@ | ||
257 | 262 | return false; |
258 | 263 | } |
259 | 264 | |
260 | -LRESULT CSettingDialog::OnBtnCopyBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl) | |
261 | -{ | |
262 | - m_pProcessSetting_Tmp = boost::shared_ptr<ProcessSetting>(new ProcessSetting); | |
263 | - RetrieveSetting(*m_pProcessSetting_Tmp); | |
264 | - return 0; | |
265 | -} | |
266 | - | |
267 | -LRESULT CSettingDialog::OnBtnPasteBnClicked(WORD wNotifyCode, WORD wID, HWND hWndCtl) | |
268 | -{ | |
269 | - if (m_pProcessSetting_Tmp) { | |
270 | - SetSetting(*m_pProcessSetting_Tmp); | |
271 | - } | |
272 | - return 0; | |
273 | -} | |
274 | - | |
275 | 265 | LRESULT CSettingDialog::OnBnClickedBtnRead(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/) |
276 | 266 | { |
277 | 267 | ReadData(); |
@@ -299,8 +289,9 @@ | ||
299 | 289 | { |
300 | 290 | if (m_readDelegate) { |
301 | 291 | ProcessSetting setting; |
302 | - RetrieveSetting(setting); | |
303 | - m_readDelegate(setting); | |
292 | + boost::shared_ptr<IDataSetting> pDataSetting; | |
293 | + RetrieveSetting(setting, pDataSetting); | |
294 | + m_readDelegate(setting, pDataSetting); | |
304 | 295 | } |
305 | 296 | } |
306 | 297 |
@@ -308,8 +299,45 @@ | ||
308 | 299 | { |
309 | 300 | if (m_processDelegate) { |
310 | 301 | ProcessSetting setting; |
311 | - RetrieveSetting(setting); | |
312 | - m_processDelegate(setting); | |
302 | + boost::shared_ptr<IDataSetting> pDataSetting; | |
303 | + RetrieveSetting(setting, pDataSetting); | |
304 | + m_processDelegate(setting, pDataSetting); | |
313 | 305 | } |
314 | 306 | } |
315 | 307 | |
308 | +void CSettingDialog::CopyToClipboard() | |
309 | +{ | |
310 | + if (!OpenClipboard()) { | |
311 | + return; | |
312 | + } | |
313 | + EmptyClipboard(); | |
314 | + HGLOBAL hG = GlobalAlloc(GHND, sizeof(ProcessSetting) + sizeof(DataSetting2D)); | |
315 | + uint8_t* mem = (uint8_t*) GlobalLock(hG); | |
316 | + | |
317 | + ProcessSetting processSetting; | |
318 | + boost::shared_ptr<IDataSetting> pDataSetting; | |
319 | + RetrieveSetting(processSetting, pDataSetting); | |
320 | + memcpy(mem, &processSetting, sizeof(processSetting)); | |
321 | + memcpy(mem+sizeof(processSetting), pDataSetting.get(), sizeof(DataSetting2D)); | |
322 | + | |
323 | + GlobalUnlock(mem); | |
324 | + SetClipboardData(clipBoardFormat_, hG); | |
325 | + CloseClipboard(); | |
326 | +} | |
327 | + | |
328 | +void CSettingDialog::PasteFromClipboard() | |
329 | +{ | |
330 | + if (!OpenClipboard()) { | |
331 | + return; | |
332 | + } | |
333 | + HANDLE hClip = GetClipboardData(clipBoardFormat_); | |
334 | + if (!hClip) { | |
335 | + CloseClipboard(); | |
336 | + return; | |
337 | + } | |
338 | + const uint8_t* mem = (const uint8_t*) GlobalLock(hClip); | |
339 | + SetSetting(*(const ProcessSetting*)mem, (const IDataSetting*)(mem+sizeof(ProcessSetting))); | |
340 | + GlobalUnlock(hClip); | |
341 | + CloseClipboard(); | |
342 | +} | |
343 | + |