Sign in to follow this  
SonicD007

Can't click on custom control in design view

Recommended Posts

Hey everyone, so I was following the tutorial on [url="http://create.msdn.com/en-US/education/catalog/sample/winforms_series_1"]http://create.msdn.c...nforms_series_1[/url] for using xna within a windows form and I'm running into an odd problem. I created a custom control to simply load a Texture2D and draw it on the screen and I have a property called DrawingArea which should be editable on the right hand side. The first time I load up the project I can move the control around and edit it's properties in the designer view but after running the program once, I can no longer move the control around or edit it's properties. Any idea why??

Language is C# API is XNA/WindowsForms
Visual Studio 2011 Ultimate Edition

Here's the code I have for my control

[source]
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
namespace texture2d_test
{
public partial class SimpleXNALoader : WinFormsGraphicsDevice.GraphicsDeviceControl
{
ContentManager content;
SpriteBatch spriteBatch;
Texture2D test;
Rectangle drawArea;
//[Browsable(false)]
public Rectangle DrawArea
{
get { return drawArea; }
set { drawArea = value; }
}
/// <summary>
/// Initializes the control, creating the ContentManager
/// and using it to load a SpriteFont.
/// </summary>
protected override void Initialize()
{
content = new ContentManager(Services, "Content");
spriteBatch = new SpriteBatch(GraphicsDevice);
test = content.Load<Texture2D>("animationtest");
this.Invalidate();
}
/// <summary>
/// Disposes the control, unloading the ContentManager.
/// </summary>
protected override void Dispose(bool disposing)
{
if (disposing)
{
content.Unload();
}
base.Dispose(disposing);
}
protected override void Draw()
{
spriteBatch.Begin();
spriteBatch.Draw(test, drawArea, Color.White);
spriteBatch.End();
}
}
}[/source] Edited by SonicD007

Share this post


Link to post
Share on other sites
Check the programs actually stopped running (calling application.exit from within the program is fairly effective).
I've had the same problem before and its always been due to me not actually closing the program (I tend to have taskbar on autohide so didn't see it open down there *facepalm*)

Click debug > Stop debugging


Otherwise it might be some sort of weird XNA related bug with it not being cleared from memory or something (in which case application.exit should work again) Edited by 6677

Share this post


Link to post
Share on other sites
The application seems to close correctly. I'm not sure whats causing this problem still. I'll try asking on the apphub forums where the tutorial is hosted. Thanks.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this