IT SOLUTIONS
Your full service technology partner! 
-Collapse +Expand
Delphi
Search Delphi Group:

Advanced
-Collapse +Expand Delphi To/From
To/FromCODEGuides
-Collapse +Expand Delphi Store
PRESTWOODSTORE

Prestwood eMagazine

November Edition
Subscribe now! It's Free!
Enter your email:

   ► KBDelphi Knowledge Base  Print This    All Groups  

Delphi FAQ Page

These FAQs are contributed by you (our online community members). They are organized by our knowledge base topics. Specifically, by the Delphi sub-topics.

Contribute a FAQ
Expand All

11 Pascal and Delphi Coding FAQs

Group: Pascal and Delphi Coding


Topic: BDE

-Collapse +Expand Q1. I have an application in Delphi 1-7, using BDE. Is there a way that I can upgrade the BDE so the can work with MSSQL 2005 or 2008. They work fine if MSSQL2000 is is used. Am I on a dead end or there is still hope?
 
Answer:
In 2001 or 2002, Borland announced that they were stopping development on the BDE and on SQL Links. That news affected SQL Links users most since SQL Servers change more dramatically than Paradox and dBase do. So, yes, you are in a bad situation.
 
You could continue with the BDE using the ODBC drivers for MS SQL but most developers switched out BDE/SQL Links for ADO/dbExpress. My suggestion is to take a look at switching out to ADO.
Posted By Mike Prestwood, Post #102119, KB Topic: BDE



Topic: Delphi for Win32

-Collapse +Expand Q2. Can I call a DotNet DLL from my Delphi Win32 application? For example, with Delphi 7 or Delphi 2010?
 
Answer:

It's not easy because the .NET RTL resides in a different process. You can wrap up the DotNet DLL into an ActiveX control and call it or have both your app and the DotNet DLL write to the registry, a file, etc. By the way, you CAN wrap up a Win32 DLL in a DotNet DLL and call it from DotNet.

Posted By Mike Prestwood, Post #100647, KB Topic: Delphi for Win32



Topic: Language Basics

-Collapse +Expand Q3. What is the difference between Camel Casing and Pascal Casing?
 
Answer:

Camel casing capitalizes the first character of each word except the first word, it can frequently resemble a camel. Used by many languages including Paradox's ObjectPAL and Java.

myAge
theBoxCar

Pascal casing capitalizes the first character of each word (including acronyms over two letters in length).

TheHtmlCode
CAStatePercent
Posted By Mike Prestwood, Post #101235, KB Topic: Language Basics
-Collapse +Expand Q4. What are the benefits of Win32/64 native code such as in Delphi over .Net?
 
Answer:

In general terms, native code offers faster potential performance and a smaller footprint but can be more complex to build. Also, native code does not require .Net's runtime -- Common Language Runtime (CLR).

Posted By Mike Prestwood, Post #101244, KB Topic: Language Basics



Topic: OOP

-Collapse +Expand Q5. What is the difference between private and strict private?
 
Answer:

Private visibility means members are invisible outside of the unit. In OO terms, this is how Object Pascal implements friendly classes (visibility to the private members of another class). To implement true private members in Delphi 1-7, put each class in a separate unit (most developers didn't bother).

Strict Private visibility means that private members within a class are visible ONLY within the class declared. In OO terms, this is true private visibility.

Posted By Mike Prestwood, Post #101231, KB Topic: OOP
-Collapse +Expand Q6. What is the difference between Protected and Strict Protected visibility?
 
Answer:

Protected visibility means members are invisible outside of the unit. In other words, protected members are visible to the class they are declared in as well as descendant classes and any class declared within the unit.

Strict Protected visibility means that protected members within a class are visible ONLY within the class declared and to descendant classes. In OO terms, this is true protected visibility.

Posted By Mike Prestwood, Post #101238, KB Topic: OOP
-Collapse +Expand Q7. What is a sealed class?
 
Answer:

A class which prevents another class from inheriting from it and/or prevents another class from overriding a member. The concept of making sure a class is the last class in a descendant class tree.

Examples - /ASPSuite/KB/CrossRef.asp?LangID=&ToLangID=&CatID=10&SyntaxID=4

Posted By Mike Prestwood, Post #101230, KB Topic: OOP
-Collapse +Expand Q8. Why do I have to specify virtual when creating an abstract method? Why not just abstract?
 
Answer:

For abstract methods, you must specify either regular virtual with the virtual keyword or dynamic virtual with the dynamic keyword. In Delphi for Win32, virtual methods are optimized for speed and dynamic methods are optimized for size. The Delphi help indicates to use virtual for most situations. 

It is true that the compiler could make virtual the default and therefore optional but requiring one or the other is consistent with Object Pascal's strong typing.

Posted By Mike Prestwood, Post #101265, KB Topic: OOP



Topic: Using Data

-Collapse +Expand Q9. How do you check screen resolution in Delphi?
 
Answer:

Use the Screen variable which is a TScreen. The Screen variable is a TScreen component that represents the screen of the system on which the application runs. By default, applications create a screen component based on information from Windows about the current screen device and assign it to Screen.

For example, put the following code in a button click:

MessageDlg( 'screen width = ' + IntToStr( Screen.Width ) + ',
screen height = ' + IntToStr( Screen.Height ),
    mtInformation, [mbOk], 0 );
Posted By Mike Prestwood, Post #100069, KB Topic: Using Data



Topic: Using Controls

-Collapse +Expand Q10. I have a form with two TEdit components on it. For the OnChange event for both, it clears the contents of the TEdit that is not changing. However, when clearing on TEdit the OnChange fires and clears the other TEdit, this then causes the OnChange in the other TEdit to fire. Fortunately, the second time the OnChange hits the original TEdit, it is already clear and nothing happens. How can I prevent the circular event firing?
 
Answer:

The simplest way to prevent the circular event firing is to check the form's ActiveControl property. This property indicates which component currently has the focus.

The OnChange event should read as follows:

procedure TForm1.EditChange(Sender: TObject);
begin
if TEdit(Sender).Name <> TEdit(ActiveControl).Name then
   begin
       // do processing
   end;
end;
Posted By Larry J. Rutledge , Post #101671, KB Topic: Using Controls
-Collapse +Expand Q11. How do you specify which color to use with TColorGrid from the samples page? Why isn't it documented?
 
Answer:

Use the public methods ForegroundColor and BackgroundColor. For example, in the OnChange event of a ColorGrid component you could do the following:

procedure TForm1.ColorGrid1Change(Sender: TObject); 
begin
   Edit1.Font.Color := ColorGrid1.ForegroundColor;
   Edit1.Color := ColorGrid1.BackgroundColor;
end;

None of the components on the "Samples" page are documented.

Posted By Mike Prestwood, Post #100073, KB Topic: Using Controls
-
   Contact Us!
 
Have a question? Need our services? Contact us now.
--Mike Prestwood

Call: 916-726-5675

email: info@prestwood.com


Go ahead!   Use Us! Call: 916-726-5675 


©1995-2017 Prestwood IT Solutions.   [Security & Privacy]