Delphi skills ABC

Source: Internet
Author: User


How does a shield system function keys?
Sometimes we don't want Program What should I do if the user is interrupted by system function keys such as ALT + TAB, CTRL + ALT + DEL, CTRL + ESC (for example, automatic demo program? It prompts you that these function keys do not work when you are running the Screen Saver-that is, as long as you "cheat" windows during your program running, make it think it is in the screen protection status! Please refer to the following section Code :
VaR
Temp: integer;
Begin
Systemparametersinfo (spi_screensaverrunning, 1, @ temp, 0 );
End;
Of course, do not forget to reset the settings at the end of the program to "wake up" windows ". The Code is as follows:
VaR
Temp: integer;
Begin
Systemparametersinfo (spi_screensaverrunning, 0, @ temp, 0 );
End;
How to Branch B prompt
Most of the controls in Delphi have a practical hint attribute, that is, floating bar prompts. But sometimes the prompt is long. Can I display the floating prompt branch? In fact, hint is a string. Therefore, when Delphi displays the string, it automatically interprets the carriage return control character. Therefore, you only need to add the carriage return control character. Based on this principle, we can also make a unique vertical tip. First, deploy a label in form1, and then look at the sample code:
Procedure tform1.formcreate (Sender: tobject );
Begin label1.hint: = 'vertical '+ #13 +' straight '+ #13 +' '+ #13 +' ′;
End;
C. How to display images in the menu
Have you used office97? Do you think the icons displayed in the menu are fresh? If you want your program to be so icing on the cake, please prepare BMP!
Assume that you want to add a printer icon (File Name: C:/inter.bmp) for "print" under "file" (Name: N1 ), write the following code in the form oncreate 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;
Here, the first bitmap. Handle is used for unchecked menu items, and the second specifies the bitmap displayed when the selected (checked) items are the same. In addition, because the menu item height is limited, if the bitmap is too large, only the upper left corner is displayed.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.