Main Page | Class Hierarchy | Class List | File List | Class Members | File Members

edslrare.c

Go to the documentation of this file.
00001 /****************************************************************************\ 00002 * edslRare.c - SL Edit controls Routines Called rarely are to be 00003 * put in a seperate segment _EDSLRare. This file contains 00004 * these routines. 00005 * 00006 * Copyright (c) 1985 - 1999, Microsoft Corporation 00007 * 00008 * Single-Line Support Routines called Rarely 00009 * 00010 * Created: 02-08-89 sankar 00011 \****************************************************************************/ 00012 00013 #include "precomp.h" 00014 #pragma hdrstop 00015 00016 /***************************************************************************\ 00017 * SLCreate 00018 * 00019 * Creates the edit control for the window hwnd by allocating memory 00020 * as required from the application's heap. Notifies parent if no memory 00021 * error (after cleaning up if needed). Returns TRUE if no error else return s 00022 * -1. 00023 * 00024 * History: 00025 \***************************************************************************/ 00026 00027 LONG SLCreate( 00028 PED ped, 00029 LPCREATESTRUCT lpCreateStruct) 00030 { 00031 LPSTR lpWindowText; 00032 LONG windowStyle = ped->pwnd->style; 00033 00034 /* 00035 * Do the standard creation stuff 00036 */ 00037 if (!ECCreate(ped, windowStyle)) 00038 return (-1); 00039 00040 /* 00041 * Single lines always have no undo and 1 line 00042 */ 00043 ped->cLines = 1; 00044 ped->undoType = UNDO_NONE; 00045 00046 /* 00047 * Check if this edit control is part of a combobox and get a pointer to the 00048 * combobox structure. 00049 */ 00050 if (windowStyle & ES_COMBOBOX) 00051 ped->listboxHwnd = GetDlgItem(lpCreateStruct->hwndParent, CBLISTBOXID); 00052 00053 /* 00054 * Set the default font to be the system font. 00055 */ 00056 ECSetFont(ped, NULL, FALSE); 00057 00058 /* 00059 * Set the window text if needed. Return false if we can't set the text 00060 * SLSetText notifies the parent in case there is a no memory error. 00061 */ 00062 if ((ULONG_PTR)lpCreateStruct->lpszName > gHighestUserAddress) 00063 lpWindowText = REBASEPTR(ped->pwnd, (PVOID)lpCreateStruct->lpszName); 00064 else 00065 lpWindowText = (LPSTR)lpCreateStruct->lpszName; 00066 00067 if ((lpWindowText != NULL) 00068 && !IsEmptyString(lpWindowText, ped->fAnsi) 00069 && !ECSetText(ped, lpWindowText)) { 00070 return (-1); 00071 } 00072 00073 if (windowStyle & ES_PASSWORD) 00074 ECSetPasswordChar(ped, (UINT)'*'); 00075 00076 return TRUE; 00077 } 00078 00079 /***************************************************************************\ 00080 * SLUndoHandler AorW 00081 * 00082 * Handles UNDO for single line edit controls. 00083 * 00084 * History: 00085 \***************************************************************************/ 00086 00087 BOOL SLUndo( 00088 PED ped) 00089 { 00090 PBYTE hDeletedText = ped->hDeletedText; 00091 BOOL fDelete = (BOOL)(ped->undoType & UNDO_DELETE); 00092 ICH cchDeleted = ped->cchDeleted; 00093 ICH ichDeleted = ped->ichDeleted; 00094 BOOL fUpdate = FALSE; 00095 00096 if (ped->undoType == UNDO_NONE) { 00097 00098 /* 00099 * No undo... 00100 */ 00101 return FALSE; 00102 } 00103 00104 ped->hDeletedText = NULL; 00105 ped->cchDeleted = 0; 00106 ped->ichDeleted = (ICH)-1; 00107 ped->undoType &= ~UNDO_DELETE; 00108 00109 if (ped->undoType == UNDO_INSERT) { 00110 ped->undoType = UNDO_NONE; 00111 00112 /* 00113 * Set the selection to the inserted text 00114 */ 00115 SLSetSelection(ped, ped->ichInsStart, ped->ichInsEnd); 00116 ped->ichInsStart = ped->ichInsEnd = (ICH)-1; 00117 00118 #ifdef NEVER 00119 00120 /* 00121 * Now send a backspace to deleted and save it in the undo buffer... 00122 */ 00123 SLCharHandler(pped, VK_BACK); 00124 fUpdate = TRUE; 00125 #else 00126 00127 /* 00128 * Delete the selected text and save it in undo buff. 00129 * Call ECDeleteText() instead of sending a VK_BACK message 00130 * which results in an EN_UPDATE notification send even before 00131 * we insert the deleted chars. This results in Bug #6610. 00132 * Fix for Bug #6610 -- SANKAR -- 04/19/91 -- 00133 */ 00134 if (ECDeleteText(ped)) { 00135 00136 /* 00137 * Text was deleted -- flag for update and clear selection 00138 */ 00139 fUpdate = TRUE; 00140 SLSetSelection(ped, ichDeleted, ichDeleted); 00141 } 00142 #endif 00143 } 00144 00145 if (fDelete) { 00146 HWND hwndSave = ped->hwnd; // Used for validation. 00147 00148 /* 00149 * Insert deleted chars. Set the selection to the inserted text. 00150 */ 00151 SLSetSelection(ped, ichDeleted, ichDeleted); 00152 SLInsertText(ped, hDeletedText, cchDeleted); 00153 UserGlobalFree(hDeletedText); 00154 if (!IsWindow(hwndSave)) 00155 return FALSE; 00156 SLSetSelection(ped, ichDeleted, ichDeleted + cchDeleted); 00157 fUpdate = TRUE; 00158 } 00159 00160 if (fUpdate) { 00161 /* 00162 * If we have something to update, send EN_UPDATE before and 00163 * EN_CHANGE after the actual update. 00164 * A part of the fix for Bug #6610 -- SANKAR -- 04/19/91 -- 00165 */ 00166 ECNotifyParent(ped, EN_UPDATE); 00167 00168 if (FChildVisible(ped->hwnd)) { 00169 // JimA changed this to ECInvalidateClient(ped, FALSE) Nov 1994 00170 // GetClientRect(ped->hwnd, &rcEdit); 00171 // if (ped->fBorder && rcEdit.right - rcEdit.left && rcEdit.bottom - rcEdit.top) { 00172 // 00173 // /* 00174 // * Don't invalidate the border so that we avoid flicker 00175 // */ 00176 // InflateRect(&rcEdit, -1, -1); 00177 // } 00178 // NtUserInvalidateRect(ped->hwnd, &rcEdit, FALSE); 00179 ECInvalidateClient(ped, FALSE); 00180 } 00181 00182 ECNotifyParent(ped, EN_CHANGE); 00183 00184 if (FWINABLE()) { 00185 NotifyWinEvent(EVENT_OBJECT_VALUECHANGE, ped->hwnd, OBJID_CLIENT, INDEXID_CONTAINER); 00186 } 00187 } 00188 00189 return TRUE; 00190 }

Generated on Sat May 15 19:39:49 2004 for test by doxygen 1.3.7