Keith: Fixes for Win32

git-svn-id: trunk@652 -
This commit is contained in:
lazarus 2002-02-01 10:13:09 +00:00
parent ffb07a8f59
commit d2c64aa547
8 changed files with 74 additions and 31 deletions

View File

@ -1540,7 +1540,7 @@ endif
.PHONY: lcl components ide tools all clean
.SUFFIXES: .rc .res
%.res: %.rc
windres -i $< -o $@
windres -i $< -o $@ --preprocessor cpp
ide:
ifeq ($(OS_TARGET), win32)
$(MAKE) lazarus.res

View File

@ -44,7 +44,7 @@ endif
.SUFFIXES: .rc .res
%.res: %.rc
windres -i $< -o $@
windres -i $< -o $@ --preprocessor cpp
ide:
ifeq ($(OS_TARGET), win32)

View File

@ -90,6 +90,8 @@ begin
left := 125;
caption := 'Close';
Checked := True;
Height := 15;
Width := 60;
Show;
end;
@ -102,6 +104,8 @@ begin
left := 125;
caption := 'Ok';
Checked := False;
Height := 15;
Width := 50;
Show;
end;
@ -114,6 +118,8 @@ begin
left := 125;
caption := 'Cancel';
Checked := False;
Height := 15;
Width := 65;
Show;
end;
@ -126,6 +132,8 @@ begin
left := 125;
caption := 'Help';
Checked := False;
Height := 15;
Width := 55;
Show;
end;

View File

@ -53,6 +53,7 @@ constructor TForm1.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
Caption := 'Scrollbar Demo v0.1';
Height := 350;
ScrollBar1 := TSCrollBar.Create(self);
with SCrollbar1 do
@ -76,34 +77,38 @@ begin
Visible := True;
Caption := 'Button1';
onclick := @button1clicked;
Width := 65;
end;
Button2 := TButton.create(self);
with Button2 do
begin
Parent := self;
Left := 25;
Left := 65;
Visible := True;
Caption := 'Button2';
onclick := @button2clicked;
Width := 65;
end;
Button3 := TButton.create(self);
with Button3 do
begin
Parent := self;
Left := 55;
Left := 130;
Visible := True;
Caption := 'Button3';
onclick := @button3clicked;
Width := 65;
end;
Button4 := TButton.create(self);
with Button4 do
begin
Parent := self;
Left := 100;
Left := 195;
Visible := True;
Caption := 'Button4';
onclick := @button4clicked;
Width := 65;
end;
end;

View File

