Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

DestroyWindow doesn't work.

Posted on 1998-02-21
5
Medium Priority
?
600 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 400 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

782 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