Board index » delphi » Parenting VCL classes to windows.

Parenting VCL classes to windows.

Hi,

 I'm having two problems at the moment,
 1) I can't seem to find a way to take a form and tell it that it's parent
is an existing window (created by another application) Is there any way to
force VCL windows to be children of non-VCL windows?

 2) I'm trying to empty the recycle bin, any ideas on how I would do this?

Bryan

   print "$m\n" if ($m = "yjhi pcdiwtg etga wprztg") =~ tr/p-za-o/a-z/;

///////////////////////////: c...@cs.ru.ac.za :///////////////////////////
// Bryan Kilian        // To stay young requires unceasing cultivation  //  
// Rhodes University   // of the ability to unlearn old falsehoods.     //
// South Africa        //                            - R. A. Heinlein   //
//////////////////////////////////////////////////////////////////////////
  Disclaimer: My views are my own. I pity anything that thinks otherwise.

 

Re:Parenting VCL classes to windows.


Hi Bryan

Quote
>  1) I can't seem to find a way to take a form and tell it that it's
parent
> is an existing window (created by another application) Is there any way
to
> force VCL windows to be children of non-VCL windows?

According to the Win32 helpfiles, parents and children *must* belong to the
same application ! (You can see for yourself: just look up SetParent API)

        Niels.

Re:Parenting VCL classes to windows.


Quote
Niels Vanspauwen <Niels.Vanspauwen@!NSPM!Student.Kuleuven.Ac.Be> wrote:
> Hi Bryan
> >  1) I can't seem to find a way to take a form and tell it that it's
> parent
> > is an existing window (created by another application) Is there any way
> to
> > force VCL windows to be children of non-VCL windows?
> According to the Win32 helpfiles, parents and children *must* belong to the
> same application ! (You can see for yourself: just look up SetParent API)

Heh, although it's another application, that application owns mine, since
mine is a DLL that gets called.

In this case, however, it's irrelevant, I have a non VCL window I have
created, and I need to set a form parented to it. Or, in the case of the DLL
that I have written, the calling programs has passed me a window handle and
my form must be a child of that window.

Bryan

   print "$m\n" if ($m = "yjhi pcdiwtg etga wprztg") =~ tr/p-za-o/a-z/;

///////////////////////////: c...@cs.ru.ac.za :///////////////////////////
// Bryan Kilian        // To stay young requires unceasing cultivation  //  
// Rhodes University   // of the ability to unlearn old falsehoods.     //
// South Africa        //                            - R. A. Heinlein   //
//////////////////////////////////////////////////////////////////////////
  Disclaimer: My views are my own. I pity anything that thinks otherwise.

Re:Parenting VCL classes to windows.


Quote
> In this case, however, it's irrelevant, I have a non VCL window I have
> created, and I need to set a form parented to it. Or, in the case of the
DLL
> that I have written, the calling programs has passed me a window handle
and
> my form must be a child of that window.

Have you tried using SetParent API ?

        Niels.

Re:Parenting VCL classes to windows.


Quote
In article <6r42cm$...@quagga.ru.ac.za>, Bryan Kilian <br...@rucus.ru.ac.za> wrote:
>Hi,
> I'm having two problems at the moment,
> 1) I can't seem to find a way to take a form and tell it that it's parent
>is an existing window (created by another application) Is there any way to
>force VCL windows to be children of non-VCL windows?

I think the ParentWindow property might be the one you're looking for.  
Delphi-created ActiveX controls use this one to put themselves "into" another
application.  Haven't tried it myself, mind you.

Quote
> 2) I'm trying to empty the recycle bin, any ideas on how I would do this?

Hmmm... it would seem that there should be a more direct way to do that... it
probably involves getting an IShellLink to the recycle bin and trying to
get the GetUIObjectOf from it (which would be an IContextMenu) and perform an
InvokeCommand for the Empty Recycle Bin item, but failing that...

You could try something like this:

uses ShlObj;

var
  PItemID : PItemIDList;
  RecyclePath : array[0..MAX_PATH] of Char;
begin
  OleCheck(
    SHGetSpecialFolderLocation(Application.Handle,CSIDL_BITBUCKET,PItemID));
  if SHGetPathFromIDList(PItemID,@RecyclePath) then
  begin
    // You can put RecyclePath into a string here, or run through the files
    // in it and delete them/whatever you wish
  end;
end;

Haven't tested that out, either, but I hope it's one of those
it-just-happens-to-work little miracles that come about every now and again :)

Hope that helps..

  --=- Ritchie Annand

Re:Parenting VCL classes to windows.


Quote
R. Annand wrote:

> In article <6r42cm$...@quagga.ru.ac.za>, Bryan Kilian <br...@rucus.ru.ac.za> wrote:
> >Hi,

> > I'm having two problems at the moment,
> > 1) I can't seem to find a way to take a form and tell it that it's parent
> >is an existing window (created by another application) Is there any way to
> >force VCL windows to be children of non-VCL windows?

Pardon my being obtuse... but doesn't the Win32 "compartmentalisation"
of apps explicitly stop that sort of thing... os is this some aspect of
the GUI I don't know about??

MH.

Re:Parenting VCL classes to windows.


Quote
R. Annand wrote:

> In article <6r42cm$...@quagga.ru.ac.za>, Bryan Kilian <br...@rucus.ru.ac.za> wrote:
> >Hi,

> > I'm having two problems at the moment,
> > 1) I can't seem to find a way to take a form and tell it that it's parent
> >is an existing window (created by another application) Is there any way to
> >force VCL windows to be children of non-VCL windows?

Pardon my being obtuse... but doesn't the Win32 "compartmentalisation"
of apps explicitly stop that sort of thing... os is this some aspect of
the GUI I don't know about??

MH.

Re:Parenting VCL classes to windows.


alias Yamal Karaffel <Please.l...@my.sig> wrote:

Quote
> On Sat, 29 Aug 1998 13:16:17 +0200, "Benoit MICHAUD"
> <BMich...@mnet.fr> wrote:
> >alias Yamal Karaffel a crit dans le message
> >>Have you tried the CreateParented constructor, descending from
> >>TWindowControl?
> >Did you ??
> >Cause i never succeed doing it that way !!  Can create "child window" but
> >still have pbs with focus and tabs links ....
> >Any idea ?
> No sorry, I've never tried it my self. I was just forwarding a tip
> from another group, discussing how to create ActiveForms without
> parents. I'm really sorry if you wasted much time on this.
> In the future I'll try to mark such tips as "not tested by me", or
> something like that.

I finally got mine working, using the createparented constructor, the
application is quite specific, if you haven't yet heard of the Litestep
windows shell, it was a modular extension to that. What you get given by the
app is a window and you have to create your window parented to that. If
anyone would like to see how I managed it, the code is at
http://litestep.ru.ac.za in the archive section under Delphi VCL SDK. A
number of litestep modules have already been written in delphi (previously
VC++ was the only choice) and they seem to work fine. I have no idea how it
would work in a more generic application though.

Bryan

   print "$m\n" if ($m = "yjhi pcdiwtg etga wprztg") =~ tr/p-za-o/a-z/;

///////////////////////////: c...@cs.ru.ac.za :///////////////////////////
// Bryan Kilian        // To stay young requires unceasing cultivation  //  
// Rhodes University   // of the ability to unlearn old falsehoods.     //
// South Africa        //                            - R. A. Heinlein   //
//////////////////////////////////////////////////////////////////////////
  Disclaimer: My views are my own. I pity anything that thinks otherwise.

Other Threads