-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditBox.cpp
More file actions
55 lines (41 loc) · 1.11 KB
/
EditBox.cpp
File metadata and controls
55 lines (41 loc) · 1.11 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
// EditBox.cpp: implementation of the EditBox class.
//
//////////////////////////////////////////////////////////////////////
#include "EditBox.h"
#include <stdio.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
EditBox::EditBox()
{
this->strControlClass = "EDIT";
}
EditBox::~EditBox()
{
}
BOOL EditBox::Append(LPTSTR text)
{
DWORD lenght = ::SendMessage(this->hWnd, WM_GETTEXTLENGTH, 0, 0);
if (lenght <= 0)
{
::SendMessage(this->hWnd, WM_SETTEXT, 0, (LPARAM)(LPTSTR)text);
return TRUE;
}
DWORD newlenght = lenght + strlen(text);
LPTSTR tmp = new CHAR[lenght + 1];
LPTSTR newtext = new CHAR[newlenght + 1];
if (tmp != NULL && newtext != NULL)
{
::SendMessage(this->hWnd, WM_GETTEXT, lenght, (LPARAM)(LPTSTR)tmp);
sprintf(newtext, "%s%s", tmp, text);
::SendMessage(this->hWnd, WM_SETTEXT, 0, (LPARAM)(LPTSTR)newtext);
delete [] tmp;
delete [] newtext;
return TRUE;
}
else
{
AddError("Buffers voor het toevoegen van de tekst is niet gelukt");
}
return FALSE;
}