forked from jps1973/Internet
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditWindow.cpp
More file actions
117 lines (82 loc) · 2.75 KB
/
EditWindow.cpp
File metadata and controls
117 lines (82 loc) · 2.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// EditWindow.cpp
#include "EditWindow.h"
// Global variables
static HWND g_hWndEdit;
BOOL IsEditWindow( HWND hWnd )
{
// See if supplied window is edit window
return( hWnd == g_hWndEdit );
} // End of function IsEditWindow
BOOL EditWindowCreate( HWND hWndParent, HINSTANCE hInstance, LPCTSTR lpszInitialText )
{
BOOL bResult = FALSE;
// Create edit window
g_hWndEdit = CreateWindowEx( EDIT_WINDOW_EXTENDED_STYLE, EDIT_WINDOW_CLASS_NAME, lpszInitialText, EDIT_WINDOW_STYLE, 0, 0, 0, 0, hWndParent, ( HMENU )NULL, hInstance, NULL );
// Ensure that edit window was created
if( g_hWndEdit )
{
// Successfully created edit window
// Update return value
bResult = TRUE;
} // End of successfully created edit window
return bResult;
} // End of function EditWindowCreate
BOOL EditWindowGetRect( LPRECT lpRect )
{
// Get edit window rect
return GetWindowRect( g_hWndEdit, lpRect );
} // End of function EditWindowGetRect
int EditWindowGetText( LPTSTR lpszText, DWORD dwMaxTextLength )
{
// Get edit window text
return SendMessage( g_hWndEdit, WM_GETTEXT, ( WPARAM )dwMaxTextLength, ( LPARAM )lpszText );
} // End of function EditWindowGetText
BOOL EditWindowHandleCommandMessage( WPARAM wParam, LPARAM, BOOL( *lpChangeFunction )( DWORD dwTextLength ) )
{
BOOL bResult = FALSE;
// Select edit window notification code
switch( HIWORD( wParam ) )
{
case EN_CHANGE:
{
// Edit window change notification code
DWORD dwTextLength;
// Get text length
dwTextLength = SendMessage( g_hWndEdit, WM_GETTEXTLENGTH, ( WPARAM )NULL, ( LPARAM )NULL );
// Call change function
( *lpChangeFunction )( dwTextLength );
// Update return value
bResult = TRUE;
// Break out of switch
break;
} // End of edit window change notification code
default:
{
// Default notification code
// No need to do anything here, just continue with default result
// Break out of switch
break;
} // End of default notification code
}; // End of selection for edit window notification code
return bResult;
} // End of function EditWindowHandleCommandMessage
BOOL EditWindowMove( int nX, int nY, int nWidth, int nHeight, BOOL bRepaint )
{
// Move edit window
return MoveWindow( g_hWndEdit, nX, nY, nWidth, nHeight, bRepaint );
} // End of function EditWindowMove
void EditWindowSelect( int nStart, int nEnd )
{
// Select edit window text
SendMessage( g_hWndEdit, EM_SETSEL, ( WPARAM )nStart, ( LPARAM )nEnd );
} // End of function EditWindowSelect
HWND EditWindowSetFocus()
{
// Focus on edit window
return SetFocus( g_hWndEdit );
} // End of function EditWindowSetFocus
void EditWindowSetFont( HFONT hFont )
{
// Set edit window font
SendMessage( g_hWndEdit, WM_SETFONT, ( WPARAM )hFont, ( LPARAM )TRUE );
} // End of function EditWindowSetFont