[phobos] Resizing child windows using phobos

Adam D. Ruppe destructionator at gmail.com
Thu Aug 22 09:43:32 PDT 2013


On Thu, Aug 22, 2013 at 06:19:18AM -0500, Alex Dahlin wrote:
> Is there any other methods that i can use that are already included in 
> the phobos libraries?

The Windows headers in phobos and druntime are very minimal and don't
include the necessary functions (either SetWindowPos or MoveWindow will
do it, the WM_SIZE message is sent to notify the window that it has already
been resized, not to actually change it.)

http://msdn.microsoft.com/en-us/library/windows/desktop/ms633545(v=vs.85).aspx

To call a Windows function that isn't included in the phobos headers, you
just have to copy the prototype. For example:


import core.sys.windows.windows; // include the basics druntime provides, aka std.c.windows.windows

// you can get the prototype from MSDN. It is almost the same, just take out the "WINAPI" and "_In_"
// and use extern(Windows) before it
extern(Windows) BOOL SetWindowPos(HWND hWnd, HWND hWndInsertAfter, int x, int y, int w, int h, UINT flags);


// call the function:

SetWindowPos(hwnd, null, 0, 0, newWidth, newHeight, /* SWP_NOZORDER */ 0x0004 | 0x002 /* SWP_NOMOVE */);



You can also copy/paste the constants out of MSDN and make enums for them instead of
just writing the number like I did here.



OR you can grab the more complete windows headers for D. I think this is the more up-to-date
repo:

http://dsource.org/projects/bindings/browser/trunk/win32


Then you can import win32.windows; and use it straight away. It would be really nice if
these headers came with the D distribution, but alas they don't yet.



More information about the phobos mailing list