00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #if !defined(SOFTERRA_HEXEDITOR_HEXEDITCTL_H_INCLUDED_)
00011 #define SOFTERRA_HEXEDITOR_HEXEDITCTL_H_INCLUDED_
00012
00013 #if _MSC_VER > 1000
00014 #pragma once
00015 #endif // _MSC_VER > 1000
00016
00018 class CHexEditCtrl : public COleControl
00019 {
00020
00021
00023 public:
00024 CHexEditCtrl();
00025
00026
00027
00028
00029 public:
00030 virtual void OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid);
00031 virtual void DoPropExchange(CPropExchange* pPX);
00032 virtual void OnResetState();
00033 protected:
00034 virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
00035
00036
00037
00038 protected:
00039
00040
00042 COleSafeArray m_data;
00043
00045 short m_digitsInAddress;
00046
00052 short m_digitsInData;
00053
00055 short m_columns;
00056
00058 short m_fontHeight;
00059
00061 DWORD m_dwStartAddr;
00062
00064 bool m_bDataModified;
00065
00066
00067
00069 bool m_bRealShowAscii;
00070
00072 int m_nHorzScroll;
00073
00075 bool m_bMouseDown;
00076
00078 bool m_bMouseMove;
00079
00081 int m_posMouseDown;
00082
00084 CSize m_charCountWindow;
00085
00087 CSize m_charCountView;
00088
00090 CSize m_cellSize;
00091
00092
00093
00094
00095
00097 long m_selStart;
00098
00100 long m_selEnd;
00101
00103 long m_editPos;
00104
00106 long m_viewPos;
00107
00109 int m_nEditDigit;
00110
00112 int m_addrMargin;
00113
00115 int m_asciiMargin;
00116
00121 int m_editMode;
00122
00124 CRect m_rcClient;
00125
00127 bool m_bTimer;
00128
00130 CPoint m_prevMousePoint;
00131
00133 static CString m_strWindowClass;
00134
00136 static CCriticalSection _critSect;
00137
00139 void TextOutWithCheck(CDC* pdc, const CRect& rcInvalid, int x, int y, CString& strText );
00140
00146 bool EnterNumber();
00147
00149 void ClearSelection();
00150
00152 void DeleteSelection();
00153
00157 void RecalcSelection(CPoint point);
00158
00160 bool IsSelectionEmpty();
00161
00165 bool UpdateScrollBars();
00166
00168 void InvalidateEditRect(long nEditPos);
00169
00171 void DeleteData ( DWORD dwPos, DWORD dwCount = 1 );
00172
00174 void InsertData ( DWORD dwPos, DWORD dwCount = 1 );
00175
00177 bool NormalizeEditPos();
00178
00182 void ChangeEditPos ( CPoint pt );
00183
00189 void ChangeEditPos ( long dx, long dy, bool bRepaint = false);
00190
00192 void PlaceCaret();
00193
00195 void RecalcLayout();
00196
00198 ~CHexEditCtrl();
00199
00200 DECLARE_OLECREATE_EX(CHexEditCtrl)
00201 DECLARE_OLETYPELIB(CHexEditCtrl)
00202 DECLARE_PROPPAGEIDS(CHexEditCtrl)
00203 DECLARE_OLECTLTYPE(CHexEditCtrl)
00204
00205
00206
00207 afx_msg void OnKillFocus(CWnd* pNewWnd);
00208 afx_msg void OnSetFocus(CWnd* pOldWnd);
00209 afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
00210 afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
00211 afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
00212 afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);
00213 afx_msg UINT OnGetDlgCode();
00214 afx_msg void OnLButtonUp(UINT nFlags, CPoint point);
00215 afx_msg void OnMouseMove(UINT nFlags, CPoint point);
00216 afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00217 afx_msg void OnEditCopy();
00218 afx_msg void OnEditCut();
00219 afx_msg void OnEditPaste();
00220 afx_msg void OnUpdateEditCopy(CCmdUI* pCmdUI);
00221 afx_msg void OnUpdateEditCut(CCmdUI* pCmdUI);
00222 afx_msg void OnUpdateEditPaste(CCmdUI* pCmdUI);
00223 afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
00224 afx_msg void OnTimer(UINT nIDEvent);
00225 afx_msg void OnSize(UINT nType, int cx, int cy);
00226
00227 afx_msg void OnEditSelectAll();
00228 afx_msg void OnUpdateEditSelectAll(CCmdUI* pCmdUI);
00229 DECLARE_MESSAGE_MAP()
00230 afx_msg void OnContextMenu(CWnd*, CPoint point);
00231
00232
00233
00234 BOOL m_showAddress;
00235 afx_msg void OnShowAddressChanged();
00236 BOOL m_showAscii;
00237 afx_msg void OnShowAsciiChanged();
00238 BOOL m_allowChangeSize;
00239 afx_msg void OnAllowChangeSizeChanged();
00240 BOOL m_dataModified;
00241 afx_msg void OnDataModifiedChanged();
00242 afx_msg short GetDigitsInAddress();
00243 afx_msg void SetDigitsInAddress(short nNewValue);
00244 afx_msg short GetDigitsInData();
00245 afx_msg void SetDigitsInData(short nNewValue);
00246 afx_msg short GetColumns();
00247 afx_msg void SetColumns(short nNewValue);
00248 afx_msg short GetFontHeight();
00249 afx_msg void SetFontHeight(short nNewValue);
00250 afx_msg SCODE SetData(VARIANT FAR* pData, long dwStartAddr);
00251
00252 DECLARE_DISPATCH_MAP()
00253
00254 afx_msg void AboutBox();
00255
00256
00257
00258
00259 DECLARE_EVENT_MAP()
00260
00261
00262 public:
00263 enum {
00264
00265 dispidShowAddress = 1L,
00266 dispidShowAscii = 2L,
00267 dispidDigitsInAddress = 5L,
00268 dispidDigitsInData = 6L,
00269 dispidColumns = 7L,
00270 dispidFontHeight = 8L,
00271 dispidAllowChangeSize = 3L,
00272 dispidDataModified = 4L,
00273 dispidSetData = 9L,
00274
00275 };
00276 };
00277
00278
00279
00280
00281 #endif // !defined(SOFTERRA_HEXEDITOR_HEXEDITCTL_H_INCLUDED_)