[lazarus] Fixes and hints for ComboBox in Win32 interface

Martin Smat martin.smat at tiscali.cz
Sat Jul 26 05:31:56 EDT 2003


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

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.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: zip00014.zip
Type: application/octet-stream
Size: 717 bytes
Desc: "win32patch.zip"
Url : http://localhost/pipermail/lazarus/attachments/20030726/a5a33f3f/zip00014.obj


More information about the Lazarus mailing list