Hide task bar shielding hotkey
In its own procedures will hide task bar and shield Ctrl + Alt + Del and Alt + Tab, etc. hotkey is also very interesting. They are relatively easy to achieve, but Do not forget to return to normal, and, in this case using three API function: FindWindow, and SystemParametersInfo ShowWindow in the use must be carried out before they were affirmed.
Implementation
Var Hwnd: THandle;
Tmp: integer;
Procedure TForm1.Button1Click (Sender: TObject);
Begin
Hwnd: = FindWindow ( 'Shell_TrayWnd' nil);
If Hwnd <> 0 then ShowWindow (Hwnd, SW_HIDE); / / Hide task bar
SystemParametersInfo (SPI_SCREEN
SAVERRUNNING, 1, @ Tmp, 0) / / shielding system hotkey
End;
Procedure TForm1.Button2Click (Sender: TObject);
Begin
Hwnd: = FindWindow ( 'Shell_TrayWnd' nil);
ShowWindow (Hwnd, SW_SHOW); / / recovery tasks column
SystemParametersInfo (SPI_SCR
EENSAVERRUNNING, 0, @ Tmp, 0);
/ / Restore system hotkey
End;
Dynamic adjustment of monitor
Delphi provides a screen resolution can dynamically change the function were EnumDisplaySettings () and ChangeDisplaySettings (). With them, programming can be changed at any time to adapt to demands resolution. Below the CRTReset function to facilitate the achievement of this feature:
Implementation
Function CRTReset (X, Y: Word): Boolean;
Var
LpDevMode: TDeviceMode;
Begin
Result: = EnumDisplaySettings (nil, 0, lpDevMode); / / acquisition mode
If Result then begin
LpDevMode.dmFields: = DM_PELSWID
TH Or DM_PELSHEIGHT;
LpDevMode.dmPelsWidth: = X;
LpDevMode.dmPelsHeight: = Y; / / Set the screen width and height
Result: = ChangeDisplaySettings (lpDevMode, 0) = DISP_CHANGE_SUCCESSFUL;
/ / Change the screen resolution and return to the success or failure
End;
End;
Procedure TForm1.Button1Click (Sender: TObject);
Begin
If CRTReset (800, 600) then ShowMessage ( 'Now is 800 * 600'); / / call functions, set up resolution of 800 × 600
End;
Mouse Wheel how Programming
We use the mouse, many of them with a wheel, user-friendly operation. Unfortunately, however, most programming usually only use the mouse to the left and right two keys, if the wheel operating functions into your program, will be able to hyperchromic many.
When the mouse pointer at the window, when Delphi OnMouseWheel provide for the wheel rolling, we can deal with it accordingly. In this case, placing the window in a Label1 labels, used to show the effect of a rolling wheel.
Implementation
Var i: integer;
Procedure TForm1.FormCreate (Sender: TObject);
Begin
I: = 0;
Label1.Caption: = inttostr (i);
End;
Procedure TForm1.FormMouseWheel (Sender: TObject; Shift: TShiftState;
WheelDelta: Integer; MousePos: TPoint; var Handled: Boolean);
Begin
If WheelDelta> 0 then i: = i +1 else i: = i-1;
/ / WheelDelta lattice parameters that the value of a rolling, rolling up positive, negative Scroll down for
Label1.Caption: = inttostr (i);
End; |