Topic: Run CMD window inside a Form

Hello All,  MVD users, experts,

I know there's a way to pin an application to a form but is there a way or has someone tried to pin a CMD window to a
form?  or to a panel?  I'm trying to do this and can't seem to get it to work.  If anyone has an example or know the
script to do it, post the snippet please!!!


Thanks in advance!

Re: Run CMD window inside a Form

Nobody? sad

Re: Run CMD window inside a Form

I'm not sure what you mean by pinning a CMD window to a form, but you can do the following within MVD.

Openfile('cmd');

Re: Run CMD window inside a Form

ehwagner wrote:

I'm not sure what you mean by pinning a CMD window to a form, but you can do the following within MVD.

Openfile('cmd');

Hi ehwagner,

Thanks, yeah I knew you can run a command window by using the OpenFile function.  What I'm looking for is to 'PIN' that CMD window to a form or a panel, just like the example of the calculator that K245 showed here: http://myvisualdatabase.com/forum/viewt … 60#p32860.   Basically I want to 'redirect' the output of a CMD window into a form or a panel. Say for example I'm running the following command:

Openfile(''c:\*.* e:\backup /S /E", 'robocopy');

.
I want to the outuput of the console to show in a Form (whether it's using a memo field or other control to hold the strings) or a panel inside of MVD and not showing the command window.  That's basically what it it, redirect output to a form in MVD.

smile   Hope that clears out any confusion.

Re: Run CMD window inside a Form

Unfortunately I'm not sure how to do that. This is something Dimitry will probably need to answer. Sorry.

Re: Run CMD window inside a Form

Understand. Thanks anyway for responding.  Dmitry, any thoughts on this? or anybody else?  Derek? I'm making a call out
to all the MVD power users here.  Help me!!

big_smile

7 (edited by k245 2019-10-18 20:14:01)

Re: Run CMD window inside a Form

procedure frmMain_Button3_OnClick (Sender: TObject; var Cancel: boolean);
var
  h: integer;
  Max: integer;
begin
  Openfile('cmd');
  // finding window's
  h := 0;
  Max := 20;
  while (h = 0) and (Max > 0) do
  begin
    h := FindWindow('', 'c:\windows\system32\cmd.exe'); // find window using caption
    Dec(Max);
    Sleep(50);
  end;
  if h <> 0 then
  begin
    SetWindowPos( h, 0, -7, -30, 0, 0, SWP_NOSIZE); // set position
    SetParent( FindWindow('', 'c:\windows\system32\cmd.exe'), frmMain.Panel1.Handle);
  end;
end;

http://myvisualdatabase.com/forum/misc.php?action=pun_attachment&amp;item=5887&amp;download=0

Post's attachments

Attachment icon 5.png 31.78 kb, 142 downloads since 2019-10-18 

Визуальное программирование: блог и телеграм-канал.

8 (edited by derek 2019-10-18 20:19:03)

Re: Run CMD window inside a Form

Hi Gonpublic,
I don't know if there are other ways - this is the only way I know how.
It looks a bit clunky but maybe it does the job for you.
Derek.
.
Sorry K245 - didn't see you'd already replied.

Post's attachments

Attachment icon cmdwindow.zip 335.61 kb, 404 downloads since 2019-10-18 

9 (edited by gonpublic2k 2019-10-18 22:31:37)

Re: Run CMD window inside a Form

Wow!  thank you both Derek and k245, both versions are working fine under Win10, I'm going to use k245's version since
it creates de CMD window inside a panel and look borderless, almost as if it were part of the MVD environment. 
Great examples, my deepest thanks and gratitude!

I will post the entire Backup Utility for everyone to use in the projects once completed.

Thanks!

Re: Run CMD window inside a Form

Hi Again Both,
I'd never tried doing it that way, but totally agree that putting it on a panel (and then sizing the panel accordingly) makes it look much more part of the MVD environment.
Thanks K245.
Derek.