PRODUCT : Borland C++ NUMBER : 861 VERSION : 3.0 OS : WIN DATE : October 19, 1993 PAGE : 1/2 TITLE : How to Create a "Non-editable" Edit Box As you probably already know, Windows does not provide a control which allows the display of a large piece of non-editable text. A static text control is not scrollable and therefore cannot show large pieces of text. An editbox will allow the user to cut, paste, and type into the body of text. Below you will find a subclass which can be used to make your editboxes non-editable - a "non-Editbox" if you will. Simply pass the handle of the edit control to the function SubClassEditBox. That's it, really! --- --- --- cut here --- --- --- // Note: this is not a complete program. Add these routines to // any Windows program which uses an Editbox control. // Function Prototypes long FAR PASCAL SubClassMsgProc(HANDLE, WORD, WORD , LONG); void SubClassEditBox(HWND); // Global variable for pointer to original wndProc. FARPROC OrigFunc; //.................................................................. // Function: SubClassMsgProc // Purpose: Provides a message proc which traps cutting, // pasting and typing into an edit box and then // passes any other messages along to the editbox's // "real" window procedure. // Parameters: The usual callback function parameters // Comments: DO NOT call this function directly - its call will // be set up by SubClassEditBox and will occur // automatically whenever your editbox receives a // message from windows. long FAR PASCAL SubClassMsgProc(HANDLE hWnd, WORD message, WORD wParam, LONG lParam) { switch (message) { case WM_CUT: return 0; PRODUCT : Borland C++ NUMBER : 861 VERSION : 3.0 OS : WIN DATE : October 19, 1993 PAGE : 2/2 TITLE : How to Create a "Non-editable" Edit Box case WM_PASTE: return 0; case WM_CHAR: if (wParam != VK_TAB) return 0; else CallWindowProc(OrigFunc, hWnd, message, wParam, lParam); default: return CallWindowProc(OrigFunc, hWnd, message, wParam, lParam); } } //.................................................................. //.................................................................. // Function: SubClassEditBox // Purpose: Makes an editbox into a "non-Editbox" via a // subclass. // Parameters: hWnd should be the handle to an editbox void SubClassEditBox(HWND hWnd) { OrigFunc = (FARPROC) GetWindowLong(hWnd, GWL_WNDPROC); SetWindowLong(hWnd, GWL_WNDPROC, (LONG) SubClassMsgProc); } //.................................................................. DISCLAIMER: You have the right to use this technical information subject to the terms of the No-Nonsense License Statement that you received with the Borland product to which this information pertains.