Solved

DestroyWindow doesn't work.

Posted on 1998-02-21
5
544 Views
Last Modified: 2008-02-26
Why i can't destroy a window with the "DestroyWindow" function in Windows95? I use Delphi 1.
0
Comment
Question by:harisis
5 Comments
 
LVL 3

Expert Comment

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

0
 
LVL 3

Expert Comment

by:Matvey
ID: 1359660
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
0
 

Author Comment

by:harisis
ID: 1359661
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.
0
 
LVL 4

Expert Comment

by:d003303
ID: 1359662
Whoat is your purpose of using DestroyWindow instead of a Delphi method ? Free would do this work for you.
0
 
LVL 5

Accepted Solution

by:
ronit051397 earned 100 total points
ID: 1359663
Try this:

procedure TForm1.Button1Click(Sender: TObject);
 var
   h:Hwnd;
begin
  h:=strtoint(copy(combobox1.text,1,pos(' ',combobox1.text)-1));
  if h<>0 then
     SendMessage(h, WM_DESTROY, 0, 0);
end;

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
IdTelnet1DataAvailable handler freezes the Application 4 62
Syntax Check Delphi Seattle IOS app without MAC ? 1 89
delphi exception 7 61
creating threads in delphi 1 81
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…
A company’s greatest vulnerability is their email. CEO fraud, ransomware and spear phishing attacks are the no1 threat to a company’s security. Cybercrime is responsible for the largest loss of money to companies today with losses projected to r…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now