⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 delsec04.txt

📁 《Delphi开发人员指南》配书原码
💻 TXT
字号:
Delphi Integrated Development Environment (IDE) Frequently  Asked  Questions (F A Q: 
Last Updated - March 16, 1995


1 Q: Where cabn I get more Delphi Information?
1 A: Now available on the "From Borland" download library are the 
     following Delphi informational files:
     DELBKS.TXT   -=> Delphi BookList
     DEL_FS.ZIP     -=> Delphi Fact Sheet
     DEL_ QI.ZIP      -=> Delphi  Quick Info Sheet

2 Q:  How do you make Button controls align themselves to the
      bottom of a window when the window/dialog is resized?
2 A:  Create a TPanel, set alignment to bottom, and place your
      button on the panel. If you don't want the panel visible,
      turn off ctl3d, set bevels to none and parentcolor = true.

3 Q:  How to I add a "Help Break" to a main menu so that it is
      aligned on the right edge?
3 A:  You can't do it at design time.  At run time, add the
      following to your form's OnCreate handler:
              Help1.Caption := #8 + Help1.Caption;
      Note: This is discouraged by Microsoft's latest design
          guidelines, and doesn't work at all under Windows 95.

4 Q:  What can I read/buy to learn about the hidden "methods"?
4 A:  The Component Writer's Help goes into deeper detail, or Buy
      the VCL source code and look at it directly.

5 Q:  How do I do decimal alignment all right justified?
        0.50
       10.55
      245.98
5 A: For TEdit objects, make them multi-line edits and set style
     to es_Right. For TDBEdits, you can add the fields to your form,
     and set the  Alignment and DisplayFormat properties.

6 Q: How do I set Tab Order?
6 A: Click on the form holding the controls, then choose 
     Edit | Tab Order.

7 Q: How do I make Windows recognize a program written in VB as a 
     screen saver?
7 A: 1) Put this line in the Project Source:
        {$D SCRNS AVE:NameOfScreenSaver}
   2) Compile the project
   3) Rename the .EXE to .SCR and put it in the Windows directory
      To make it  ACT as a screen saver and respond to OnClick and 
      OnKeyUp by calling Close. Respond to OnMouseMove by checking
      if this is the FIRST OnMouseMove and, if not, calling Close.
           CONST FirstTime : Boolean = True;
              begin
               IF NOT FirstTime THEN Close;

8 Q: How do I handle a Stream Read Error?
8 A: Try deleting the *.DSM file, and re-compiling your project.

9 Q: Is there any way to create global variables in Delphi?  
9 A: Open up a new unit and declare the global structures in the
     interface portion of that unit (the implementation portion
     can be empty).  Add the name of that unit to the USES list of
     any other units from which you want to access the globals.

10 Q: Why does closing the unit (pas) window also close the form?
10 A: Because Delphi has to be able to manipulate the code when you
      work with the dialog. It is constantly watching what you do
      and alters the code to reflect the changes to the form.

11 Q: When I compile code that calls the WinPrn unit, Delphi says it
      can't find WinPrn.DCU.
11 A:  Add \DELPHI\SOURCE\RTL70 to your application's Search Path.

12 Q: How do you center a form on the screen?
12 A: Use the div, operator not the / operator:
      MyLeft := (Screen.Left - Form1.Left) div 2;
      Or You can also set the Position property of
      the form to poScreenCenter.

13 Q: If I compile my BP7 project in Delphi, will I be able to 
      use Delphi's integrated debugger with it? If so, how do I
      tell Delphi what my "Primary File" is? Since I don't have
      any forms?
13 A: Yes, you can use the integrated debugger. The primary file
      is the *.P AS file that you opened as a project.  You have to 
      select Open Project and change the file type from *.DPR to
      *.P AS and then select the BP7 program you want to compile.

14 Q: As I add items (listBoxName.items.add('xxx')), how can I
      show the newest item?  When there are more items than show,
      and the scrollbar appears, the new items are added below 
      what is visible on the screen.  I would like to have the 
      list 'move up' so that the latest item is visible.
14 A: Try setting:
      listBoxName.items.add('xxx')
      listBoxName.itemIndex := (listBoxName.items.count-1)

15 Q: Is there a property to align the text in the listBox
      to the right?
15 A: No. Try padding the string with spaces.

16 Q: What does the debugger message "Debugger Is Unable To Stop 
      Due To 'Hard Mode'" mean?
16 A: DEFINITION:Hard mode is a state of Windows when no message
      processing can take place. It happens during menu drawing 
      and some kernel operations.  It means that you are in a 
      state that Delphi can not "freeze" your application without 
      locking up Windows. Typically, that arises as a result of 
      multiple SendMessage calls. In addition a workaround which 
      often works: What you need to do is kick the system out of 
      hard mode. Interestingly enough, this can happen when the
      debugger puts up the system modal messagebox to tell you it's 
      in hard mode! So try putting an additional breakpoint on the
      line *before* your breakpoint. This first one will cause the 
      hard mode warning and should kick Windows out of hard mode. 
      When you OK that messagebox the second, desired, breakpoint
      should work.
      NOTE: Since the debugger is message driven, it cannot 
             allow you to stop at a breakpoint if it thinks 
             the system is in hard mode, because you wouldn't
             be able to do anything and the system would appear
             to be hung.

17 Q: Is it possible to load a BP program (either as a project or 
      as a program) in the IDE and have it compiled?
17 A: Yes, it is possible, but let me qualify that.  More precisely,
      a BPW program can be loaded into Delphi. Select Open Project
      from the menu or speedbar, and then in the filter combo box 
      select *.P AS files.  This will allow you to load BPW *.P AS 
      programs. You'll need to add \DELPHI\SOURCE\RTL70 to your 
      project's search path.

