Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

hide the dos windows when my application is launched

Posted on 2008-10-09
16
Medium Priority
?
419 Views
Last Modified: 2008-10-10
Hello Experts
how can i hide my dos windows when my application is running?
I am using Dev c++ as compiler
i tried
int WINAPI WinMain (HINSTANCE,  HINSTANCE, LPSTR, int)

 my code here

return 0;

but it seems not working yet
0
Comment
Question by:kagami01
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 6
  • 2
  • +1
16 Comments
 
LVL 31

Expert Comment

by:Zoppo
ID: 22677705
Hi kagami01,

I'm not sure if this works, but you can give it a try: With 'GetConsoleWindow' you should be able to retrieve the HWND of the DOS-window, then you can ShowWindow( ..., SW_HIDE ); to hide it.

Hope that helps,

ZOPPO
0
 

Author Comment

by:kagami01
ID: 22677733
you mean like the code below here:
int WINAPI WinMain( HINSTANCE,  HINSTANCE, LPSTR, int)
 
 
{
  
  HWND Console;             
  AllocConsole ();
  Console=FindWindowA ("ConsoleWindowClass",NULL);
  ShowWindow (Console,SW_HIDE);
 
 
 my other c++ code here
 
 
 return 0;
}

Open in new window

0
 
LVL 31

Expert Comment

by:Zoppo
ID: 22677755
Yes, it might be this works (never tried this before, so I'm not sure) ...
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 

Author Comment

by:kagami01
ID: 22677787
maybe i's ok but it's not running on vista
anywya any other solutins beside that?
0
 
LVL 13

Expert Comment

by:Mark_FreeSoftware
ID: 22678175
set your project type to a normal windows application instead of a console application
0
 

Author Comment

by:kagami01
ID: 22678447
already settled to windows application but i didn't marked the "XP teme" option
anyway it's not working yet on Vista
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 720 total points
ID: 22678531
Sorry, seems I didn't read you code-snippet carefully - you use 'FindWindowA', but I suggested to use 'GetConsoleWindow'.

So, it should be:

HWND console = GetConsoleWindow();
if ( NULL != console )
{
 ::ShowWindow( console, SW_HIDE );
}

ZOPPO
0
 

Author Comment

by:kagami01
ID: 22679424
that code has caused many erros while the compiling
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 22679493
Hm - to get 'GetConsoleWindow' compiled you need to define _WIN32_WINNT as 0x0500 or to retrieve the function pointer 'manually' using LoadLibrary and GetProcAddress.
0
 

Author Comment

by:kagami01
ID: 22679504
i have dev c ++ plus as compiler how can i fix it?
0
 

Author Comment

by:kagami01
ID: 22679538
i got this error:

`GetConsoleWindow' undeclared (first use this function)
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 22679546
I'm not sure since I never used dev c++ - anyway, LoadLibrary and GetProcAddress are Win32-API functions, so you should be able to use them ...
0
 
LVL 31

Expert Comment

by:Zoppo
ID: 22679667
Yes, you get this since either you have a old SDK or _WIN32_WINNT is less than 0x0500.
0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 22679681
>>>> how can i hide my dos windows when my application is running?
How do you invoke your application?

Should it run in background with no user interface? Or does it has a window to show? Or do you start it in a console (DOS Box) and you don't want a further console to pop-up?
0
 

Author Comment

by:kagami01
ID: 22679974
Dear Zoppo you were right i forgot the put
 #define _WIN32_WINNT 0x500 before the #include <windows.h>
 and i added in dev c++ in "tools"--->"option compilation"--> "-lgdi32"
so the i compiled the exe without problem and it worked for win vista thank you so much Zoppo.

question?!?!?!

i got a file after the compiling like follow:

Myapplication.exe.Manifest

i need it in in where the .exe folder is  or not??

0
 
LVL 39

Expert Comment

by:itsmeandnobodyelse
ID: 22680473
>>>> i need it in in where the .exe folder is  or not??
Yes. The .manifest is some kind of configuration file where parts of the information was stored that formerly was in Windows registry.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Script Host (WSH) has been part of Windows since Windows NT4. Windows Script Host provides architecture for building dynamic scripts that consist of a core object model, scripting hosts, and scripting engines. The key components of Window…
If you haven’t already, I encourage you to read the first article (http://www.experts-exchange.com/articles/18680/An-Introduction-to-R-Programming-and-R-Studio.html) in my series to gain a basic foundation of R and R Studio.  You will also find the …
This video teaches viewers about errors in exception handling.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

722 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question