fix cursor handling, and statictext alignment

git-svn-id: trunk@6517 -
This commit is contained in:
micha 2005-01-08 22:19:51 +00:00
parent 423adf9b59
commit f771e4ab9a
2 changed files with 55 additions and 39 deletions

View File

@ -407,7 +407,41 @@ Var
End;
end;
end;
procedure HandleSetCursor;
var
lControl: TControl;
BoundsOffset: TRect;
begin
if (lWinControl <> nil) and not (csDesigning in lWinControl.ComponentState)
and (Lo(LParam) = HTCLIENT) then
begin
Windows.GetCursorPos(P);
Windows.ScreenToClient(Window, P);
if GetLCLClientBoundsOffset(lWinControl.Parent, BoundsOffset) then
begin
Dec(P.X, BoundsOffset.Left);
Dec(P.Y, BoundsOffset.Top);
end;
// statictext controls do not get WM_SETCURSOR messages...
lControl := lWinControl.ControlAtPos(P, false, true);
if lControl = nil then
lControl := lWinControl;
if lControl.Cursor <> crDefault then
begin
Windows.SetCursor(Windows.LoadCursor(0, LclCursorToWin32CursorMap[lControl.Cursor]));
LMessage.Result := 1;
end;
end;
if LMessage.Result = 0 then
begin
LMessage.Msg := LM_SETCURSOR;
LMessage.WParam := WParam;
LMessage.LParam := LParam;
end;
WinProcess := false;
end;
Begin
Assert(False, 'Trace:WindowProc - Start');
@ -1006,18 +1040,7 @@ Begin
End;
WM_SETCURSOR:
begin
if (lWinControl <> nil) and (lWinControl.Cursor <> crDefault) and
not (csDesigning in lWinControl.ComponentState) and
(Lo(LParam) = HTCLIENT) then
begin
Windows.SetCursor(Windows.LoadCursor(0, LclCursorToWin32CursorMap[lWinControl.Cursor]));
LMessage.Result := 1;
end else begin
LMessage.Msg := LM_SETCURSOR;
LMessage.WParam := WParam;
LMessage.LParam := LParam;
end;
WinProcess := false;
HandleSetCursor;
end;
WM_SETFOCUS:
Begin
@ -1493,6 +1516,9 @@ end;
{
$Log$
Revision 1.182 2005/01/08 22:19:51 micha
fix cursor handling, and statictext alignment
Revision 1.181 2005/01/07 10:51:07 vincents
send LM_CHANGE message for trackbar

View File

@ -891,6 +891,15 @@ end;
{ TWin32WSCustomStaticText }
const
AlignmentToStaticTextFlags: array[TAlignment] of dword = (SS_LEFT, SS_RIGHT, SS_CENTER);
LayoutToStaticTextFlags: array[TTextLayout] of dword = (0,0,0) {(SS_TOP, SS_VCENTER, SS_BOTTOM)};
function CalcStaticTextFlags(const Alignment: TAlignment; const Layout: TTextLayout): dword;
begin
Result := AlignmentToStaticTextFlags[Alignment] or LayoutToStaticTextFlags[Layout];
end;
function TWin32WSCustomStaticText.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): HWND;
var
@ -903,7 +912,8 @@ begin
begin
pClassName := 'STATIC';
WindowTitle := StrCaption;
Flags := Flags or SS_LEFT;
Flags := Flags or CalcStaticTextFlags(
TCustomStaticText(AWinControl).Alignment, TCustomStaticText(AWinControl).Layout);
end;
// create window
FinishCreateWindow(AWinControl, Params, false);
@ -911,36 +921,16 @@ begin
end;
procedure TWin32WSCustomStaticText.SetAlignment(const ACustomStaticText: TCustomStaticText; const NewAlignment: TAlignment);
var
Style: dword;
begin
case NewAlignment of
taLeftJustify:
Style := SS_LEFT;
taCenter:
Style := SS_CENTER;
taRightJustify:
Style := SS_RIGHT;
else
Style := SS_LEFT; // default, shouldn't happen
end;
UpdateWindowStyle(ACustomStaticText.Handle, Style, SS_LEFT or SS_CENTER or SS_RIGHT or SS_LEFTNOWORDWRAP);
// can not apply on the fly: needs window recreate
TWin32WidgetSet(InterfaceObject).RecreateWnd(ACustomStaticText);
end;
procedure TWin32WSCustomStaticText.SetLayout(const ACustomStaticText: TCustomStaticText; const NewLayout: TTextLayout);
var
Style: dword;
begin
case NewLayout of
tlTop:
Style := BS_TOP;
tlCenter:
Style := BS_VCENTER;
else
{tlBottom:}
Style := BS_BOTTOM;
end;
UpdateWindowStyle(ACustomStaticText.Handle, Style, BS_TOP or BS_VCENTER or BS_BOTTOM);
// TODO
UpdateWindowStyle(ACustomStaticText.Handle,
LayoutToStaticTextFlags[NewLayout], 0 {SS_TOP or SS_VCENTER or SS_BOTTOM});
end;
{ TWin32WSCustomCheckBox }