[Customdrawn] TCDWSCustomForm.SetPosition
Giuliano Colla
giuliano.colla at fastwebnet.it
Thu Mar 22 16:10:17 CET 2012
Hi,
it's fully unclear to me what was meant from whoever wrote this portion
of code in customdrawnwsforms_x11.inc (starting from line 97) :
if AWinControl.Parent = nil then
begin
{$Note This doesn't work yet. I want to position a new window relative to
another window. Used for popup windows, like the TComboBox dropdown. }
{$IFDEF DEBUG} writeln('SetPosition with no Parent'); {$ENDIF}
lx := APosition.x;
ly := APosition.y;
XTranslateCoordinates(CDWidgetSet.FDisplay, lWindow,
XDefaultRootWindow(CDWidgetSet.FDisplay),
lx, ly, @dx, @dy, @cw);
lx := dx;
ly := dy;
end
This portion is execute to position whatever control is a root window,
as opposed to controls inside a windows. The effect is that XTranslate
returns garbage in dx and dy, and any attempt to position a window fails.
By commenting out the XTranslate and the following assignments, window
positioning is correct (poDesigned, poScreenCenter, etc. or simply
Top:=Something or Left:=SomethingElse.
I assume that the idea is that a TComboBox dropdown may be higher than
the widow containing the widget, and therefore a new window is required,
but IMHO, the simplest way to position a new window relative to an
existing one is that whoever creates the new window decides its position
on the screen relative to the existing one, and gives the Top and Left
values accordingly, without attempting to use a function which isn't
intended for that purpose.
Am I missing something?
Giuliano
More information about the Customdrawn
mailing list