www.digitalmars.com         C & C++   DMDScript  

c++.windows.32-bits - how to close the console window

reply "¶ÎÄþÔ¶" <danny server.hftc.com> writes:
I compiled a win32 application with option -mn -WA.
But When I run this app, it first show a console window,
then show my app's main window. How can I remove the
console window?
Jul 23 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
What kind of main window does your application use?



"¶ÎÄþÔ¶" wrote:

 I compiled a win32 application with option -mn -WA.
 But When I run this app, it first show a console window,
 then show my app's main window. How can I remove the
 console window?

Jul 23 2001
parent reply "¶ÎÄþÔ¶" <danny server.hftc.com> writes:
source code show below:

/*------------------------------------------------------------
   HELLOWIN.C -- Displays "Hello, Windows 98!" in client area
                 (c) Charles Petzold, 1998
  ------------------------------------------------------------*/

#include <windows.h>

LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                    PSTR szCmdLine, int iCmdShow)
{
     static TCHAR szAppName[] = TEXT ("HelloWin") ;
     HWND         hwnd ;
     MSG          msg ;
     WNDCLASS     wndclass ;

     wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
     wndclass.lpfnWndProc   = WndProc ;
     wndclass.cbClsExtra    = 0 ;
     wndclass.cbWndExtra    = 0 ;
     wndclass.hInstance     = hInstance ;
     wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
     wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
     wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
     wndclass.lpszMenuName  = NULL ;
     wndclass.lpszClassName = szAppName ;

     if (!RegisterClass (&wndclass))
     {
          MessageBox (NULL, TEXT ("This program requires Windows NT!"),
                      szAppName, MB_ICONERROR) ;
          return 0 ;
     }
     hwnd = CreateWindow (szAppName,                  // window class name
                          TEXT ("The Hello Program"), // window caption
                          WS_OVERLAPPEDWINDOW,        // window style
                          CW_USEDEFAULT,              // initial x position
                          CW_USEDEFAULT,              // initial y position
                          CW_USEDEFAULT,              // initial x size
                          CW_USEDEFAULT,              // initial y size
                          NULL,                       // parent window
handle
                          NULL,                       // window menu handle
                          hInstance,                  // program instance
handle
                          NULL) ;                     // creation parameters

     ShowWindow (hwnd, iCmdShow) ;
     UpdateWindow (hwnd) ;

     while (GetMessage (&msg, NULL, 0, 0))
     {
          TranslateMessage (&msg) ;
          DispatchMessage (&msg) ;
     }
     return msg.wParam ;
}

LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
lParam)
{
     HDC         hdc ;
     PAINTSTRUCT ps ;
     RECT        rect ;

     switch (message)
     {
     case WM_PAINT:
          hdc = BeginPaint (hwnd, &ps) ;

          GetClientRect (hwnd, &rect) ;

          DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
                    DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
          EndPaint (hwnd, &ps) ;
          return 0 ;

     case WM_DESTROY:
          PostQuitMessage (0) ;
          return 0 ;
     }
     return DefWindowProc (hwnd, message, wParam, lParam) ;
}
Jul 23 2001
parent reply Jan Knepper <jan smartsoft.cc> writes:
OK, you are creating a GUI application and compiling it as console
application???
I don't think that really works.
I am kinda short in time today, but I posted a .DEF file and a linker line for a
GUI applications before here on the news groups.

HTH

Jan



"¶ÎÄþÔ¶" wrote:

 source code show below:

 /*------------------------------------------------------------
    HELLOWIN.C -- Displays "Hello, Windows 98!" in client area
                  (c) Charles Petzold, 1998
   ------------------------------------------------------------*/

 #include <windows.h>

 LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                     PSTR szCmdLine, int iCmdShow)
 {
      static TCHAR szAppName[] = TEXT ("HelloWin") ;
      HWND         hwnd ;
      MSG          msg ;
      WNDCLASS     wndclass ;

      wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
      wndclass.lpfnWndProc   = WndProc ;
      wndclass.cbClsExtra    = 0 ;
      wndclass.cbWndExtra    = 0 ;
      wndclass.hInstance     = hInstance ;
      wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
      wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
      wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
      wndclass.lpszMenuName  = NULL ;
      wndclass.lpszClassName = szAppName ;

      if (!RegisterClass (&wndclass))
      {
           MessageBox (NULL, TEXT ("This program requires Windows NT!"),
                       szAppName, MB_ICONERROR) ;
           return 0 ;
      }
      hwnd = CreateWindow (szAppName,                  // window class name
                           TEXT ("The Hello Program"), // window caption
                           WS_OVERLAPPEDWINDOW,        // window style
                           CW_USEDEFAULT,              // initial x position
                           CW_USEDEFAULT,              // initial y position
                           CW_USEDEFAULT,              // initial x size
                           CW_USEDEFAULT,              // initial y size
                           NULL,                       // parent window
 handle
                           NULL,                       // window menu handle
                           hInstance,                  // program instance
 handle
                           NULL) ;                     // creation parameters

      ShowWindow (hwnd, iCmdShow) ;
      UpdateWindow (hwnd) ;

      while (GetMessage (&msg, NULL, 0, 0))
      {
           TranslateMessage (&msg) ;
           DispatchMessage (&msg) ;
      }
      return msg.wParam ;
 }

 LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
 lParam)
 {
      HDC         hdc ;
      PAINTSTRUCT ps ;
      RECT        rect ;

      switch (message)
      {
      case WM_PAINT:
           hdc = BeginPaint (hwnd, &ps) ;

           GetClientRect (hwnd, &rect) ;

           DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
                     DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
           EndPaint (hwnd, &ps) ;
           return 0 ;

      case WM_DESTROY:
           PostQuitMessage (0) ;
           return 0 ;
      }
      return DefWindowProc (hwnd, message, wParam, lParam) ;
 }

