Resizing a window

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Resizing a window

Jeff M.
Okay, the View classes are great, but I'm having one hell-uv-a-time
trying to get something to work properly that I *need* to work
properly. :-)

After the window is created and displayed, I need to adjust the size of
it, because the size is wrong when first displayed. In C, this would be
done like so:

RECT cr;
DWORD style, styleEx;

GetClientRect(hWnd, &cr);

style = GetWindowLong(hWnd, GWL_STYLE);
styleEx = GetWindowLong(hWnd, GWL_EXSTYLE);

AdjustWindowRectEx(&cr, style, FALSE, styleEx);

Now 'cr' contains the *real* desired size of the window. Originally, if
I specify the window should be 800x600, when it's created, that
includes all the "fluff" as well - frame, menubar (if there is one),
etc. We adjust the rectangle to compensate for this and then resize the
window so that the actual "viewport" area is proper:

int width = cr.right - cr.left + 1;
int height = cr.bottom - cr.top + 1;

SetWindowPos(hWnd, NULL, 0, 0, width, height, SWP_NOMOVE |
SWP_NOZOREDER);

Phew. Too much C. Now, I can do all of this with the UserLibrary and
all the code works, except that the SetWindowPos doesn't actually seem
to do anything. I do all of this in #onViewCreated, which could
possibly be the problem (I actually don't know the order of events in
Dolphin - in C I would do this right before ShowWindow). I've tried
using #width: and #height:, but none of these appear to actually work.

I can confirm 100% that the view is not the correct size, because
rendering a square in the viewport is not a *real* square (note: this
is rendering with Direct3D, not GDI which deals with pixels and not
projections).

Any helpful hints appreciated. Thanks!

Jeff M.


Reply | Threaded
Open this post in threaded view
|

Re: Resizing a window

Udo Schneider
Jeff M. wrote:
> Any helpful hints appreciated. Thanks!
The following code snippet might help:
presenter := ImagePresenter create: 'Gdiplus view' on: nimage.
                        (presenter topShell)
                                extent: (presenter topShell calcExtentFromClientExtent: nimage extent).

CU,

Udo


Reply | Threaded
Open this post in threaded view
|

Re: Resizing a window

Jeff M.
Udo Schneider wrote:
> Jeff M. wrote:
> > Any helpful hints appreciated. Thanks!
> The following code snippet might help:
> presenter := ImagePresenter create: 'Gdiplus view' on: nimage.
> (presenter topShell)
> extent: (presenter topShell calcExtentFromClientExtent: nimage extent).

#calcExtentFromClientExtent was exactly what I was looking for. Thanks.
I actually got the original code to work, but it took a little
fenagling. The problem is that it appears to be an order of operations
problem. I ended up having to put the calculation in #defaultExtent,
instead of trying to resize it later (although I have no idea why).

Regardless, the method you pointed me to works, and now I have 1 line
of code where there used to be 10. Thanks. :-)

Jeff M.