home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Programming Tool Box
/
SIMS_2.iso
/
vb_tools
/
readonly
/
rdonly.c
next >
Wrap
C/C++ Source or Header
|
1992-11-12
|
2KB
|
79 lines
/*******************************************************************
RDONLY.DLL
Jeff Simms
72200,3173
November 11, 1992
Declare Sub SetMsgFilter Lib "RDONLY.DLL" (ByVal hWnd As Integer)
Idea - 'TRUE' Read-Only scrolling text box.
Purpose - Subclass standard VB edit control to intercept messages,
eliminating any indication of a normal textbox. One: trap
WM_SETCURSOR to keep the cursor from changing to IBEAM.
Two: trap WM_MOUSEMOVE and WM_LBUTTONDBLCLK to keep text
from being highlighted. Also HideCaret() on WM_SETFOCUS.
LIBRARY RDONLY
DESCRIPTION 'Read Only TextBox'
EXETYPE WINDOWS
CODE PRELOAD MOVEABLE DISCARDABLE
DATA PRELOAD MOVEABLE SINGLE
HEAPSIZE 1024
EXPORTS WEP @1 RESIDENTNAME
SetMsgFilter @2
MainFilterProc @3
*******************************************************************/
#include <windows.h>
VOID __export FAR PASCAL SetMsgFilter(HWND);
LONG __export FAR PASCAL MainFilterProc(HWND,unsigned,WORD,LONG);
HCURSOR hcursor;
FARPROC lpfnEditWndProc;
HWND EDhWnd;
VOID __export FAR PASCAL SetMsgFilter(HWND hEditWnd)
{
EDhWnd = hEditWnd;
SendMessage(hEditWnd,EM_SETREADONLY,TRUE,0L);
HideCaret(EDhWnd);
lpfnEditWndProc = (FARPROC) SetWindowLong(hEditWnd,GWL_WNDPROC,
(DWORD)(FARPROC) MainFilterProc);
}
LONG __export FAR PASCAL MainFilterProc(HWND hWnd,unsigned wMsg,WORD wParam,LONG lParam)
{
switch (wMsg)
{
case WM_SETFOCUS:
CallWindowProc(lpfnEditWndProc,hWnd, wMsg, wParam, lParam);
HideCaret(EDhWnd);
return 0;
case WM_SETCURSOR:
hcursor = LoadCursor(NULL,IDC_IBEAM);
if (hcursor == GetCursor())
SetCursor(LoadCursor(NULL,IDC_ARROW));
case WM_MOUSEMOVE:
case WM_LBUTTONDBLCLK:
return 0;
case WM_DESTROY:
SetWindowLong(EDhWnd,GWL_WNDPROC, (DWORD)(FARPROC) lpfnEditWndProc);
PostMessage(EDhWnd,WM_DESTROY,0,0);
return 0;
}
return(CallWindowProc(lpfnEditWndProc,hWnd, wMsg, wParam, lParam));
}