Play Windows desktop icon
Everyone must be as unsatisfactory about Windows desktop. Then pick up the surgery knife (Delphi) to move surgery.
First of all, it is necessary to deal with the desktop icon. It's ugly, with a background color, not only looks awkward, but also covers a beautiful wallpaper, you must remove it, turn it into transparency. Secondly, the location of the icon will only be stupid to stay on the left side of the screen, and we have to go to drag, really tired! Give it some new patterns, please follow me!
1. Create a new project, add a CommCtrl unit in the USES, add a button on the form;
2, declare a function of obtaining a desktop handle:
Function TFORM1.GETDESKTOPHAND: THANDLE;
Begin
Result: = FindWindow ('Progman', NIL);
Result: = getWindow (Result, GW_CHILD);
Result: = getWindow (Result, GW_CHILD);
END;
3, declare a process of setting the icon text color:
Procedure TFORM1.SETTEXTCOLOR (ForeclR, BackCLR: Tcolor);
Var hand: thandle;
Begin
Hand: = getDesktophand;
ListView_setTextColor (Hand, ForeCLR); // Sets the text foreground color;
ListView_setTextBkcolor (Hand, BackCLR); // Sets the text background color, crnone is transparent;
Listview_redrawitems (hand, 0, listview_getimemcount (hand)); // Heavy painting;
END;
With the two methods above, you can have a small surgery on the desktop. The following describes the arrangement of icons.
4, with the center of the screen as a circular arrangement:
Procedure TFORM1.CIRCLE (R: Integer); //-gin R is a radius;
VAR
I, Count, Centerx, Centery, Tempr: Integer
Hand: thandle;
Radian: Double;
TEMPRECT: TRECT;
Desktopheight, DesktopWidth: Integer;
X, Y: Word;
Begin
Hand: = getDesktophand;
SystemParametersInfo (SPI_GetWorkarea, 0, @ TempRect, 0); // acquire work area;
DesktopWidth: = TempRect.right - tempRect.Light; // Width (ie, the width of the screen);
Desktopheight: = TempRect.Bottom - TempRect.top; // High (ie, the screen is high);
CenterX: = DesktopWidth Div 2; // Get the round X coordinate;
Center: = Desktopheight Div 2; // All-round Y coordinate;
If centerx> centery the
Tempr: = centery
Else
Tempr: = centerx;
IF r> Tempr THEN R: = Tempr; // The radius cannot exceed the shortest distance of the screen center point to the four sides;
Count: = listview_getimemcount (hand); // On the table, the number of icons; RADIAN: = 2 * 3.14159 / count; // The radians between adjacent icons;
For i: = 0 to count-1 do
Begin
// The first icon is above the top;
X: = Integer (Centerx Trunc (r * sin (i * radian)); // icon's X coordinate;
Y: = Integer (CNtery Trunc (R * COS (i * radian)))); // icon's Y coordinate;
SendMessage (Hand, LVM_SETITETETETETE, I, MAKELPARAM (X, Y)); // Set coordinates;
END;
END;
5, the icon right alignment:
Procedure align (Rec: integer); // The meticulin REC is an area of an icon, which is generally 77;
Var hand: thandle;
H, I, J, Desktopht, DesktopWidth: Integer;
TEMPRECT: TRECT;
Begin
Hand: = getDesktophand;
SystemParametersInfo (SPI_GetWorkarea, 0, @ TempRect, 0); // acquire work area;
DesktopWidth: = TempRect.right - tempRect.Light; // Width (ie, the width of the screen);
Desktopheight: = TempRect.Bottom - TempRect.top; // High (ie, the screen is high);
I: = 0; // The number of columns ranked in the icon
J: = 0;
For h: = 0 to listview_getitemcount (hand) -1 do
Begin
INC (j);
IF J * REC> Desktopheight Ten // Run a column;
Begin
INC (i); //
J: = 1;
END;
SendMessage (Hand, LVM_SETITETEMPSITION, H,
MakelParam (DesktopWidth-Rec * (i 1), REC * (J-1));
End; // FOR cycle ends;
END;
6. Add code in the click event:
Procedure TFORM1.BUTTON1CLICK (Sender: TOBJECT);
Begin
SetTextColor (CLBLACK, CRNONE); // Set the icon text color;
Circle (200); // Arranging the icon into a circle having a radius of 200;
// alignright (77); // right alignment;
END;
Compile operation, click the button. Wow! awesome! You can also play your imagination, slightly improve the program, put the icon into a snake shape, oval, ring, and more. The above procedures run in Win98 Delphi5.