addes,labels,brusges,listview and partial support of comboboxes from roozbeh

git-svn-id: trunk@9182 -
This commit is contained in:
mattias 2006-04-25 16:07:59 +00:00
parent bc2f516a32
commit cf48584170
8 changed files with 898 additions and 213 deletions

View File

@ -863,15 +863,15 @@ Begin
End;
WM_CLOSE:
Begin
// if (Window = TWinCEWidgetSet(WidgetSet).AppHandle) and
// (Application.MainForm <> nil) then
if (Window = TWinCEWidgetSet(WidgetSet).AppHandle) and
(Application.MainForm <> nil) then
begin
Windows.SendMessage(Application.MainForm.Handle, WM_CLOSE, 0, 0);
Application.Terminate;
// Application.Terminate;
end
else begin
LMessage.Msg := LM_CLOSEQUERY;
end;
// else begin
// LMessage.Msg := LM_CLOSEQUERY;
// end;
// default is to destroy window, inhibit
WinProcess := false;
End;
@ -1002,7 +1002,6 @@ Begin
End;
WM_DESTROY:
Begin
Writeln('Got WM_DESTROY');
Assert(False, 'Trace:WindowProc - Got WM_DESTROY');
/// if lWinControl is TCheckListBox then
/// TWinCECheckListBoxStrings.DeleteItemRecords(Window);

View File

@ -168,6 +168,8 @@ type
property ThemesActive: boolean read FThemesActive;//just for not removing all those refrences
end;
{$I wincelistslh.inc}
const
BOOL_RESULT: Array[Boolean] Of String = ('False', 'True');
@ -239,13 +241,14 @@ var
IgnoreNextCharWindow: HWND = 0; // ignore next WM_(SYS)CHAR message
ComboBoxHandleSizeWindow: HWND = 0;//just dont know the use ye
{$I wincelistsl.inc}
{$I wincecallback.inc}
{$I winceobject.inc}
{$I wincewinapi.inc}
{$I wincelclintf.inc}
initialization
Assert(False, 'Trace:WinCEint.pp - Initialization');
finalization

View File

@ -48,6 +48,9 @@ begin
end;
procedure TWinCEWidgetSet.AppInit(var ScreenInfo: TScreenInfo);
var
Handle: HWND;
DC: HDC;
begin
{$ifdef VerboseWinCE}
WriteLn('TWinCEWidgetSet.AppInit');
@ -84,13 +87,28 @@ begin
FStockWhiteBrush := CreateBrushIndirect(LogBrush);
}
// Create parent of all windows, `button on taskbar'
//does this work on wince?!
FAppHandle := CreateWindow(@ClsName, CreatePWideCharFromString(Application.Title), WS_POPUP or
WS_CLIPSIBLINGS or WS_CAPTION or WS_SYSMENU or WS_MINIMIZEBOX,
0, {Windows.GetSystemMetrics(SM_CXSCREEN) div 2,}
0, {Windows.GetSystemMetrics(SM_CYSCREEN) div 2,}
0, 0, HWND(nil), HMENU(nil), HInstance, nil);
AllocWindowInfo(FAppHandle);
// set nice main icon
SendMessage(FAppHandle, WM_SETICON, ICON_BIG,
Windows.LoadIcon(MainInstance, 'MAINICON'));
// remove useless menuitems from sysmenu
// initialize ScreenInfo
{ Handle := GetDesktopWindow;
Handle := GetDesktopWindow;
DC := Windows.GetDC(Handle);
ScreenInfo.PixelsPerInchX := GetDeviceCaps(DC, LOGPIXELSX);
ScreenInfo.PixelsPerInchY := GetDeviceCaps(DC, LOGPIXELSY);
ScreenInfo.ColorDepth := GetDeviceCaps(DC, BITSPIXEL);
ReleaseDC(Handle, DC);}
ReleaseDC(Handle, DC);
end;

View File

