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
|
#include "GUI_Functions.h"
void StaticText::Create(std::string text, int Xpos, int Ypos, int Xsize, int Ysize, HWND parent, int ident)
{
hwnd = CreateWindowEx(0,"Static", text.c_str(), WS_CHILD | WS_VISIBLE, Xpos, Ypos, Xsize, Ysize, parent, (HMENU)ident, NULL, NULL);
}
void StaticText::Text(std::string text)
{
SetWindowText(hwnd, text.c_str());
}
////////////////////////////////////////////////////////////////////////////
void Button::Create(std::string text, int Xpos, int Ypos, int Xsize, int Ysize, HWND parent, int ident, bool def)
{
DWORD style = WS_CHILD | WS_VISIBLE;
if (def) style |= BS_DEFPUSHBUTTON;
hwnd = CreateWindowEx(0, "Button", text.c_str(), style , Xpos, Ypos, Xsize, Ysize, parent, (HMENU)ident, NULL, NULL);
}
////////////////////////////////////////////////////////////////////////////
void GroupBox::Create(std::string text, int Xpos, int Ypos, int Xsize, int Ysize, HWND parent, int ident)
{
hwnd = CreateWindowEx(0, "Button", text.c_str(), WS_CHILD | WS_VISIBLE | BS_GROUPBOX, Xpos, Ypos, Xsize, Ysize, parent, (HMENU)ident, NULL, NULL);
}
void GroupBox::SetText(std::string text)
{
SetWindowText(hwnd, text.c_str());
}
////////////////////////////////////////////////////////////////////////////
void EditBox::Create(int Xpos, int Ypos, int Xsize, int Ysize, HWND parent, int ident)
{
hwnd = CreateWindow("Edit", NULL, WS_VISIBLE | WS_CHILD | WS_BORDER, Xpos, Ypos, Xsize, Ysize, parent, (HMENU)ident, NULL, NULL);
}
std::string EditBox::GetText()
{
char text[2048];
int len = GetWindowTextLength(hwnd) + 1;
GetWindowText(hwnd, text, min(len,2048));
return text;
}
void EditBox::SetText(std::string text)
{
SetWindowText(hwnd, text.c_str());
}
////////////////////////////////////////////////////////////////////////////
void CreateObjects(HWND hwnd)
{
GBox1.Create("Text to speech", 5, 5, 500, 77, hwnd, ID_GBOX_1);
Edit1.Create( 10, 27, 420, 22, hwnd, ID_EDIT_1);
Bttn1.Create("Go" , 440, 25, 50, 27, hwnd, ID_BTTN_1);
Stat1.Create("" , 20, 57, 400, 18, hwnd, ID_STAT_1);
}
////////////////////////////////////////////////////////////////////////////
// Globals
GroupBox GBox1;
EditBox Edit1;
Button Bttn1;
StaticText Stat1;
|