simple c programming gui

Viewed 7516

I developed the steam table equation solver in C language...but the inputing the values in black screen console is boring.

So I strictly wanted to create simple GUI in C.

I searched for hello world codes, all were pretty long. But this was the only one I understood.

#include <windows.h>

int main()
{
MessageBoxA( NULL, "Hello World!", "Hello", MB_OK );
}

By using a gui builder for C, i got this code, now I was thinking how to scan values from TEXTBOX1 and TEXTBOX2 on Clicking of COMMANDBUTTON1 and display the output in TEXTBOX3?

#define WIN32_LEAN_AND_MEAN

#include <windows.h>
#include <windowsx.h>
#include <commctrl.h>
#include "hello.auto.h"


HWND hwnd_Label1, hwnd_Label2, hwnd_TextBox1, hwnd_TextBox2, hwnd_CommandButton1,
hwnd_TextBox3;

HFONT MSSansSerif_8pt;



void CreateChildWindows(HWND hwndMainWindow, HINSTANCE hInstance)
{
InitCommonControls();

MSSansSerif_8pt = CreateFont(-11,0,0,0,FW_NORMAL,0,0,0,0,0,0,0,0,"MS Sans Serif");

hwnd_Label1 = CreateWindowEx(0, "Static", "Pressure",
    WS_CHILD | WS_VISIBLE,
    11, 55, 95, 38, hwndMainWindow,
    (HMENU)Label1, hInstance, NULL);

SetWindowFont(hwnd_Label1, MSSansSerif_8pt, TRUE);

hwnd_Label2 = CreateWindowEx(0, "Static", "Temperature",
    WS_CHILD | WS_VISIBLE,
    11, 110, 95, 38, hwndMainWindow,
    (HMENU)Label2, hInstance, NULL);

SetWindowFont(hwnd_Label2, MSSansSerif_8pt, TRUE);

hwnd_TextBox1 = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit" , NULL,
    WS_CHILD | ES_WANTRETURN | WS_VISIBLE,
    187, 55, 83, 35, hwndMainWindow,
    (HMENU)TextBox1, hInstance, NULL);

SetWindowFont(hwnd_TextBox1, MSSansSerif_8pt, TRUE);

hwnd_TextBox2 = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit" , NULL,
    WS_CHILD | ES_WANTRETURN | WS_VISIBLE,
    187, 99, 83, 35, hwndMainWindow,
    (HMENU)TextBox2, hInstance, NULL);

SetWindowFont(hwnd_TextBox2, MSSansSerif_8pt, TRUE);

hwnd_CommandButton1 = CreateWindowEx(0, "Button", "CommandButton1",
    WS_CHILD | BS_MULTILINE | BS_PUSHBUTTON | WS_VISIBLE,
    308, 77, 117, 52, hwndMainWindow,
    (HMENU)CommandButton1, hInstance, NULL);


SetWindowFont(hwnd_CommandButton1, MSSansSerif_8pt, TRUE);

hwnd_TextBox3 = CreateWindowEx(WS_EX_CLIENTEDGE, "Edit" , NULL,
    WS_CHILD | ES_WANTRETURN | WS_VISIBLE,
    66, 220, 385, 35, hwndMainWindow,
    (HMENU)TextBox3, hInstance, NULL);

SetWindowFont(hwnd_TextBox3, MSSansSerif_8pt, TRUE);

return;
}



HWND GetItem(int nIDDlgItem)
{
switch(nIDDlgItem)
{
    case -1:
        return GetParent(hwnd_Label1);
    case Label1:
        return hwnd_Label1;
    case Label2:
        return hwnd_Label2;
    case TextBox1:
        return hwnd_TextBox1;
    case TextBox2:
        return hwnd_TextBox2;
    case CommandButton1:
        return hwnd_CommandButton1;
    case TextBox3:
        return hwnd_TextBox3;
    default: return NULL;
}
}



void Form_Unload(HWND hMainWnd)
{
DeleteFont(MSSansSerif_8pt);
return;
}

I tried many times, but failed. Even if you people give me links of good sites, then I will be greatful.

2 Answers
Related