johnbraum
johnbraum

Reputation: 296

AxWindowsMediaPlayer control location/size

I have a AxWindowsMediaPlayer control on my WinForm.

Everything works so far. But I can't resize or move the control.

I initialize the control like this:

mediaPlayer = new AxWMPLib.AxWindowsMediaPlayer();

mediaPlayer.CreateControl();
mediaPlayer.enableContextMenu = false;
((System.ComponentModel.ISupportInitialize)(mediaPlayer)).BeginInit();
mediaPlayer.Name = "wmPlayer";
mediaPlayer.Enabled = true;
mediaPlayer.Dock = System.Windows.Forms.DockStyle.Fill;
mediaPlayer.Size = this.Size;
this.Controls.Add(mediaPlayer);
((System.ComponentModel.ISupportInitialize)(mediaPlayer)).EndInit();
mediaPlayer.uiMode = "none";
mediaPlayer.URL = fileName;
mediaPlayer.settings.setMode("loop", true);

mediaPlayer.Ctlcontrols.play();

But the size ist always the same. How can I set the Size or the Bounds of this Controls?

Thanks for help

Upvotes: 1

Views: 5956

Answers (2)

Vulpi
Vulpi

Reputation: 1

For anyone who wants to zoom in on AxWindowsMediaPlayer

        axWindowsMediaPlayer1.stretchToFit = true;
        axWindowsMediaPlayer1.Width *= 2;
        axWindowsMediaPlayer1.Height *= 2;

Upvotes: 0

kennyzx
kennyzx

Reputation: 13003

It is better do this in designer, rather than code.

In your code, you set the size of the player control as large as the form.

//occupies all the form's available space
mediaPlayer.Dock = System.Windows.Forms.DockStyle.Fill; 
//again, the player is the same size as form
mediaPlayer.Size = this.Size; 

In order to set the bound of the player control within the form, you can set the its AnchorStyle- anchoring the control to the edges of the form- and set the control's Location and Size properties.

mediaPlayer.Location = new Point(50, 50);
mediaPlayer.Size = new Size(this.ClientSize.Width - 100, this.ClientSize.Height - 100);
mediaPlayer.Anchor = AnchorStyles.Top | AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Bottom;

Upvotes: 1

Related Questions