fixed combobox height from Vincent

git-svn-id: trunk@4475 -
This commit is contained in:
mattias 2003-08-13 16:26:07 +00:00
parent 122d5ff33f
commit e8f5c08e4a
7 changed files with 70 additions and 29 deletions

View File

@ -93,6 +93,7 @@ Var
LMInsertText: TLMInsertText; // used by CB_INSERTSTRING, LB_INSERTSTRING
LMScroll: TLMScroll; // used by WM_HSCROLL
LMKey: TLMKey; // used by WM_KEYDOWN WM_KEYUP
LMChar: TLMChar; // used by WM_CHAR
LMMouse: TLMMouse; // used by WM_LBUTTONDBLCLK
LMMouseMove: TLMMouseMove; // used by WM_MOUSEMOVE
LMMouseEvent: TLMMouseEvent; // used by WM_MOUSEWHEEL
@ -192,6 +193,17 @@ Begin
// UserData := Pointer(GetWindowLong(Window, GWL_USERDATA));
End;
End;
WM_CHAR:
Begin
PLMsg:=@LMChar;
With LMChar Do
Begin
Msg := LM_CHAR;
KeyData := LParam;
CharCode := WParam;
writeln('WM_CHAR KeyData=',KeyData,' CharCode=',CharCode);
End;
End;
WM_CLOSE:
Begin
LMessage.Msg := LM_CLOSEQUERY;
@ -505,9 +517,7 @@ Begin
End;
End;
WM_SIZE:
Begin
if not (OwnerObject is TCustomComboBox) then
begin
Begin
With TLMSize(LMessage) Do
Begin
Msg := LM_SIZE;
@ -522,7 +532,6 @@ Begin
if (Windows.GetWindowLong(Window, GWL_STYLE) and WS_HSCROLL) <> 0 then
Height := Height - GetSystemMetrics(SM_CYHSCROLL);
End;
end;
End;
WM_SYSKEYDOWN:
Begin
@ -645,6 +654,9 @@ end;
{
$Log$
Revision 1.50 2003/08/13 16:26:07 mattias
fixed combobox height from Vincent
Revision 1.49 2003/08/12 14:02:54 mattias
fixed keypress/keyup, createcaret on synedit focus

View File

@ -40,7 +40,11 @@ Begin
Result := StrComp(AStr, BStr);
end;
Procedure SetComboHeight(Handle:THandle;ALeft,Atop,AWidth,AHeight,AEditHeight:Integer);
begin
MoveWindow(Handle,ALeft,ATop,AWidth,AHeight,true);
SendMessage(Handle, WM_SIZE, 0, MakeLParam(AWidth,AEditHeight));
end;
{*************************************************************}
{ TWin32ListStringList methods }
{*************************************************************}
@ -52,6 +56,8 @@ end;
------------------------------------------------------------------------------}
Constructor TWin32ListStringList.Create(List : HWND; TheOwner: TControl);
Var
R:TRect;
Begin
Inherited Create;
If List = HWND(Nil) Then
@ -71,9 +77,12 @@ Begin
FFlagDeleteString:=CB_DELETESTRING;
FFlagInsertString:=CB_INSERTSTRING;
FFlagAddString:=CB_ADDSTRING;
FEditHeight:= SendMessage(FWin32List,CB_GETITEMHEIGHT,-1,0);
//Get edit and item sizes
Windows.GetClientRect(FWin32List,@R);
FEditHeight:= R.Bottom;
FItemHeight:= SendMessage(FWin32List,CB_GETITEMHEIGHT,0,0);
FDropDownCount:= TComboBox(TheOwner).DropDownCount;
If FDropDownCount = 0 then FDropDownCount:= 8;
end;
csListBox:begin
FFlagSort:=LBS_SORT;
@ -130,9 +139,16 @@ Begin
{ Do not call inherited Assign as it does things we do not want to happen }
If Source Is TStrings Then
Begin
Clear;
SendMessage(FWin32List,FFlagResetContent, 0, 0); // Clear;
For Counter := TStrings(Source).Count - 1 DownTo 0 Do
Insert(0, TStrings(Source)[Counter]);
SendMessage(FWin32List,FFlagAddString, 0, LPARAM(PChar(TStrings(Source)[Counter]))); //Insert
if FSender.FCompStyle=csComboBox Then
begin
if Count = 0 then
SetComboHeight(FWin32List,FSender.Left,FSender.Top,FSender.Width,FEditHeight + FItemHeight + 2,FEditHeight)
else
SetComboHeight(FWin32List,FSender.Left,FSender.Top,FSender.Width,FEditHeight + FDropDownCount*FItemHeight + 2,FEditHeight);
end;
End
Else
inherited Assign(Source);
@ -179,7 +195,7 @@ End;
Procedure TWin32ListStringList.Clear;
Begin
if FSender.FCompStyle=csComboBox Then
FSender.Height := FEditHeight + FItemHeight;
SetComboHeight(FWin32List,FSender.Left,FSender.Top,FSender.Width,FEditHeight + FItemHeight + 2,FEditHeight);
SendMessage(FWin32List,FFlagResetContent, 0, 0);
End;
@ -193,7 +209,7 @@ Procedure TWin32ListStringList.Delete(Index: Integer);
Begin
If (FSender.FCompStyle = csComboBox)
and (GetCount <= 1) Then
FSender.Height := FEditHeight + FItemHeight;
SetComboHeight(FWin32List,FSender.Left,FSender.Top,FSender.Width,FEditHeight + FItemHeight + 2,FEditHeight);
SendMessage(FWin32List,FFlagDeleteString, Index, 0);
End;
@ -205,6 +221,9 @@ End;
------------------------------------------------------------------------------}
Procedure TWin32ListStringList.Insert(Index: Integer; Const S: String);
Begin
If (FSender.FCompStyle = csComboBox)
and (GetCount = 0) Then
SetComboHeight(FWin32List,FSender.Left,FSender.Top,FSender.Width,FEditHeight + FItemHeight + 2,FEditHeight);
If FSorted Then
SendMessage(FWin32List,FFlagAddString, 0, LPARAM(PChar(S)))
Else
@ -378,8 +397,8 @@ End;
{ =============================================================================
$Log$
Revision 1.11 2003/08/12 14:02:54 mattias
fixed keypress/keyup, createcaret on synedit focus
Revision 1.12 2003/08/13 16:26:07 mattias
fixed combobox height from Vincent
Revision 1.10 2003/07/28 06:42:42 mattias
removed debuggging SetName, Patch from Karl Brandt

View File

@ -32,6 +32,7 @@ Type
FSender: TControl;
FEditHeight: Integer;
FItemHeight: Integer;
FDropDownCount: Integer;
//Win32 Flags
FFlagSort: Cardinal;
FFlagGetText:Cardinal;
@ -85,6 +86,9 @@ Type
{ =============================================================================
$Log$
Revision 1.7 2003/08/13 16:26:07 mattias
fixed combobox height from Vincent
Revision 1.6 2003/07/28 06:42:42 mattias
removed debuggging SetName, Patch from Karl Brandt

View File

@ -651,14 +651,19 @@ activate_time : the time at which the activation event occurred.
Left := R.Left;
Top := R.Top;
end
end;
R := Rect(Left, Top, R.Right - R.Left, R.Bottom - R.Top);
end
else if TControl(Sender).FCompStyle = csComboBox then
begin
Windows.GetWindowRect(TWinControl(Sender).Handle,@R);
R.Right:=Right;
R.Left:=Left;
end;
{Adjust for scrollbar}
// if (Windows.GetWindowLong(TWinControl(Sender).Handle, GWL_STYLE) and WS_VSCROLL) <> 0 then
// R.Right := R.Right + GetSystemMetrics(SM_CXVSCROLL);
// if (Windows.GetWindowLong(TWinControl(Sender).Handle, GWL_STYLE) and WS_HSCROLL) <> 0 then
// R.Bottom := R.Bottom + GetSystemMetrics(SM_CYHSCROLL);
ResizeChild(Sender, R.Left, R.Top, R.Right , R.Bottom);
ResizeChild(Sender, Left, Top, R.Right - R.Left, R.Bottom - R.Top);
end;
end;
End;
@ -1848,7 +1853,7 @@ Begin
End;
csComboBox:
Begin
Window := CreateWindow('COMBOBOX', Nil, Flags Or CBS_DROPDOWN, Left, Top, Width, Height, Parent, HMENU(Nil), HInstance, Nil);
Window := CreateWindow('COMBOBOX', Nil, Flags Or CBS_DROPDOWN or WS_VSCROLL, Left, Top, Width, Height, Parent, HMENU(Nil), HInstance, Nil);
SetProp(Window, 'Lazarus', Sender);
End;
csImage:
@ -2735,6 +2740,9 @@ End;
{
$Log$
Revision 1.85 2003/08/13 16:26:07 mattias
fixed combobox height from Vincent
Revision 1.84 2003/08/12 16:09:54 mattias
fixed sizing from Vincent

View File

@ -604,7 +604,7 @@ begin
DestroyWindow(ListHandle);
NewHandle:= CreateWindow('COMBOBOX', Nil, ListFlags, Left, Top, Width, Height, ParentHandle, HMENU(Nil), HInstance, Nil);
NewHandle:= CreateWindow('COMBOBOX', Nil, ListFlags or WS_VSCROLL, Left, Top, Width, Height, ParentHandle, HMENU(Nil), HInstance, Nil);
Handle:=NewHandle;
SendMessage(NewHandle, WM_SETFONT, GetStockObject(DEFAULT_GUI_FONT), 0);
@ -752,6 +752,9 @@ End;
{ =============================================================================
$Log$
Revision 1.18 2003/08/13 16:26:07 mattias
fixed combobox height from Vincent
Revision 1.17 2003/08/11 20:18:46 mattias
fixed position of control in TGroupBox from Micha

View File

@ -2042,16 +2042,6 @@ Begin
Result := HideCaret(Handle)
End;
Function TWin32Object.SetComboMinDropDownSize(Handle: HWND; MinItemsWidth, MinItemsHeight, MinItemCount: integer): boolean;
var
ComboBox: TCustomComboBox;
Begin
ComboBox := TObject(GetProp(Handle, 'Lazarus')) as TCustomComboBox;
if ComboBox = nil then exit;
Windows.MoveWindow(Handle, ComboBox.Left, ComboBox.Top, ComboBox.Width, ComboBox.Height + 15 * MinItemCount + 2, TRUE);
Result := true;
End;
{------------------------------------------------------------------------------
Method: SetFocus
Params: HWnd - Handle of new focus window
@ -2391,6 +2381,9 @@ end;
{ =============================================================================
$Log$
Revision 1.49 2003/08/13 16:26:07 mattias
fixed combobox height from Vincent
Revision 1.48 2003/07/29 22:32:48 marc
* Applied patch from Vincent Snijders

View File

@ -150,7 +150,6 @@ Function SetCapture(Value: LongInt): LongInt; Override;
Function SetCaretPos(X, Y: Integer): Boolean; Override;
Function SetCaretPosEx(Handle: HWnd; X, Y: Integer): Boolean; Override;
Function SetCaretRespondToFocus(Handle: HWND; ShowHideOnFocus: Boolean): Boolean; Override;
Function SetComboMinDropDownSize(Handle: HWND; MinItemsWidth, MinItemsHeight, MinItemCount: integer): boolean; Override;
Function SetFocus(HWnd: HWND): HWND; Override;
Function SetProp(Handle: hwnd; Str: PChar; Data: Pointer): Boolean; Override;
Function SetScrollInfo(Handle: HWND; SBStyle: Integer; ScrollInfo: TScrollInfo; BRedraw: Boolean): Integer; Override;
@ -180,6 +179,9 @@ Procedure DeleteCriticalSection(var CritSection: TCriticalSection); Override;
{ =============================================================================
$Log$
Revision 1.30 2003/08/13 16:26:07 mattias
fixed combobox height from Vincent
Revision 1.29 2003/07/29 07:38:09 marc
+ Added GetCursorPos