Delphi-PRAXiS
Seite 1 von 2  1 2      

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Win32/Win64 API (native code) (https://www.delphipraxis.net/17-win32-win64-api-native-code/)
-   -   Delphi Move taskbar (https://www.delphipraxis.net/128492-move-taskbar.html)

Razor 30. Jan 2009 18:59


Move taskbar
 
Ok here we go i want to move the whole taskbar from 1280x30 cordinates(found by winspy 2008) to about 1280x80.But it looks like its not working i can change other stuff like tray,running applications etc.But not whole taskbar.Explain what i am doing wrong.


I currently got this code but it changes size of
Delphi-Quellcode:
var
  MyHandle: THandle;
  WinRect: TRect;
begin
MoveWindow(FindWindowEx(FindWindow('Shell_TrayWnd', nil), 0, '', nil),
             1280, 80, 80, 22, true);

ken_jones 30. Jan 2009 20:14

Re: Move taskbar
 
I'm not sure if your code snippet really finds the taskbar...
Take a look at this code (part of amaTaBaSo, OpenSource, use DelphiPraxis Search to locate the whole Sourcecode):

Delphi-Quellcode:
function GetToolbarWindowHandle:HWND;
var
 hDesktop : HWND;
 hTray   : HWND;
 hReBar  : HWND;
 hTask   : HWND;
 hToolbar : HWND;
begin
  hDesktop := GetDesktopWindow;

  hTray   := FindWindowEx( hDesktop, 0, 'Shell_TrayWnd', nil );

  hReBar  := FindWindowEx( hTray, 0, 'ReBarWindow32', nil );

  hTask   := FindWindowEx( hReBar, 0, 'MSTaskSwWClass', nil );

  hToolbar := FindWindowEx( hTask, 0, 'ToolbarWindow32', nil );

  if ( hToolbar = 0 ) then
    MessageDlg(
      'Taskbar konnte nicht gefunden werden',
      mtError,
      [mbOK],
      0);

  Result := hToolbar;
end;

Razor 31. Jan 2009 15:45

Re: Move taskbar
 
Liste der Anhänge anzeigen (Anzahl: 1)
Okay i've found a complete solution by myself using my knowledge however,the code is still not perfect.Can anybody tell me how to erase background of a window via his handle.

Btw i need this for a sidebar if anybody is interested why so much stuff.I want icons on my sidebar.


Delphi-Quellcode:
procedure TForm3.Button1Click(Sender: TObject);
var
myhandle:hwnd;
handle2:hwnd;
handle3:hwnd;
begin



myhandle:=FindWindowEx(FindWindow('shell_traywnd', nil), 0, 'traynotifywnd', nil) ;
if myhandle>0 then begin
windows.SetParent(myhandle,0);
MoveWindow(myhandle,0, -9,TaskBarwidth(myhandle), TaskBarheight(myhandle), true)
       end
   else
showmessage('wont work handle is zero');
end;

Razor 31. Jan 2009 18:25

Re: Move taskbar
 
Somebody?I am sorry to bump but atleast give me a feedback.If am going the right way.. :cry:

quendolineDD 1. Feb 2009 05:51

Re: Move taskbar
 
#2 has all answers you're needing to deal with it.
In your code you're just moving the tray around, leaving all others at their place.

Razor 1. Feb 2009 10:49

Re: Move taskbar
 
i need to remove the taskbar so its transparent is it possible?

mr_emre_d 1. Feb 2009 15:00

Re: Move taskbar
 
i dont get it, whats your problem exactly ?

do you want to remove the taskbar or just adjust the size of it ?

for removing(making it invisible) use this:
Delphi-Quellcode:
procedure ShowShellTrayWindow(Show: Boolean);
begin
  ShowWindow( FindWindow( 'shell_traywnd', 0 ), Integer(Show) );
end;
for makin it transparent:
Delphi-Quellcode:
procedure TransparentTrayWindow(Percent: Byte);
var
  hWnd: Cardinal;
begin
  hWnd := FindWindow( 'shell_traywnd', 0 );
  if Percent in [1..100] then
  begin
    SetWindowLong( hWnd, GWL_EXSTYLE,
      GetWindowLong( hWnd, GWL_EXSTYLE ) or WS_EX_LAYERED );
    SetLayeredWindowAttributes( hWnd, 0, Round($FF/$64*Percent), LWA_ALPHA );
  end;
end;

Luckie 1. Feb 2009 15:37

Re: Move taskbar
 
What are we talkig about now? Moving the taskbar or erasing a window's background?

Razor 1. Feb 2009 22:21

Re: Move taskbar
 
I erased the background so thats done.We are talking about moving. :oops:

I got it in X=1280 in Y=0 but cant move it anywhere else.
I can't move it anywhere why is that?? :?

Delphi-Quellcode:
unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

type
  TForm3 = class(TForm)
    Button1: TButton;
    Edit1: TEdit;
    Label1: TLabel;
    Edit2: TEdit;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    Timer1: TTimer;
    Button2: TButton;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form3: TForm3;

implementation

{$R *.dfm}


 function TaskBarwidth(handle:hwnd): integer;
var
  hTB: HWND; // taskbar handle
  TBRect: TRect; // taskbar rectangle
begin
  hTB:= handle;
  if hTB = 0 then
    Result := 0
  else begin
    GetWindowRect(hTB, TBRect);
    Result := TBRect.Left- TBRect.Right;
  end;
end;



function TaskBarHeight(handle:hwnd): integer;
var
  hTB: HWND; // taskbar handle
  TBRect: TRect; // taskbar rectangle
begin
  hTB:= handle;
  if hTB = 0 then
    Result := 0
  else begin
    GetWindowRect(hTB, TBRect);
    Result := TBRect.Bottom - TBRect.Top;
  end;
end;




procedure TForm3.Button1Click(Sender: TObject);
var
myhandle:hwnd;
handle2:hwnd;
handle3:hwnd;
begin



myhandle:=FindWindow('shell_traywnd', nil);

if myhandle>0 then

MoveWindow(myhandle,strtoint(edit1.Text), strtoint(edit2.Text),TaskBarwidth(myhandle), TaskBarheight(myhandle), true)

else
showmessage('wont work handle is zero');
end;


procedure TForm3.Button2Click(Sender: TObject);
var
myhandle:hwnd;
begin
myhandle:=FindWindowEx(FindWindow('shell_traywnd', nil), 0, 'traynotifywnd', nil) ;
windows.SetParent(myhandle,0);
end;

procedure TForm3.Timer1Timer(Sender: TObject);
var
miska:tmouse;
begin

  label3.Caption:=inttostr(miska.CursorPos.X);
  label4.Caption:=inttostr(miska.CursorPos.y);
end;

end.

Razor 1. Feb 2009 23:03

Re: Move taskbar
 
Sorry again,after i setparent(myhandle,0) i can't really move the window anymore why is that? :x :wall: :wall:


Alle Zeitangaben in WEZ +1. Es ist jetzt 22:36 Uhr.
Seite 1 von 2  1 2      

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz