comp.lang.ada
 help / color / mirror / Atom feed
* HWND of the console
@ 2005-06-24 13:56 Sylvain
  2005-06-24 14:25 ` Adrien Plisson
  2005-06-25  1:46 ` Steve
  0 siblings, 2 replies; 5+ messages in thread
From: Sylvain @ 2005-06-24 13:56 UTC (permalink / raw)


Hi,
Can you give me a piece of code which give me the HWND of the current
console window given by default by Adagide in the Gnat environment
with the only add-on called "Win32ADA", please.


Thank you ! Bye !



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: HWND of the console
  2005-06-24 13:56 HWND of the console Sylvain
@ 2005-06-24 14:25 ` Adrien Plisson
  2005-06-25  1:46 ` Steve
  1 sibling, 0 replies; 5+ messages in thread
From: Adrien Plisson @ 2005-06-24 14:25 UTC (permalink / raw)


Sylvain wrote:
> Hi,
> Can you give me a piece of code which give me the HWND of the current
> console window given by default by Adagide in the Gnat environment
> with the only add-on called "Win32ADA", please.
> 

from the MSDN 
<http://support.microsoft.com/default.aspx?scid=kb;en-us;124103>:

"It may be useful to manipulate a window associated with a console 
application. The Win32 API provides no direct method for obtaining the 
window handle associated with a console application. However, you can 
obtain the window handle by calling FindWindow(). This function 
retrieves a window handle based on a class name or window name. "

IMHO, the method they describe in the article is risky. i can think of 
2 other methods to get the HWND but they are risky as well !

OTOH, i can't see anything useful in retrieving the HWND of a console 
application... may we have more information on the purpose of this 
request ?

> Thank you ! Bye !

-- 
rien



^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: HWND of the console
  2005-06-24 13:56 HWND of the console Sylvain
  2005-06-24 14:25 ` Adrien Plisson
@ 2005-06-25  1:46 ` Steve
  2005-06-25  7:32   ` Adrien Plisson
  1 sibling, 1 reply; 5+ messages in thread
From: Steve @ 2005-06-25  1:46 UTC (permalink / raw)


"Sylvain" <sisi.ard@laposte.net> wrote in message 
news:e465bcf0.0506240556.7a08f26a@posting.google.com...
> Hi,
> Can you give me a piece of code which give me the HWND of the current
> console window given by default by Adagide in the Gnat environment
> with the only add-on called "Win32ADA", please.
>
>
> Thank you ! Bye !

WinBase.GetStdHandle( WinBase.STD_OUTPUT_HANDLE )

Sample code:

PROCEDURE CursorPosnTIF( row, col : Natural ) IS

  result : Win32.BOOL;
  toRow : Natural := Natural'MAX( row, 1 );
  toCol : Natural := Natural'MAX( col, 1 );

BEGIN
  result := WinCon.SetConsoleCursorPosition(
                  WinBase.GetStdHandle( WinBase.STD_OUTPUT_HANDLE ),
                  WinCon.COORD'( X => Win32.Short( toCol - 1 ),
                                 y => Win32.Short( toRow - 1 ) ) );
END CursorPosnTIF;

Note: This only works for the console window.

Steve
(The Duck) 





^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: HWND of the console
  2005-06-25  1:46 ` Steve
@ 2005-06-25  7:32   ` Adrien Plisson
  2005-06-26  1:07     ` Steve
  0 siblings, 1 reply; 5+ messages in thread
From: Adrien Plisson @ 2005-06-25  7:32 UTC (permalink / raw)


Steve wrote:
> WinBase.GetStdHandle( WinBase.STD_OUTPUT_HANDLE )

this does not return a WINDOW handle (HWND) but a DEVICE handle. the 
return value of this function cannot be used in function taking a HWND 
as a parameter.

-- 
rien




^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: HWND of the console
  2005-06-25  7:32   ` Adrien Plisson
@ 2005-06-26  1:07     ` Steve
  0 siblings, 0 replies; 5+ messages in thread
From: Steve @ 2005-06-26  1:07 UTC (permalink / raw)


"Adrien Plisson" <aplisson-news@stochastique.net> wrote in message 
news:42bd0802$0$24266$ba620e4c@news.skynet.be...
> Steve wrote:
>> WinBase.GetStdHandle( WinBase.STD_OUTPUT_HANDLE )
>
> this does not return a WINDOW handle (HWND) but a DEVICE handle. the 
> return value of this function cannot be used in function taking a HWND as 
> a parameter.
>
> -- 
> rien
>

Then try "GetConsoleWindow" defined in Kernel32.lib.

Requires W2K or XP.

In the SDK documentation:

  HWND GetConsoleWindow(void);

The GetConsoleWindow function retrieves the window handle used by the 
console associated with the calling process.

Steve
(The Duck) 





^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2005-06-26  1:07 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-24 13:56 HWND of the console Sylvain
2005-06-24 14:25 ` Adrien Plisson
2005-06-25  1:46 ` Steve
2005-06-25  7:32   ` Adrien Plisson
2005-06-26  1:07     ` Steve

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox