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 :)">
Windowed/fullscreen changes...
Almar JolingHi, 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 :)
cjb0087look 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
Eric ColemanWhat about using two forms, one for windowed mode, and the other for fullscreen mode?
VBBRLet 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) [code]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) 'in PIXELS Me.Width = (Width * 15) + BorderWidth Me.Height = (Height * 15) + BorderHeight End Sub Private Sub Form_Load() 'anything... CalcBorders 'anything... End Sub[/code] Also I'm assuming here that you are using VB6?
Almar JolingHmm, 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..
Almar JolingLearned 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: [code] 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) 'in PIXELS With frmMain .Width = .ScaleX(Width, vbPixels, vbTwips) + BorderWidth .Height = .ScaleY(Height, vbPixels, vbTwips) + BorderHeight End With End Sub [/code] since I'm using Pixels.