@ -38,6 +38,7 @@ uses
end;
function CreatePWideCharFromString(inString : string): PWideChar;
function WideStringToString(inWideString : WideString) : String;
procedure DisposePWideChar(inPWideChar : PWideChar);
Function ObjectToHWND(Const AObject: TObject): HWND;
@ -45,6 +46,10 @@ function AllocWindowInfo(Window: HWND): PWindowInfo;
function DisposeWindowInfo(Window: HWND): boolean;
function GetWindowInfo(Window: HWND): PWindowInfo;
//roozbeh:these are simply copy-pasted from win32...i bet most of them can be changed
//or not that much neccessary on wince!
function LCLControlSizeNeedsUpdate(Sender: TWinControl;SendSizeMsgOnDiff: boolean): boolean;
Procedure LCLBoundsToWin32Bounds(Sender: TObject;var Left, Top, Width, Height: Integer);
procedure LCLFormSizeToWin32Size(Form: TCustomForm; var AWidth, AHeight: Integer);
function GetLCLClientBoundsOffset(Sender: TObject; var ORect: TRect): boolean;
function GetLCLClientBoundsOffset(Handle: HWnd; var Rect: TRect): boolean;
@ -63,11 +68,15 @@ function DisableWindowsProc(Window: HWND; Data: LParam): LongBool; stdcall;
procedure DisableApplicationWindows(Window: HWND);
procedure EnableApplicationWindows(Window: HWND);
function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean;
function GetControlText(AHandle: HWND): string;
procedure AddToChangedMenus(Window: HWnd);
//roozbeh:this thing belong to windows unit...someone should move them there!
function GetTextExtentPoint(DC: HDC; Str: PWideChar; Count: Integer; var Size: TSize): BOOL;
function GetTextExtentPoint32(DC: HDC; Str: PWideChar; Count: Integer; var Size: TSize): BOOL;
//becouse wince is only unicode,it allocs in unicode!
function SysAllocStringLen(psz:pointer;len:dword):pointer;
procedure SysFreeString(bstr:pointer);
@ -109,21 +118,57 @@ procedure SysFreeString(bstr:pointer);stdcall;
function SysReAllocStringLen(var bstr:pointer;psz: pointer;
len:dword): Integer; stdcall;external 'oleaut32.dll' name 'SysReAllocStringLen';
//better name for this?!
function CreatePWideCharFromString(inString : string): PWideChar;
var
tmpWideChar : PWideChar;
begin
tmpWideChar := SysAllocStringLen(nil,Length(inString));
tmpWideChar := SysAllocStringLen(nil,Length(inString));//it automatically reserves +1 to string!
MultiByteToWideChar(CP_ACP, 0, PChar(inString), -1, tmpWideChar, Length(inString));
Result := tmpWideChar;
end;
//well this is diffrent from normal string(widestring) or other rtl functions becouse it uses windows local codepage
//better name for this?!
function WideStringToString(inWideString : WideString) : String;
var
tmpStr : PChar;
//test : string;
inStrLen: integer;
begin
// test := string(inWideString);
inStrLen := Length(inWideString);
tmpStr := StrAlloc(inStrLen+1);
WideCharToMultiByte(CP_ACP, 0, PWideChar(inWideString), -1, tmpStr, inStrLen,nil,nil);
char((tmpStr+inStrLen)^) := #0;
Result := string(tmpStr);
StrDispose(tmpStr);
end;
procedure DisposePWideChar(inPWideChar: PWideChar);
begin
SysFreeString(inPWideChar);
end;
function GetLCLClientBoundsOffset(Handle: HWnd; var Rect: TRect): boolean;
var
OwnerObject: TObject;
begin
OwnerObject := GetWindowInfo(Handle)^.WinControl;
Result:=GetLCLClientBoundsOffset(OwnerObject, Rect);
end;
Procedure LCLBoundsToWin32Bounds(Sender: TObject;
var Left, Top, Width, Height: Integer);
var
ORect: TRect;
Begin
if (Sender=nil) or (not (Sender is TWinControl)) then exit;
if not GetLCLClientBoundsOffset(TWinControl(Sender).Parent, ORect) then exit;
inc(Left, ORect.Left);
inc(Top, ORect.Top);
End;
{-------------------------------------------------------------------------------
function GetLCLClientOriginOffset(Sender: TObject;
@ -194,13 +239,6 @@ Begin
Result:=true;
end;
function GetLCLClientBoundsOffset(Handle: HWnd; var Rect: TRect): boolean;
var
OwnerObject: TObject;
begin
OwnerObject := GetWindowInfo(Handle)^.WinControl;
Result:=GetLCLClientBoundsOffset(OwnerObject, Rect);
end;
procedure GetWin32ControlPos(Window, Parent: HWND; var Left, Top: integer);
var
@ -212,6 +250,45 @@ begin
Top := winRect.Top - parRect.Top;
end;
{-------------------------------------------------------------------------------
function LCLBoundsNeedsUpdate(Sender: TWinControl;
SendSizeMsgOnDiff: boolean): boolean;
Returns true if LCL bounds and win32 bounds differ for the control.
-------------------------------------------------------------------------------}
function LCLControlSizeNeedsUpdate(Sender: TWinControl;
SendSizeMsgOnDiff: boolean): boolean;
var
Window:HWND;
LMessage: TLMSize;
IntfWidth, IntfHeight: integer;
begin
Result:=false;
Window:= Sender.Handle;
LCLIntf.GetWindowSize(Window, IntfWidth, IntfHeight);
if (Sender.Width = IntfWidth)
and (Sender.Height = IntfHeight)
and (not Sender.ClientRectNeedsInterfaceUpdate) then
exit;
Result:=true;
if SendSizeMsgOnDiff then begin
//writeln('LCLBoundsNeedsUpdate B ',TheWinControl.Name,':',TheWinControl.ClassName,' Sending WM_SIZE');
Sender.InvalidateClientRectCache(true);
// send message directly to LCL, some controls not subclassed -> message
// never reaches LCL
with LMessage do
begin
Msg := LM_SIZE;
SizeType := SIZE_RESTORED or Size_SourceIsInterface;
Width := IntfWidth;
Height := IntfHeight;
end;
DeliverMessage(Sender, LMessage);
end;
end;
{
Updates the window style of the window indicated by Handle.
The new style is the Style parameter.
@ -485,7 +562,6 @@ begin
writeln('getprop called with nil list');
exit;
end;
//writeln('getprop ok');
repeat
if (pPropertyLists^.WindowHWND = hWnd) then
begin
@ -626,6 +702,44 @@ begin
end;
function MeasureText(const AWinControl: TWinControl; Text: string; var Width, Height: integer): boolean;
var
textSize: Windows.SIZE;
winHandle: HWND;
canvasHandle: HDC;
oldFontHandle: HFONT;
tmpText : PWideChar;
begin
winHandle := AWinControl.Handle;
canvasHandle := GetDC(winHandle);
oldFontHandle := SelectObject(canvasHandle, Windows.SendMessage(winHandle, WM_GetFont, 0, 0));
DeleteAmpersands(Text);
tmpText := CreatePWideCharFromString(Text);
Result := GetTextExtentPoint32(canvasHandle, PWideChar(tmpText), Length(Text), textSize);
DisposePWideChar(tmpText);
if Result then
begin
Width := textSize.cx;
Height := textSize.cy;
end;
SelectObject(canvasHandle, oldFontHandle);
ReleaseDC(winHandle, canvasHandle);
end;
function GetControlText(AHandle: HWND): string;
var
TextLen: dword;
tmpWideStr : PWideChar;
begin
TextLen := GetWindowTextLength(AHandle);
tmpWideStr := SysAllocStringLen(nil,TextLen + 1);
GetWindowText(AHandle, PWideChar(tmpWideStr), TextLen + 1);
Result := WideStringToString(widestring(tmpWideStr));
DisposePWideChar(tmpWideStr);
end;
{-------------------------------------------------------------------------------
procedure AddToChangedMenus(Window: HWnd);

View File

@ -203,9 +203,9 @@ end;
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.CreateBitmap(Width, Height: Integer; Planes, BitCount: LongInt; BitmapBits: Pointer): HBITMAP;
Begin
Assert(False, Format('Trace:> [TWin32WidgetSet.CreateBitmap] Width: %d, Height: %d, Planes: %d, BitCount: %d, BitmapBits: 0x%x', [Width, Height, Planes, BitCount, Longint(BitmapBits)]));
Assert(False, Format('Trace:> [TWinCEWidgetSet.CreateBitmap] Width: %d, Height: %d, Planes: %d, BitCount: %d, BitmapBits: 0x%x', [Width, Height, Planes, BitCount, Longint(BitmapBits)]));
Result := Windows.CreateBitmap(Width, Height, Planes, BitCount, BitmapBits);
Assert(False, Format('Trace:< [TWin32WidgetSet.CreateBitmap] --> 0x%x', [Integer(Result)]));
Assert(False, Format('Trace:< [TWinCEWidgetSet.CreateBitmap] --> 0x%x', [Integer(Result)]));
End;
{function TWinCEWidgetSet.ComboBoxDropDown(Handle: HWND; DropDown: boolean
@ -221,18 +221,23 @@ begin
AlwaysCreateMask);
end;}
{Function TWinCEWidgetSet.CreateBrushIndirect(Const LogBrush: TLogBrush): HBRUSH;
Function TWinCEWidgetSet.CreateBrushIndirect(Const LogBrush: TLogBrush): HBRUSH;
Var
LB: Windows.LogBrush;
Begin
LB.lbStyle := LogBrush.lbStyle;
LB.lbColor := Windows.COLORREF(ColorToRGB(LogBrush.lbColor));
LB.lbHatch := LogBrush.lbHatch;
Assert(False, Format('Trace:> [TWin32WidgetSet.CreateBrushIndirect] Style: %d, Color: %8x', [lb.lbStyle, lb.lbColor]));
// Result := Windows.CreateBrushIndirect(LB);
Result := Windows.CreatesBrushIndirect(LB);
Assert(False, Format('Trace:< [TWin32WidgetSet.CreateBrushIndirect] Got --> %x', [Result]));
End;}
Assert(False, Format('Trace:> [TWinCEWidgetSet.CreateBrushIndirect] Style: %d, Color: %8x', [lb.lbStyle, lb.lbColor]));
Result := 0;
if lb.lbStyle = BS_SOLID then
Result := Windows.CreateSolidBrush(LB.lbColor);
if lb.lbStyle= BS_NULL then
Result := Windows.GetStockObject(NULL_BRUSH);
if lb.lbStyle = BS_DIBPATTERNPT then
Result := CreateDIBPatternBrushPt(pointer(lb.lbHatch), lb.lbColor);
Assert(False, Format('Trace:< [TWinCEWidgetSet.CreateBrushIndirect] Got --> %x', [Result]));
End;
{------------------------------------------------------------------------------
Method: CreateCaret
@ -332,7 +337,7 @@ Var
Begin
LP := LogPen;
Lp.lopnColor := Windows.COLORREF(ColorToRGB(Lp.lopnColor));
Assert(False, 'Trace:[TWin32WidgetSet.CreatePenIndirect]');
Assert(False, 'Trace:[TWinCEWidgetSet.CreatePenIndirect]');
Result := Windows.CreatePenIndirect(Windows.LOGPEN(LP));
End;
@ -425,11 +430,7 @@ begin
Assert(False, Format('trace:> [TWinCEWidgetSet.DrawText] DC:0x%x, Str:''%s'', Count: %d, Rect = %d,%d,%d,%d, Flags:%d',
[DC, Str, Count, Rect.Left, Rect.Top, Rect.Right, Rect.Bottom, Flags]));
WideStr := CreatePWideCharFromString(String(str));
dc:=getdc(0);
SetTextColor(dc,GetSysColor(COLOR_WINDOWTEXT));
rect.Left:=10;rect.top:=10;rect.Right:=90;rect.bottom:=90;
Result := Windows.DrawText(DC, 'salam', -1, @Rect, DT_LEFT or DT_TOP or DT_WORDBREAK );
Result := Windows.DrawText(DC, WideStr, Count, @Rect, Flags);
DisposePWideChar(WideStr);
Assert(False, Format('trace:> [TWinCEWidgetSet.DrawText] DC:0x%x, Str:''%s'', Count: %d, Rect = %d,%d,%d,%d, Flags:%d',
[DC, Str, Count, Rect.Left, Rect.Top, Rect.Right, Rect.Bottom, Flags]));
@ -508,18 +509,18 @@ Function TWinCEWidgetSet.ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Re
var
pWideStr : PWideChar;
Begin
Assert(False, Format('trace:> [TWin32WidgetSet.ExtTextOut] DC:0x%x, X:%d, Y:%d, Options:%d, Str:''%s'', Count: %d', [DC, X, Y, Options, Str, Count]));
Assert(False, Format('trace:> [TWinCEWidgetSet.ExtTextOut] DC:0x%x, X:%d, Y:%d, Options:%d, Str:''%s'', Count: %d', [DC, X, Y, Options, Str, Count]));
pWideStr := CreatePWideCharFromString(string(Str));
Result := Boolean(Windows.ExtTextOut(DC, X, Y, Options, LPRECT(Rect), pWideStr, Count, Dx));
DisposePWideChar(pWideStr);
Assert(False, Format('trace:< [TWin32WidgetSet.ExtTextOut] DC:0x%x, X:%d, Y:%d, Options:%d, Str:''%s'', Count: %d', [DC, X, Y, Options, Str, Count]));
Assert(False, Format('trace:< [TWinCEWidgetSet.ExtTextOut] DC:0x%x, X:%d, Y:%d, Options:%d, Str:''%s'', Count: %d', [DC, X, Y, Options, Str, Count]));
End;
{function TWinCEWidgetSet.ExtSelectClipRGN(dc: hdc; rgn: hrgn; Mode: Longint
function TWinCEWidgetSet.ExtSelectClipRGN(dc: hdc; rgn: hrgn; Mode: Longint
): Integer;
begin
Result:=inherited ExtSelectClipRGN(dc, rgn, Mode);
end;}
end;
{------------------------------------------------------------------------------
Method: FillRect
@ -713,13 +714,13 @@ Function TWinCEWidgetSet.GetDC(HWnd: HWND): HDC;
var
ORect: TRect;
Begin
Assert(False, Format('Trace:> [TWin32WidgetSet.GetDC] HWND: 0x%x', [HWnd]));
Assert(False, Format('Trace:> [TWinCEWidgetSet.GetDC] HWND: 0x%x', [HWnd]));
Result := Windows.GetDC(HWnd);
if (Result<>0) and (HWnd<>0)
and GetLCLClientBoundsOffset(HWnd, ORect) then begin
MoveWindowOrgEx(Result, ORect.Left, ORect.Top);
end;
Assert(False, Format('Trace:< [TWin32WidgetSet.GetDC] Got 0x%x', [Result]));
Assert(False, Format('Trace:< [TWinCEWidgetSet.GetDC] Got 0x%x', [Result]));
End;
@ -861,7 +862,7 @@ end;}
Function TWinCEWidgetSet.GetScrollInfo(Handle: HWND; BarFlag: Integer; var ScrollInfo: TScrollInfo): Boolean;
Begin
ScrollInfo.cbSize:=sizeof(ScrollInfo);
Assert(False, 'Trace:TODO: [TWin32WidgetSet.GetScrollInfo]');
Assert(False, 'Trace:TODO: [TWinCEWidgetSet.GetScrollInfo]');
Result := Boolean(Windows.GetScrollInfo(Handle, BarFlag, @ScrollInfo));
End;
@ -874,9 +875,9 @@ End;
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.GetStockObject(Value: Integer): LongInt;
Begin
Assert(False, Format('Trace:> [TWin32WidgetSet.GetStockObject] %d ', [Value]));
Assert(False, Format('Trace:> [TWinCEWidgetSet.GetStockObject] %d ', [Value]));
Result := Windows.GetStockObject(Value);
Assert(False, Format('Trace:< [TWin32WidgetSet.GetStockObject] %d --> 0x%x', [Value, Result]));
Assert(False, Format('Trace:< [TWinCEWidgetSet.GetStockObject] %d --> 0x%x', [Value, Result]));
End;
{------------------------------------------------------------------------------
@ -890,7 +891,7 @@ Function TWinCEWidgetSet.GetSysColor(NIndex: Integer): DWORD;
Begin
if NIndex = COLOR_FORM then
NIndex := COLOR_BTNFACE;
Result := Windows.GetSysColor(nIndex);
Result := Windows.GetSysColor(nIndex or $40000000);
End;
{------------------------------------------------------------------------------
@ -955,27 +956,27 @@ tmw: TTextMetricW;
Begin
Assert(False, Format('Trace:> TODO FINISH[TWinCEWidgetSet.GetTextMetrics] DC: 0x%x', [DC]));
Result := Boolean(Windows.GetTextMetrics(DC, @TMw));
TM.tmHeight:= TMW.tmHeight;
TM.tmAscent:= TMW.tmAscent;
TM.tmDescent:= TMW.tmDescent;
TM.tmInternalLeading:= TMW.tmInternalLeading;
TM.tmExternalLeading:= TMW.tmExternalLeading;
TM.tmAveCharWidth:= TMW.tmAveCharWidth;
TM.tmMaxCharWidth:= TMW.tmMaxCharWidth;
TM.tmWeight:= TMW.tmWeight;
TM.tmOverhang:= TMW.tmOverhang;
TM.tmDigitizedAspectX:= TMW.tmDigitizedAspectX;
TM.tmDigitizedAspectY:= TMW.tmDigitizedAspectY;
TM.tmFirstChar:= TMW.tmFirstChar;
TM.tmLastChar:= TMW.tmLastChar;
TM.tmDefaultChar:= TMW.tmDefaultChar;
TM.tmBreakChar:= TMW.tmBreakChar;
TM.tmItalic:= TMW.tmItalic;
TM.tmUnderlined:= TMW.tmUnderlined;
TM.tmStruckOut:= TMW.tmStruckOut;
TM.tmPitchAndFamily:= TMW.tmPitchAndFamily;
TM.tmCharSet:= TMW.tmCharSet;
Assert(False, Format('Trace:< TODO FINISH[TWinCEWidgetSet.GetTextMetrics] DC: 0x%x', [DC]));
TM.tmHeight:= TMW.tmHeight;
TM.tmAscent:= TMW.tmAscent;
TM.tmDescent:= TMW.tmDescent;
TM.tmInternalLeading:= TMW.tmInternalLeading;
TM.tmExternalLeading:= TMW.tmExternalLeading;
TM.tmAveCharWidth:= TMW.tmAveCharWidth;
TM.tmMaxCharWidth:= TMW.tmMaxCharWidth;
TM.tmWeight:= TMW.tmWeight;
TM.tmOverhang:= TMW.tmOverhang;
TM.tmDigitizedAspectX:= TMW.tmDigitizedAspectX;
TM.tmDigitizedAspectY:= TMW.tmDigitizedAspectY;
TM.tmFirstChar:= TMW.tmFirstChar;
TM.tmLastChar:= TMW.tmLastChar;
TM.tmDefaultChar:= TMW.tmDefaultChar;
TM.tmBreakChar:= TMW.tmBreakChar;
TM.tmItalic:= TMW.tmItalic;
TM.tmUnderlined:= TMW.tmUnderlined;
TM.tmStruckOut:= TMW.tmStruckOut;
TM.tmPitchAndFamily:= TMW.tmPitchAndFamily;
TM.tmCharSet:= TMW.tmCharSet;
Assert(False, Format('Trace:< TODO FINISH[TWinCEWidgetSet.GetTextMetrics] DC: 0x%x', [DC]));
End;
{------------------------------------------------------------------------------
@ -1004,7 +1005,7 @@ End;
specified device context.
------------------------------------------------------------------------------}
{
//not in wince?
//roozbeh:not in wince?//not even getviewportorgex?!
Function TWinCEWidgetSet.GetWindowOrgEx(DC: HDC; P: PPoint): Integer;
Begin
Result := Integer(Windows.GetWindowOrgEx(DC, LPPoint(P)));
@ -1105,7 +1106,7 @@ begin
end;}
WindowInfo := GetWindowInfo(Handle);
//debugln('TWin32WidgetSet.GetWindowSize ',DbgSName(WindowInfo^.WinControl),' SW_MAXIMIZE=',dbgs(WP.showCmd=SW_MAXIMIZE),' ',dbgs(WP.rcNormalPosition));
//debugln('TWinCEWidgetSet.GetWindowSize ',DbgSName(WindowInfo^.WinControl),' SW_MAXIMIZE=',dbgs(WP.showCmd=SW_MAXIMIZE),' ',dbgs(WP.rcNormalPosition));
// convert top level lcl window coordinaties to win32 coord
Style := Windows.GetWindowLong(Handle, GWL_STYLE);
@ -1228,26 +1229,72 @@ procedure TWinCEWidgetSet.LeaveCriticalSection(var CritSection: TCriticalSection
);
begin
inherited LeaveCriticalSection(CritSection);
end;
end;}
function TWinCEWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
begin
Result:=inherited LineTo(DC, X, Y);
end;
{------------------------------------------------------------------------------
Method: LineTo
Params: DC - device context handle
X - x-coordinate of line's ending point
Y - y-coordinate of line's ending point
Returns: if the function succeeds
function TWinCEWidgetSet.MessageBox(hWnd: HWND; lpText, lpCaption: PChar;
uType: Cardinal): integer;
begin
Result:=inherited MessageBox(hWnd, lpText, lpCaption, uType);
end;
Draws a line from the current position up to, but not including, the specified point.
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.LineTo(DC: HDC; X, Y: Integer): Boolean;
Begin
Assert(False, Format('Trace:> [TWinCEWidgetSet.LineTo] DC:0x%x, X:%d, Y:%d', [DC, X, Y]));
Result := Boolean(Windows.LineTo(DC, X, Y));
Assert(False, Format('Trace:< [TWinCEWidgetSet.LineTo] DC:0x%x, X:%d, Y:%d', [DC, X, Y]));
End;
function TWinCEWidgetSet.MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint
): Boolean;
begin
Result:=inherited MoveToEx(DC, X, Y, OldPoint);
end;
{------------------------------------------------------------------------------
Method: MessageBox
Params: HWnd - The handle of parent window
LPText - text in message box
LPCaption - title of message box
UType - style of message box
Returns: 0 if not successful (out of memory), otherwise one of the defined
values:
IDABORT
IDCANCEL
IDIGNORE
IDNO
IDOK
IDRETRY
IDYES
function TWinCEWidgetSet.MoveWindowOrgEx(DC: HDC; dX, dY: Integer): Boolean;
The MessageBox function displays a modal dialog, with text and caption defined,
and includes buttons.
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.MessageBox(HWnd: HWND; LPText, LPCaption: PChar; UType: Cardinal): Integer;
var
LPWCaption,LPWText : PWideChar;
Begin
LPWCaption := CreatePWideCharFromString(String(LPCaption));
LPWText := CreatePWideCharFromString(String(LPText));
Result := Windows.MessageBox(HWnd, LPWText, LPWCaption, UType);
DisposePWideChar(LPWCaption);
DisposePWideChar(LPWText);
End;
{------------------------------------------------------------------------------
Method: MoveToEx
Params: DC - handle of device context
X - x-coordinate of new current position
Y - x-coordinate of new current position
OldPoint - address of old current position
Returns: If the function succeeds.
Updates the current position to the specified point.
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint): Boolean;
Begin
Assert(False, Format('Trace:> [TWinCEWidgetSet.MoveToEx] DC:0x%x, X:%d, Y:%d', [DC, X, Y]));
Result := Boolean(Windows.MoveToEx(DC, X, Y, LPPOINT(OldPoint)));
Assert(False, Format('Trace:< [TWinCEWidgetSet.MoveToEx] DC:0x%x, X:%d, Y:%d', [DC, X, Y]));
End;
{function TWinCEWidgetSet.MoveWindowOrgEx(DC: HDC; dX, dY: Integer): Boolean;
begin
Result:=inherited MoveWindowOrgEx(DC, dX, dY);
end;
@ -1275,31 +1322,79 @@ begin
Result:=inherited PairSplitterSetPosition(SplitterHandle, NewPosition);
end;
function TWinCEWidgetSet.PeekMessage(var lpMsg: TMsg; Handle: HWND;
wMsgFilterMin, wMsgFilterMax, wRemoveMsg: UINT): Boolean;
begin
Result:=inherited PeekMessage(lpMsg, Handle, wMsgFilterMin, wMsgFilterMax,
wRemoveMsg);
end;
function TWinCEWidgetSet.PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer;
Filled, Continuous: boolean): boolean;
begin
Result:=inherited PolyBezier(DC, Points, NumPts, Filled, Continuous);
end;
function TWinCEWidgetSet.Polygon(DC: HDC; Points: PPoint; NumPts: Integer;
Winding: boolean): boolean;
begin
Result:=inherited Polygon(DC, Points, NumPts, Winding);
end;
function TWinCEWidgetSet.Polyline(DC: HDC; Points: PPoint; NumPts: Integer
): boolean;
begin
Result:=inherited Polyline(DC, Points, NumPts);
end;}
{------------------------------------------------------------------------------
Method: PeekMessage
Params: LPMsg - Where it should put the message
Handle - Handle of the window (thread)
WMsgFilterMin - Lowest MSG to grab
WMsgFilterMax - Highest MSG to grab
WRemoveMsg - Should message be pulled out of the queue
Returns: Boolean if an event was there
Checks a thread message queue for a message.
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.PeekMessage(Var LPMsg: TMsg; Handle: HWND; WMsgFilterMin, WMsgFilterMax, WRemoveMsg: UINT): Boolean;
Begin
Result := Boolean(Windows.PeekMessage(@LPMsg, Handle, WMsgFilterMin, WMsgFilterMax, WRemoveMsg));
End;
{------------------------------------------------------------------------------
Method: Polygon
Params: DC - handle to device context
Points - pointer to polygon's vertices
NumPts - count of polygon's vertices
Winding
Returns: If the function succeeds
Use Polygon to draw a closed, many-sided shape on the canvas, using the value
of Pen. After drawing the complete shape, Polygon fills the shape using the
value of Brush.
The Points parameter is an array of points that give the vertices of the
polygon.
Winding determines how the polygon is filled.
When Winding is True, Polygon
fills the shape using the Winding fill algorithm. When Winding is False,
Polygon uses the even-odd (alternative) fill algorithm.
NumPts indicates the number of points to use.
The first point is always connected to the last point.
To draw a polygon on the canvas, without filling it, use the Polyline method,
specifying the first point a second time at the end.
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.Polygon(DC: HDC; Points: PPoint; NumPts: Integer; Winding: Boolean): Boolean;
var
PFMode : Longint;
Begin
Assert(False, Format('Trace:TWinCEWidgetSet.Polygon --> DC: 0x%X, Number of points: %D, Use winding fill: %S', [DC, NumPts, BOOL_RESULT[Winding]]));
// If Winding then
// PFMode := SetPolyFillMode(DC, Windows.WINDING)
// else
// PFMode := SetPolyFillMode(DC, Windows.ALTERNATE);
Result := Boolean(Windows.Polygon(DC, LPPOINT(Points), NumPts));
// SetPolyFillMode(DC, PFMode);
End;
{------------------------------------------------------------------------------
Method: Polyline
Params: DC - handle of device context
Points - address of array containing endpoints
NumPts - number of points in the array
Returns: If the function succeeds
Draws a series of line segments by connecting the points in the specified
array.
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.Polyline(DC: HDC; Points: PPoint; NumPts: Integer): Boolean;
Begin
Result := Boolean(Windows.Polyline(DC, LPPOINT(Points), NumPts));
End;
{------------------------------------------------------------------------------
Method: PostMessage
Params: Handle - handle of destination window
@ -1337,19 +1432,33 @@ end;
function TWinCEWidgetSet.RealizePalette(DC: HDC): Cardinal;
begin
Result:=inherited RealizePalette(DC);
end;
end;}
function TWinCEWidgetSet.Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean;
{------------------------------------------------------------------------------
Method: Rectangle
Params: DC - handle of device context
X1 - x-coordinate of bounding rectangle's upper-left corner
Y1 - y-coordinate of bounding rectangle's upper-left corner
X2 - x-coordinate of bounding rectangle's lower-right corner
Y2 - y-coordinate of bounding rectangle's lower-right corner
Returns: If the function succeeds
The Rectangle function draws a rectangle. The rectangle is outlined by using
the current pen and filled by using the current brush.
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean;
Begin
Assert(False, Format('Trace:> [TWinCEWidgetSet.Rectangle] DC:0x%x, X1:%d, Y1:%d, X2:%d, Y2:%d', [DC, X1, Y1, X2, Y2]));
Result := Boolean(Windows.Rectangle(DC, X1, Y1, X2+1, Y2+1));
Assert(False, Format('Trace:< [TWinCEWidgetSet.Rectangle] DC:0x%x, X1:%d, Y1:%d, X2:%d, Y2:%d', [DC, X1, Y1, X2, Y2]));
End;
function TWinCEWidgetSet.RectVisible(dc : hdc; const ARect: TRect) : Boolean;
begin
Result:=inherited Rectangle(DC, X1, Y1, X2, Y2);
Result := Boolean(Windows.RectVisible(DC, LPRECT(@ARect)^));
end;
function TWinCEWidgetSet.RectVisible(dc: hdc; const ARect: TRect): Boolean;
begin
Result:=inherited RectVisible(dc, ARect);
end;
function TWinCEWidgetSet.RegroupMenuItem(hndMenu: HMENU; GroupIndex: integer
{function TWinCEWidgetSet.RegroupMenuItem(hndMenu: HMENU; GroupIndex: integer
): Boolean;
begin
Result:=inherited RegroupMenuItem(hndMenu, GroupIndex);
@ -1370,9 +1479,9 @@ end;}
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.ReleaseDC(Window: HWND; DC: HDC): Integer;
Begin
Assert(False, Format('Trace:> [TWin32WidgetSet.ReleaseDC] DC:0x%x', [DC]));
Assert(False, Format('Trace:> [TWinCEWidgetSet.ReleaseDC] DC:0x%x', [DC]));
Result := Windows.ReleaseDC(Window, DC);
Assert(False, Format('Trace:< [TWin32WidgetSet.ReleaseDC] DC:0x%x', [DC]));
Assert(False, Format('Trace:< [TWinCEWidgetSet.ReleaseDC] DC:0x%x', [DC]));
End;
{
@ -1392,9 +1501,9 @@ end;}
-------------------------------------------------------------------------------}
Function TWinCEWidgetSet.RestoreDC(DC: HDC; SavedDC: Integer): Boolean;
Begin
Assert(False, Format('Trace:> [TWin32WidgetSet.RestoreDC] DC:0x%x, SavedDC: %d', [DC, SavedDC]));
Assert(False, Format('Trace:> [TWinCEWidgetSet.RestoreDC] DC:0x%x, SavedDC: %d', [DC, SavedDC]));
Result := Boolean(Windows.RestoreDC(DC, SavedDC));
// Assert(False, Format('Trace:< [TWin32WidgetSet.RestoreDC] DC:0x%x, Saved: %d --> %s', [Integer(DC), SavedDC, BOOL_TEXT[Result]]));
// Assert(False, Format('Trace:< [TWinCEWidgetSet.RestoreDC] DC:0x%x, Saved: %d --> %s', [Integer(DC), SavedDC, BOOL_TEXT[Result]]));
End;
{------------------------------------------------------------------------------
@ -1423,9 +1532,9 @@ end;
-------------------------------------------------------------------------------}
Function TWinCEWidgetSet.SaveDC(DC: HDC): Integer;
Begin
Assert(False, Format('Trace:> [TWin32WidgetSet.SaveDC] 0x%x', [Integer(DC)]));
Assert(False, Format('Trace:> [TWinCEWidgetSet.SaveDC] 0x%x', [Integer(DC)]));
Result := Windows.SaveDC(DC);
Assert(False, Format('Trace:< [TWin32WidgetSet.SaveDC] 0x%x --> %d', [Integer(DC), Result]));
Assert(False, Format('Trace:< [TWinCEWidgetSet.SaveDC] 0x%x --> %d', [Integer(DC), Result]));
End;
@ -1496,9 +1605,9 @@ end;
Function TWinCEWidgetSet.SelectObject(DC: HDC; GDIObj: HGDIOBJ): HGDIOBJ;
Begin
//TODO: Finish this;
Assert(False, Format('Trace:> [TWin32WidgetSet.SelectObject] DC: 0x%x', [DC]));
Assert(False, Format('Trace:> [TWinCEWidgetSet.SelectObject] DC: 0x%x', [DC]));
Result := Windows.SelectObject(DC, GDIObj);
Assert(False, Format('Trace:< [TWin32WidgetSet.SelectObject] DC: 0x%x --> 0x%x', [DC, Result]));
Assert(False, Format('Trace:< [TWinCEWidgetSet.SelectObject] DC: 0x%x --> 0x%x', [DC, Result]));
End;
{function TWinCEWidgetSet.SelectPalette(DC: HDC; Palette: HPALETTE;
@ -1547,9 +1656,9 @@ end;
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.SetBKColor(DC: HDC; Color: TColorRef): TColorRef;
Begin
Assert(False, Format('Trace:> [TWin32WidgetSet.SetBKColor] DC: 0x%x Color: %8x', [Integer(DC), Color]));
Assert(False, Format('Trace:> [TWinCEWidgetSet.SetBKColor] DC: 0x%x Color: %8x', [Integer(DC), Color]));
Result := Windows.SetBkColor(DC, Windows.COLORREF(ColorToRGB(Color)));
Assert(False, Format('Trace:< [TWin32WidgetSet.SetBKColor] DC: 0x%x Color: %8x --> %8x', [Integer(DC), Color, Result]));
Assert(False, Format('Trace:< [TWinCEWidgetSet.SetBKColor] DC: 0x%x Color: %8x --> %8x', [Integer(DC), Color, Result]));
End;
{------------------------------------------------------------------------------
@ -1608,18 +1717,33 @@ function TWinCEWidgetSet.SetProp(Handle: hwnd; Str: PChar; Data: Pointer
): Boolean;
begin
Result:=inherited SetProp(Handle, Str, Data);
end;
end;}
function TWinCEWidgetSet.SetROP2(DC: HDC; Mode: Integer): Integer;
begin
Result:=inherited SetROP2(DC, Mode);
result := Windows.SetROP2(DC, Mode);
end;
function TWinCEWidgetSet.SetScrollInfo(Handle: HWND; SBStyle: Integer;
ScrollInfo: TScrollInfo; bRedraw: Boolean): Integer;
begin
Result:=inherited SetScrollInfo(Handle, SBStyle, ScrollInfo, bRedraw);
end;}
{------------------------------------------------------------------------------
Method: SetScrollInfo
Params: Handle - handle of window with scroll bar
SBStyle - scroll bar flag
ScrollInfo - record with scroll parameters
BRedraw - is the scroll bar is redrawn?
Returns: The old position value
Sets the parameters of a scroll bar.
------------------------------------------------------------------------------}
Function TWinCEWidgetSet.SetScrollInfo(Handle: HWND; SBStyle: Integer; ScrollInfo: TScrollInfo; BRedraw: Boolean): Integer;
Begin
// Assert(False, 'Trace:[TWin32WidgetSet.SetScrollInfo]');
//With ScrollInfo Do
// Assert(False, Format('Trace:> [TWin32WidgetSet.SetScrollInfo] Mask:0x%x, Min:%d, Max:%d, Page:%d, Pos:%d', [FMask, NMin, NMax, NPage, NPos]));
ScrollInfo.cbSize:=sizeof(ScrollInfo);
Result := Windows.SetScrollInfo(Handle, SBStyle, @ScrollInfo, BRedraw);
With ScrollInfo Do
Assert(False, Format('Trace:> [TWin32WidgetSet.SetScrollInfo] --> %d', [Result]));
End;
{------------------------------------------------------------------------------
Method: SetSysColors
@ -1668,22 +1792,29 @@ End;
Function TWinCEWidgetSet.SetWindowLong(Handle: HWND; Idx: Integer; NewLong: PtrInt): PtrInt;
Begin
//TODO: Finish this;
Assert(False, Format('Trace:> [TWin32WidgetSet.SETWINDOWLONG] HWND: 0x%x, Idx: 0x%x(%d), Value: 0x%x(%d)', [Handle, Idx, Idx, NewLong, NewLong]));
Assert(False, Format('Trace:> [TWinCEWidgetSet.SETWINDOWLONG] HWND: 0x%x, Idx: 0x%x(%d), Value: 0x%x(%d)', [Handle, Idx, Idx, NewLong, NewLong]));
Result := Windows.SetWindowLong(Handle, Idx, NewLong);
Assert(False, Format('Trace:< [TWin32WidgetSet.SETWINDOWLONG] HWND: 0x%x, Idx: 0x%x(%d), Value: 0x%x(%d) --> 0x%x(%d)', [Handle, Idx, Idx, NewLong, NewLong, Result, Result]));
Assert(False, Format('Trace:< [TWinCEWidgetSet.SETWINDOWLONG] HWND: 0x%x, Idx: 0x%x(%d), Value: 0x%x(%d) --> 0x%x(%d)', [Handle, Idx, Idx, NewLong, NewLong, Result, Result]));
End;
{function TWinCEWidgetSet.SetWindowLong(Handle: HWND; Idx: Integer;
NewLong: PtrInt): PtrInt;
begin
Result:=inherited SetWindowLong(Handle, Idx, NewLong);
end;
{------------------------------------------------------------------------------
Method: SetWindowOrgEx
Params: DC - handle of device context
NewX - new x-coordinate of window origin
NewY - new y-coordinate of window origin
Point - record receiving original origin
Returns: Whether the call was successful
function TWinCEWidgetSet.SetWindowOrgEx(dc: hdc; NewX, NewY: Integer;
Sets the window origin of the device context by using the specified coordinates.
------------------------------------------------------------------------------}
//roozbeh:does this always work?it is heavily used in labels and some other drawing controls!
Function TWinCEWidgetSet.SetWindowOrgEx(DC: HDC; NewX, NewY: Integer;
OldPoint: PPoint): Boolean;
begin
Result:=inherited SetWindowOrgEx(dc, NewX, NewY, OldPoint);
end;}
Begin
Result := Boolean(SetViewPortOrgEx(DC, -NewX, -NewY, LPPoint(OldPoint)));
// Result:=inherited SetWindowOrgEx(dc, NewX, NewY, OldPoint);
End;
{------------------------------------------------------------------------------
Method: SetWindowPos
Params: HWnd - handle of window

View File

@ -63,7 +63,7 @@ Function CombineRgn(Dest, Src1, Src2 : HRGN; fnCombineMode : Longint) : Longint;
//function ComboBoxDropDown(Handle: HWND; DropDown: boolean): boolean; override;
function CreateBitmap(Width, Height: Integer; Planes, BitCount: Longint; BitmapBits: Pointer): HBITMAP; override;
//function CreateBitmapFromRawImage(const RawImage: TRawImage; var Bitmap, MaskBitmap: HBitmap; AlwaysCreateMask: boolean): boolean; override;
//function CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH; override;
function CreateBrushIndirect(const LogBrush: TLogBrush): HBRUSH; override;
function CreateCaret(Handle : HWND; Bitmap : hBitmap; width, Height : Integer) : Boolean; override;
function CreateCompatibleBitmap(DC: HDC; Width, Height: Integer): HBITMAP; override;
function CreateCompatibleDC(DC: HDC): HDC; override;
@ -92,7 +92,7 @@ function EnumFontFamilies(DC: HDC; Family: Pchar; EnumFontFamProc: FontEnumProc;
function EnumFontFamiliesEx(DC: HDC; lpLogFont: PLogFont; Callback: FontEnumExProc; Lparam: LParam; Flags: dword): longint; override;
function ExcludeClipRect(dc: hdc; Left, Top, Right, Bottom : Integer) : Integer; override;}
function ExtTextOut(DC: HDC; X, Y: Integer; Options: Longint; Rect: PRect; Str: PChar; Count: Longint; Dx: PInteger): Boolean; override;
{function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;}
function ExtSelectClipRGN(dc: hdc; rgn : hrgn; Mode : Longint) : Integer; override;
function FillRect(DC: HDC; const Rect: TRect; Brush: HBRUSH): Boolean; override;
//function Frame(DC: HDC; const ARect: TRect): Integer; override;
@ -155,31 +155,31 @@ function IntersectClipRect(dc: hdc; Left, Top, Right, Bottom: Integer): Integer;
function InvalidateRect(aHandle : HWND; Rect : pRect; bErase : Boolean) : Boolean; override;
function IsWindowEnabled(handle: HWND): boolean; override;
function IsWindowVisible(handle: HWND): boolean; override;
{
Procedure LeaveCriticalSection(var CritSection: TCriticalSection); Override;
//Procedure LeaveCriticalSection(var CritSection: TCriticalSection); Override;
function LineTo(DC: HDC; X, Y: Integer): Boolean; override;
function MessageBox(hWnd: HWND; lpText, lpCaption: PChar; uType: Cardinal): integer; override;
function MoveToEx(DC: HDC; X, Y: Integer; OldPoint: PPoint): Boolean; override;
function MoveWindowOrgEx(DC: HDC; dX, dY: Integer): Boolean; override;
{function MoveWindowOrgEx(DC: HDC; dX, dY: Integer): Boolean; override;
function PairSplitterAddSide(SplitterHandle, SideHandle: hWnd; Side: integer): Boolean; override;
function PairSplitterGetInterfaceInfo: Boolean; override;
function PairSplitterRemoveSide(SplitterHandle, SideHandle: hWnd; Side: integer): Boolean; override;
function PairSplitterSetPosition(SplitterHandle: hWnd; var NewPosition: integer): Boolean; override;
function PairSplitterSetPosition(SplitterHandle: hWnd; var NewPosition: integer): Boolean; override;}
function PeekMessage(var lpMsg : TMsg; Handle : HWND; wMsgFilterMin, wMsgFilterMax,wRemoveMsg : UINT): Boolean; override;
function PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer; Filled, Continuous: boolean): boolean; override;
//function PolyBezier(DC: HDC; Points: PPoint; NumPts: Integer; Filled, Continuous: boolean): boolean; override;
function Polygon(DC: HDC; Points: PPoint; NumPts: Integer; Winding: boolean): boolean; override;
function Polyline(DC: HDC; Points: PPoint; NumPts: Integer): boolean; override;}
function Polyline(DC: HDC; Points: PPoint; NumPts: Integer): boolean; override;
function PostMessage(Handle: HWND; Msg: Cardinal; wParam: WParam; lParam: LParam): Boolean; override;
{function RadialArc(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer): Boolean; override;
function RadialChord(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer): Boolean; override;
function RadialPie(DC: HDC; x,y,width,height,sx,sy,ex,ey : Integer): Boolean; override;
function RealizePalette(DC: HDC): Cardinal; override;
function RealizePalette(DC: HDC): Cardinal; override;}
function Rectangle(DC: HDC; X1, Y1, X2, Y2: Integer): Boolean; override;
function RectVisible(dc : hdc; const ARect: TRect) : Boolean; override;
function RegroupMenuItem(hndMenu: HMENU; GroupIndex: integer): Boolean; override;
{function RegroupMenuItem(hndMenu: HMENU; GroupIndex: integer): Boolean; override;
Function ReleaseCapture : Boolean; override;}
function ReleaseDC(Window: HWND; DC: HDC): Integer; override;
//function RemoveProp(Handle: hwnd; Str: PChar): THandle; override;
@ -203,14 +203,14 @@ function SetCaretPosEx(Handle: HWnd; X, Y: Integer): Boolean; override;
function SetCaretRespondToFocus(handle: HWND; ShowHideOnFocus: boolean): Boolean; override;
function SetCursorPos(X, Y: Integer): Boolean; override;
function SetFocus(hWnd: HWND): HWND; override;
Function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override;
Function SetProp(Handle: hwnd; Str : PChar; Data : Pointer) : Boolean; override;}
function SetROP2(DC: HDC; Mode: Integer): Integer; override;
function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override;}
function SetScrollInfo(Handle : HWND; SBStyle : Integer; ScrollInfo: TScrollInfo; bRedraw : Boolean): Integer; override;
function SetSysColors(cElements: Integer; const lpaElements; const lpaRgbValues): Boolean; override;
{Function SetTextCharacterExtra(_hdc : hdc; nCharExtra : Integer):Integer; override;}
function SetTextColor(DC: HDC; Color: TColorRef): TColorRef; override;
function SetWindowLong(Handle: HWND; Idx: Integer; NewLong: PtrInt): PtrInt; override;
//function SetWindowOrgEx(dc : hdc; NewX, NewY : Integer; OldPoint: PPoint) : Boolean; override;
function SetWindowOrgEx(dc : hdc; NewX, NewY : Integer; OldPoint: PPoint) : Boolean; override;
function SetWindowPos(hWnd: HWND; hWndInsertAfter: HWND;
X, Y, cx, cy: Integer; uFlags: UINT): Boolean; override;
{function ShowCaret(hWnd: HWND): Boolean; override;

View File

@ -195,11 +195,11 @@ begin
if TCustomControl(AWinControl).BorderStyle = bsSingle then
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
{$IFDEF VerboseSizeMsg}
writeln('TWin32WidgetSet.CreateComponent A ',AWinControl.Name,':',AWinControl.ClassName,' ',Left,',',Top,',',Width,',',Height);
writeln('TWinCEWidgetSet.CreateComponent A ',AWinControl.Name,':',AWinControl.ClassName,' ',Left,',',Top,',',Width,',',Height);
{$ENDIF}
//Assert(False, Format('Trace:TWin32WidgetSet.CreateComponent - Creating component %S with the caption of %S', [AWinControl.ClassName, AWinControl.Caption]));
//Assert(False, Format('Trace:TWin32WidgetSet.CreateComponent - Left: %D, Top: %D, Width: %D, Height: %D, Parent handle: 0x%X, instance handle: 0x%X', [Left, Top, Width, Height, Parent, HInstance]));
//Assert(False, Format('Trace:TWinCEWidgetSet.CreateComponent - Creating component %S with the caption of %S', [AWinControl.ClassName, AWinControl.Caption]));
//Assert(False, Format('Trace:TWinCEWidgetSet.CreateComponent - Left: %D, Top: %D, Width: %D, Height: %D, Parent handle: 0x%X, instance handle: 0x%X', [Left, Top, Width, Height, Parent, HInstance]));
end;
end;
@ -278,7 +278,7 @@ procedure WindowCreateInitBuddy(const AWinControl: TWinControl;
var
lhFont: HFONT;
begin
{ with Params do
with Params do
if Buddy <> HWND(Nil) then
begin
BuddyWindowInfo := AllocWindowInfo(Buddy);
@ -292,7 +292,7 @@ begin
Windows.SendMessage(Buddy, WM_SETFONT, lhFont, 0);
end
else
BuddyWindowInfo := nil;}
BuddyWindowInfo := nil;
end;
@ -395,7 +395,6 @@ begin
if AfterWnd = 0 then Exit; // nothing to do
end;
Windows.SetWindowPos(AChild.Handle, AfterWnd, 0, 0, 0, 0,
SWP_NOACTIVATE or SWP_NOMOVE or SWP_NOOWNERZORDER or
SWP_NOSIZE or SWP_NOSENDCHANGING);
@ -416,20 +415,20 @@ var
IntfLeft, IntfTop, IntfWidth, IntfHeight: integer;
suppressMove: boolean;
begin
(* IntfLeft := ALeft; IntfTop := ATop;
IntfLeft := ALeft; IntfTop := ATop;
IntfWidth := AWidth; IntfHeight := AHeight;
LCLBoundsToWin32Bounds(AWinControl, IntfLeft, IntfTop, IntfWidth, IntfHeight);
{$IFDEF VerboseSizeMsg}
writeln('TWin32WSWinControl.ResizeWindow A ',AWinControl.Name,':',AWinControl.ClassName,
writeln('TWinCEWSWinControl.ResizeWindow A ',AWinControl.Name,':',AWinControl.ClassName,
' LCL=',ALeft,',',ATop,',',AWidth,',',AHeight,
' Win32=',IntfLeft,',',IntfTop,',',IntfWidth,',',IntfHeight,
'');
{$ENDIF}
suppressMove := false;
AdaptBounds(AWinControl, IntfLeft, IntfTop, IntfWidth, IntfHeight, suppressMove);
if not suppressMove then
MoveWindow(AWinControl.Handle, IntfLeft, IntfTop, IntfWidth, IntfHeight, true);
LCLControlSizeNeedsUpdate(AWinControl, false);*)
// if not suppressMove then
// MoveWindow(AWinControl.Handle, IntfLeft, IntfTop, IntfWidth, IntfHeight, true);
LCLControlSizeNeedsUpdate(AWinControl, false);
end;
procedure TWinCEWSWinControl.SetColor(const AWinControl: TWinControl);
@ -489,7 +488,7 @@ initialization
// which actually implement something
////////////////////////////////////////////////////
// RegisterWSComponent(TDragImageList, TWSDragImageList);
RegisterWSComponent(TControl, TWinCEWSControl);
// RegisterWSComponent(TControl, TWinCEWSControl);
RegisterWSComponent(TWinControl, TWinCEWSWinControl);
// RegisterWSComponent(TGraphicControl, TWSGraphicControl);
// RegisterWSComponent(TCustomControl, TWSCustomControl);

View File

@ -43,9 +43,9 @@ type
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class procedure SetParams(const AScrollBar: TCustomScrollBar); override;}
class procedure SetParams(const AScrollBar: TCustomScrollBar); override;
end;
{ TWinCEWSCustomGroupBox }
@ -112,7 +112,7 @@ type
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class function GetSelCount(const ACustomListBox: TCustomListBox): integer; override;
class function GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean; override;
@ -126,7 +126,7 @@ type
AMultiSelect: boolean); override;
class procedure SetStyle(const ACustomListBox: TCustomListBox); override;
class procedure SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean); override;
class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override;}
class procedure SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer); override;
end;
{ TWinCEWSListBox }
@ -145,18 +145,18 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
{ class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
class function GetSelStart(const ACustomEdit: TCustomEdit): integer; override;
class function GetSelLength(const ACustomEdit: TCustomEdit): integer; override;
class function GetMaxLength(const ACustomEdit: TCustomEdit): integer; override;}
class function GetMaxLength(const ACustomEdit: TCustomEdit): integer; {override;}
class function GetText(const AWinControl: TWinControl; var AText: string): boolean; override;
{ class procedure SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); override;
class procedure SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase); override;
class procedure SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode); override;
class procedure SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
class procedure SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char); override;
class procedure SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean); override;
class procedure SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer); override;
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;}
class procedure SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer); override;
end;
{ TWinCEWSCustomMemo }
@ -165,13 +165,13 @@ type
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
class function GetStrings(const ACustomMemo: TCustomMemo): TStrings; override;
class procedure AppendText(const ACustomMemo: TCustomMemo; const AText: string); override;
class procedure SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle); override;
class procedure SetText(const AWinControl: TWinControl; const AText: string); override;
class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override;}
class procedure SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean); override;
end;
{ TWinCEWSEdit }
@ -215,8 +215,8 @@ type
private
protected
public
{ class procedure GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer); override;}
class procedure GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer); override;
end;
{ TWinCEWSCustomCheckBox }
@ -227,12 +227,12 @@ type
public
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
{ class procedure GetPreferredSize(const AWinControl: TWinControl;
class procedure GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer); override;
class function RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState; override;
class procedure SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut); override;
class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); override;}
class procedure SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState); override;
end;
{ TWinCEWSCheckBox }
@ -249,8 +249,8 @@ type
private
protected
public
{ class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;}
class function CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND; override;
end;
{ TWinCEWSRadioButton }
@ -263,8 +263,245 @@ type
const AParams: TCreateParams): HWND; override;
end;
{$DEFINE MEMOHEADER}
{$I wincememostrings.inc}
{$UNDEF MEMOHEADER}
implementation
{$I wincememostrings.inc}
{ TWinCEWSScrollBar }
function TWinCEWSScrollBar.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
Params: TCreateWindowExParams;
begin
// general initialization of Params
PrepareCreateWindow(AWinControl, Params);
// customization of Params
with Params do
begin
case TScrollBar(AWinControl).Kind of
sbHorizontal:
Flags := Flags or SBS_HORZ;
sbVertical:
Flags := Flags or SBS_VERT;
end;
pClassName := 'SCROLLBAR';
end;
// create window
FinishCreateWindow(AWinControl, Params, false);
Result := Params.Window;
end;
procedure TWinCEWSScrollBar.SetParams(const AScrollBar: TCustomScrollBar);
begin
with AScrollBar do
begin
SendMessage(Handle, SBM_SETRANGE, Min, Max);
SendMessage(Handle, SBM_SETPOS, Position, LPARAM(true));
case Kind of
sbHorizontal:
SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) or SBS_HORZ);
sbVertical:
SetWindowLong(Handle, GWL_STYLE, GetWindowLong(Handle, GWL_STYLE) or SBS_VERT);
end;
Assert(False, 'Trace:TODO: [TWinCEWSScrollBar.SetParams] Set up step and page increments for csScrollBar');
end;
end;
{ TWinCEWSCustomListBox }
function TWinCEWSCustomListBox.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
Params: TCreateWindowExParams;
begin
// general initialization of Params
PrepareCreateWindow(AWinControl, Params);
// customization of Params
with Params do
begin
with TCustomListBox(AWinControl) do
begin
if Sorted then
Flags := Flags or LBS_SORT;
if MultiSelect then
if ExtendedSelect then
Flags := Flags or LBS_EXTENDEDSEL
else
Flags := Flags or LBS_MULTIPLESEL;
if AWinControl.FCompStyle = csCheckListBox then
Flags := Flags or LBS_OWNERDRAWFIXED
else case Style of
lbOwnerDrawFixed: Flags := Flags or LBS_OWNERDRAWFIXED;
lbOwnerDrawVariable: Flags := Flags or LBS_OWNERDRAWVARIABLE;
end;
if BorderStyle=bsSingle then
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
end;
pClassName := 'LISTBOX';
Flags := Flags or (WS_VSCROLL or LBS_NOINTEGRALHEIGHT or LBS_HASSTRINGS or
LBS_NOTIFY);
end;
// create window
FinishCreateWindow(AWinControl, Params, false);
// listbox is not a transparent control -> no need for parentpainting
Params.WindowInfo^.hasTabParent := false;
Result := Params.Window;
end;
//this should not be called in multiple selection things
function TWinCEWSCustomListBox.GetItemIndex(const ACustomListBox: TCustomListBox): integer;
begin
Result := SendMessage(ACustomListBox.Handle, LB_GETCURSEL, 0, 0);
if Result = LB_ERR then
begin
Assert(false, 'Trace:[TWinCEWSCustomListBox.GetItemIndex] could not retrieve itemindex, try selecting an item first');
Result := -1;
end;
end;
function TWinCEWSCustomListBox.GetSelCount(const ACustomListBox: TCustomListBox): integer;
begin
// GetSelCount only works for multiple-selection listboxes
if ACustomListBox.MultiSelect then
Result := Windows.SendMessage(ACustomListBox.Handle, LB_GETSELCOUNT, 0, 0)
else begin
if Windows.SendMessage(ACustomListBox.Handle, LB_GETCURSEL, 0, 0) = LB_ERR then
Result := 0
else
Result := 1;
end;
end;
function TWinCEWSCustomListBox.GetSelected(const ACustomListBox: TCustomListBox; const AIndex: integer): boolean;
var
WindowInfo: PWindowInfo;
winHandle: HWND;
begin
winHandle := ACustomListBox.Handle;
WindowInfo := GetWindowInfo(winHandle);
// if we're handling a WM_DRAWITEM, then LB_GETSEL is not reliable, check stored info
if (WindowInfo^.DrawItemIndex <> -1) and (WindowInfo^.DrawItemIndex = AIndex) then
Result := WindowInfo^.DrawItemSelected
else
Result := Windows.SendMessage(winHandle, LB_GETSEL, Windows.WParam(AIndex), 0) > 0;
end;
function TWinCEWSCustomListBox.GetStrings(const ACustomListBox: TCustomListBox): TStrings;
var
Handle: HWND;
begin
Handle := ACustomListBox.Handle;
Result := TWinCEListStringList.Create(Handle, ACustomListBox);
GetWindowInfo(Handle)^.List := Result;
end;
function TWinCEWSCustomListBox.GetTopIndex(const ACustomListBox: TCustomListBox): integer;
begin
Result:=Windows.SendMessage(ACustomListBox.Handle, LB_GETTOPINDEX, 0, 0);
end;
procedure TWinCEWSCustomListBox.SelectItem(const ACustomListBox: TCustomListBox; AIndex: integer; ASelected: boolean);
begin
if ACustomListBox.MultiSelect then
Windows.SendMessage(ACustomListBox.Handle, LB_SETSEL,
Windows.WParam(ASelected), Windows.LParam(AIndex))
else
if ASelected then
SetItemIndex(ACustomListBox, AIndex)
else
SetItemIndex(ACustomListBox, -1);
end;
procedure TWinCEWSCustomListBox.SetBorder(const ACustomListBox: TCustomListBox);
var
Handle: HWND;
StyleEx: dword;
begin
Handle := ACustomListBox.Handle;
StyleEx := GetWindowLong(Handle, GWL_EXSTYLE);
if ACustomListBox.BorderStyle = TBorderStyle(bsSingle) Then
StyleEx := StyleEx or WS_EX_CLIENTEDGE
else
StyleEx := StyleEx and not WS_EX_CLIENTEDGE;
SetWindowLong(Handle, GWL_EXSTYLE, StyleEx);
end;
procedure TWinCEWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer);
var
Handle: HWND;
begin
Handle := ACustomListBox.Handle;
if ACustomListBox.MultiSelect then
begin
// deselect all items first
Windows.SendMessage(Handle, LB_SETSEL, Windows.WParam(false), -1);
if AIndex >= 0 then
Windows.SendMessage(Handle, LB_SETSEL, Windows.WParam(true), Windows.LParam(AIndex));
end else
Windows.SendMessage(Handle, LB_SETCURSEL, Windows.WParam(AIndex), 0);
end;
procedure TWinCEWSCustomListBox.SetSelectionMode(const ACustomListBox: TCustomListBox;
const AExtendedSelect, AMultiSelect: boolean);
begin
RecreateWnd(ACustomListBox);
end;
procedure TWinCEWSCustomListBox.SetStyle(const ACustomListBox: TCustomListBox);
begin
// The listbox styles can't be updated, so recreate the listbox
RecreateWnd(ACustomListBox);
end;
procedure TWinCEWSCustomListBox.SetSorted(const ACustomListBox: TCustomListBox; AList: TStrings; ASorted: boolean);
begin
TWinCEListStringList(AList).Sorted := ASorted;
end;
procedure TWinCEWSCustomListBox.SetTopIndex(const ACustomListBox: TCustomListBox; const NewTopIndex: integer);
begin
Windows.SendMessage(ACustomListBox.Handle, LB_SETTOPINDEX, NewTopIndex, 0);
end;
{ TWinCEWSCustomEdit helper functions }
function EditGetSelStart(WinHandle: HWND): integer;
begin
Windows.SendMessage(WinHandle, EM_GETSEL, Windows.WPARAM(@Result), 0);
end;
function EditGetSelLength(WinHandle: HWND): integer;
var
startpos, endpos: integer;
begin
Windows.SendMessage(WinHandle, EM_GETSEL, Windows.WPARAM(@startpos), Windows.LPARAM(@endpos));
Result := endpos - startpos;
end;
procedure EditSetSelStart(WinHandle: HWND; NewStart: integer);
begin
Windows.SendMessage(WinHandle, EM_SETSEL, Windows.WParam(NewStart), Windows.LParam(NewStart));
// scroll caret into view
Windows.SendMessage(WinHandle, EM_SCROLLCARET, 0, 0);
end;
procedure EditSetSelLength(WinHandle: HWND; NewLength: integer);
var
startpos, endpos: integer;
begin
Windows.SendMessage(WinHandle, EM_GETSEL, Windows.WParam(@startpos), Windows.LParam(@endpos));
endpos := startpos + NewLength;
Windows.SendMessage(WinHandle, EM_SETSEL, Windows.WParam(startpos), Windows.LParam(endpos));
end;
{ TWinCEWSCustomEdit }
function TWinCEWSCustomEdit.CreateHandle(const AWinControl: TWinControl;
@ -297,25 +534,160 @@ begin
Result := hwnd;
end;
function TWinCEWSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;
begin
Result := EditGetSelStart(ACustomEdit.Handle);
end;
function TWinCEWSCustomEdit.GetSelLength(const ACustomEdit: TCustomEdit): integer;
begin
Result := EditGetSelLength(ACustomEdit.Handle);
end;
function TWinCEWSCustomEdit.GetMaxLength(const ACustomEdit: TCustomEdit): integer;
begin
Result := GetWindowInfo(ACustomEdit.Handle)^.MaxLength;
end;
function TWinCEWSCustomEdit.GetText(const AWinControl: TWinControl; var AText: string): boolean;
var
TextLen: dword;
Str: array of WideChar;
Buffer: array[0..255] of Char;
begin
Result := AWinControl.HandleAllocated;
if not Result then Exit;
TextLen := GetWindowTextLength(AWinControl.Handle);
SetLength(Str, TextLen);
GetWindowText(AWinControl.Handle, @Str, TextLen + 1);
WideCharToMultiByte(CP_ACP, 0, @Str, TextLen, @Buffer, 256, nil, nil);
AText := string(PChar(Buffer));
if not Result then
exit;
AText := GetControlText(AWinControl.Handle);
end;
procedure TWinCEWSCustomEdit.SetCharCase(const ACustomEdit: TCustomEdit; NewCase: TEditCharCase);
const
EditStyles: array[TEditCharCase] of integer = (0, ES_UPPERCASE, ES_LOWERCASE);
EditStyleMask = ES_UPPERCASE or ES_LOWERCASE;
begin
UpdateWindowStyle(ACustomEdit.Handle, EditStyles[NewCase], EditStyleMask);
end;
procedure TWinCEWSCustomEdit.SetEchoMode(const ACustomEdit: TCustomEdit; NewMode: TEchoMode);
begin
end;
procedure TWinCEWSCustomEdit.SetMaxLength(const ACustomEdit: TCustomEdit; NewLength: integer);
var
winhandle: HWND;
begin
winhandle := ACustomEdit.Handle;
SendMessage(winhandle, EM_LIMITTEXT, NewLength, 0);
GetWindowInfo(winhandle)^.MaxLength := NewLength;
end;
procedure TWinCEWSCustomEdit.SetPasswordChar(const ACustomEdit: TCustomEdit; NewChar: char);
begin
SendMessage(ACustomEdit.Handle, EM_SETPASSWORDCHAR, WParam(NewChar), 0);
end;
procedure TWinCEWSCustomEdit.SetReadOnly(const ACustomEdit: TCustomEdit; NewReadOnly: boolean);
begin
Windows.SendMessage(ACustomEdit.Handle, EM_SETREADONLY, Windows.WPARAM(NewReadOnly), 0);
end;
procedure TWinCEWSCustomEdit.SetSelStart(const ACustomEdit: TCustomEdit; NewStart: integer);
begin
EditSetSelStart(ACustomEdit.Handle, NewStart);
end;
procedure TWinCEWSCustomEdit.SetSelLength(const ACustomEdit: TCustomEdit; NewLength: integer);
begin
EditSetSelLength(ACustomEdit.Handle, NewLength);
end;
{ TWinCEWSCustomMemo }
function TWinCEWSCustomMemo.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
Params: TCreateWindowExParams;
begin
// general initialization of Params
PrepareCreateWindow(AWinControl, Params);
// customization of Params
with Params do
begin
Flags := Flags or ES_AUTOVSCROLL or ES_MULTILINE or ES_WANTRETURN;
if TCustomMemo(AWinControl).ReadOnly then
Flags := Flags or ES_READONLY;
case TCustomMemo(AWinControl).ScrollBars of
ssHorizontal, ssAutoHorizontal:
Flags := Flags or WS_HSCROLL;
ssVertical, ssAutoVertical:
Flags := Flags or WS_VSCROLL;
ssBoth, ssAutoBoth:
Flags := Flags or WS_HSCROLL or WS_VSCROLL;
end;
if TCustomMemo(AWinControl).WordWrap then
Flags := Flags and not WS_HSCROLL
else
Flags := Flags or ES_AUTOHSCROLL;
FlagsEx := FlagsEx or WS_EX_CLIENTEDGE;
pClassName := 'EDIT';
WindowTitle := StrCaption;
end;
// create window
FinishCreateWindow(AWinControl, Params, false);
// memo is not a transparent control -> no need for parentpainting
Params.WindowInfo^.hasTabParent := false;
Result := Params.Window;
end;
function TWinCEWSCustomMemo.GetStrings(const ACustomMemo: TCustomMemo
): TStrings;
begin
Result:=TWinCEMemoStrings.Create(ACustomMemo.Handle, ACustomMemo)
end;
procedure TWinCEWSCustomMemo.AppendText(const ACustomMemo: TCustomMemo; const AText: string);
var
S: string;
begin
if Length(AText) > 0 then
begin
GetText(ACustomMemo, S);
S := S + AText;
SetText(ACustomMemo, S);
end;
end;
procedure TWinCEWSCustomMemo.SetScrollbars(const ACustomMemo: TCustomMemo; const NewScrollbars: TScrollStyle);
begin
// TODO: check if can be done without recreation
RecreateWnd(ACustomMemo);
end;
procedure TWinCEWSCustomMemo.SetText(const AWinControl: TWinControl; const AText: string);
var
tmpWideStr : PWideChar;
begin
tmpWideStr := CreatePWideCharFromString(AText);
SendMessage(AWinControl.Handle, WM_SETTEXT, 0, LPARAM(PWideChar(tmpWideStr)));
DisposePWideChar(tmpWideStr);
end;
procedure TWinCEWSCustomMemo.SetWordWrap(const ACustomMemo: TCustomMemo; const NewWordWrap: boolean);
begin
// TODO: check if can be done without recreation
RecreateWnd(ACustomMemo);
end;
{ TWin32WSButtonControl }
procedure TWinCEWSButtonControl.GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer);
begin
if MeasureText(AWinControl, AWinControl.Caption, PreferredWidth, PreferredHeight) then
begin
Inc(PreferredWidth, 20);
Inc(PreferredHeight, 12);
end;
end;
{ TWinCEWSCustomCheckBox }
function TWinCEWSCustomCheckBox.CreateHandle(const AWinControl: TWinControl;
@ -340,27 +712,74 @@ begin
end;
// create window
FinishCreateWindow(AWinControl, Params, false);
DisposePWideChar(Params.WindowTitle);
Result := Params.Window;
{
MultiByteToWideChar(CP_ACP, 0, PChar(AWinControl.Caption), -1, @Str, 256);
end;
Result := CreateWindow(
@ButtonClsName, // Name of the registered class
@Str, // Title of the window
WS_CHILD or WS_VISIBLE or WS_TABSTOP or BS_AUTOCHECKBOX or BS_LEFT, // Style of the window
AWinControl.Left, // x-position (at beginning)
AWinControl.Top, // y-position (at beginning)
AWinControl.Width, // window width
AWinControl.Height, // window height
AWinControl.Parent.Handle, // handle to parent or owner window
0, // handle to menu
System.hInstance, // handle to application instance
nil); // pointer to window-creation data
procedure TWinCEWSCustomCheckBox.GetPreferredSize(const AWinControl: TWinControl;
var PreferredWidth, PreferredHeight: integer);
var
iconHeight: integer;
begin
if MeasureText(AWinControl, AWinControl.Caption, PreferredWidth, PreferredHeight) then
begin
// 7 pixels spacing between checkbox and text
Inc(PreferredWidth, GetSystemMetrics(SM_CXMENUCHECK) + 7);
iconHeight := GetSystemMetrics(SM_CYMENUCHECK);
if iconHeight > PreferredHeight then
PreferredHeight := iconHeight;
end;
end;
if (hwnd = 0) then WriteLn('CreateWindow failed');
function TWinCEWSCustomCheckBox.RetrieveState(const ACustomCheckBox: TCustomCheckBox): TCheckBoxState;
begin
case SendMessage(ACustomCheckBox.Handle, BM_GETCHECK, 0, 0) of
BST_CHECKED: Result := cbChecked;
BST_INDETERMINATE: Result := cbGrayed;
else
{BST_UNCHECKED:} Result := cbUnChecked;
end;
end;
Result := hwnd;}
procedure TWinCEWSCustomCheckBox.SetShortCut(const ACustomCheckBox: TCustomCheckBox;
const OldShortCut, NewShortCut: TShortCut);
begin
// TODO: implement me!
end;
procedure TWinCEWSCustomCheckBox.SetState(const ACustomCheckBox: TCustomCheckBox; const NewState: TCheckBoxState);
var
Flags: WPARAM;
begin
case NewState of
cbChecked: Flags := Windows.WParam(BST_CHECKED);
cbUnchecked: Flags := Windows.WParam(BST_UNCHECKED);
else
Flags := Windows.WParam(BST_INDETERMINATE);
end;
Windows.SendMessage(ACustomCheckBox.Handle, BM_SETCHECK, Flags, 0);
end;
{ TWinCEWSToggleBox }
function TWinCEWSToggleBox.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
Params: TCreateWindowExParams;
begin
// general initialization of Params
PrepareCreateWindow(AWinControl, Params);
// customization of Params
with Params do
begin
pClassName := 'BUTTON';
WindowTitle := StrCaption;
Flags := Flags or BS_AUTOCHECKBOX or BS_PUSHLIKE;
end;
// create window
FinishCreateWindow(AWinControl, Params, false);
Result := Params.Window;
end;
{ TWinCEWSRadioButton }
@ -390,6 +809,7 @@ begin
end;
// create window
FinishCreateWindow(AWinControl, Params, false);
DisposePWideChar(Params.WindowTitle);
Result := Params.Window;
end;
@ -424,7 +844,7 @@ begin
// create window
FinishCreateWindow(AWinControl, Params, false);
DisposePWideChar(Params.WindowTitle);
Result := Params.Window;
end;
@ -434,6 +854,7 @@ begin
inherited SetAlignment(ACustomStaticText, NewAlignment);
end;
initialization
////////////////////////////////////////////////////
@ -442,21 +863,21 @@ initialization
// To improve speed, register only classes
// which actually implement something
////////////////////////////////////////////////////
// RegisterWSComponent(TScrollBar, TWinCEWSScrollBar);
RegisterWSComponent(TScrollBar, TWinCEWSScrollBar);
// RegisterWSComponent(TCustomGroupBox, TWinCEWSCustomGroupBox);
// RegisterWSComponent(TGroupBox, TWinCEWSGroupBox);
// RegisterWSComponent(TCustomComboBox, TWinCEWSCustomComboBox);
// RegisterWSComponent(TComboBox, TWinCEWSComboBox);
// RegisterWSComponent(TCustomListBox, TWinCEWSCustomListBox);
RegisterWSComponent(TCustomListBox, TWinCEWSCustomListBox);
// RegisterWSComponent(TListBox, TWinCEWSListBox);
RegisterWSComponent(TCustomEdit, TWinCEWSCustomEdit);
// RegisterWSComponent(TCustomMemo, TWinCEWSCustomMemo);
RegisterWSComponent(TCustomMemo, TWinCEWSCustomMemo);
// RegisterWSComponent(TEdit, TWinCEWSEdit);
// RegisterWSComponent(TMemo, TWinCEWSMemo);
// RegisterWSComponent(TButtonControl, TWinCEWSButtonControl);
RegisterWSComponent(TCustomCheckBox, TWinCEWSCustomCheckBox);
// RegisterWSComponent(TCheckBox, TWinCEWSCheckBox);
// RegisterWSComponent(TToggleBox, TWinCEWSToggleBox);
RegisterWSComponent(TToggleBox, TWinCEWSToggleBox);
RegisterWSComponent(TRadioButton, TWinCEWSRadioButton);
RegisterWSComponent(TCustomStaticText, TWinCEWSCustomStaticText);
// RegisterWSComponent(TStaticText, TWinCEWSStaticText);