News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Centering a video

Started by Grincheux, February 05, 2016, 05:01:25 AM

Previous topic - Next topic

Grincheux

I have a window into which I play a video.
The video is left aligned.
With MCI_WHERE I can know the video size (w & h).
Knowing that I would like to center the video.
One solution is to make a parent window centered onto the screen but is it on other way to to it?
Thanks.

dedndave

get the screen dimensions using GetSystemMetrics (SM_CXSCREEN and M_CYSCREEN)
get the parent window rectangle, using GetWindowRect (returns screen coordinates)
and, assuming you know the video dimensions....
do a little math to figure out where to place the video using client coordinates
you may need to use ScreenToClient to convert coordinates

Grincheux

The answer is : :t :greenclp: :eusa_clap: :eusa_dance:

Quote
   Get the client rect
   INVOKE GetClientRect,__hWnd,ADDR _Rc

   Get the size of the video
   INVOKE mciSendCommand,_mciOpen.wDeviceID,MCI_WHERE,MCI_DGV_WHERE_DESTINATION,ADDR _MciRectParm

   mov eax,__hWnd
   mov _MciRectParm.dwCallback,eax

   mov ecx,_Rc.right
   sub ecx,_MciRectParm.rc.right
   shr ecx,1

   mov edx,_Rc.bottom
   sub edx,_MciRectParm.rc.bottom
   shr edx,1

   _MciRectParm.rc.left,ecx
   _MciRectParm.rc.top,edx

   INVOKE mciSendCommand,_mciOpen.wDeviceID,MCI_PUT,MCI_DGV_PUT_WINDOW or MCI_DGV_RECT,ADDR _MciRectParm

   The MCI_PUT command place the video as I expected


Grincheux

I prefer GetSystemInfo because the taskbar is not seen as a free space. Screen dimensions remove it. Like this windows can be created without covering the taskbar.

In my case I could make a MoveWindow too but I preferred that MCI does it without changing my code.