My Project
editfield.cpp
Go to the documentation of this file.
1 #include "stdafx.h"
2 #include "../stdafx.h"
3 #include "editfield.h"
4 
6 {
7 
8 }
9 
11 {
12  this->ID = ID;
13 }
14 
15 Editfield::Editfield(int X, int Y, int HEIGHT, int WIDTH, WCHAR* TEXT)
16 {
17  this->create(X, Y, HEIGHT, WIDTH, TEXT);
18 }
19 
21 {
22  this->remove();
23 }
24 
25 HWND Editfield::create(int X, int Y, int HEIGHT, int WIDTH, WCHAR* TEXT)
26 {
27  if (this->ehWnd)
28  {
29  return this->ehWnd;
30  }
31  this->ehWnd = CreateWindowExW(WS_EX_WINDOWEDGE, TEXT("Edit"), TEXT,
32  WS_CHILD | WS_VISIBLE | WS_BORDER | ES_CENTER,
33  X, Y, WIDTH, HEIGHT,
34  this->hWnd, (HMENU)this->ID, this->hInst, NULL);
35 
36  HFONT hfont = CreateFont(HEIGHT-2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, TEXT("Arial"));
37  SendMessage(this->ehWnd, WM_SETFONT, (WPARAM)hfont, 0);
38 
39  return this->ehWnd;
40 }
41 
43 {
44  TCHAR buf[5];
45  GetWindowText(this->ehWnd, buf, 5);
46  return buf;
47 }
48 
50 {
51  WCHAR* result = this->getText();
52  if (wcslen(result) == 0)
53  {
54  return 0;
55  }
56  return _wtoi(result);
57 }
58 
60 {
61  return this->ehWnd;
62 }
63 
65 {
66  DestroyWindow(GetDlgItem(this->hWnd, this->ID));
67  this->ehWnd = NULL;
68 }
static HINSTANCE hInst
Definition: interface.h:61
int getInt()
Definition: editfield.cpp:49
HWND getHWND()
Definition: editfield.cpp:59
void remove() override
Definition: editfield.cpp:64
WCHAR * getText()
Definition: editfield.cpp:42
HWND create(int X, int Y, int HEIGHT, int WIDTH, WCHAR *TEXT) override
Definition: editfield.cpp:25
static HWND hWnd
Definition: interface.h:60