[lazarus] Fixes and hints for ComboBox in Win32 interface

Mattias Gaertner nc-gaertnma at netcologne.de
Sat Jul 26 06:04:36 EDT 2003


On Sat, 26 Jul 2003 11:47:00 +0200
Martin Smat <martin.smat at tiscali.cz> wrote:

> Hi,
> in the attached patch (for win32object.inc) is added processing 
> LM_GETITEMINDEX message for csComboBox and fixed TWin32Object.GetText 
> for csComboBox.

Thanks. Applied.

I will have a look at the ansistring issue today ..

Mattias


> 
> 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.
> 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