Be your own task bar

zhaozj2021-02-17  47

Use this program to be a book, including the Handle, Windown, Program Path, Icon, which lists the programs on the taskbar. You can select a window and advance it in advance or switch between program. If your program is full screen, and if you block the system key, you may use the following skills.

******************** AppAbp.dprProgram AppTabP;

Uses form, AppTab_f in 'AppTab_f.pas' {apptab};

{$ R * .res}

Begin Application.INITIALIZE; Application.createform; Application.Run; End.

*********************** AppAb_f.Pasunit AppTab_f;

Interface

Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls, Tlhelp32, Buttons, Shellapi, ExtCtrls, Imglist;

type TAppTab = class (TForm) ListBox1: TListBox; BitBtn1: TBitBtn; CaptionListBox: TListBox; PathListBox: TListBox; HwndListBox: TListBox; Label1: TLabel; tempImageList: TImageList; tempImage: TImage; procedure BitBtn1Click (Sender: TObject); procedure FormCloseQuery ( Sender: TObject; var CanClose: Boolean); procedure FormShow (Sender: TObject); procedure FormCreate (Sender: TObject); private {Private declarations} AppList: TStrings; AppName_Btn: Array [0..20] of TBitBtn; procedure AppName_BtnClickHandle ( Sender: TOBJECT); public {public declarations}

VAR AppTab: TappTab; // Get window Windowname function gettext (wnd: hwnd): string; // Traverse window Function EnumWindowsProc (WND: hwnd; lparam: lparam): Bool; stdcall; // Get program name by process handle (including Path) Function Wndtoproc (hwnd: hwnd): String; // Get an icon for an external program, is a folder icon Function GetFilecon (const filename: string; smallicon: boolean): hicon; importation

