Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2003-07

Fixes and hints for ComboBox in Win32 interface

3 messages · 2 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Mattias Gaertner
to Martin Smat: in the attached patch (for win32object.inc) is added processing LM_GETITEMINDEX message…
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

Show quoted text 40 lines
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.

Reply by email

Mattias Gaertner
to Martin Smat: in the attached patch (for win32object.inc) is added processing LM_GETITEMINDEX message…
Show quoted text 5 lines
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

Show quoted text 35 lines
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.

Reply by email

Martin Smat

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

Reply by email