Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 where to put code?
Index -> Programming, C++ -> C++ Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
apomb




PostPosted: Tue Oct 12, 2004 11:26 am   Post subject: where to put code?

me again ... with a very noob question. i am using devC++ on windows Me, where do i put the code to execute in a windows applicatoin window

code:

#include <windows.h>


/*  Declare Windows procedure  */
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);

/*  Make the class name into a global variable  */
char szClassName[ ] = "WindowsApp";


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

{
    HWND hwnd;               /* This is the handle for our window */
    MSG messages;            /* Here messages to the application are saved */
    WNDCLASSEX wincl;        /* Data structure for the windowclass */

    /* The Window structure */
    wincl.hInstance = hThisInstance;
    wincl.lpszClassName = szClassName;
    wincl.lpfnWndProc = WindowProcedure;      /* This function is called by windows */
    wincl.style = CS_DBLCLKS;                 /* Catch double-clicks */
    wincl.cbSize = sizeof (WNDCLASSEX);

    /* Use default icon and mouse-pointer */
    wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
    wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
    wincl.lpszMenuName = NULL;                 /* No menu */
    wincl.cbClsExtra = 0;                      /* No extra bytes after the window class */
    wincl.cbWndExtra = 0;                      /* structure or the window instance */
    /* Use Windows's default color as the background of the window */
    wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;

    /* Register the window class, and if it fails quit the program */
    if (!RegisterClassEx (&wincl))
        return 0;

    /* The class is registered, let's create the program*/
    hwnd = CreateWindowEx (
           0,                   /* Extended possibilites for variation */
           szClassName,         /* Classname */
           "Windows App",       /* Title Text */
           WS_OVERLAPPEDWINDOW, /* default window */
           CW_USEDEFAULT,       /* Windows decides the position */
           CW_USEDEFAULT,       /* where the window ends up on the screen */
           544,                 /* The programs width */
           375,                 /* and height in pixels */
           HWND_DESKTOP,        /* The window is a child-window to desktop */
           NULL,                /* No menu */
           hThisInstance,       /* Program Instance handler */
           NULL                 /* No Window Creation data */
           );

    /* Make the window visible on the screen */
    ShowWindow (hwnd, nFunsterStil);

    /* Run the message loop. It will run until GetMessage() returns 0 */
    while (GetMessage (&messages, NULL, 0, 0))
    {
        /* Translate virtual-key messages into character messages */
        TranslateMessage(&messages);
        /* Send message to WindowProcedure */
        DispatchMessage(&messages);
    }

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


/*  This function is called by the Windows function DispatchMessage()  */

LRESULT CALLBACK
WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)                  /* handle the messages */
    {
        case WM_DESTROY:
            PostQuitMessage (0);       /* send a WM_QUIT to the message queue */
            break;
        default:                      /* for messages that we don't deal with */
            return DefWindowProc (hwnd, message, wParam, lParam);
    }

    return 0;
}


in here, where do i put the stuff to execute?
Sponsor
Sponsor
Sponsor
sponsor
Andy




PostPosted: Tue Oct 12, 2004 4:50 pm   Post subject: (No subject)

hmmm if u claim to be a noob, then y rnt u using console application? for windows applications, the code goes in winmain
wtd




PostPosted: Tue Oct 12, 2004 5:26 pm   Post subject: (No subject)

Indeed. Console applications can push your basic programming skills pretty far.

To do more graphical stuff on Windows, I would advise you to stay away from the Win32 API. Microsoft has all but abandoned it and declared that .NET is the way to go.

If you can't use Microsoft's own tools on your computer (with Windows ME), I suggest grabbing a copy of Mono.

D'oh! Mono's only available for Windows 2000 or later.

Well, there's always Java, which is still world's better than Win32. Smile
rizzix




PostPosted: Tue Oct 12, 2004 6:41 pm   Post subject: (No subject)

wht? mono's only for win2k? well.. there's always dotgnu.. but i think it only supports c# and c.. in anycase.. yep the world prefers java.

i think the main reason people want a port of the .NET framework is cuz of the VB.NET.. lame.. but yea.


and another good think (i guess) of dotgnu is the fact that it can compile stuff into java bytecode instead if you prefer so.
wtd




PostPosted: Tue Oct 12, 2004 7:23 pm   Post subject: (No subject)

Unfortunately, if you're planning to concentrate on Windows programming, C# and .NET are a far more practical way to go than Java.
wtd




PostPosted: Tue Oct 12, 2004 7:32 pm   Post subject: (No subject)

rizzix wrote:
wht? mono's only for win2k?


NT4 and Win9x are just too old, apparently.

Oh, and if you plan to write GTK# programs, I think you need the GTK+ libraries installed. Installing The GIMP for Windows is probably the best way.
Andy




PostPosted: Tue Oct 12, 2004 7:50 pm   Post subject: (No subject)

i think its time u get a copy of vc compwiz
apomb




PostPosted: Tue Oct 12, 2004 10:52 pm   Post subject: (No subject)

see, im such a noob, i dont know what kind of applications to write! haha i dont know why i want to write windows applications, mabe cuz it looks kool, but i thought that is what most people make, any way i am going to be learning C++ next semester, but wanted to get a head start during spare and stuff, so ya, then console applications eh? i see now, thanx guys.

if i have time ... ya right... ill check out some of the .NET stuff ... for personal use ... ha riiiight Rolling Eyes
Sponsor
Sponsor
Sponsor
sponsor
wtd




PostPosted: Tue Oct 12, 2004 11:31 pm   Post subject: (No subject)

It probably is what most people are using right now. But by the time you get to be any good at it, that will have changed dramatically. Smile
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: