Windows Taskbar Tips&Tricks

Some "secrets" of Windows Taskbar

How to press a "Start" button from your program:



procedure TForm1.PressStart(Sender: TObject);

var

 hTaskBar, hButton : HWND;

 hDCScreen : HDC;

 ScreenHeight : DWORD;

begin

  //find "Start" button

  hDCScreen := GetDC(0);

  ScreenHeight :=GetDeviceCaps(hDCScreen,VERTRES);

  ReleaseDC(0, hDCScreen);

  hTaskBar := FindWindow('Shell_TrayWnd', nil);

  hButton := GetWindow(hTaskBar, GW_CHILD);



  //press "Start" button

  SendMessage(hButton, WM_LBUTTONDOWN,MK_LBUTTON,LOWORD(5)+

    HIWORD(ScreenHeight-20));



  //hide "Start" button

  ShowWindow(hButton, SW_HIDE);

  Sleep(2000);

  //show "Start" button

  ShowWindow(hButton, SW_NORMAL);

end;



How to hide and show Windows Taskbar:

procedure TForm1.HideTaskBar(Sender: TObject);

var

 H : HWND;

begin

    H := FindWindow('Shell_TrayWnd', nil);

    ShowWindow(H, SW_HIDE);



    Sleep(2000);

    ShowWindow(H, SW_SHOW);

end;



How to hide an application button from Windows Taskbar:

procedure TForm1.HideButton(Sender: TObject);

begin

  ShowWindow(Application.Handle,SW_HIDE);

end;



procedure TForm1.ShowButton(Sender: TObject);

begin

  ShowWindow(Application.Handle,SW_SHOW);

end;



The same example, but using Windows API:

var

  m_hWnd : HWND;

  hMain : HWND;



procedure TForm1.CreateWindow(Sender: TObject);

begin

 m_hWnd :=CreateWindowEx(0,'staic', '', WS_POPUP, 0,0,1600,1200,

   0, 0, 0, nil);

 hMain := CreateWindowEx (0,'static', 'Main window',

  WS_POPUP + WS_VISIBLE, 40,50,200,300,m_hWnd, 0, 0, nil);

end;



procedure TForm1.HideWindow(Sender: TObject);

begin

  //hide button

  ShowWindow(hMain,SW_HIDE);

end;



procedure TForm1.ShowWindow(Sender: TObject);

begin

  //show button

  ShowWindow(hMain,SW_SHOW);

end;


 

Share this article!

Follow us!

Find more helpful articles: