Link to home
Start Free TrialLog in
Avatar of harisis
harisis

asked on

DestroyWindow doesn't work.

Why i can't destroy a window with the "DestroyWindow" function in Windows95? I use Delphi 1.
Avatar of KE
KE

What kind of windows do you try to destroy ?
Is it your own application windows, or windows created by another application ?

Hmmm, I have two queses: D1 and w95 problem or you paste bad parameters to the procedure...

Anyway, I quess you should try it with other windows or smth, and try to monitor the parameters you paste.

Wana` send it to me so I can check it with D3?

Good luck!
bosism@netvision.net.il
Avatar of harisis

ASKER

I sent the routines. The parameters should be ok. I checked the handles with other programs too.

 The form has a ComboBox which gives the running windows and their handles. When the user selects a window title and presses the OK button the DestroyWindow executes... What's wrong?

---------------------------------------


unit Unit1;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls, Buttons;

type
  TForm1 = class(TForm)
    OKButton: TBitBtn;
    ComboBox1: TComboBox;
    procedure ComboBox1DropDown(Sender: TObject);
    procedure OKButtonClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.ComboBox1DropDown(Sender: TObject);
 var i:word;
     ls:byte;
     sa:array[1..255] of char;
     s:string;
     hndl:hwnd;
begin
 combobox1.items.clear;
 hndl:=GetNextWindow(application.handle,GW_HWNDNEXT);
  for i:=1 to GetNumTasks-1 do
   begin
    ls:=GetWindowText(hndl,@sa, 255);
    s:=strpas(@sa);
    if s<>'' then combobox1.items.add(inttostr(hndl)+' '+s);
    hndl:=GetNextWindow(hndl,GW_HWNDNEXT);
   end;
end;

procedure TForm1.OKButtonClick(Sender: TObject);
 var
   h:Hwnd;
   sa,cl:array[1..255] of char;
   dd:boolean;

begin
 h:=strtoint(copy(combobox1.text,1,pos(' ',combobox1.text)-1));
 if h<>0 then
            dd:=DestroyWindow(h);
end;

end.
Whoat is your purpose of using DestroyWindow instead of a Delphi method ? Free would do this work for you.
ASKER CERTIFIED SOLUTION
Avatar of ronit051397
ronit051397

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial