[lazarus] Fixes and hints for ComboBox in Win32 interface
Mattias Gaertner
nc-gaertnma at netcologne.de
Sat Jul 26 06:57:03 EDT 2003
On Sat, 26 Jul 2003 11:47:00 +0200
Martin Smat <martin.smat at tiscali.cz> wrote:
> Hi,
> In file win32callback.inc is a bug in processing message CB_INSERTSTRING.
> 1. Overcasting "With PLMInsertText(@LMessage)^ Do" is wrong because of
> different sizes of TLMessage(16B) and TLMInsertText(20B) => overwrites
> other local variable.
Exactly.
Messages are allowed to be bigger than 16 bytes, so WindowProc must be
extended to suport this. I added a PLMsg: PLMessage pointer to WindowProc,
so bigger messages can now be used. And I changed the CB_INSERTSTRING,
LB_INSERTSTRING.
I tested the combobox example without crash. (Although the used memo is
buggy.)
Mattias
> 2. NewText := String(LParam) causes access violation for me. I'm not
> sure why (maybe in internal implementation of Ansistrings in FPC when
> increasing the reference counter).
> I suggest following changes:
> 1. In file lmessages.pp change the TLMInsertText:
> TLMInsertText = record
> Msg : Cardinal;
> NewText : PChar; //NewText : String;
> Length : Word; //Length : Integer;
> Position : Word; //Position : Integer;
> UserData : Pointer;
> end;
>
> Size of TLMInsertText is now 16B.
>
> 2. In file win32callback.inc change processing CB_INSERTSTRING:
> With TLMInsertText(LMessage) Do
> Begin
> Msg := LM_INSERTTEXT;
> Position := WParam;
> NewText := PChar(String(LParam)); //NewText := String(LParam);
> Length := System.Length(NewText);
> UserData := Pointer(GetWindowLong(Window, GWL_USERDATA));
> End;
>
> After this changes I can run the combobox example without access
> violation.
>
> I know this is not 100% correct because WParam is longint and
> TLMInsertText.Position is after the changes Word. And I don't know if
> changing TLMInsertText record doesn't break GTK compatibility. A better
> solution is welcomed.
>
> Martin Smat.
>
--
More information about the Lazarus
mailing list