I've tested some of my avi files and I've finded the following:
If you want to know the MovieWindowSize of an .AVI file, you have to read the 32bit value at (decimal)offset 64 for the width, and the 32bit value at (decimal)offset 68 for the height.
NOTE: I can't assure you that all the avi files have the dimension information at that offset, but mine yes!
There is a BEEEEETTER way to retrieve information about avi files, and it's through API calls (here is a VisualBasic example taken from API-Guide that retrieves the AVI file window dimesions):
Code:
Private Const OF_SHARE_DENY_WRITE As Long = &H20
Private Type AVIFileInfo
dwMaxBytesPerSec As Long
dwFlags As Long
dwCaps As Long
dwStreams As Long
dwSuggestedBufferSize As Long
dwWidth As Long
dwHeight As Long
dwScale As Long
dwRate As Long
dwLength As Long
dwEditCount As Long
szFileType As String * 64
End Type
Private Declare Function AVIFileOpen Lib "avifil32" Alias "AVIFileOpenA" (ppfile As Long, ByVal szFile As String,
ByVal mode As Long, pclsidHandler As Any) As Long
Private Declare Function AVIFileRelease Lib "avifil32" (ByVal pfile As Long) As Long
Private Declare Function AVIFileInfo Lib "avifil32" Alias "AVIFileInfoA" (ByVal pfile As Long, pfi As AVIFileInfo,
ByVal lSize As Long) As Long
Private Declare Sub AVIFileInit Lib "avifil32" ()
Private Declare Sub AVIFileExit Lib "avifil32" ()
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim hFile As Long, AviInfo As AVIFileInfo
'initialize the AVIFile library
AVIFileInit
'create a handle to the AVI file
If AVIFileOpen(hFile, "C:\PATH\file_name.avi", OF_SHARE_DENY_WRITE, ByVal 0&) = 0 Then
'retrieve the AVI information
If AVIFileInfo(hFile, AviInfo, Len(AviInfo)) = 0 Then
MsgBox "AVI dimensions: " + CStr(AviInfo.dwWidth) + "x" + CStr(AviInfo.dwHeight)
Else
MsgBox "Error while retrieving AVI information... :("
End If
'release the file handle
AVIFileRelease hFile
Else
MsgBox "Error while opening the AVI file... :("
End If
'exit the AVIFile library and decrement the reference count for the library
AVIFileExit
End Sub
Here below is the code (that I made still for Visual Basic) I suggest you to use instead of any SendMessage call to BSplayer (note, the code may be defective, but to me works without problems):
Code:
Const SWP_ASYNCWINDOWPOS As Long = &H4000
Const SWP_DEFERERASE As Long = &H2000
Const SWP_FRAMECHANGED As Long = &H20
Const SWP_DRAWFRAME As Long = SWP_FRAMECHANGED
Const SWP_HIDEWINDOW As Long = &H80
Const SWP_NOACTIVATE As Long = &H10
Const SWP_NOCOPYBITS As Long = &H100
Const SWP_NOMOVE As Long = &H2
Const SWP_NOOWNERZORDER As Long = &H200
Const SWP_NOREDRAW As Long = &H8
Const SWP_NOREPOSITION As Long = SWP_NOOWNERZORDER
Const SWP_NOSENDCHANGING As Long = &H400
Const SWP_NOSIZE As Long = &H1
Const SWP_NOZORDER As Long = &H4
Const SWP_SHOWWINDOW As Long = &H40
Const HWND_BOTTOM As Long = 1
Const HWND_TOP As Long = 0
Const HWND_TOPMOST As Long = -1
Const HWND_NOTOPMOST As Long = -2
Private Declare Sub SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long,
ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long)
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Declare Function GetWindowRect Lib "user32" (ByVal hWnd As Long, lpRect As RECT) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim Rec As RECT
Dim ParentHwnd As Long
Dim AspectRatio As Single
'If you click on Button "Command1"
Private Sub Command1_Click()
'Retrieve the handle of the MovieWindo
ParentHwnd = FindWindow("TBSForm", "BForm")
'If the MovieWindow exists
If ParentHwnd <> 0 Then
'Retrieve the MovieWindowSize
GetWindowRect ParentHwnd, Rec
'Calculate the AspectRatio of the current MovieWindow
AspectRatio = Round((Rec.Right - Rec.Left) / (Rec.Bottom - Rec.Top), 3)
'Resize the MovieWindow
SetWindowPos ParentHwnd, HWND_TOPMOST, 0, 0, 800, Int(800 / AspectRatio), SWP_NOACTIVATE Or SWP_NOMOVE
'Get the new MovieWindowSize
GetWindowRect ParentHwnd, Rec
'Display the current MovieWindowSize in the caption of the Button "Command1"
Command1.Caption = (Rec.Right - Rec.Left) & " x " & (Rec.Bottom - Rec.Top)
End If
End Sub
This code resize the MovieWindow to have a width of 800pixels (as you asked in previous posts), and the height to the respective aspect-ratio height.
That means that if the movie window was 640x480, after the resizing it will be 800x600!
With this code the movie window will not be moved, if you want also to move the window, you have to delete the
Or SWP_NOMOVE string from the SetWindowPos call!
I hope that finally this could help you :D