Recent

Author Topic: Manipulating Console Window  (Read 27950 times)

PAEz

  • New Member
  • *
  • Posts: 29
Re: Manipulating Console Window
« Reply #15 on: March 02, 2011, 12:20:02 pm »
What I meant was that getconsolewindow will only work if run from inside an app thats running through the console, it will get the console window its running in....it wont get the console window of something you run from your app.

So I think your going to have to do something like run the cli app through cmd and get thats hwnd.
Find attached a little demo I made for you.
Lazarus 0.9.29  Windows XP sp3
E6400 2gig ram 7900GTX 512meg

I have a shocking memory and am a crap coder, so take everything I say with a grain of doubt

j0x

  • Full Member
  • ***
  • Posts: 126
Re: Manipulating Console Window
« Reply #16 on: March 03, 2011, 04:06:10 am »
PAEz i got it to work now, its just missing AllocConsole() to allocate a console to the GUI App and then when the TProcess is done i just use FreeConsole() to detach the console to the GUI App so that i can close the console app

Code: [Select]
uses
   Windows;

function GetConsoleWindow(): HWND; stdcall; external 'kernel32.dll' name 'GetConsoleWindow';  

var
   hMenuHandle: HMENU;  
begin
   AllocConsole();

   hMenuHandle := GetSystemMenu(GetConsoleWindow(), FALSE);
   DeleteMenu(hMenuHandle, SC_CLOSE, MF_BYCOMMAND);
   SetConsoleTitle('Handbrake CLI!!!');
   DrawMenuBar(GetConsoleWindow());

   // do something more here

   FreeConsole();
end.

thanks for your help dude  :D

PAEz

  • New Member
  • *
  • Posts: 29
Re: Manipulating Console Window
« Reply #17 on: March 06, 2011, 02:47:57 pm »
I had no idea about AllocConsole, thanks alot for sharing that with me....one for the vault
Lazarus 0.9.29  Windows XP sp3
E6400 2gig ram 7900GTX 512meg

I have a shocking memory and am a crap coder, so take everything I say with a grain of doubt

 

TinyPortal © 2005-2018