18 Q: Why are simple EXE's so large(1 form and 1 button about 200K)?
18 A: Delphi's VCL is based on RTTI and exceptions. This requires a 
      'footprint' of about 120Kb for an 'empty' application. The 
      200K you get has additional debug info or is not optimised by 
      the compiler. Note that the size of your .EXE doesn't go to 
      400K for two buttons, but rather to 201K, i.e. after the
      footprint each additional control just adds the 'usual' amount
      of data/code size.   Additionally, you can slim your EXE's down
      by checking the "Optimize For Size  And Load Time" checkbox on
      the Linker page of the OPTIONS|PROJECT dialog.  

19 Q: Can I use a second monitor to watch the BP program output?
19 A: In order to use two monitors one must be an MD A monitor
      (the old Hercules monochrome style) and the other VG A 
      (or EG A etc.).  They must use two address spaces $B000 for the 
      MD A and $B800 for the VG A.  Once you have these monitors 
      installed you can tell the BP IDE to use the second monitor in
      Options/Environment/StartUp.  The default monitor at starting 
      up the BP IDE will become the program's output display. 
       NOTE: once the Hercules card is installed, your VG A card
             will be accessed as an 8 bit card.
                    NOT  APPLIC ABLE TO DELPHI 

20 Q: How does a speedbutton on a frame trigger a save event in the 
      active child MDI Sheet?  A call to TEditForm.Save1click does 
      not work.
20 A: Try:
      with  Application.MainForm. ActiveMDIChild as TEditForm do
      Save1Click(Sender);
      Or Try:
      if  ActiveMDIChild is TEditForm do
        TEditForm( ActiveMDIChild).Save1Click(Sender);

21 Q: Why in a comboboxcomponent if the 'Style'-property is set to
      'csDropDownList' does the following do nothing?
      combobox1.text := 'Something strange going on here!';
21 A: That's standard behavior of the windows combobox working as 
      DropDownList. The concept is that the shown text has to be 
      exactly the same as one of the elements of the list. The right
      way to execute this code is to choose the appropiate element 
      from the list:
       combobox1.ItemIndex:=0;
 {assuming combobox1.Item[0] = 'Something strange going on here!'}

22 Q: The edit controls automatically respond to CTRL-C, CTRL-X, 
      CTRL-Y, CTRL-Z for copy, cut, paste and undo. How do I display
      these options on the menubar and have them to the appropriate 
      places?
22 A: Try these event handlers:
      procedure 
      TStaffSearch.SpeedButtonCutToClipBoardClick(Sender: TObject); 
       begin if ((  ActiveControl ) is TCustomEdit ) then
         TEdit( ActiveControl).CutToClipBoard; end;
      procedure TStaffSearch.Delete1Click(Sender: TObject);
       begin if ((  ActiveControl ) is TCustomEdit ) then
         TEdit( ActiveControl).ClearSelection; end;
     In both cases you must determine which control is active and 
     call its appropriate method.  All of the controls that allow 
     editing of data descend from TCustomEdit. The above code 
     determines if the active control descends from TCustomEdit 
     and if it does calls the the desired method.

23 Q: What does the Object Inspector Display?
23 A: The Object Inspector displays all published properties 
      (that can be read and written and aren't array properties) of 
      a class.  The Object Inspector doesn't display the methods of
      a class.

24 Q: What is the difference between "SetKey / GoToKey" and 
      "FindKey"? What determines when one should be used instead of 
      the other?
24 A: There really is no difference in the functionality. SetKey + 
      some assignments to IndexFields + GotoKey is equivalent to a 
      simple FindKey. If the IndexFields are extraordinarily complex
      then the SetKey sequence may be simpler to code.

25 Q: Is there any way to determine if a particular button on a 
      TDBNavigator control is enabled?
25 A: Try:
         type
           TDBNavCracker = class(TDBnavigator);
          ...
         if TDBNavCracker(DBNavigator1).Buttons[nbEdit].Enabled 
         then...;

26 Q: Can I use older versions of S QL Links use those with the ID API
      that ships with Delphi?
26 A: No, For old S QL linkers, you can get everything in the 
      Client/Server edition, or you can get Delphi + new S QL Links.  

27 Q: How does Delphi handle run-Time errors?
27 A: When a run-time error occurs in Delphi an exception is 
      generated. If the appropriate option is set in the Environment
      settings, when an exception occurs while running your app from
      within Delphi, then Delphi will position the cursor on the 
      offending line. However, the program is not terminated. Since,
      an exception was generated, your app. does not exit 
      automatically.

28 Q: How does Delphi store code/forms? 
28 A: Forms are stored in DFM files (as binary) but if you open a it 
      (FILE|OPEN FILE) in the IDE Editor it opens as text, which you
      can edit directly.

29 Q: Will the TMediaPlayer in Delphi play avi files?
29 A: Delphi will play avi files with the TMediaPlayer, just set the
      media type, filename to the right values, set the display to a
      TPanel, and use the open method. Playing  AVI files requires an
      up-to-date copy of Video for Windows propertly installed on 
      your system. Once you've done that, though, it's as easy as 
      playing a W AV file. Leave the media player on dt AutoSelect for
      device type, assign FOOB AR. AVI to the filename, and play. The 
      movie will appear in a separate little window.

30 Q: How do you set a field's display to have a 'No Echo' effect
      for Password entry?
30 A:  All you need to do is specify which character ( * for example)
      you want to display in the Password property of the TEdit.  If
      you don't want to display any character, use a space, #32.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -