Exemplo n.º 1
0
//Entry point of the program
int WINAPI WinMain (HINSTANCE hThisInstance, HINSTANCE hPrevInstance, LPSTR lpszArgument, int nCmdShow)
{
    //Create a window
    cWindow = Window(WindowProcedure, hThisInstance, "MealTrackApp", nCmdShow);
    cWindow.Create("MealTrack - Untitled", 462, 375);

    //Actually create the button with the window as its parent
    RECT rEditBox = {16, 280, 272, 24};
    cEditBox = EditBox(cWindow, rEditBox, "Disconnected");
    cEditBox.SetReadOnly(1);

    //Create the Button
    RECT rButton = {304, 280, 128, 24};
    cButton = Button(cWindow, rButton, "Start Meal", IDR_START_BUTTON);
    cButton.SetEnabled(0);

    //Create the listbox
    RECT rListBox = {16, 16, 272, 272};
    cListBox = ListBox(cWindow, rListBox, "MealListBox");

    //Meal wait box
    RECT rLabelDelay = {304, 16, 128, 16};
    RECT rEditDelay = {304, 32, 128, 24};
    cLabelDelay = Label(cWindow, rLabelDelay, "Meal wait (seconds)");
    cEditDelay = EditBox(cWindow, rEditDelay, "10");

    //Create Date format box
    RECT rLabelDate = {304, 64, 128, 16};
    RECT rComboDate = {304, 80, 128, 24};
    cLabelDate = Label(cWindow, rLabelDate, "Date format");
    cComboDate = ComboBox(cWindow, rComboDate, "ComboBoxDate");
    cComboDate.AddItem("12 Hour AM/PM");
    cComboDate.AddItem("24 Hour");
    cComboDate.SetDefaultItem(1);

    //Record format box
    RECT rLabelRecord = {304, 112, 128, 16};
    RECT rComboRecord = {304, 128, 128, 24};
    cLabelRecord = Label(cWindow, rLabelRecord, "Record change type");
    cComboRecord = ComboBox(cWindow, rComboRecord, "ComboBoxRecord");
    cComboRecord.AddItem("Increases");
    cComboRecord.AddItem("Decreases");
    cComboRecord.AddItem("Both");
    cComboRecord.SetDefaultItem(1);

    //Record format box
    RECT rLabelSensitivity = {304, 160, 128, 16};
    RECT rComboSensitivity = {304, 176, 128, 24};
    cLabelSensitivity = Label(cWindow, rLabelSensitivity, "Sensitivity");
    cComboSensitivity = ComboBox(cWindow, rComboSensitivity, "ComboBoxSensitivity");
    cComboSensitivity.AddItem("0.01 g");
    cComboSensitivity.AddItem("0.02 g");
    cComboSensitivity.AddItem("0.03 g");
    cComboSensitivity.AddItem("0.04 g");
    cComboSensitivity.AddItem("0.05 g");
    cComboSensitivity.AddItem("0.06 g");
    cComboSensitivity.AddItem("0.07 g");
    cComboSensitivity.AddItem("0.08 g");
    cComboSensitivity.AddItem("0.09 g");
    cComboSensitivity.SetDefaultItem(2);

    //Custom function to creeate window
    CreateWindowMenu(cWindow);

    //Message loop
    MSG msg;
    while (cWindow.GetMessage(&msg))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);
    }

    // The program return-value is 0 - The value that PostQuitMessage() gave
    return msg.wParam;
}