{$ R * .dfm} Function GetText (WND: HWND): String; Var TextLength: Integer; Text: Pchar; Begin TextLength: = SendMessage (WND, WM_GETTEXTLENGTH, 0, 0); if TextLength = 0 Then Result: = ' 'else begin GetMem (Text, TextLength 1); SendMessage (Wnd, WM_GETTEXT, TextLength 1, Integer (Text)); Result: = Text; FreeMem (Text); end; end; function EnumWindowsProc (Wnd: HWND; LParam : LPARAM): BOOL; stdcall; begin Result: = True; if (IsWindowVisible (Wnd) or IsIconic (wnd)) and ((GetWindowLong (Wnd, GWL_HWNDPARENT) = 0) or (GetWindowLong (Wnd, GWL_HWNDPARENT) = GetDesktopWindow)) AND (getWindowlong (WND, GWL_EXSTYLE) AND WS_EX_TOOLWINDOW = 0) THEN BEGIN IF WND <> Application.Handle Then Begin AppAb.ListBox1.Items.Add (INTTOSTR (WND) ***** ' GetText (WND) '*****' WNDTOPROC (WND)); AppAb.hwndListBox.Items.Add (INTTOSTR (WND)); AppAb.captionListBox.Items.Add (GetText (WND)); AppAb.PathListBox.Items.Add ( WNDTOPROC (WND)); // The following icon is added to ImageList, and use IF to dynamically generate Copy (WNDTOPROC (WND), Length (Wndtoproc (WND)) - 12, 13) = '/ Explorer.exe' Then AppTab.tempimage.Picture.icon.Handle: = Extracticon (// Hinstance, Pchar (GetEnvironmentvariable ('WINDIR ') ' / system / shell32.dll '), 3) else appab.tempimage.picture.icon.handle: = Extracticon (Hinstance, Pchar (Wndtoproc (WND)), 0); AppAb.tempimagelist.addicon (AppTab. Tempimage.picture.icon); end; end;

procedure TAppTab.BitBtn1Click (Sender: TObject); var AppNum: Integer; begin for AppNum: = 0 to ListBox1.Items.Count-1 do begin AppName_Btn [AppNum]: = TBitBtn.Create (Self); AppName_Btn [AppNum] .Hint : = [appNum] CaptionListBox.Items; AppName_Btn [appNum] .Caption: = Copy (CaptionListBox.Items [appNum], 1,8); AppName_Btn [appNum] .Parent: = Self; AppName_Btn [appNum] .Left: = 82 * appNum; AppName_Btn [appNum] .Width: = 80; AppName_Btn [appNum] .ShowHint: = True; AppName_Btn [appNum] .Layout: = blGlyphLeft; AppName_Btn [appNum] .OnClick: = AppName_BtnClickHandle; AppName_BTN [appNum] .Tag: = Start (hwndlistbox.items [appnum]); // Use the Tag property to use // to use // to press // to press the Newgrass Icon TempimageList.getbitmap (AppNum, AppName_BTN [Appnum] .Glyph); end; end; Function Wndtoproc (hwnd: hwnd): string; var pid: dword; ok: boolean; processListHandle: thandle; // Process list handle ProcessStruct: procestruct: processentry32; // The structure of the process is in this structure Begin Result: = ''; GetWindowThreadProcessid (hwnd, pid); ProcessListHandl e: = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0); ProcessStruct.dwSize: = Sizeof (ProcessStruct); ok: = Process32First (ProcessListHandle, ProcessStruct); while ok do begin if PID = ProcessStruct.th32ProcessID then Break; ok: = Process32Next (ProcessListHandle, ProcessStruct); end; closehandle; result: = processstruct.szeefile;

Procedure tapptab.formclosequery (sender: Tobject; var canclose: boolean); begin appl.free; end;

Procedure Tapp Tapptab.FormShow (Sender: TOBJECT); Begin ListBox1.clear; EnumWindows (@ enumwindowsproc, sizeof (integer);

procedure TAppTab.FormCreate (Sender: TObject); begin AppList: = TStringList.Create; end; procedure TAppTab.AppName_BtnClickHandle (Sender: TObject); begin // Tag to use, it is not a waste !! ShowWindow (TBitBtn (Sender). Tag, sw_show; showwindow (Tbitbtn (sender) .tag, sw_restore; setForegroundWindow (Tbitbtn (sender). Why is it used to use three sentences? Weird

function GetFileIcon (const Filename: String; SmallIcon: Boolean): HICON; var info: TSHFILEINFO; Flag: Integer; begin if SmallIcon then Flag: = (SHGFI_SMALLICON or SHGFI_ICON) else Flag: = (SHGFI_LARGEICON or SHGFI_ICON); SHGetFileInfo (Pchar ( FileName), 0, INFO, SIZEOF (INFO), FLAG); Result: = info.chicon;

End.

*************************************** AppAb_f.dfmobject AppAb: TappTab Left = 4 TOP = 87 width = 797 Height = 424 CAPTION = 'AppTab' Color = clBtnFace Font.Charset = GB2312_CHARSET Font.Color = clWindowText Font.Height = -13 Font.Name = 'Arial' Font.Style = [] OldCreateOrder = False OnCloseQuery = FormCloseQuery OnCreate = FormCreate OnShow = FormShow PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel Left = 24 Top = 216 Width = 521 Height = 13 Caption = 'Handle program path Win' 'dowName' end object tempImage: TImage Left = 528 Top = 16 Width = 41 Height = 41 Visible = False end object bitbtn1: tbitbtn left = 0 TOP = 52 width = 137 height = 25 caption = 'generated button' Taborder = 1 OnClick = bitbtn1click glyph.data =

{DE010000424DDE01000000000000760000002800000024000000120000000100 0400000000006801000000000000000000001000000000000000000000000000 80000080000000808000800000008000800080800000C0C0C000808080000000 FF0000FF000000FFFF00FF000000FF00FF00FFFF0000FFFFFF00333333336633 3333333333333FF3333333330000333333364463333333333333388F33333333 00003333333E66433333333333338F38F3333333000033333333E66333333333 33338FF8F3333333000033333333333333333333333338833333333300003333 3333446333333333333333FF3333333300003333333666433333333333333888 F333333300003333333E66433333333333338F38F333333300003333333E6664 3333333333338F38F3333333000033333333E6664333333333338F338F333333 0000333333333E6664333333333338F338F3333300003333344333E666433333 333F338F338F3333000033336664333E664333333388F338F338F33300003333 E66644466643333338F38FFF8338F333000033333E6666666663333338F33888 3338F3330000333333EE666666333333338FF33333383333000033333333EEEE E333333333388 FFFFF8333330000333333333333333333333333388888333333 0000} NumGlyphs = 2 end object CaptionListBox: TListBox Left = 456 Top = 232 Width = 332 Height = 162 ItemHeight = 13 TabOrder = 2 end object PathListBox: TListBox Left = 104 Top = 232 Width = 345 Height = 163 ItemHeight = 13 TabOrder = 3 end object ListBox1: TListBox Left = 1 Top = 81 Width = 784 Height = 128 ItemHeight = 13 TabOrder = 0 end object HwndListBox: TListBox Left = 0 Top = 232 Width = 101 Height = 161 ItemHeight = 13 TabOrder = 4 end object TempimageList: Timagelist Left =

转载请注明原文地址:https://www.9cbs.com/read-30288.html

New Post(0)