Delphi

  Home  Computer Programming  Delphi


“Delphi Programming Interview Questions and Answers will guide us not that Object Pascal refers to a branch of object-oriented derivatives of Pascal, mostly known as the primary programming language of Delphi. Pascal compilers, including those for Object Pascal, generally run very fast while producing highly optimized code. Learn Delphi Programming by this Delphi Programming Interview Questions with Answers guide”



31 Delphi Questions And Answers

21⟩ Do I have to know a lot about the Windows API to use Delphi?

There seems to be a feeling that you need to know more about Windows to use Delphi than you do to use Visual Basic. This isn't really true; you can get by in both environments with a very minimal understanding of Windows internals. However, in both environments, you have to know at least a little about the Windows API in order to really make the most of what you have. The difference is that Delphi gives you a lot more power to do all these interesting things, so you feel more limited if you don't know how.

 170 views

22⟩ How can I manipulate data programatically?

It is sometimes desirable to write code that deals with databases but is not associated with any particular form or user-interface details. To do this, you declare variables of type TDatabase, TTable and/or TQuery, and set their properties in code just as you would in the design environment. Make sure that you include the DB and DBTables units in your uses statement, or you will get "unknown identifier" errors during compilation.

 188 views

23⟩ How do I write a change password function for a Paradox table?

There is no way to do this within the Delphi VCL. Seems like a pretty serious omission to me. However, it is possible to do it by talking directly to the Borland Database Engine through the interface provided by the DBIPROCS and DBITYPES units. You call DbiDoRestructure, but set all the "number of" variables to zero, which makes it leave the existing values intact. I have code to do this, but it's a bit too long to included here. E-mail graham (at) mhn.org if you want it.

 182 views

24⟩ How does Delphis exception handling work?

The basic structure goes something like this:

p := new(big_thing);

try

blah(p);

foo(p);

finally

dispose(p);

end;

The first line allocates a big block of memory. Then, in the "try" block, we execute several statements, each of which might produce an error--or, in other words, "raise an event." If an error does occur, the rest of the "try" block will be skipped, "finally" blocks will be executed. If there are no errors, then the "finally" block will be entered when the last statement in the "try" block completes. So, either way, the big block of memory gets freed. These "try/finally" blocks will trap anything up to and including a Windows GPF.

 164 views

25⟩ Why do I get compile errors acessing the Sender object in events?

If you look at the declaration, the Sender object is of type TObject, which is the class from which (almost) all other objects are derived. You're probably trying to access a property that isn't defined in TObject, like Text or Caption or something. For this reason, "Sender.Text" will fail, but if (for example) you know that the sender is of type TEdit, then you could use "(Sender As TEdit).Text". If you aren't certain that the Sender object will always be the same type, you can check it with "if (Sender is TEdit) then < blah> ;". See section 5.14.

 187 views

27⟩ I am trying to call from Delphi and it GPFs. Whats up?

Based on the number of postings to comp.lang.pascal, it would seem that by far the largest number of problems calling Windows API functions or non-Delphi DLLs are caused by passing Pascal-style strings to functions that expect null-terminated (PChar) strings. This is the first thing you should check if you get a GPF or other strange results when calling an external function. See section 6.11 for more information on which type of strings go where.

 164 views

28⟩ How does Delphi handle Windows callbacks?

Just like C: You can get a far pointer to your callback procedure (you have to remember to declare it with the "far" qualifier, unless you have {F$+} in effect to force all calls to be far), pass the pointer to the Windows callback function, and there it is.

 161 views

30⟩ How do I write a global error handler?

Use the Application.OnException event. Look in the help under "application events" for details of how to create and attach an event handler to the application variable.

 213 views