mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-15 12:39:07 +02:00
implements SET_LABEL from Micha
git-svn-id: trunk@4535 -
This commit is contained in:
parent
115757e25e
commit
d0b28bec51
@ -77,7 +77,7 @@ Type
|
||||
|
||||
Procedure CreateComponent(Sender: TObject);
|
||||
Function RecreateWnd(Sender: TObject): Integer; virtual;
|
||||
Function GetText(Sender: TComponent; var Data: String): Boolean; virtual;
|
||||
Function GetText(Sender: TComponent; Handle: HWND; var Data: String): Boolean; virtual;
|
||||
Procedure SetLabel(Sender: TObject; Data: Pointer);
|
||||
Procedure AddChild(Parent, Child: HWND);
|
||||
Procedure ResizeChild(Sender: TObject; Left, Top, Width, Height: Integer);
|
||||
@ -191,6 +191,9 @@ End.
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.36 2003/08/27 09:33:26 mattias
|
||||
implements SET_LABEL from Micha
|
||||
|
||||
Revision 1.35 2003/08/26 08:12:33 mattias
|
||||
applied listbox/combobox patch from Karl
|
||||
|
||||
|
@ -86,7 +86,7 @@ Begin
|
||||
//Get edit and item sizes
|
||||
Windows.GetClientRect(FWin32List,@R);
|
||||
FEditHeight:= R.Bottom;
|
||||
FItemHeight:= SendMessage(FWin32List,CB_GETITEMHEIGHT,0,0);
|
||||
FItemHeight:= Windows.SendMessage(FWin32List,CB_GETITEMHEIGHT,0,0);
|
||||
FDDownCount:= TComboBox(FSender).DropDownCount;
|
||||
If FDDownCount = 0 then FDDownCount:= 8;
|
||||
end;
|
||||
@ -141,19 +141,28 @@ End;
|
||||
Procedure TWin32ListStringList.Assign(Source: TPersistent);
|
||||
Var
|
||||
Counter: Integer;
|
||||
EditText: String;
|
||||
Begin
|
||||
{ Do not call inherited Assign as it does things we do not want to happen }
|
||||
If Source Is TStrings Then
|
||||
Begin
|
||||
SendMessage(FWin32List,FFlagResetContent, 0, 0); // Clear;
|
||||
// save any text in edit box
|
||||
if FSender.FCompStyle=csComboBox then
|
||||
CNSendMessage(LM_GETTEXT, FSender, @EditText);
|
||||
|
||||
Windows.SendMessage(FWin32List, FFlagResetContent, 0, 0);
|
||||
For Counter := TStrings(Source).Count - 1 DownTo 0 Do
|
||||
SendMessage(FWin32List,FFlagAddString, 0, LPARAM(PChar(TStrings(Source)[Counter]))); //Insert
|
||||
Windows.SendMessage(FWin32List, FFlagAddString, 0, LPARAM(PChar(TStrings(Source)[Counter]))); //Insert
|
||||
|
||||
if FSender.FCompStyle=csComboBox Then
|
||||
begin
|
||||
if Count = 0 then
|
||||
SetComboHeight(FSender,FSender.Left,FSender.Top,FSender.Width,FEditHeight + FItemHeight + 2)
|
||||
else
|
||||
SetComboHeight(FSender,FSender.Left,FSender.Top,FSender.Width,FEditHeight + FDDownCount*FItemHeight + 2);
|
||||
|
||||
// restore text in edit box
|
||||
CNSendMessage(LM_SETLABEL, FSender, PChar(EditText));
|
||||
end;
|
||||
End
|
||||
Else
|
||||
@ -174,8 +183,8 @@ Begin
|
||||
Raise Exception.Create('Out of bounds.')
|
||||
Else
|
||||
Begin
|
||||
Getmem(Item,SendMessage(FWin32List,FFlagGetTextLen,Index,0)+1);
|
||||
SendMessage(FWin32List, FFlagGetText, Index, LPARAM(Item));
|
||||
Getmem(Item,Windows.SendMessage(FWin32List,FFlagGetTextLen,Index,0)+1);
|
||||
Windows.SendMessage(FWin32List, FFlagGetText, Index, LPARAM(Item));
|
||||
End;
|
||||
Result := StrPas(Item);
|
||||
Dispose(Item);
|
||||
@ -189,7 +198,7 @@ End;
|
||||
------------------------------------------------------------------------------}
|
||||
Function TWin32ListStringList.GetCount: Integer;
|
||||
Begin
|
||||
Result := SendMessage(FWin32List, FFlagGetCount, 0, 0);
|
||||
Result := Windows.SendMessage(FWin32List, FFlagGetCount, 0, 0);
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -203,7 +212,7 @@ Begin
|
||||
if FSender.FCompStyle=csComboBox Then
|
||||
SetComboHeight(FSender,FSender.Left,FSender.Top,FSender.Width,
|
||||
FEditHeight + FItemHeight + 2);
|
||||
SendMessage(FWin32List,FFlagResetContent, 0, 0);
|
||||
Windows.SendMessage(FWin32List,FFlagResetContent, 0, 0);
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -218,7 +227,7 @@ Begin
|
||||
and (GetCount <= 1) Then
|
||||
SetComboHeight(FSender,FSender.Left,FSender.Top,FSender.Width,
|
||||
FEditHeight + FItemHeight + 2);
|
||||
SendMessage(FWin32List,FFlagDeleteString, Index, 0);
|
||||
Windows.SendMessage(FWin32List,FFlagDeleteString, Index, 0);
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -234,9 +243,9 @@ Begin
|
||||
SetComboHeight(FSender,FSender.Left,FSender.Top,FSender.Width,
|
||||
FEditHeight + FDDownCount*FItemHeight + 2);
|
||||
If FSorted Then
|
||||
SendMessage(FWin32List,FFlagAddString, 0, LPARAM(PChar(S)))
|
||||
Windows.SendMessage(FWin32List,FFlagAddString, 0, LPARAM(PChar(S)))
|
||||
Else
|
||||
SendMessage(FWin32List,FFlagInsertString, Index, LPARAM(PChar(S)));
|
||||
Windows.SendMessage(FWin32List,FFlagInsertString, Index, LPARAM(PChar(S)));
|
||||
End;
|
||||
|
||||
{*************************************************************}
|
||||
@ -315,7 +324,7 @@ End;
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TWin32CListStringList.Clear;
|
||||
Begin
|
||||
SendMessage(FWin32CList, LB_RESETCONTENT, 0, 0);
|
||||
Windows.SendMessage(FWin32CList, LB_RESETCONTENT, 0, 0);
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -326,7 +335,7 @@ End;
|
||||
------------------------------------------------------------------------------}
|
||||
procedure TWin32CListStringList.Delete(Index: Integer);
|
||||
begin
|
||||
SendMessage(FWin32CList, LB_DELETESTRING, Index, 0);
|
||||
Windows.SendMessage(FWin32CList, LB_DELETESTRING, Index, 0);
|
||||
end;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -343,8 +352,8 @@ Begin
|
||||
Raise Exception.Create('Out of bounds.')
|
||||
Else
|
||||
Begin
|
||||
Getmem(Item,SendMessage(FWin32CList,LB_GETTEXTLEN,Index,0)+1);
|
||||
SendMessage(FWin32CList, LB_GETTEXT, Index, LPARAM(Item));
|
||||
Getmem(Item,Windows.SendMessage(FWin32CList,LB_GETTEXTLEN,Index,0)+1);
|
||||
Windows.SendMessage(FWin32CList, LB_GETTEXT, Index, LPARAM(Item));
|
||||
Result := StrPas(Item);
|
||||
Dispose(Item);
|
||||
End;
|
||||
@ -358,7 +367,7 @@ End;
|
||||
------------------------------------------------------------------------------}
|
||||
Function TWin32CListStringList.GetCount: Integer;
|
||||
Begin
|
||||
Result := SendMessage(FWin32CList, LB_GETCOUNT, 0, 0);
|
||||
Result := Windows.SendMessage(FWin32CList, LB_GETCOUNT, 0, 0);
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -369,7 +378,7 @@ End;
|
||||
------------------------------------------------------------------------------}
|
||||
Function TWin32CListStringList.GetObject(Index: Integer): TObject;
|
||||
Begin
|
||||
HWND(Result) := SendMessage(FWin32CList, LB_GETITEMDATA, Index, 0);
|
||||
HWND(Result) := Windows.SendMessage(FWin32CList, LB_GETITEMDATA, Index, 0);
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -381,9 +390,9 @@ End;
|
||||
Procedure TWin32CListStringList.Insert(Index: Integer; Const S: String);
|
||||
Begin
|
||||
If FSorted Then
|
||||
SendMessage(FWin32CList,LB_ADDSTRING, 0, LPARAM(PChar(S)))
|
||||
Windows.SendMessage(FWin32CList,LB_ADDSTRING, 0, LPARAM(PChar(S)))
|
||||
Else
|
||||
SendMessage(FWin32CList,LB_INSERTSTRING, Index, LPARAM(PChar(S)));
|
||||
Windows.SendMessage(FWin32CList,LB_INSERTSTRING, Index, LPARAM(PChar(S)));
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -394,7 +403,7 @@ End;
|
||||
------------------------------------------------------------------------------}
|
||||
Procedure TWin32CListStringList.PutObject(Index: Integer; AObject: TObject);
|
||||
Begin
|
||||
SendMessage(FWin32CList, LB_SETITEMDATA, Index, LPARAM(AObject));
|
||||
Windows.SendMessage(FWin32CList, LB_SETITEMDATA, Index, LPARAM(AObject));
|
||||
End;
|
||||
|
||||
{$IFDEF H_PLUS}
|
||||
@ -406,6 +415,9 @@ End;
|
||||
{ =============================================================================
|
||||
|
||||
$Log$
|
||||
Revision 1.17 2003/08/27 09:33:26 mattias
|
||||
implements SET_LABEL from Micha
|
||||
|
||||
Revision 1.16 2003/08/26 08:12:33 mattias
|
||||
applied listbox/combobox patch from Karl
|
||||
|
||||
|
@ -182,7 +182,7 @@ End;
|
||||
Retrieves the text from a Windows control. This is a replacement for
|
||||
the LM_GetText message.
|
||||
------------------------------------------------------------------------------}
|
||||
Function TWin32Object.GetText(Sender: TComponent; Var Data: String): Boolean;
|
||||
Function TWin32Object.GetText(Sender: TComponent; Handle: HWND; var Data: String): Boolean;
|
||||
Var
|
||||
CapLen: Cardinal;
|
||||
Caption: PChar;
|
||||
@ -192,20 +192,21 @@ Begin
|
||||
Assert(False, Format('Trace:TWin32Object.GetText - Start --> %S', [Sender.ClassName]));
|
||||
Data := '';
|
||||
Result := True;
|
||||
Case (Sender as TControl).FCompStyle Of
|
||||
Case TControl(Sender).FCompStyle Of
|
||||
csComboBox:
|
||||
Begin
|
||||
CapLen := SendMessage((Sender As TWinControl).Handle, CB_GETLBTEXTLEN, CNSendMessage(LM_GETITEMINDEX, Sender, Nil), 0);
|
||||
Caption := StrAlloc(CapLen + 1);
|
||||
SendMessage((Sender As TWinControl).Handle, CB_GETLBTEXT, CNSendMessage(LM_GETITEMINDEX, Sender, Nil), LPARAM(Caption));
|
||||
// + 1 = terminating null character
|
||||
CapLen := Windows.SendMessage(Handle, WM_GETTEXTLENGTH, 0, 0) + 1;
|
||||
Caption := StrAlloc(CapLen);
|
||||
Windows.SendMessage(Handle, WM_GETTEXT, CapLen, LPARAM(Caption));
|
||||
Data := StrPas(Caption);
|
||||
StrDispose(Caption);
|
||||
End;
|
||||
csEdit, csMemo:
|
||||
Begin
|
||||
CapLen := GetWindowTextLength((Sender As TWinControl).Handle);
|
||||
CapLen := GetWindowTextLength(Handle);
|
||||
Caption := StrAlloc(CapLen + 1);
|
||||
GetWindowText((Sender As TWinControl).Handle, Caption, CapLen + 1);
|
||||
GetWindowText(Handle, Caption, CapLen + 1);
|
||||
Data := StrPas(Caption);
|
||||
StrDispose(Caption);
|
||||
End;
|
||||
@ -231,7 +232,6 @@ Begin
|
||||
Else
|
||||
Result := False;
|
||||
End;
|
||||
// Result := Data <> '';
|
||||
End;
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
@ -311,7 +311,10 @@ Begin
|
||||
Begin
|
||||
Assert(False, Format('Trace:TWin32Object.SetLabel - Got %S', [CS_To_String(TControl(Sender).FCompStyle)]));
|
||||
Assert(False, Format('Trace:TWin32Object.SetLabel - label --> %S', [String(PChar(Data))]));
|
||||
Assert(False, 'Trace:TWin32Object.SetLabel - I''m not sure if this''ll work');
|
||||
if TCustomComboBox(Sender).Style = csDropDownList then
|
||||
Windows.SendMessage(Handle, CB_SELECTSTRING, -1, LPARAM(Data))
|
||||
else
|
||||
Windows.SendMessage(Handle, WM_SETTEXT, 0, LPARAM(Data));
|
||||
End;
|
||||
csMemo:
|
||||
Begin
|
||||
@ -844,7 +847,7 @@ activate_time : the time at which the activation event occurred.
|
||||
End;
|
||||
LM_GETTEXT :
|
||||
Begin
|
||||
Result := Integer(GetText(Sender As TComponent,PString(Data)^));
|
||||
Result := Integer(GetText(TComponent(Sender), Handle, PString(Data)^));
|
||||
End;
|
||||
LM_GETITEMINDEX :
|
||||
Begin
|
||||
@ -1805,6 +1808,10 @@ Var
|
||||
//TCI: TC_ITEM;
|
||||
Const
|
||||
BitsPerPixel: Array[Boolean] Of Cardinal = (3, 1);
|
||||
ComboBoxStyles: array[TComboBoxStyle] of DWORD = (
|
||||
CBS_DROPDOWN, CBS_SIMPLE, CBS_DROPDOWNLIST,
|
||||
CBS_DROPDOWNLIST or CBS_OWNERDRAWFIXED,
|
||||
CBS_DROPDOWNLIST or CBS_OWNERDRAWVARIABLE);
|
||||
Begin
|
||||
Assert(False, 'Trace:CreateComponent - Start');
|
||||
Assert(False, 'Trace:CreateComponent - Value of Sender is $' + IntToHex(LongInt(Sender), 8));
|
||||
@ -1933,7 +1940,8 @@ Begin
|
||||
End;
|
||||
csComboBox:
|
||||
Begin
|
||||
Window := CreateWindow('COMBOBOX', Nil, Flags Or CBS_DROPDOWN or WS_VSCROLL, Left, Top, Width, Height, Parent, HMENU(Nil), HInstance, Nil);
|
||||
Flags := Flags or ComboBoxStyles[TCustomComboBox(Sender).Style];
|
||||
Window := CreateWindow('COMBOBOX', Nil, Flags or WS_VSCROLL or CBS_AUTOHSCROLL or CBS_HASSTRINGS, Left, Top, Width, Height, Parent, HMENU(Nil), HInstance, Nil);
|
||||
SetProp(Window, 'Lazarus', Sender);
|
||||
End;
|
||||
csImage:
|
||||
@ -2870,6 +2878,9 @@ End;
|
||||
|
||||
{
|
||||
$Log$
|
||||
Revision 1.98 2003/08/27 09:33:26 mattias
|
||||
implements SET_LABEL from Micha
|
||||
|
||||
Revision 1.97 2003/08/27 08:14:37 mattias
|
||||
fixed system fonts for win32 intf
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user