Several Delphi skills

xiaoxiao2021-03-06  93

Several Delphi Tips 1, Judging Num Lock, Caps Lock, Scroll Lock Indicator Status as an Example of Num Lock: Function isnumlockon (): Boolean; Begin Result: = (GetKeyState (vk_numlock) and $ 01) <> 0; If the light is on, returns true, and it is not light to return false. VK_NUMLOCK replaces VK_Capital or Scroll, you can determine the status of the Caps Lock or Scroll Lock indicator. 2. Change the width of the pull-down box of the ComboBox component The width of the COMBOX drop-down box is the same as the COMBOBOX's width (width), so if the ComboBox's ITEM content is longer, the pull-down box will not display. At this time, you can change the width of the drop-down box with the code to display the full content: ComboBox1.Perform (CB_SETDROPPEDTH, 600, 0); "600" indicates a new width and can be modified as needed. 3, activate the current screen saver PostMessage (getDesktopWindow, WM_SYSCOMMAND, SC_SCREENSAVE, 0); 4, open the Windows Find Dialog (add shellapi unit) shellexecute (Handle, 'Find', 'c: / windows', // Start Search for directory ',' ', sw_show; 5, determine if the system uses a large font. If the user sets the display effect is a big font, it will seriously affect the display of the software interface. If Screen.Pixelsperinch = 96 Then; // Normal font;

If Screen.pixelsperinch = 120 Then; // Big font; 6, cancel the default Beep. Delphi's TEDIT component After using the Enter key, the PC speaker will be Beep. The following code is used to cancel this sound: Procedure TFORM1.EDIT1KEYPRESS (Sender: Tobject; Var Key: char); begin if key = # 13 kiln key: = # 0; end; 7, determining whether the external application stops responding to Procedure TFORM1 .Button1Click (Sender: TObject); var H: THandle; lngReturnValue: longint; dWResult: DWORD; begin H: = FindWindow ( 'Notepad', nil); // to determine program if H> 0 then begin lngReturnValue: = SendMessageTimeout (H, WM_NULL, 0, 0, SMTO_ABORTIFHUNG And SMTO_BLOCK, 1000, dWResult); if lngReturnValue> 0 then ShowMessage ( 'responding') else ShowMessage ( 'Not responding'); end else ShowMessage ( 'Application not found'); end ;

转载请注明原文地址:https://www.9cbs.com/read-96541.html

New Post(0)