Note: You must be registered in order to post a reply.
|
Almar |
Posted - Aug 19 2004 : 09:32:33 AM Hi,
If there's one thing that can frustrate me a lot in DirectX, it would be the windowed/fullscreen changes. You have to take into account the client area ("body" of the window) and the actual windowsize. Stir that with ScaleX,ScaleY, Twips, ScaleWidth & scaleHeight and you'll get a headache gauranteed :).
I've got some half working thing. It takes into account the caption bar and borders, but somehow, with resetting to windowed, from fullscreen, the dimensions are different than simply resizing it from already windowed mode. My code is based on the desperate SDK code (the util bas file)
Does anyone have a easy to use chunk of code to fix this nightmare? I think it's one of the few last structural problems in YALG.
Thanks, Almar :)
|
cjb0087 |
Posted - Aug 28 2004 : 8:21:47 PM look up the AdjustWindowRectEx api NOW! it does all of this for you, resises the inside bit of a form to the requested size, how do i know this? ive had this problem before |
Almar |
Posted - Aug 19 2004 : 12:29:30 PM Learned something new too: never knew the scale has influence on the way DirectX renders things? Or maybe it's something in my code. but if I put it on userscale and 320x240, it is rendered that way. Maybe I'm using ScaleWidth somewhere. Funny though :)
Okay, it works fine now, the solution was - and here it comes - to resize your window after the device reset instead of before. I always thought you had to resize your window before the change, but guess not.
I updated your code a bit:
Public Sub CalcBorders() With frmMain .ScaleMode = vbTwips BorderHeight = .Height - .ScaleHeight BorderWidth = .Width - .ScaleWidth .ScaleMode = vbPixels End With End Sub Public Sub ResizeClient(Width As Integer, Height As Integer) With frmMain .Width = .ScaleX(Width, vbPixels, vbTwips) + BorderWidth .Height = .ScaleY(Height, vbPixels, vbTwips) + BorderHeight End With End Sub
since I'm using Pixels. |
Almar |
Posted - Aug 19 2004 : 12:21:57 PM Hmm, the * 15 should be a value from screen.twipsperpixelX and screen.twipsperpixelY I think? :)
But I guess I can give it a try.
Eric: Two forms is a real dirty way, and it should just work with one form anyway, the borders are the only problem in my calculations I think.. |
VBBR |
Posted - Aug 19 2004 : 11:23:32 AM Let me see, if I understood your problem right, this code should help a little. Just call ResizeClient to set a size for the client area (in pixels).
Also be sure to set ScaleMode to Twips. (or put in some code to set it)
Private BorderHeight As Integer Private BorderWidth As Integer Public Sub CalcBorders() Me.Width = 1500 Me.Height = 1500 BorderHeight = Me.Height - Me.ScaleHeight BorderWidth = Me.Width - Me.ScaleWidth End Sub Public Sub ResizeClient(Width As Integer, Height As Integer) Me.Width = (Width * 15) + BorderWidth Me.Height = (Height * 15) + BorderHeight End Sub Private Sub Form_Load() CalcBorders End Sub
Also I'm assuming here that you are using VB6? |
Eric Coleman |
Posted - Aug 19 2004 : 10:59:21 AM What about using two forms, one for windowed mode, and the other for fullscreen mode? |
|
|
VBGamer |
© |
|
|
|
|