Solved

DestroyWindow doesn't work.

Posted on 1998-02-21
5
550 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi XE10, MySQL Query 4 143
Intraweb download file link ? 1 132
Working with hours 3 57
Base1 Encode/Decode 3 77
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

776 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