AHow to block system function keys
Sometimes we don't want the program to be interrupted by the user using Alt+Tab, Ctrl+Alt+Del, Ctrl+Esc and other system function keys (such as automatic demonstration programs), so what should we do? Let me remind you that these function keys are inactive when running the screen saver - that is, as long as your program is running, you can "trick" Windows so that it thinks it is on the screen. The protection status is now in place! Please look at the following code:
var
temp : integer;
begin
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 1, @temp, 0);
end;
Of course, don't forget to restore settings and "wake up" Windows at the end of the program. The code is as follows:
var
temp : integer;
begin
SystemParametersInfo(SPI_SCREENSAVERRUNNING, 0, @temp, 0);
end;
BHow to prompt branches
Most controls in Delphi have a practical Hint property, which is a floating bar prompt. But sometimes the prompt is long. Can the floating prompt bar be displayed in separate lines? In fact, Hint is a string, so Delphi will automatically interpret the carriage return control character when displaying the string, so just add the carriage return control character. Based on this principle, we can also make a unique vertical prompt bar. Please first arrange a label in form1, and then look at the sample code:
PRocedure TForm1.FormCreate(Sender: TObject);
begin label1.Hint := 'vertical' + #13 + 'straight' + #13 + 'ti' + #13 + 'show';
end;
CHow to display pictures in menu
Have you used Office97? Do you find it refreshing to display icons in menus? If you want your program to be so icing on the cake, then please prepare bmp as soon as possible!
Suppose you plan to add a printer icon (the file name is c:/inter.bmp) to the 9th item (the serial number is changed to 8) "Print" under the "File" menu bar (name is n1), then as long as the form's OnCreate The event is written like this:
var
Bmp: TPicture;
begin
Bmp := TPicture.Create;
Bmp.LoadFromFile(′c:/printer.bmp′);
SetMenuItemBitmaps(n1.Handle,8, MF_BYPOSITION,Bmp.Bitmap.Handle, Bmp.Bitmap.Handle);
end;
Among them, the first bitmap.handle is used for unselected menu items (unchecked), and the second one specifies the bitmap displayed when it is selected (checked). They can be the same or different. In addition, since the height of menu items is limited, if the bitmap is too large, only the upper left corner will be displayed. (Shanghai Wang Zhen)