By adding show_window (sw_hide) to initstance (), you can write the following code in Initialization without displaying the icon on the taskbar:
: Setwindowlong (getsafehwnd (), gwl_exstyle, ws_ex_toolwindow); make it not displayed on the taskbar or add ws_ex_toolwindow In the first parameter of createmediawex to have the same effect as above.
Void hide_proc () // hide the process. It is applicable to Win9x and can still be seen in pwview! {Hinstance hdllinst = loadlibrary ("kernel32.dll"); If (hdllinst) {typedef DWORD (winapi * myfunc) (DWORD, DWORD); myfunc registerserviceprocessalias = NULL; handler = (myfunc) getprocaddress (hdllinst, "registerserviceprocess"); If (registerserviceprocessalias) {registerserviceprocessalias (getcurrentprocessid (), 1);} freelibrary (hdllinst );}}
The taskbar is a toolbar that can be stretched on the screen. It is the position of the program icon. To hide the taskbar icon of a program, you can apply the showwindow function and pass it to application-> handle window handle.
Showwindow (Application-> handle, sw_hide );
To make the taskbar icon appear again, change sw_hide to sw_show.
Showwindow (Application-> handle, sw_show );
Note: You can set the visible attribute of the main window to false to hide it.
Note: Using showwindow to hide the taskbar icon of the window is not persistent. Some actions will reproduce the taskbar icon. You can set the hidden application window to tool window to remove the taskbar icon of the program to avoid its re-emergence. Tool Windows never has a taskbar icon. There is a side effect of making the application window a tool window: When you press Alt-tab, it will not appear in the program list. You can call the API functions getwindowlong and setwindowlong to make the application window a tool window.
// This article from C ++ builder research-http://www.ccrun.com/article.asp? I = 459 & D = f6bfi1
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int){ DWORD dwExStyle = GetWindowLong(Application->Handle, GWL_EXSTYLE); dwExStyle |= WS_EX_TOOLWINDOW; SetWindowLong(Application->Handle, GWL_EXSTYLE, dwExStyle); try { Application->Initialize(); Application->CreateForm(__classid(TForm1), &Form1); Application->Run(); } catch (Exception &exception) { Application->ShowException(&exception); } return 0;}
Full control of your Windows Desktop
I believe you are very familiar with Windows desktop interfaces. Most of the screens are desktops and tables are arranged on them.
Area icon.
The taskbar is generally located under the desktop or on other desktop edges. On the far left is the start button, followed by the "Quick Start Press
Button area,
The button area of the program is the taskbar icon area, on which the volume adjustment icon and Input Method adjustment icon and clock are usually displayed.
This article first describes how to hide the content described above in the taskbar. We know that using the Windows API function showwindow can
Hide or
The key is how to obtain the window handle. In Windows, each window not only has a window HANDLE flag window, but also
There is a name
The window for marking the string of the class name. If you know the class name of the window, you can use the findwindow function to obtain the window handle. While
Windows Desktop
Itself is a window. The desktop icon area, the taskbar, And the start button under the taskbar are all its subwindows. We can use
Finddomainwex
Function to find these windows. Use the showwindow function to hide or display the window. The following uses a Delphi example to demonstrate how to control
Task Bar.
First, create a New Delphi project, add seven checkbox controls to form1, and then add the following code to form1:
Unit unit1; interfaceuses windows, messages, sysutils, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) checkbox1: tcheckbox; checkbox2: tcheckbox; checkbox3: tcheckbox; checkbox4: tcheckbox; checkbox5: tcheckbox; checkbox6: tcheckbox; checkbox7: tcheckbox; Procedure destroy (Sender: tobject); Private Procedure destroy (Sender: tobject); {private Declaration S} public {public declarations} end; constfile: // defines the class name straywindow = 'Shell _ traywnd 'for different windows; straynotify = 'traypolicywnd'; sstartbutton = 'twent '; sappswitchbar = 'rebarwindow32'; sappswitch = 'callback'; sappicon = 'toolbarwindow32'; strayclock = 'callback'; ssf-topicon = 'shelldll _ defview'; sprogman = 'progress '; vaR form1: tform1; WND: integer; implementation {$ R *. DFM} procedure tform1.formre Ate (Sender: tobject); begin checkbox1.caption: = 'hide task'; checkbox1.onclick: = checkbuttonclick; checkbox2.caption: = 'hide start button '; checkbox2.onclick: = checkbuttonclick; checkbox3.caption: = 'hide taskbar icons '; checkbox3.onclick: = checkbuttonclick; checkbox4.caption: = 'hide program click'; checkbox4.onclick: = checkbuttonclick; checkbox5.caption: = 'hide taskbar clock'; checkbox5.onclick: = checkbuttonclick; checkbox6.caption: =' Hide the desktop icon '; checkbox6.onclick: = checkbuttonclick; checkbox7.caption: = 'hide quick run icons'; checkbox7.onclick: = checkbuttonclick; end; [url = file: // 7] file: // 7 [/url] The click processing function procedure tform1.checkbuttonclick (Sender: tobject); var I: integer; begin file: // find the window handle WND: = findwindow (straywindow, nil); If (tcheckbox (sender ). name) = 'checkbox2 'Then WND: = find1_wex (WND, 0, sstartbutton, nil); If (TCH Eckbox (sender ). name) = 'checkbox3' then WND: = find1_wex (WND, 0, stray1_y, nil); If (tcheckbox (sender ). name) = 'checkbox4 'Then begin WND: = find1_wex (WND, 0, sappswitchbar, nil); WND: = find1_wex (WND, 0, sappswitch, nil); end; if (tcheckbox (sender ). name) = 'checkbox5' then begin WND: = find1_wex (WND, 0, stray1_y, nil); WND: = find1_wex (WND, 0, strayclock, nil); end; if (tcheckbo X (sender ). name) = 'checkbox6' then begin WND: = findwindow (sprogman, nil); WND: = find1_wex (WND, 0, s1_topicon, nil); end; if (tcheckbox (sender ). name) = 'checkbox7' then begin WND: = find1_wex (WND, 0, sappswitchbar, nil); WND: = find1_wex (WND, 0, sappicon, nil); end; if tcheckbox (sender ). checked then showwindow (WND, sw_hide) else showwindow (WND, sw_show); end. run the program and click different selection boxes to hide any Service bar or different parts on the taskbar. Next we will introduce how to manipulate the desktop icon. Set the background and color of the icon text and set the arrangement of icons. Through the above introduction, we know that Windows desktop is also a window, but it is a listview window. For listview window, there are a series of messages starting with LVM, you can use the Windows API function sendmessage to send these messages to the listview window to control the properties of the window. in Delphi, there are also a series of functions starting with listview, these functions can replace LVM _ messages. An example is as follows: first create a New Delphi project, add two commandbutton controls to form1, and then add the following code to form1: Unit unit1; interfaceuses windows, messages, examples, classes, graphics, controls, forms, dialogs, comctrls, stdctrls, commctrl; Type tform1 = Class (tform) button1: tbutton; button2: tbutton; Procedure button1click (Sender: tobject); Procedure button2click (Sender: tobject); Procedure formcreate (Sender: tobject); Private {private Declarations} public {public declarations} end; var form1: tform1; implementation {$ R *. DFM} procedure setdesktopiconcolor (forground, Background: tcolor; Trans: Boolean); var window: hwnd; begin window: = findwindow ('progman ', 'program manager'); file: // find the desktop window: = find1_wex (window, hwnd (NiL), 'shelldll _ defview', ''); file: // find the listview window where the desktop icon is placed: = find1_wex (window, hwnd (NiL), 'sysli Stview32', ''); If trans then file: // set the transparent text background color listview_settextbkcolor (window, $ ffffffff) // back color else file: // set the opaque text background color listview_settextbkcolor (window, background); // back color listview_settextcolor (window, forground); // foreground color file: // redraw the desktop icon listview_redrawitems (window, 0, listview_getitemcount (window)-1); updatewindow (window); file: // re-draw the window end; Procedure setdesktopiconarr (Iwidth, iheight: integer); var window: hwnd; I, i1, I2, icount: integer; begin window: = findwindow ('progman ', 'program manager '); window: = find1_wex (window, hwnd (NiL), 'shelldll _ defview', ''); window: = find1_wex (window, hwnd (NiL), 'syslistview32 ', ''); file: // set the distance between the icon and the border. I1: = 20; I2: = 20; file: // obtain the number of desktop icons icount: = listview_getitemcount (window)-1; for I: = 0 to icount do begin file: // set the icon position listview_setitemposition (window, I, i1, I2); I1: = I1 + iwidth; If I1> (screen. width-32) then begin I1: = 20; I2: = I2 + iheight; end; listview_redrawitems (window, 0, listview_getitemcount (window)-1 ); updatewindow (window); end; Procedure setdefaulticoncolors; var kind: integer; color: tcolor; begin kind: = color_desktop; color: = getsyscolor (color_desktop); setsyscolors (1, kind, color); end; Procedure tform1.button1click (Sender: tobject); begin file: // you can change clwhite and clblack to other color values to see the file: // setshorttopiconcolor (clwhite, clblack, true); end; Procedure tform1.button2click (Sender: tobject); begin file: // set the spacing of icons to 100 pixels. setdesktopiconarr (100,100); end; Procedure tform1.formcreate (Sender: tobject); begin button1.caption: = 'set the icon text color'; button2.caption: = 'set icon arrangement '; end.
In the preceding procedure, the setmediatopiconcolor function sets the foreground color, background color, and transparency of the icon text. The foreground and background Parameters specify the foreground color and background color of the text respectively, the Trans parameter specifies whether the text background is transparent (if there is a background pattern ).
The setmediatopiconarr function is used to arrange the desktop icons. The iwidth and iheight parameters respectively specify the horizontal vertical distance between icons. If you want the setmediatopiconarr function to take effect, you need to remove the automatic arrangement option of the desktop icon. In addition, other control messages of the listview class can be used to control more desktop icon options.