D / GtkD for SQL Server
Adam D. Ruppe
destructionator at gmail.com
Mon Oct 21 16:27:39 PDT 2013
On Monday, 21 October 2013 at 22:23:16 UTC, John Joyus wrote:
> 1. When I click the OK button, the message dialog pops-up
> *after* the main window is closed, though the window.close();
> line is after the call to the MessageBox..
that's because the MessageBox class here is implemented as
another window with an event loop, so it doesn't stop execution.
If you want a message box that stops execution, you should just
use the regular Windows call
http://msdn.microsoft.com/en-us/library/windows/desktop/ms645505%28v=vs.85%29.aspx
it is available in D if you do this:
import core.sys.windows.windows;
import std.string : toStringz;
MessageBoxA(null, toStringz("You clicked ok."), toStringz("title
here"), MB_OK);
(or you can use MessageBoxW and toUTF16z instead of toStringz if
you need unicode support)
> 2. The controls appear to align to client by default. How do I
> position them where I want them and with the height and width
> of my choice.
I just added a new thing called StaticLayout that lets you do
this:
auto window = new MyMainWindow();
auto layout = new StaticLayout(layout);
auto btn = new Button("test", layout);
btn.x = 100;
btn.y = 200;
btn.width = 100;
btn.height = 50;
If the only child of the window is a StaticLayout, you can set
the x,y, width, height on each part of it and it will honor that.
The method registerMovement() btw is the key here. When it is
called, it calls MoveWindow to inform Windows of the updated
position. It is called automatically by the function
recomputeChildLayout(), which by default, also changes the size
and position automatically.
The new StaticLayout class overrides recomputeChildLayout to call
registerMovement without trying to change things itself.
(This is new btw becuase I kinda hate doing manual positioning
and wanted the automatic grid to work first. But then I didn't
get back to finish the other options when another project took
over, so there's a lot of minigui.d that isn't quite done,
including this.)
More information about the Digitalmars-d-learn
mailing list