@ -172,7 +172,7 @@ begin
Track1.Parent := Self;
Track1.Left := 50;
Track1.Top := 150;
Track1.Width := 200;
Track1.Width := 140;
Track1.Height := 140;
Track1.Min := 0;
Track1.Max := 100;
@ -301,6 +301,9 @@ begin
end.
{
$Log$
Revision 1.3 2002/02/01 10:13:09 lazarus
Keith: Fixes for Win32
Revision 1.2 2000/07/23 19:04:42 lazarus
enhanced examples, stoppok

View File

@ -88,7 +88,7 @@ Type
Procedure CreateComponent(Sender: TObject);
Procedure AddChild(Parent, Child: HWND; Left, Top: Integer);
Procedure ResizeChild(Window: HWND; Left, Top, Width, Height: Integer);
Procedure ResizeChild(Sender: TObject; Left, Top, Width, Height: Integer);
Function GetLabel(CompStyle: Integer; Window: HWnd): String;
Procedure AssignSelf(Window: HWnd; Data: Pointer);
Procedure ReDraw(Child: TObject);
@ -332,6 +332,9 @@ End.
{ =============================================================================
$Log$
Revision 1.9 2002/02/01 10:13:09 lazarus
Keith: Fixes for Win32
Revision 1.8 2002/01/31 09:32:07 lazarus
Keith:
* Open and save dialogs can now coexist in apps (however, only one of each type of common dialog can be used per app :( )

View File

@ -38,8 +38,8 @@ Constructor TWin32ListStringList.Create(List: HWND);
Begin
Inherited Create;
If List = HWND(Nil) Then
//Raise Exception.Create('Unspecified list window');
Assert(False, 'Trace:Unspecified list window');
Raise Exception.Create('Unspecified list window');
//Assert(False, 'Trace:Unspecified list window');
FWin32List := List;
End;
@ -153,10 +153,11 @@ End;
Procedure TWin32ListStringList.Insert(Index: Integer; Const S: String);
Var
Li: HWND;
begin
Begin
SendMessage(FWin32List, CB_INSERTSTRING, Index, LPARAM(PChar(S)));
if FSorted then Sort;
end;
If FSorted Then
Sort;
End;
{*************************************************************}
{ TWin32CListStringList methods }
@ -306,7 +307,7 @@ Var
CSize: Integer;
K: Integer;
Begin
SendMessage(FWin32CList, CB_INSERTSTRING, Index, LPARAM(PChar(S)));
SendMessage(FWin32CList, CB_INSERTSTRING, Index, LPARAM(PChar(@S)));
End;
{------------------------------------------------------------------------------
@ -329,6 +330,9 @@ End;
{ =============================================================================
$Log$
Revision 1.3 2002/02/01 10:13:09 lazarus
Keith: Fixes for Win32
Revision 1.2 2002/01/17 03:17:44 lazarus
Keith: Fixed TPage creation

View File

@ -148,6 +148,7 @@ End;
Procedure TWin32Object.SetLabel(Sender: TObject; Data: Pointer);
Var
Handle, Wnd: HWnd;
I: Integer;
P: Pointer;
TbBI: TBBUTTONINFO;
TCI: TC_ITEM;
@ -185,8 +186,6 @@ 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');
SendMessage(Handle, CB_DELETESTRING, (Sender As TComboBox).ItemIndex, 0);
SendMessage(Handle, CB_INSERTSTRING, (Sender As TComboBox).ItemIndex, LPARAM(Data));
End;
csPage:
Begin
@ -535,7 +534,7 @@ activate_time : the time at which the activation event occurred.
If Sender Is TWinControl Then
With (Sender As TWinControl), PRect(Data)^ Do
If HandleAllocated Then
ResizeChild(Handle, Left, Top, Right, Bottom);
ResizeChild(Sender, Left, Top, Right, Bottom);
End;
LM_SHOWMODAL:
Begin
@ -703,7 +702,7 @@ activate_time : the time at which the activation event occurred.
Else
Raise Exception.Create('Message LM_GETITEMS - Not implemented');
End;
Data := TWin32ListStringList.Create(Control);
Data := TWin32ListStringList.Create(Handle{Control});
Result := Integer(Data);
End;
End;
@ -1116,7 +1115,7 @@ Begin
TWinControl(Sender).Parent := Nil;
TWinControl(Sender).Parent := AParent;
ResizeChild(TWinControl(Sender).Handle, TWinControl(Sender).Left, TWinControl(Sender).Top, TWinControl(Sender).Width, TWinControl(Sender).Height);
ResizeChild(Sender, TWinControl(Sender).Left, TWinControl(Sender).Top, TWinControl(Sender).Width, TWinControl(Sender).Height);
ShowHide(Sender);
Result := 0;
@ -1427,14 +1426,18 @@ End;
Resize a window
------------------------------------------------------------------------------}
Procedure TWin32Object.ResizeChild(Window: HWND; Left, Top, Width, Height: Integer);
Procedure TWin32Object.ResizeChild(Sender: TObject; Left, Top, Width, Height: Integer);
Var
Handle: HWND;
R: TRect;
Begin
//Handle := (Sender As TWinControl).Handle;
Handle := (Sender As TWinControl).Handle;
If (Sender Is TButton) Then
Height := Height - 4;
If TControl(Sender).Parent Is TCustomGroupBox Then
Top := Top + 14;
//If Handle <> HWND(Nil) Then
MoveWindow(Window, Left, Top, Width, Height, True)
MoveWindow(Handle, Left, Top, Width, Height, True)
{Else
Begin
GetClientRect(Handle, R);
@ -1534,6 +1537,7 @@ Type
Var
AccelIndex: Byte;
AItems: TMenuItem;
AProcess: TProcess;
Bottom, CompStyle, I, J, K, Left, Right, Top: Integer;
Buddy, Handle, ParentWindow, Window: HWnd;
Caption : String;
@ -1573,6 +1577,7 @@ Begin
Else
Parent :=((Sender As TWinControl).Parent As TPage).Parent.Handle;
Assert(False, Format('Trace:TWin32Object.CreateComponent - parent handle --> 0x%X', [Parent]));
Assert(False, 'Trace:Setting parent');
End
Else
@ -1659,7 +1664,7 @@ Begin
Flags := Flags Or BS_PUSHBUTTON
Else
Flags := Flags Or BS_DEFPUSHBUTTON;
Window := CreateWindow('BUTTON', StrTemp, Flags, Left, Top, Width, Height, Parent, HMENU(Nil), HInstance, Nil);
Window := CreateWindow('BUTTON', StrTemp, Flags, Left, Top, Width, Height - 8, Parent, HMENU(Nil), HInstance, Nil);
Assert(False, 'Trace:CreateComponent - Button Window Handle Value = $' + IntToHex(Window, 8));
Assert(False, 'Trace:CreateComponent - Creating a Button - SetProp');
If Window <> HWND(Nil) Then
@ -1670,8 +1675,19 @@ Begin
Begin
Assert(False, 'Trace:TODO: TWin32Object.CreateComponent - Code style csCalendar');
Assert(False, 'Trace:TODO: TWin32Object.CreateComponent (style csCalendar) - Opening the date/time control applet. This will have to be good enough for now.');
Window := CreateWindow('CalendarWndClass', StrTemp, Flags, Left, Top, Width, Height, Parent, HMenu(Nil), HInstance, Nil);
{$IFDEF VER1_0_4}
AProcess := TProcess.Create('control timedate.cpl', [poNoConsole]);
{$ELSE}
AProcess := TProcess.Create(TComponent(Sender).Owner);
AProcess.CommandLine := 'control timedate.cpl';
AProcess.Options := [poNoConsole];
{$ENDIF}
AProcess.Execute;
Window := HWND(AProcess);
//Window := CreateWindow('CalendarWndClass', StrTemp, Flags, Left, Top, Width, Height, Parent, HMenu(Nil), HInstance, Nil);
SetName(Window, StrTemp);
AProcess.Free;
AProcess := Nil;
End;
csCanvas:
Begin
@ -1688,8 +1704,7 @@ Begin
End;
csComboBox:
Begin
Window := CreateWindow('COMBOBOX', Nil, Flags Or CBS_AUTOHSCROLL Or CBS_DROPDOWN, Left, Top, Width, Height, Parent, HMENU(Nil), HInstance, Nil);
SendMessage(Window, CB_ADDSTRING, 0, LPARAM(LPCTSTR(StrTemp)));
Window := CreateWindow('COMBOBOX', Nil, Flags Or CBS_AUTOHSCROLL Or CBS_DROPDOWNLIST Or CBS_HASSTRINGS, Left, Top, Width, Height, Parent, HMENU(Nil), HInstance, Nil);
SetProp(Window, 'Lazarus', Sender);
SetName(Window, StrTemp);
End;
@ -1791,7 +1806,7 @@ Begin
End;
csFrame:
Begin
Window := CreateWindow('BUTTON', StrTemp, Flags Or BS_GROUPBOX, Left, Top, Width, Height, Parent, HMENU(Nil), HInstance, Nil);
Window := CreateWindow('BUTTON', StrTemp, Flags Or BS_GROUPBOX Or BS_TOP, Left, Top, Width, Height, Parent, HMENU(Nil), HInstance, Nil);
SetProp(Window, 'Lazarus', Sender);
SetName(Window, StrTemp);
End;
@ -2301,7 +2316,7 @@ Begin
Assert(False, Format('Trace:WARNING: [TWin32Object.GetValue] %S --> No Decendant of TWinControl', [Sender.ClassName]));
Handle := TWinControl(Sender).Handle;
Assert (Handle = 0, 'WARNING: TWin32Object.GetValue --> got no window');
Assert (Handle = 0, 'Trace:WARNING: TWin32Object.GetValue --> got no window');
Case TControl(Sender).FCompStyle Of
csTrackbar:
@ -2418,11 +2433,13 @@ Begin
End;
csRadiobutton, csCheckbox:
Begin
If TCheckBoxState(Data) = cbChecked Then
SendMessage(Handle, BM_SETCHECK, BST_CHECKED, 0)
If TCheckBoxState(Data^) = cbChecked Then
SendMessage(Handle, BM_SETCHECK, WParam(BST_CHECKED), 0)
Else If TCheckboxState(Data^) = cbUnchecked Then
SendMessage(Handle, BM_SETCHECK, WParam(BST_UNCHECKED), 0)
Else
SendMessage(Handle, BM_SETCHECK, BST_UNCHECKED, 0);
End;
SendMessage(Handle, BM_SETCHECK, WParam(BST_INDETERMINATE), 0);
End
Else
Assert (True, Format('Trace:WARNING: [TWin32Object.SetValue] failed for %S', [Sender.ClassName]));
End;
@ -3020,6 +3037,9 @@ End;
{
$Log$
Revision 1.13 2002/02/01 10:13:09 lazarus
Keith: Fixes for Win32
Revision 1.12 2002/01/31 09:32:07 lazarus
Keith:
* Open and save dialogs can now coexist in apps (however, only one of each type of common dialog can be used per app :( )