Delphi skills ABC
A How to Shield System Function Key
Sometimes we don't want the program to be interrupted by the user with ALT TAB, CTRL ALT DEL, CTRL ESC and other system function keys (such as automatic demos), then what to do? Prompt you, when running the screen saver, these function keys don't work - that is, as long as you run in your program, "deceive" Windows, make it self-righteous in the screen The protection status will become! Please see the following code:
VAR
Temp: integer;
Begin
SystemParametersInfo (SPI_Screensaverrunning, 1, @temp, 0);
END;
Of course, don't forget to restore settings at the end of the program, and wake up Windows. code show as below:
VAR
Temp: integer;
Begin
SystemParametersInfo (spi_screensaverrunning, 0, @temp, 0);
END;
B How to branch tips
Most of Delphi has a practical Hint property, that is, floating strips prompt. But sometimes it is longer, can you display the floating prompt bar branch? In fact, Hint is a string, so Delphi will automatically explain the carriage return control when the string is displayed, so as long as the carriage return control is equal. According to this principle, we can make a unique vertical prompt. Please set a label in Form1, then look at the sample code:
Procedure TFORM1.FormCreate (Sender: TOBJECT);
Begin label1.hint: = '' # 13 'straight' # 13 '提' # 13 'show';
END;
C How to display a picture in the menu
Have you used office97? Is it feeling that the icon is very fresh in the menu? If you want your program, you can add it so much, then you will prepare BMP!
Suppose you intend to add a printer icon (print "to the" file "menu bar (NAME N1)" Print "Add a printer icon (file name c: /inter.bmp), as long as the Form's oncreate This is written in the event:
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 unchecked menu items, and the second specified BitMap displayed when selected (CHECKED) is selected. In addition, since the menu item is limited, if Bitmap is too large, only the upper left corner is displayed.