Solved

DestroyWindow doesn't work.

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

706 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

13 Experts available now in Live!

Get 1:1 Help Now