delphi

Unmanaged Exports: Cannot compile assembly

I want to create a .NET assembly that can be accessed from unmanaged code (Delphi 5). I have found Unmanaged Exports and followed the steps there but I am unable to successfuly compile even the basic example: using RGiesecke.DllExport; namespace DelphiNET { public class Class1 { [DllExport("add")] public stati...

widestring compatibility problem in Delphi

In a dll build with Delphi 2006 Foo(aPath: widestring); begin _rootPath := aPath; end; In an executable built with Delphi 2010 _Foo := GetProcAddress(FooModule,’Foo’); _Foo(‘123456’); Stepping into the dll, aPath = '123'. In fact any string I pass gets cut exactly in half. 1.) Why is my literal being halved? 2.) How do I fix it...

How to embed HTML help in a form window

I'm wondering if it is possible to display topics from a CHM help file in a form of my Delphy application? I know how to use the htmlhelp api but it launches the external help viewer. I would like to display the help topics within a form ...

How does minimax work?

Here's the case. I'm trying to make a Chess engine. Not that I believe that I can make anything better than what's already out there, but I want to see how it works. I've made some of the important parts, such as board representation and the evaluation function. The evaluation function seems to produce decent results, so now I need to im...

Stroring values in TBlobField using sql

I want to store images into a database using SQL commands, I know other ways using TBlobField.LoadFromFile etc, but we make our own sql commands to update the database that's why I need to do this. Any suggestions / pointers to how I should go about doing this? Sandeep ...

How to select (highlight and receive focus) entire text of selected cell in Delphi DBGrid?

Hello, I have a simple DBGrid, DBNavigator, and an 'Edit' Button which simply calls DBNavigator.BtnClick(nbEdit); When the user clicks 'Edit', I want the text in the selected cell (just the text - not the whole cell) to be highlighted - as if ready to be overwritten; whereas when I do DBGid.SetFocus; DBNavigator.BtnClick(nbEdit);...

Simple types with generics in Delphi

Hi How can I create a generic class only containing primitive types? TField<T: xxx> = class private FValue: T; public property Value: T read FValue write FValue; end; I don't need interfaces, classes, etc, I only want booleans, ints, floats and so on... Or there is another way to do that? Thanks ...

Hosting CLR in Delphi with/without JCL - example

Can somebody please post here an example how to host CLR in Delphi? I have read similar question here but I cannot use JCL as I want to host it in Delphi 5. Thank you. EDIT: This article about hosting CLR in Fox Pro looks promising but I don't know how to access clrhost.dll from Delphi. Edit 2: I give up on Delphi 5 requirement. No...

Get ready for Delphi 2009 and up when developing with Delphi 7?

Hi I'm developing a Word addin in Delphi 7, but soon I'll upgrade it to Delphi 2010, as you know, since version 2009 Delphi introduces the new string type UnicodeString which equals to the keyword string . On the other hand, according to this thread we need to use WideString to communicate with COM. My question is, what should I do in...

Problem with WM_COMMAND on Lazarus/FPC

I have form with MainMenu and I want to intercept when the user selects a command item from a menu. This works in Delphi: type TForm1 = class(TForm) ... // Memo and MainMenu created protected procedure WMCommand(var Info: TWMCommand); message WM_COMMAND; end; procedure TForm1.WMCommand(var Info: TWMCommand); begin if (...

Cast a form dynamically

I am writing a procedure to close all adoquery created and open on a (any) form, the problem is I need to do a cast on the form to identify the components. how can I make a dynamic cast like shown in the example? I need something like this Procedure OpenADODataSets(Form:TForm;FormType:TClass); ... ... (Form as FormType).ComponentCount ...

TADOQuery filter and an expression always true.

I am trying to filter some records from a TADOQuery. I set the filtered property to true and when I set the filter to field='value', all works fine. I would like to dynamically build this filter by appending <space>AND field='value' to a value always true, and I thought 1=1 would do the trick. So I would have 1=1 as the default filte...

Separate dbx connection to a thread

I made a small app that connects to a mysql db using dbx. It works ok with my local mysql server, but it's supposed to work with a remote server. Connecting to the remote server takes a few seconds, which freezes the app. So my question is, how can I put the connection code in a different thread? I'll have to pass that connection to t...

how to safely bypass Delphi Error: "types of formal and actual parameters must be identical"

I need a way to write a generic procedure to act upon an object type or any of its descendants. My first attempt was to declare procedure TotalDestroy(var obj:TMyObject); but when using it with a descendant object type TMyNewerObject = class(TMyObject); var someNewerObject: TMyNewerObject; TotalDestroy(someNewerObject); I get the...

How do I Import TypeLib as safecall vs stdcall in Delphi 2010

Delphi versions before 2010 had an option in the Delphi Environment that one could set: "All v-table interfaces". This would change the calling convention when importing type libraries. In 2010, the option is gone. How do I import a type library with the safecall calling convention? I'm hoping maybe there is a more granular level of ...

How to connect from Delphi to Sybase Sql Server?

How can I connect from Delphi to Sybase Sql Server? I want to be able to make querys, execute stored procedures, reference views, etc., all the things that the server allows me to do. Are there any components (like the dbGo components) or something like that? ...

Looking for non-rectangular panel VCL component

Title says it all. Sometimes I want L-shaped, T-shaped, triangular, polygonal ... Free reusable component please . . . ...

Responding to linked Delphi Component Events

I have a custom Component (cut down) TMyComponent = class(TComponent) public procedure ClientConnected; published property ClientSocket: TClientSocket Read ...etc Right now i have in the OnConnect Event of the ClientSocket Call ClientConnected e.g. procedure TForm1.ElvinClient1Connect(Sender: TObject; Socket: TCustomWinS...

WM_SysCommand Preventing window move in delphi

I use the following code to capture when the minimise button of my program is pressed so that I can hide the form from the taskbar, and as such minimise to the system tray. procedure TForm1.WMSysCommand; begin if (Msg.CmdType = SC_MINIMIZE) then begin form1.Hide; show1.Checked :=false; hide1.Checked :=true; end; ...

EAccessViolation apparently being thrown by FreeMem

In the following method, FreeMem(), throws an EAccessViolation. What are the possible reasons? procedure TCustomDataset.FreeRecordBuffer(var Buffer: PChar); begin FreeMem(Buffer); end; EDIT: As far as I understand TDataset Buffers are only allocated in: function TCustomDataset.AllocRecordBuffer: PChar; begin Result := AllocMem(...