reactos/base/applications/mspaint/textedit.c
Amine Khaldi ddb3d908c9 * Sync up to trunk HEAD (r62285). Branch guys deserve the significant speedups too ;)
svn path=/branches/shell-experiments/; revision=62286
2014-02-22 10:31:26 +00:00

70 lines
2.4 KiB
C

/*
* PROJECT: PAINT for ReactOS
* LICENSE: LGPL
* FILE: base/applications/paint/textedit.c
* PURPOSE: Text editor and font chooser for the text tool
* PROGRAMMERS: Benedikt Freisen
*/
/* INCLUDES *********************************************************/
#include "precomp.h"
#include "textedit.h"
/* FUNCTIONS ********************************************************/
void
RegisterWclTextEdit()
{
WNDCLASSEX wclTextEdit;
/* initializing and registering the window class used for the text editor */
wclTextEdit.hInstance = hProgInstance;
wclTextEdit.lpszClassName = _T("TextEdit");
wclTextEdit.lpfnWndProc = TextEditWinProc;
wclTextEdit.style = CS_DBLCLKS;
wclTextEdit.cbSize = sizeof(WNDCLASSEX);
wclTextEdit.hIcon = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
wclTextEdit.hIconSm = LoadIcon(hProgInstance, MAKEINTRESOURCE(IDI_APPICON));
wclTextEdit.hCursor = LoadCursor(NULL, IDC_ARROW);
wclTextEdit.lpszMenuName = NULL;
wclTextEdit.cbClsExtra = 0;
wclTextEdit.cbWndExtra = 0;
wclTextEdit.hbrBackground = GetSysColorBrush(COLOR_BTNFACE);
RegisterClassEx (&wclTextEdit);
}
LRESULT CALLBACK
TextEditWinProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_SIZE:
{
RECT clientRect;
GetClientRect(hwnd, &clientRect);
MoveWindow(hwndEditCtl, clientRect.left, clientRect.top, RECT_WIDTH(clientRect), RECT_HEIGHT(clientRect), TRUE);
break;
}
case WM_CLOSE:
ShowWindow(hwnd, SW_HIDE);
break;
case WM_COMMAND:
switch(HIWORD(wParam))
{
case EN_UPDATE:
{
HeapFree(GetProcessHeap(), 0, textToolText);
textToolTextMaxLen = GetWindowTextLength(hwndEditCtl) + 1;
textToolText = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS, sizeof(TCHAR) * textToolTextMaxLen);
GetWindowText(hwndEditCtl, textToolText, textToolTextMaxLen);
ForceRefreshSelectionContents();
break;
}
}
break;
default:
return DefWindowProc(hwnd, message, wParam, lParam);
}
return 0;
}