directX WINDOWED mode?

Started by
9 comments, last by bilsa 20 years, 11 months ago
Hi! I have converted my project to windowed mode. I have created the surfaces and the clipper and changed the flip method to the blit method... But when I load a bitmap it is automaticly resized so that it is like 5 pixels smaller in width and height?! I actually have no Idee why it is like this... does anyone else know why it is like this ?? Thats right... I use WS_POPUP, WS_SYSMENU, WS_CAPTION for my window. Could it be that I use the title bar or something?? thx! [edited by - bilsa on April 29, 2003 11:53:15 AM]
Advertisement
Ok, I have checked it out some more and have come to the following:

while in window mode and having the same resolution as my desktop:

1280x1024

the pictures get resized a little.


But when I change screen resolution with SetDisplayMode to 640x480...

then the pictures are OK!

wth?!
I dont have a slightest idee why it would be like that?!
When you create the direct3d object, you need to specify the resolution used in the window(via the D3DPRESENT_PARAMETERS BackBufferWidth or BackBufferHeight field). If you set it to the desktop resolution, the window will have coordinates ranging from 0 to 1024(if thats the desktop resoltion) in the space provided by the window.(If your window width is 800, the coordinates will be adjusted to emulate 1024 pixels in that 800 pixel space) I usually adjust the backbuffer resolution to the exact pixel size of the window on resize.
Hope this helps.
Ah, I c...

But the thing is that I use DirectDraw7 for this.
And I now DEFENITELY KNOW what the problem is!

When I create a window WITH A TITLE BAR on top, then the pictures screw up! Instead of just cutting away the space that the titlebar takes, the re rest of the window is pressed together!?

I have tried to create windows WITHOUT title bars and then everything is fine.

first create a RECT with the dimensions of your display area.
use the API AdjustWindowRect to expand it a little
and create your window with these resized dimensions... all will be well
Could you please tell me some more about it?

I read some documentation about AdjustWindowRect()
But I dont what to do with this?

Will the values change in the rect that I pass with the function?
thx!

[edited by - bilsa on April 29, 2003 2:49:49 PM]
Great, thank you!
I was going crazy about this

I messed half day with my drawing functions and surface creation and other stuff

thx!
The easiest way to do it (that I know of):


    // Get the client and window dimensionsRECT ClientRect, WndRect;GetClientRect(hWnd, &ClientRect);GetWindowRect(hWnd, &WndRect);// Set the width and height (set your dimensions here)DWORD DesiredWidth  = 640;DWORD DesiredHeight = 480;DWORD Width  = (WndRect.right - WndRect.left) + (DesiredWidth  - ClientRect.right);DWORD Height = (WndRect.bottom - WndRect.top) + (DesiredHeight - ClientRect.bottom);// Set the window's dimensionsMoveWindow(hWnd, WndRect.left, WndRect.top, Width, Height, TRUE);    



[edited by - Jim Adams on April 29, 2003 3:06:22 PM]
Using AdjustWindowRect:

RECT rectClient = { 0, 0, 640, 480 };AdjustWindowRect(&rectClient, WS_OVERLAPPEDWINDOW, TRUE);  


Substitute whichever window style your window has. Pass TRUE if it has a menu, FALSE if not.

rectClient will then contain the size needed to get a 640x480 client area. It won't necessarily be at 0,0.



[edited by - Donavon Keithley on April 29, 2003 3:18:16 PM]
Donavon KeithleyNo, Inky Death Vole!
Thx for the posts guys

That was exactly what messed my images.

This topic is closed to new replies.

Advertisement