Join 131,648 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 3,205 people online right now. Registration is fast and FREE... Join Now!
/* 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; }
EDIT: Ok, I don't understand the first time I had no DOS box. I re-compiled it and I did. I re-compiled it again and I now I don't?
This post has been edited by Israel: 13 Dec, 2005 - 02:47 AM
I understood C++ is more or less just and extention of C. I still don't make the connection that Win32 in not script? If you mean it's not a scripting language like html or php and more of a real programming langauge like C or Java I'll agree with you. But when I write programs (small and basic as they may be..) I call them scripts. I've heard other people refer to running .exe files and others as "running a script". Maybe I'm just around hacks with bad diction but what are you really trying to say? (just to educate me).
I am sure this will set of a storm of contoversy, but the short answer is this:
If the code is being run by a scripting engine (cShell, BASH, PHP Interpreter, etc...) then it is a script.
If the code is compiled by a compiler and linker, then it is generally not referred to as a script.
Those, of course, are strict definitions...in the real world of today, almost any piece of programming that is native to the machine (i.e. not an application that has been compiled elsewhere and installed on the machine) is referred to as a script.
Who's to say who's right or wrong in this crazy mixed up world of ours?
And just to be picky, HTML is not a scripting language, and C++ is not an extension of C...it is a full language, complete with specifications, that was loosely based on C and incorporates it's concepts. It would be better to refer to C++ as a superset of C.
Cue the angry responses, insults, self righteous debaters, and purveyors of links to sites that claim to have the true definitions!
I am sure this will set of a storm of contoversy, but the short answer is this:
If the code is being run by a scripting engine (cShell, BASH, PHP Interpreter, etc...) then it is a script.
If the code is compiled by a compiler and linker, then it is generally not referred to as a script.
Those, of course, are strict definitions...in the real world of today, almost any piece of programming that is native to the machine (i.e. not an application that has been compiled elsewhere and installed on the machine) is referred to as a script.
Who's to say who's right or wrong in this crazy mixed up world of ours?
And just to be picky, HTML is not a scripting language, and C++ is not an extension of C...it is a full language, complete with specifications, that was loosely based on C and incorporates it's concepts. It would be better to refer to C++ as a superset of C.
Cue the angry responses, insults, self righteous debaters, and purveyors of links to sites that claim to have the true definitions!
Very nicely said, couldnt have said it better myself.
EDITED whats wrong with my typing today, like wtf.
This post has been edited by Mrafcho001: 15 Dec, 2005 - 11:52 AM
I agree with Amadeus for the most part .. as far as HTML and the like go; I personally refer to any interpreted language as script I tend to include mark up languages like HTML , SGML and XML in the same category as scripting languages like VBSCRIPT JSCRIPT etc .. Although I can definately see where some ppl wouldnt .. anyway short answer is I agree with his statement.
but the main reason for posting a reply in this thread is to elaborate a little on "Win32 is not script" This in my opinion is 100% correct ..
<MY OPINION>
Win32 is a platform for programming. when people reffer to Win32 from a programming standpoint they are almost always reffering to the Win32 API (application programming interface) wich is a set of functions , structures, and data types that are for the most part written in c/c++ they are just functions that the OS exposes for you to use to perform everyday jobs, like file functions , setting the wallpaper etc etc .. the list is huge .. and lets not forget one of the most commonly used Win32 APIs CreateWindow() this function is actually part of windows you just use it in your programs to create the UI .. from the main window to the text boxes you type in .. right down to the buttons that you click .. Even in "DOS" or console applications you still have a good chunck of the Win32 API at your disposal. so you could even go as far as to say Win32 is a style of programming but definately not scripting (shell scripting is a differnt matter)
</MY OPINION>
anyway Ive rambled on enough .. I hope at least some of this post was releavent. I just love working with the Win32 API so much I cant bear to see it reffered to as script with out at least getting a comment in there lol it just seems to trivialize it lol
Anyway as for the original post I cant see anything in that code that should produce a console window under any circumstance its a generic template for a windows app ... wonder if its possible there were two projects open and a console app was inadvertantly compiled the second time ..
Well a rather incoherent first post I promise not all posts will be this muddled lol by the way nice forum you guys have here.
I agree with Amadeus for the most part .. as far as HTML and the like go; I personally refer to any interpreted language as script I tend to include mark up languages like HTML , SGML and XML in the same category as scripting languages like VBSCRIPT JSCRIPT etc .. Although I can definately see where some ppl wouldnt .. anyway short answer is I agree with his statement.
but the main reason for posting a reply in this thread is to elaborate a little on "Win32 is not script" This in my opinion is 100% correct ..
<MY OPINION>
Win32 is a platform for programming. when people reffer to Win32 from a programming standpoint they are almost always reffering to the Win32 API (application programming interface) wich is a set of functions , structures, and data types that are for the most part written in c/c++ they are just functions that the OS exposes for you to use to perform everyday jobs, like file functions , setting the wallpaper etc etc .. the list is huge .. and lets not forget one of the most commonly used Win32 APIs CreateWindow() this function is actually part of windows you just use it in your programs to create the UI .. from the main window to the text boxes you type in .. right down to the buttons that you click .. Even in "DOS" or console applications you still have a good chunck of the Win32 API at your disposal. so you could even go as far as to say Win32 is a style of programming but definately not scripting (shell scripting is a differnt matter)
</MY OPINION>
anyway Ive rambled on enough .. I hope at least some of this post was releavent. I just love working with the Win32 API so much I cant bear to see it reffered to as script with out at least getting a comment in there lol it just seems to trivialize it lol
Anyway as for the original post I cant see anything in that code that should produce a console window under any circumstance its a generic template for a windows app ... wonder if its possible there were two projects open and a console app was inadvertantly compiled the second time ..
Well a rather incoherent first post I promise not all posts will be this muddled lol by the way nice forum you guys have here.
Just for a little more clarification, Win32 APIs are written in C only no C++. MFC is written in C++, but its just Win32 APIs wrapped into classes.
QUOTE
I just love working with the Win32 API so much I cant bear to see it reffered to as script with out at least getting a comment in there lol it just seems to trivialize it lol