Posts

Showing posts from April, 2018

Undeclared windows.bitmap error

When we migrate a old version Delphi application to new version and if we have used windows.bitmap type variable in our project then we generally get following error. Undeclared identifier windows.bitmap   Actually we get this error because earlier  bitmap  type was declared in windows unit which is replaced with  winapi.windows in latest versions. So if we replace  windows.bitmap with  winapi.windows.bitmap then error will be resolved. just replace windows.bitmap   with  winapi.windows.bitmap  Cheers...😊

E2251 Ambiguous overloaded call to '%s' Delphi error

While porting our legacy project from old Delphi version to new Delphi version like from Delphi 7 to Delphi XE5, we faced above error frequently as we have used StrPas / StrPos / StrLen / TextToFloat function calls. And we found several cases and several reasons for cause of this error. Here I will explain why we get this error and what is the solution of this error. Some of following error we faced. E2251 Ambiguous overloaded call to 'Pos' E2251 Ambiguous overloaded call to 'StrPas' E2251 Ambiguous overloaded call to 'StrLen' E2251 Ambiguous overloaded call to 'TextToFloat' Why we get this error and what is the solution? Following are possible reasons of occurring this error in latest Delphi versions code. Case 1 If more than one overloaded version of a function exists in a unit and we are passing wrong arguments to the function call then this error will show. For example. We have different versions of StrPas function in  SysUtils.pa

Best practice to prevent Bugs and Exceptions during coding in Delphi

To develop a good application it needs to be bug free and as a good developer we need to code in best to prevent Bugs and Exception that may be raise during application run. So here in this blog I have pointed some steps for best coding practice. 1.  Hints and Warnings Solve all hints and warnings that shows during compile and build of an application in Delphi IDE.  The warnings marked by Delphi can really cause some errors in runtime. 2. Items of lists Never access items of a list without being sure that the item really exists in that list or not freed. Example if objText.Count > 10 then strText := objText.Strings[10]; 3. Pointers to objects Use the Assign function to check if an object is still assigned to a pointer. When freeing the object, also make sure the pointer is set to nil. Example if Assigned(objText) then intCount := objText.Count; FreeAndNil(objText); 4. Using of Try - Finally Always use a try-finally structure where you have to be sure some