GME
13
|
00001 // InPlaceEdit.cpp : implementation file 00002 // 00003 // Adapted by Chris Maunder <cmaunder@mail.com> 00004 // Copyright (c) 1998-2002. All Rights Reserved. 00005 // 00006 // The code contained in this file is based on the original 00007 // CInPlaceEdit from http://www.codeguru.com/listview/edit_subitems.shtml 00008 // 00009 // This code may be used in compiled form in any way you desire. This 00010 // file may be redistributed unmodified by any means PROVIDING it is 00011 // not sold for profit without the authors written consent, and 00012 // providing that this notice and the authors name and all copyright 00013 // notices remains intact. 00014 // 00015 // An email letting me know how you are using it would be nice as well. 00016 // 00017 // This file is provided "as is" with no expressed or implied warranty. 00018 // The author accepts no liability for any damage/loss of business that 00019 // this product may cause. 00020 // 00021 // For use with CGridCtrl v2.10+ 00022 // 00023 // History: 00024 // 10 May 1998 Uses GVN_ notifications instead of LVN_, 00025 // Sends notification messages to the parent, 00026 // instead of the parent's parent. 00027 // 15 May 1998 There was a problem when editing with the in-place editor, 00028 // there arises a general protection fault in user.exe, with a 00029 // few qualifications: 00030 // (1) This only happens with owner-drawn buttons; 00031 // (2) This only happens in Win95 00032 // (3) This only happens if the handler for the button does not 00033 // create a new window (even an AfxMessageBox will avoid the 00034 // crash) 00035 // (4) This will not happen if Spy++ is running. 00036 // PreTranslateMessage was added to route messages correctly. 00037 // (Matt Weagle found and fixed this problem) 00038 // 26 Jul 1998 Removed the ES_MULTILINE style - that fixed a few probs! 00039 // 6 Aug 1998 Added nID to the constructor param list 00040 // 6 Sep 1998 Space no longer clears selection when starting edit (Franco Bez) 00041 // 10 Apr 1999 Enter, Tab and Esc key prob fixed (Koay Kah Hoe) 00042 // Workaround for bizzare "shrinking window" problem in CE 00043 // 00045 00046 #include "stdafx.h" 00047 #include "objectinspector.h" 00048 #include "InPlaceEdit.h" 00049 #include "InspectorDefs.h" 00050 00051 #ifdef _DEBUG 00052 #define new DEBUG_NEW 00053 #undef THIS_FILE 00054 static char THIS_FILE[] = __FILE__; 00055 #endif 00056 00058 // CInPlaceEdit 00059 00060 CInPlaceEdit::CInPlaceEdit() 00061 { 00062 } 00063 00064 CInPlaceEdit::~CInPlaceEdit() 00065 { 00066 } 00067 00068 00069 BEGIN_MESSAGE_MAP(CInPlaceEdit, CEdit) 00070 //{{AFX_MSG_MAP(CInPlaceEdit) 00071 ON_WM_KILLFOCUS() 00072 //}}AFX_MSG_MAP 00073 END_MESSAGE_MAP() 00074 00076 // CInPlaceEdit message handlers 00077 00078 void CInPlaceEdit::OnKillFocus(CWnd* pNewWnd) 00079 { 00080 CEdit::OnKillFocus(pNewWnd); 00081 00082 if(GetModify()) 00083 { 00084 GetParent()->SendMessage(MSG_EDIT_END_OK,0,0); 00085 } 00086 00087 ShowWindow(SW_HIDE); 00088 } 00089 00090 00091 LRESULT CInPlaceEdit::WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 00092 { 00093 if(message == WM_KEYDOWN) 00094 { 00095 switch(wParam) 00096 { 00097 case VK_ESCAPE: 00098 { 00099 SetModify(FALSE); 00100 GetParent()->SetFocus(); 00101 return 0; 00102 }break; 00103 case VK_RETURN: 00104 { 00105 if(!(GetStyle()&ES_MULTILINE)) 00106 case VK_TAB: // for JIRA GME-178 00107 { 00108 GetParent()->SetFocus(); 00109 GetParent()->SendMessage(WM_KEYDOWN, VK_TAB, lParam); 00110 } 00111 }break; 00112 case'D': 00113 { 00114 if(::GetKeyState(VK_CONTROL) & 0x8000) 00115 { 00116 GetParent()->SendMessage(message,wParam,lParam); 00117 GetParent()->SetFocus(); 00118 } 00119 }break; 00120 case 'A': 00121 { 00122 if(::GetKeyState(VK_CONTROL) & 0x8000) 00123 { 00124 SetSel(0, -1); 00125 } 00126 }break; 00127 default: 00128 ; 00129 } 00130 } 00131 return CEdit::WindowProc(message, wParam, lParam); 00132 }