Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 193
  • Last Modified:

windows manager

i know this is asking a lot but i am providing 250 points.

Can someone please post code for a windows manager.

ie a listbox with all the open windows and then you can click on an open window and have the ability to:

minimize window
maxamize window
disable sys menu
enable sys menu
Close selected window
change the text caption of a selected window


PLEASE can somone help?

thanks
0
marksmall
Asked:
marksmall
1 Solution
 
marksmallAuthor Commented:
oh i forgot to add

disable/enable "X"
disable/enable minimize and maxamise
0
 
DragonSlayerCommented:
basically you need to enumerate all the windows, and get their handles, using EnumWindows, e.g.

function EnumWindowsProc(Hw: hWnd; TF: TfrmEnumWin): Boolean; stdcall;
begin
  Result := True;
  // do whatever you want, store the handle, store the caption, etc
  // to get the caption, use GetWindowText
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  EnumWindows(@EnumWindowsProc);
end;

later on, to minimize a window, call
ShowWindow(handleToWindow, SW_MINIMIZE);
and likewise, substitute SW_MINIMIZE with SW_MAXIMIZE or SW_RESTORE or SW_HIDE/SW_SHOW for the other desired effects

to close a window, use
SendMessage(handleToWindow, WM_CLOSE, 0, 0);

to change caption, use
SetWindowText(handleToWindow, PChar(NewString));

you can use SetWindowLong to change the style of a window so that it does not have a system menu (remove WS_SYSMENU from the style)... see Madshi's comment on how to do it onto a different process: http://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20178822

otherwise, I can't think of any ways to disable the system menu for now, but you may try this:

DestroyMenu(GetSystemMenu(handleToWindow, False));

and to recreate it again:

GetSystemMenu(handleToWindow, True);


When disabling the 'X', you should also remember to disable the Close command from the system menu
EnableMenuItem(GetSystemMenu(handleToWindow, False), SC_CLOSE, MF_BYCOMMAND or MF_GRAYED);



Hope that helps!


DragonSlayer
0
 
intheCommented:
DragonSlayer has covered it all pretty well ,so i just have to mention:
http://www.gxexplorer.org/

its a opensource explorer replacemnet ,maybe you can find something in it to enhance your app..
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
marksmallAuthor Commented:
thanks, but can anyone provide a full working program of this? i can increase the points!!!
0
 
marksmallAuthor Commented:
FIRST off all SORRY ABOUT DELAY, BEEN POORLY AND COULD GET ACCESS TO MY COMPUTER!

Secondly for 250 points could someone PLEASE provide me with a FULL source example!!!
0
 
marksmallAuthor Commented:
i got this code from a client server program but it has been adapted
for the client server, so i got the code that i think is necessary and
am posting it below, to see if some kind person will sort it out and
make it work in program thats NOT client server. i got this code
from the url mentioned in "nod31"s question! I want the program to
look EXACTALY like the one in this screen shot!!!

www.noel16.freeserve.co.uk/tasklist.jpg

if the option is selected then it displays ALL applications as well,
and if its not selected then it ONLY shows the open windows. It is
a listview that the info is dislpayed in!

\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

function TaskList(FirstHandle: THandle; ListAll: Boolean): string;
var
   lngLen:longint;
   strBuffer,This,All:string;
   TaskHandle:THandle;
   cChar:Char;
begin
   cChar:=Chr(13);
   TaskHandle:=GetWindow(FirstHandle,GW_HWNDFIRST);
   while TaskHandle > 0 do
   begin
      if (TaskHandle <> FirstHandle) and (TaskHandle <> Application.Handle) then
      begin
         lngLen:=GetWindowTextLength(TaskHandle) + 1;
         SetLength(strBuffer,lngLen);
         lngLen:=GetWindowText(TaskHandle,PChar(strBuffer),lngLen);
         if lngLen > 0 then
         begin
            This:=TrimRight(strBuffer);
            if ListAll then
               All:=All + This + cChar + IntToStr(TaskHandle) + cChar
            else
               if IsWindowVisible(TaskHandle) then
                  All:=All + This + cChar + IntToStr(TaskHandle) + cChar;
         end;
      end;
      TaskHandle:=GetWindow(TaskHandle,GW_HWNDNEXT);
   end;
   TaskList:=Copy(All,1,Length(All) - 1);
end;


0
 
ginsonicCommented:
Use next unit to list all processes and terminate the selected .

unit Unit1;

interface
uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, TlHelp32;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;
    lst: TListBox;
    Button3: TButton;

    procedure Button1Click(Sender: TObject);
    procedure lstDblClick(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
    procedure Scrie(inf: TProcessEntry32);
  public
    { Public declarations }
    snapshot: THandle;
    info: array[0..100] of TProcessEntry32;
    count: integer;
    procedure RefreshList;
  end;

var
  Form1: TForm1;
  names:String;

implementation

{$R *.DFM}

procedure TForm1.RefreshList;
var inf: TProcessEntry32;
begin
  SnapShot:=CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS,0);
  lst.Clear; count:=0; inf.dwSize:=sizeof(inf);
  Process32First(snapshot,inf); scrie(inf);
  while Process32Next(snapshot,inf) do scrie(inf);
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  RefreshList;
end;

procedure TForm1.Scrie(inf: TProcessEntry32);
begin
  info[count]:=inf;
  lst.items.add(info[count].szExeFile);
  inc(count);
end;

procedure TForm1.lstDblClick(Sender: TObject);
var z: integer;
  str: TStringList;
begin
  z:=lst.ItemIndex;
  str:=TStringList.Create;
  try
    str.add(format('Usage      = %4d',[info[z].cntUsage]));
    str.add(format('ProcessID  = %8x',[info[z].th32ProcessID]));
    str.add(format('def. HeapID= %8x',[info[z].th32DefaultHeapID]));
    str.add(format('ModuleID   = %8x',[info[z].th32ModuleID]));
    str.add(format('Threads    = %4d',[info[z].cntThreads]));
    str.add(format('Parent Proc= %8x',[info[z].th32ParentProcessID]));
    str.add(format('Class Base = %4d',[info[z].pcPriClassBase]));
    str.add(format('ExeFile    = %s',[info[z].szExeFile]));
    names:= info[z].szExeFile;
    ShowMessage(str.Text);
  finally
    str.Free;
  end;
end;

procedure TForm1.Button2Click(Sender: TObject);
var z: integer;
    han: THandle;
begin
  z:=lst.ItemIndex; if z=-1 then exit;
  han:=OpenProcess(PROCESS_TERMINATE,false,info[z].th32ProcessID);
  TerminateProcess(han,0); WaitForSingleObject(han,INFINITE);
  CloseHandle(SnapShot);
  RefreshList;
end;


end.
0
 
ginsonicCommented:
Just handle to processes and do what you wish .
Good luck.
0
 
ginsonicCommented:
Sorry for Button3. Just remove it .
0

Featured Post

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now