how to hide console or terminal

Pages: 12
Jul 3, 2013 at 11:46am
oops...

I parsed your sentence as

so we can
compile
& then
run it both in unix-like & windows platforms

But the answer really depends on what Linux required. From the Windows point of view, it's achievable if you include the WinMain stub I proposed above. That's how the cross-platform GUI toolkits Qt, wxWidgets, and FLTK do it.

Of course, you need a suitable #if test:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#ifdef _WINDOWS

// TODO
// For some reason or other Microsoft only provide the Unicode version
// of this function:
// CommandLineToArgvW function
// http://msdn.microsoft.com/en-us/library/bb776391%28VS.85%29.aspx
LPSTR* CommandLineToArgv(LPCSTR lpCmdLine, int *pNumArgs);

int CALLBACK WinMain(HINSTANCE, HINSTANCE, LPSTR lpCmdLine, int)
{
  int argc = 0;
  char* argv = CommandLineToArgv(lpCmdLine, &argc);
  return main(argc, argv);
}

#endif // _WIN32 


(Plus whatever Linux need?)

Andy
Last edited on Jul 3, 2013 at 11:50am
Jul 3, 2013 at 1:31pm
@Andy
thanks for your answer.
but as i already told i want program to be independent from any programing kind or way (like WinAPI or gtk+ or etc) or from their libraries.


maybe it's better for me to forget it
Jul 3, 2013 at 4:39pm
mokhi64 wrote:
i already told i want program to be independent from any programing kind or way
I mentioned earlier that this is not possible. You code specifically for different OSs in different #if guards like andy said.
1
2
3
4
5
6
7
8
9
#ifdef _WIN32
//do what is required for windows
#endif
#ifdef __linux__
//do what is required for linux
#endif
#ifdef __APPLE__
//OS x machines...
#endif 
Jul 5, 2013 at 6:24pm
Ok !
thank you & I accept your idea !

can i understand how ShowWindow(hwnd_win,SW_HIDE); works?
(by myself i think it should be impossible !)
Jul 5, 2013 at 7:00pm
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633548(v=vs.85).aspx

Above is the Microsoft documentation of the function.
Jul 5, 2013 at 11:30pm
@Thumper
Dear friend thanks a lot for your answers , but i wanted to see its source !( i think i had told my perspective so unclear )

I think it must be impossible, according to the Microsoft policies . isn't it?
Jul 6, 2013 at 12:06am
As others have said, the best you can probably do is use something like Qt or other similar GUI framework. Have one set of code which you can cross compile to whichever platform you want.

If all you want is the source code for ShowWindow, then WHY? Just use the function.
Jul 6, 2013 at 12:41am
I think it must be impossible, ...

(to see the Windows source code.)

Actually, it's not totally impossible. If you become a Most Valuable Professional (MVP) then it is possible obtain the right to access the Windows source code.

Andy

MVP Source Licensing Program
http://www.microsoft.com/en-us/sharedsource/mvp-source-licensing-program.aspx

Become an MVP
http://mvp.microsoft.com/en-us/becoming-an-mvp.aspx
Jul 6, 2013 at 11:21am
@TheIdeasMan
using functions without knowing them clearly, brings to me very very bad feeling !
but i'll try to get the habit ;)

=====================================================

@andywestken
thank you for your guide.
i'll try it as soon as possible !!!
Jul 6, 2013 at 3:10pm
using functions without knowing them clearly, brings to me very very bad feeling !


That's what documentation is for. The page Thumper linked to tells you exactly what the function does and how to use it.

WinAPI is a beast. If you think it'll be easier to understand the source than the documentation, you're in for a rude awakening.
Last edited on Jul 6, 2013 at 3:10pm
Topic archived. No new replies allowed.
Pages: 12