HWND of console

Started by
27 comments, last by G a m e D e v 22 years, 8 months ago
Is there any way to get the HWND of a win32 console window?
"Beware of computer programmers that carry screw drivers"
Advertisement
The console window was never really meant to be "known about" by the program running in it. It''s basically an emulator of the old DOS system. I suppose that it''s theoretically possible to query the system and find the process to pull out the HWND, but I really can''t see why you''d ever want to do that.

What exactly are you trying to accomplish?

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Actually, you should create a normal Win32 Application project (if you''re using MSVC) and set up your own console window. i remember seeing it in the MSDN sample application for __beginthread and __endthread. It''s way more powerful and flexible. I''m too far away from my own computer to provide more info and too lazy to check MSDN online.
GetStdHandle()
Im trying to use DirectX with a console window. I found a function for getting the HWND but it only works with Windows 2000. Is there a way to do it that would work on most versions of windows?
"Beware of computer programmers that carry screw drivers"
You should probably be using a Win32 application rather than a console then, you''re going to be needing a lot more control than a console is capable of giving you.

The console is more or less meant for text-based programs that don''t require any windows support.

-fel
~ The opinions stated by this individual are the opinions of this individual and not the opinions of her company, any organization she might be part of, her parrot, or anyone else. ~
Use SetConsoleTitle() to make the title (temporarily) something wierd, then use FindWindow() to get the HWND, then set it back.
It doesn''t really matter if your application is a console application or a windows application. If it''s a conolse application, you can still call all the regular windows functions (CreateWindow, et al) and a windows application can still use a console (but it just has to call AllocConsole() first).

The onle difference between the two is the entry point. A console application''s entry point is main() and a windows'' one is WinMain().

War Worlds - A 3D Real-Time Strategy game in development.
Incidentally, the console is a kernel object and is not owned by your application, so there may be a restriction on what you can do with the window, or else you could mess up the kernel.
VK
quote:Original post by GayleSaver
Incidentally, the console is a kernel object and is not owned by your application, so there may be a restriction on what you can do with the window, or else you could mess up the kernel.


If you try to mess with the console it might work on 9x but it''ll most likely crash in windows NT/2000. Stick to Win32 Applications, unless you''re using glut(which, since you said you''re using dx, is very unlikely).

This topic is closed to new replies.

Advertisement