**NOTE** I'm using
First of all, I need to figure out how to retrieve/change/clear a input box's text when using
CreateWindow(TEXT("Edit"), "0",
WS_CHILD | WS_VISIBLE | WS_BORDER,
170, 30, 30, 20, hwnd, (HMENU) 6,
NULL, NULL);
I know in VC# it's textBox1.Clear(); textBox1.Text = ""; string example = textBox1.Text; but I have no clue what it is in Dev-C++...
I wouldn't ask on something this simple, but I searched like mad and either am searching the wrong query (empty/clear/change/retrieve input box text in C++) or there is no other results.... LOL
Second, It's not really neccesary ( I can probably find this on my own, but it's be nice to see help with this as well, as for I haven't started with this yet so I don't expect it) is I need help forming the code behind my GUI, I'm making a timer application and i needed help with the timer (function?), any help would be appreciated.
And Last but not least, I'm not asking for it, but if you find any code corrections/suggestions I would appreciate a post with a better code snippet
*drumroll* How's this look for a one-day-old C++ programmer? (just the GUI, no code behind it yet)

Source code here:
#include <windows.h>
static void chfont(int size, HWND where) {
HFONT hfffont;
hfffont = CreateFont(size,
0,
0,
0,
FW_BOLD,
0,
0,
0,
ANSI_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS,
DEFAULT_QUALITY,
DEFAULT_PITCH | FF_DONTCARE,
"Arial");
SendMessage(where, WM_SETFONT, (DWORD)hfffont, 0);
}
LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
static HWND hwndEdit1;
static HWND cc;
static HWND cb;
static HFONT hfffont;
static HWND hwndEdit2;
static HWND hwndEdit3;
static HWND hwndEdit4;
static HWND startButton;
static HWND pauseButton;
static HWND stopButton;
static HWND hrlbl;
static HWND minlbl;
static HWND seclbl;
static HWND DisplayFont;
HINSTANCE hInst;
static int len;
static TCHAR text[30];
switch(msg)
{
case WM_CREATE:
hwndEdit1 = CreateWindow(TEXT("Edit"), "0", WS_CHILD | WS_VISIBLE | WS_BORDER,
90, 30, 30, 20, hwnd, (HMENU) 4,
NULL, NULL);
hwndEdit2 = CreateWindow(TEXT("Edit"), "0", WS_CHILD | WS_VISIBLE | WS_BORDER,
130, 30, 30, 20, hwnd, (HMENU) 5,
NULL, NULL);
hwndEdit3 = CreateWindow(TEXT("Edit"), "0", WS_CHILD | WS_VISIBLE | WS_BORDER,
170, 30, 30, 20, hwnd, (HMENU) 6,
NULL, NULL);
hwndEdit4 = CreateWindow(TEXT("Edit"), "Alarm msg here", WS_CHILD | WS_VISIBLE | WS_BORDER,
90, 80, 110, 20, hwnd, (HMENU) 10,
NULL, NULL);
CreateWindow(TEXT("STATIC"), "hrs", WS_CHILD | WS_VISIBLE | SS_LEFT, 90, 50, 30, 20, hwnd, (HMENU) 1, hInst, NULL);
CreateWindow(TEXT("STATIC"), "min", WS_CHILD | WS_VISIBLE | SS_LEFT, 130, 50, 30, 20, hwnd, (HMENU) 2, hInst, NULL);
CreateWindow(TEXT("STATIC"), "sec", WS_CHILD | WS_VISIBLE | SS_LEFT, 170, 50, 30, 20, hwnd, (HMENU) 3, hInst, NULL);
CreateWindow(TEXT("STATIC"), "Set Time:", WS_CHILD | WS_VISIBLE | SS_LEFT, 17, 30, 70, 20, hwnd, (HMENU) 11, hInst, NULL);
CreateWindow(TEXT("STATIC"), "Message:", WS_CHILD | WS_VISIBLE | SS_LEFT, 17, 80, 70, 20, hwnd, (HMENU) 12, hInst, NULL);
hrlbl = CreateWindow(TEXT("STATIC"), "00", WS_CHILD | WS_VISIBLE | SS_LEFT, 35, 180, 50, 50, hwnd, (HMENU) 13, hInst, NULL);
cc = CreateWindow(TEXT("STATIC"), ":", WS_CHILD | WS_VISIBLE | SS_LEFT, 90, 180, 15, 50, hwnd, (HMENU) 14, hInst, NULL);
minlbl = CreateWindow(TEXT("STATIC"), "00", WS_CHILD | WS_VISIBLE | SS_LEFT, 115, 180, 50, 50, hwnd, (HMENU) 15, hInst, NULL);
cb = CreateWindow(TEXT("STATIC"), ":", WS_CHILD | WS_VISIBLE | SS_LEFT, 170, 180, 115, 50, hwnd, (HMENU) 16, hInst, NULL);
seclbl = CreateWindow(TEXT("STATIC"), "00", WS_CHILD | WS_VISIBLE | SS_LEFT, 195, 180, 50, 50, hwnd, (HMENU) 17, hInst, NULL);
CreateWindow(TEXT("STATIC"), "Hours:", WS_CHILD | WS_VISIBLE | SS_LEFT, 15, 160, 70, 20, hwnd, (HMENU) 18, hInst, NULL);
CreateWindow(TEXT("STATIC"), "Minutes:", WS_CHILD | WS_VISIBLE | SS_LEFT, 80, 160, 70, 20, hwnd, (HMENU) 19, hInst, NULL);
CreateWindow(TEXT("STATIC"), "Seconds:", WS_CHILD | WS_VISIBLE | SS_LEFT, 155, 160, 70, 20, hwnd, (HMENU) 20, hInst, NULL);
chfont(50, hrlbl);
chfont(50, cc);
chfont(50, minlbl);
chfont(50, cb);
chfont(50, seclbl);
startButton = CreateWindow(
TEXT("button"), TEXT("Start"),
WS_VISIBLE | WS_CHILD,
215, 25, 50, 25,
hwnd, (HMENU) 7, NULL, NULL);
pauseButton = CreateWindow(
TEXT("button"), TEXT("Pause"),
WS_VISIBLE | WS_CHILD,
215, 60, 50, 25,
hwnd, (HMENU) 8, NULL, NULL);
stopButton = CreateWindow(
TEXT("button"), TEXT("Stop"),
WS_VISIBLE | WS_CHILD,
215, 95, 50, 25,
hwnd, (HMENU) 9, NULL, NULL);
break;
case WM_COMMAND:
if (LOWORD(wParam) == 7) {
MessageBox(NULL, "START", "START", 0);
}
if (LOWORD(wParam) == 8) {
MessageBox(NULL, "PAUSE", "PAUSE", 0);
}
if (LOWORD(wParam) == 9) {
MessageBox(NULL, "STOP", "STOP", 0);
}
break;
case WM_DESTROY:
PostQuitMessage(0);
break;
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow )
{
MSG msg ;
WNDCLASS wc = {0};
wc.lpszClassName = TEXT( "Edit Control" );
wc.hInstance = hInstance ;
wc.hbrBackground = GetSysColorBrush(COLOR_3DFACE);
wc.lpfnWndProc = WndProc ;
wc.hCursor = LoadCursor(0,IDC_ARROW);
RegisterClass(&wc);
CreateWindow( wc.lpszClassName, TEXT("Alarm by RJ"),
WS_OVERLAPPEDWINDOW | WS_VISIBLE,
220, 220, 285, 290, 0, 0, hInstance, 0);
while( GetMessage(&msg, NULL, 0, 0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (int) msg.wParam;
}
Thanks in advance!
P.S.
Please Don't flame/scold me for posting errors, it's my first post, there's bound to be a problem or ten :
EDIT - Forgot to say, it's a countdown alarm - input hour/min/sec and it counts down that input and alarms when time >= 0, NOT a clock timer as in input the day/time to alarm.
EDIT #2 - Code i placed probably won't be updated for a bit, working on the timer engine or whatever you want to call it, GUI will stay pretty much the same.
This post has been edited by Immortal_King: 10 March 2010 - 02:38 PM

New Topic/Question
Reply




MultiQuote




|