Jul 24 2001
parent reply "¶ÎÄþÔ¶" <danny server.hftc.com> writes:
But can you tell me where to find it?

Jan Knepper <jan smartsoft.cc> wrote in message
news:3B5D6647.960E5786 smartsoft.cc...
 OK, you are creating a GUI application and compiling it as console
 application???
 I don't think that really works.
 I am kinda short in time today, but I posted a .DEF file and a linker line

 GUI applications before here on the news groups.

 HTH

 Jan



 "¶ÎÄþÔ¶" wrote:

 source code show below:

 /*------------------------------------------------------------
    HELLOWIN.C -- Displays "Hello, Windows 98!" in client area
                  (c) Charles Petzold, 1998
   ------------------------------------------------------------*/

 #include <windows.h>

 LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                     PSTR szCmdLine, int iCmdShow)
 {
      static TCHAR szAppName[] = TEXT ("HelloWin") ;
      HWND         hwnd ;
      MSG          msg ;
      WNDCLASS     wndclass ;

      wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
      wndclass.lpfnWndProc   = WndProc ;
      wndclass.cbClsExtra    = 0 ;
      wndclass.cbWndExtra    = 0 ;
      wndclass.hInstance     = hInstance ;
      wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
      wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
      wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
      wndclass.lpszMenuName  = NULL ;
      wndclass.lpszClassName = szAppName ;

      if (!RegisterClass (&wndclass))
      {
           MessageBox (NULL, TEXT ("This program requires Windows NT!"),
                       szAppName, MB_ICONERROR) ;
           return 0 ;
      }
      hwnd = CreateWindow (szAppName,                  // window class


                           TEXT ("The Hello Program"), // window caption
                           WS_OVERLAPPEDWINDOW,        // window style
                           CW_USEDEFAULT,              // initial x


                           CW_USEDEFAULT,              // initial y


                           CW_USEDEFAULT,              // initial x size
                           CW_USEDEFAULT,              // initial y size
                           NULL,                       // parent window
 handle
                           NULL,                       // window menu


                           hInstance,                  // program


 handle
                           NULL) ;                     // creation


      ShowWindow (hwnd, iCmdShow) ;
      UpdateWindow (hwnd) ;

      while (GetMessage (&msg, NULL, 0, 0))
      {
           TranslateMessage (&msg) ;
           DispatchMessage (&msg) ;
      }
      return msg.wParam ;
 }

 LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
 lParam)
 {
      HDC         hdc ;
      PAINTSTRUCT ps ;
      RECT        rect ;

      switch (message)
      {
      case WM_PAINT:
           hdc = BeginPaint (hwnd, &ps) ;

           GetClientRect (hwnd, &rect) ;

           DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
                     DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
           EndPaint (hwnd, &ps) ;
           return 0 ;

      case WM_DESTROY:
           PostQuitMessage (0) ;
           return 0 ;
      }
      return DefWindowProc (hwnd, message, wParam, lParam) ;
 }


Jul 24 2001
parent reply Arjan Knepper <arjan jak.nl> writes:
Search c++ newsgroup for this thread.

Good Luck
Arjan

-------- Original Message --------
Subject: The Console window while running a Win32 Program
Date: Thu, 19 Apr 2001 07:11:03 +0530
From: "pramod" <pramod_sx rediffmail.com>
Organization: Digital Mars
Newsgroups: c++

