I tried this one and it didn't work, does this help make any difference
to how I send the string, it mentions the string has to be a long
pointer to a null-terminated string. So a long pointer to a Pchar, also
if I make a Pchar, will that need to be in memory for the life of the
dialog, or just long enough to populate the combo box?

Jason
CB_ADDSTRING
This message is sent by an application to add a string to the list box
of a combo box. If the combo box does not have the CBS_SORT style, the
string is added to the end of the list. Otherwise, the string is
inserted into the list, and the list is sorted. 
CB_ADDSTRING wParam = 0, 
lParam = (LPARAM)(LPCSTR) lpsz
Parameters
lpsz 
Long pointer to the null-terminated string to be added. If you create
the combo box with an owner-drawn style but without the CBS_HASSTRINGS
style, the value of the lpsz parameter is stored as item data rather
than the string it would otherwise point to. The item data can be
retrieved or modified by sending the CB_GETITEMDATA <combobx_12.htm> or
CB_SETITEMDATA <combobx_28.htm> message. 


 -----Original Message-----
From:   Carl Reynolds [mailto:[EMAIL PROTECTED]] 
Sent:   Wednesday, 7 February 2001 5:13 p.m.
To:     Multiple recipients of list delphi
Subject:         RE: [DUG]:  SendMessage and strings

CB_AddString takes a null terminated string, ie. PChar, as an LParam
parameter, ie. Integer.  You could just cast the string to a pchar, and
thence to an integer, but I have a funny feeling that if you do
reference
counting might destroy it after the cast but before the sendmessage
completes.  I haven't looked to see whether that may happen, so unless
someone else is kind enough to investigate, I suggest you do things the
long
way and copy the string:

var p: PChar;

  GetMem(p, Length(MyString) + 1);
  try
    StrPCopy(p, MyString);
    SendMessage(GetDlgItem(hdlg, DLG_HELPSIZE), CB_ADDSTRING, 0,
Integer(p));
  finally
    FreeMem(p);
  end;

Cheers,
Carl

-----Original Message-----
From: Jason L. Coley [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, 7 February 2001 12:31 PM
To: Multiple recipients of list delphi
Subject: [DUG]: SendMessage and strings


Hi,

I still haven't got this working yet, I still cannot send a string using
the SendMessage command, so can anyone help me, I need it to add strings
to a combo box in a properties dialog.

How do I send a string as the lparam in the sendmessage command?

          SendMessage(GetDlgItem(hdlg, DLG_HELPSIZE), CB_ADDSTRING, 0,
MyString);

Regards
>Jason Coley
>Manawatu Software Solutions
>http://www.software-solutions.co.nz
<http://www.software-solutions.co.nz/> 

------------------------------------------------------------------------
---
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
------------------------------------------------------------------------
---
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"


---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED]
with body of "unsubscribe delphi"

Reply via email to