Welcome to Dream.In.Code
Getting C++ Help is Easy!

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!




Drop the Dos Box w/ Win32 script

 
Reply to this topicStart new topic

Drop the Dos Box w/ Win32 script, Drop the Dos Box w/ Win32 script

Israel
post 13 Dec, 2005 - 01:08 AM
Post #1


D.I.C Addict

Group Icon
Joined: 21 Nov, 2004
Posts: 595



Dream Kudos: 175
My Contributions


Trying get rid of this DOS box with this script. Any suggestions?

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;
}


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
User is offlineProfile CardPM

Go to the top of the page


Mrafcho001
post 13 Dec, 2005 - 03:14 PM
Post #2


D.I.C Addict

Group Icon
Joined: 1 Nov, 2005
Posts: 753



Thanked 5 times

Dream Kudos: 120
My Contributions


everything seems to work just fine. Make sure you are compiling a Win32 project, not a win32 console.

Win32 is not script by the way.

also check out ths snippet, see whats different, but it should work just fine.

http://code.dreamincode.net/snippet305.htm
User is offlineProfile CardPM

Go to the top of the page

Israel
post 13 Dec, 2005 - 11:36 PM
Post #3


D.I.C Addict

Group Icon
Joined: 21 Nov, 2004
Posts: 595



Dream Kudos: 175
My Contributions


Win32 is not script?
User is offlineProfile CardPM

Go to the top of the page

Mrafcho001
post 14 Dec, 2005 - 01:21 PM
Post #4


D.I.C Addict

Group Icon
Joined: 1 Nov, 2005
Posts: 753



Thanked 5 times

Dream Kudos: 120
My Contributions


No its rather an extension of C.
User is offlineProfile CardPM

Go to the top of the page

Israel
post 15 Dec, 2005 - 01:42 AM
Post #5


D.I.C Addict

Group Icon
Joined: 21 Nov, 2004
Posts: 595



Dream Kudos: 175
My Contributions


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). rolleyes.gif
User is offlineProfile CardPM

Go to the top of the page

Amadeus
post 15 Dec, 2005 - 03:26 AM
Post #6


g++ -o drink whiskey.cpp

Group Icon
Joined: 12 Jul, 2002
Posts: 12,163



Thanked 32 times

Dream Kudos: 25
My Contributions


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! smile.gif
User is online!Profile CardPM

Go to the top of the page

Mrafcho001
post 15 Dec, 2005 - 11:16 AM
Post #7


D.I.C Addict

Group Icon
Joined: 1 Nov, 2005
Posts: 753



Thanked 5 times

Dream Kudos: 120
My Contributions


QUOTE(Amadeus @ 15 Dec, 2005 - 05:23 AM)
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! smile.gif

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
User is offlineProfile CardPM

Go to the top of the page

Israel
post 15 Dec, 2005 - 11:47 AM
Post #8


D.I.C Addict

Group Icon
Joined: 21 Nov, 2004
Posts: 595



Dream Kudos: 175
My Contributions


QUOTE
Cue the angry responses, insults, self righteous debaters, and purveyors of links to sites that claim to have the true definitions! smile.gif


Nope no debating.... gotta agree that was nicely put. I've never really used C so that was just my best understanding. Thanks for the clarity!
User is offlineProfile CardPM

Go to the top of the page

hippocrat
post 29 Dec, 2005 - 07:49 PM
Post #9


New D.I.C Head

*
Joined: 29 Dec, 2005
Posts: 1


My Contributions


Just my two cents


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.
User is offlineProfile CardPM

Go to the top of the page

Mrafcho001
post 29 Dec, 2005 - 08:40 PM
Post #10


D.I.C Addict

Group Icon
Joined: 1 Nov, 2005
Posts: 753



Thanked 5 times

Dream Kudos: 120
My Contributions


QUOTE(hippocrat @ 29 Dec, 2005 - 09:46 PM)
Just my two cents


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


Feel the exact same way!
User is offlineProfile CardPM

Go to the top of the page

Reply to this topicStart new topic
Time is now: 11/20/08 06:22AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

Bye Bye Ads

Free DIC T-Shirt

T-Shirt Example

Related Sites

Monthly Drawing

Thumb Drive

Partners

Top Contributors

Top 10 Kudos This Month