How can you get rid of that console window (the place where the printf's and
scanf's go) when you're creating an exclusive GUI app that doesn't need one
?

"¶ÎÄþÔ¶" wrote:

 But can you tell me where to find it?

 Jan Knepper <jan smartsoft.cc> wrote in message
 news:3B5D6647.960E5786 smartsoft.cc...
 OK, you are creating a GUI application and compiling it as console
 application???
 I don't think that really works.
 I am kinda short in time today, but I posted a .DEF file and a linker line

 GUI applications before here on the news groups.

 HTH

 Jan



 "¶ÎÄþÔ¶" wrote:

 source code show below:

 /*------------------------------------------------------------
    HELLOWIN.C -- Displays "Hello, Windows 98!" in client area
                  (c) Charles Petzold, 1998
   ------------------------------------------------------------*/

 #include <windows.h>

 LRESULT CALLBACK WndProc (HWND, UINT, WPARAM, LPARAM) ;

 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance,
                     PSTR szCmdLine, int iCmdShow)
 {
      static TCHAR szAppName[] = TEXT ("HelloWin") ;
      HWND         hwnd ;
      MSG          msg ;
      WNDCLASS     wndclass ;

      wndclass.style         = CS_HREDRAW | CS_VREDRAW ;
      wndclass.lpfnWndProc   = WndProc ;
      wndclass.cbClsExtra    = 0 ;
      wndclass.cbWndExtra    = 0 ;
      wndclass.hInstance     = hInstance ;
      wndclass.hIcon         = LoadIcon (NULL, IDI_APPLICATION) ;
      wndclass.hCursor       = LoadCursor (NULL, IDC_ARROW) ;
      wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH) ;
      wndclass.lpszMenuName  = NULL ;
      wndclass.lpszClassName = szAppName ;

      if (!RegisterClass (&wndclass))
      {
           MessageBox (NULL, TEXT ("This program requires Windows NT!"),
                       szAppName, MB_ICONERROR) ;
           return 0 ;
      }
      hwnd = CreateWindow (szAppName,                  // window class


                           TEXT ("The Hello Program"), // window caption
                           WS_OVERLAPPEDWINDOW,        // window style
                           CW_USEDEFAULT,              // initial x


                           CW_USEDEFAULT,              // initial y


                           CW_USEDEFAULT,              // initial x size
                           CW_USEDEFAULT,              // initial y size
                           NULL,                       // parent window
 handle
                           NULL,                       // window menu


                           hInstance,                  // program


 handle
                           NULL) ;                     // creation


      ShowWindow (hwnd, iCmdShow) ;
      UpdateWindow (hwnd) ;

      while (GetMessage (&msg, NULL, 0, 0))
      {
           TranslateMessage (&msg) ;
           DispatchMessage (&msg) ;
      }
      return msg.wParam ;
 }

 LRESULT CALLBACK WndProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM
 lParam)
 {
      HDC         hdc ;
      PAINTSTRUCT ps ;
      RECT        rect ;

      switch (message)
      {
      case WM_PAINT:
           hdc = BeginPaint (hwnd, &ps) ;

           GetClientRect (hwnd, &rect) ;

           DrawText (hdc, TEXT ("Hello, Windows 98!"), -1, &rect,
                     DT_SINGLELINE | DT_CENTER | DT_VCENTER) ;
           EndPaint (hwnd, &ps) ;
           return 0 ;

      case WM_DESTROY:
           PostQuitMessage (0) ;
           return 0 ;
      }
      return DefWindowProc (hwnd, message, wParam, lParam) ;
 }



Jul 25 2001
parent reply "danny" <danny server.hftc.com> writes:
 Subject: The Console window while running a Win32 Program
 Date: Thu, 19 Apr 2001 07:11:03 +0530
 From: "pramod" <pramod_sx rediffmail.com>
 Organization: Digital Mars
 Newsgroups: c++

 How can you get rid of that console window (the place where the printf's

 scanf's go) when you're creating an exclusive GUI app that doesn't need

 ?

 "¶ÎÄþÔ¶" wrote:

 But can you tell me where to find it?

 Jan Knepper <jan smartsoft.cc> wrote in message
 news:3B5D6647.960E5786 smartsoft.cc...
 OK, you are creating a GUI application and compiling it as console
 application???
 I don't think that really works.
 I am kinda short in time today, but I posted a .DEF file and a linker



 for a
 GUI applications before here on the news groups.



MS document and books about win32 programing said it dosen't need the .DEF file while developing win32 program. Why not get rid of it in dmC++?
Dec 26 2001
parent "Walter" <walter digitalmars.com> writes:
"danny" <danny server.hftc.com> wrote in message
news:a0e0vd$1m5v$1 digitaldaemon.com...
 MS document and books about win32 programing said it dosen't need the .DEF
 file while developing win32 program.
 Why not get rid of it in dmC++?

The development tools are set up to make use of them. There is not a compelling enough reason to risk destabilizing them.
Dec 27 2001