Add Windows taskbar Tips&Tricks


  1.  
  2. How to press a "Start" button from your program:
  3.  
  4. procedure TForm1.PressStart(Sender: TObject);
  5. var
  6.  hTaskBar, hButton : HWND;
  7.  hDCScreen : HDC;
  8.  ScreenHeight : DWORD;
  9. begin
  10.   //find "Start" button
  11.   hDCScreen := GetDC(0);
  12.   ScreenHeight :=GetDeviceCaps(hDCScreen,VERTRES);
  13.   ReleaseDC(0, hDCScreen);
  14.   hTaskBar := FindWindow('Shell_TrayWnd', nil);
  15.   hButton := GetWindow(hTaskBar, GW_CHILD);
  16.  
  17.   //press "Start" button
  18.   SendMessage(hButton, WM_LBUTTONDOWN,MK_LBUTTON,LOWORD(5)+
  19.     HIWORD(ScreenHeight-20));
  20.  
  21.   //hide "Start" button
  22.   ShowWindow(hButton, SW_HIDE);
  23.   Sleep(2000);
  24.   //show "Start" button
  25.   ShowWindow(hButton, SW_NORMAL);
  26. end;

How to hide and show Windows Taskbar:
  1. procedure TForm1.HideTaskBar(Sender: TObject);
  2. var
  3.  H : HWND;
  4. begin
  5.     H := FindWindow('Shell_TrayWnd', nil);
  6.     ShowWindow(H, SW_HIDE);
  7.     Sleep(2000);
  8.     ShowWindow(H, SW_SHOW);
  9. end;

How to hide an application button from Windows Taskbar:
  1. procedure TForm1.HideButton(Sender: TObject);
  2. begin
  3.   ShowWindow(Application.Handle,SW_HIDE);
  4. end;
  5.  
  6. procedure TForm1.ShowButton(Sender: TObject);
  7. begin
  8.   ShowWindow(Application.Handle,SW_SHOW);
  9. end;

The same example, but using Windows API:
  1. var
  2.   m_hWnd : HWND;
  3.   hMain : HWND;
  4.  
  5. procedure TForm1.CreateWindow(Sender: TObject);
  6. begin
  7.  m_hWnd :=CreateWindowEx(0,'staic', '', WS_POPUP, 0,0,1600,1200,
  8.    0, 0, 0, nil);
  9.  hMain := CreateWindowEx (0,'static', 'Main window',
  10.   WS_POPUP + WS_VISIBLE, 40,50,200,300,m_hWnd, 0, 0, nil);
  11. end;
  12.  
  13. procedure TForm1.HideWindow(Sender: TObject);
  14. begin
  15.   //hide button
  16.   ShowWindow(hMain,SW_HIDE);
  17. end;
  18.  
  19. procedure TForm1.ShowWindow(Sender: TObject);
  20. begin
  21.   //show button
  22.   ShowWindow(hMain,SW_SHOW);
  23. end;

Related Discussions
  • USING DLLS (2001-01-04 01:47:50)
    Hi again Goober ... :o) Let's take NETAPI32.DLL as an example. This DLL is created by Microsoft and the explanation of its use is described in...
  • DOT ON SCREEN (2001-01-03 05:42:55)
    Delphi does not support a Pixel function with a HDC, you have to use the Windows-API-function COLORREF SetPixel( HDC hdc, // handle...
  • HOW TO RUN DATABASE APPLICATION ON THE INTERNET (2017-06-09 10:54:22)
    Well, in design I think there is already an issue. Backend is more then just a database with which you connect. There should be a complete layer...
  • HELP WITH CHDIR !!!! TURBO PASCAL VS DELPHI (2001-01-03 08:48:49)
    This is because the ChDir Procedure, the SetCurrentDir and SetCurrentDirectory Functions are changing the directory in the active process. Try...
  • REPEATING FUNCTIONS (2001-01-04 11:46:34)
    The OnIdle event is not hardware dependent. It is called when the program has idle time. The OnIdle event is in TApplication and is a warpper...
  • HOW TO CREATE SEQURE LOGIN TO DESKTOP APPLICATION (2001-01-05 11:30:01)
    I'm not pretty sure, what your intention is. One possible approach would be to use a edit-field, which cannot be "spyed out" by the usual password...
  • HOW TO LOAD INI INTO A DLL (2001-01-05 16:43:45)
    unfortunatelly I haven't found anything interesting in the win32api help. I tried different methods. It seems like it is loading the data while...
  • MANIPULATING WINDOWS OF OTHER PROGRAMS (2001-01-04 21:11:41)
    You need to use the EnumWindows API function to figure out the handle of each window that you want to manipulate (you may also need to use...
  • EXES CONTAINING MORE THAN ONE ICON RESOURCE ... (2001-01-05 11:25:58)
    Just draw your icons with the Borland Image Editor (Delivered with Delphi). It allows to save different icons in one ico file as well.
  • HOW TO LOAD/SAVE FROM/TO INI FILES WITHOUT COMPONENTS? (2001-01-05 13:55:47)
    Thx...:)
Latest News
Submit News Form Past News
Latest Forum Entries