I am just messin around with this "A Simple Win32 GUI Introduction" snippet I found on this site. I am able to paste it in to a simple project in my Visual C++ application and run it. Basically it is just a blank window. It says you can play around with it, and I did figure out how to change the Title. But what else can we do with this? I have a simple console application that I wrote that calculates two resistors in parallel.

#include <iostream>
using namespace std;

int main()
    int R1, R2;
    float Rpar;
    cout << "Enter the value for R1: " ;
    cin >> R1;
    cout << "Enter the value for R2: ";
    cin >> R2;
    Rpar = (R1 * R2) / (R1 + R2);
    cout <<"The value of parallel resistance is: " << Rpar << "\n";
    system ("pause");
    return 0;

Here is the Snippet

#include <windows.h> /* Windows header */

char szClassName[ ] = "WindowsApp";   /* Class ID */

WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)

        HWND hwnd;
        MSG messages;
        WNDCLASSEX wincl;

        wincl.hInstance = hThisInstance;
        wincl.lpszClassName = szClassName;
        wincl.lpfnWndProc = WindowProcedure; /* See end of code */
        wincl.style = CS_DBLCLKS;
        wincl.cbSize = sizeof (WNDCLASSEX);
        wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
        wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
        wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
        wincl.lpszMenuName = NULL;
        wincl.cbClsExtra = 0;
        wincl.cbWndExtra = 0;
        wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND; /* Default windows background colour */

        if (!RegisterClassEx (&wincl))
        return 0;

        hwnd = CreateWindowEx (
        szClassName,         /* Classname */
        "Windows App",       /* Title Text */
        CW_USEDEFAULT,       /* Default x... */
        CW_USEDEFAULT,       /* ...and default y position of window */
        640,                 /* The programs width... */
        480,                 /* ...and height in pixels */

        /* Make the window visible on the screen */
        ShowWindow (hwnd, nFunsterStil);
        while (GetMessage (&messages, NULL, 0, 0))

        /* Return: wParam from a quit message usually = 0 */
        return messages.wParam;

WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{ /* Called when window processes a message */
        switch (message)
                case WM_DESTROY: /* Destoy message: called if you press the "x" in the top right corner */
                PostQuitMessage (0); /* Send a message to quit */
                return DefWindowProc (hwnd, message, wParam, lParam);
        return 0;

Can this be incorporated into this window, and not disappear after hitting any key?

Just playin around. Oh Yes! How do you change the background color?

any help would be appreciated

ThanX BandM

Just a hint, on your parallel resistor calculator declare both R1 and R2 as a float or something like:

R1 = 1
R2 = 2

will give you a parallel resistance of 0

BTW, the Windows snippet you have is the one that comes up with DevCpp when you create a Windows Application. You need to add EditBoxes for data entry and output, also a button to click to do your calculations. The easiest way to do all of this is with a form builder in visual studio. The problem there is, that your total code is now scattered across several goofy sounding files.

Plotzki schmotzki!

This question has already been answered. Start a new discussion instead.