Forum
Contact





DirectX using C#
DirectX using C++
DirectX using Visual Basic



Latest Forum posts

 Tutorial 3 for Windows Phone 7
  Posted by: Anonymous
  When: 20/05/2013 at 02:30:13

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09

 Math boggles me
  Posted by: cityguy
  When: 17/03/2013 at 03:44:48

 Collision Class?
  Posted by: Da_Boom
  When: 16/03/2013 at 03:44:42

 Tree update
  Posted by: Anonymous
  When: 15/03/2013 at 21:11:22

 XNA 4.0
  Posted by: Anonymous
  When: 15/03/2013 at 19:43:57

 Error when I try to run.
  Posted by: Anonymous
  When: 15/03/2013 at 19:21:06

 Error With the Effect File
  Posted by: Anonymous
  When: 15/03/2013 at 18:21:01

 Can only get shadowmap
  Posted by: Anonymous
  When: 15/03/2013 at 15:48:52

 Vertex and Pixel Shader Versions?
  Posted by: Anonymous
  When: 15/03/2013 at 15:07:16

 Unsupported properties
  Posted by: Anonymous
  When: 15/03/2013 at 14:23:00

 Problem Loading Skybox
  Posted by: Rana
  When: 15/03/2013 at 10:34:45

 Black Screen Of Death - Help!
  Posted by: Anonymous
  When: 15/03/2013 at 03:43:43

 2.0 anyone?
  Posted by: Anonymous
  When: 15/03/2013 at 02:19:48

 Defitinition of tha rotation axis
  Posted by: Anonymous
  When: 15/03/2013 at 00:55:14




Topic: this.Invalidate(); buttons problem



  
Goto parent category
  
Create a new user account


   this.Invalidate(); buttons problem
 Poster : psyche
 Posts: 2
 Country : Romania
 City: Constanta

  
Posted by psyche on 26/01/2008 at 03:21:06
... at least for me it doesn't :)

Hello there ! I am quite new to game dev. And I must say, if it wasn't for your tuts, I'd probably never started this in the first place... so thanks a bunch ! :)

I have to make a game as an university project, it's going well, everything works fine, except the fact that I cannot use the button and label components properly... I suspect the this.Invalidate(); function is to blame... and I can't take it out either because my game won't refresh... and I don't want that :))

Here is how it goes: I start my game, everything shows well, but in the place of my buttons and labels are these white rectangles... if I move the window a bit, they show up... after that, I click my start button, the new scene appears, with the same problem... I move the window, they appear again.

Can anyone help me out on this ?

Thank you !
 Poster : Anonymous
 Posts:
 Country :
 City:

  
Posted by Anonymous on 29/04/2008 at 05:45:30
I have same problem.

Best solution I found is to create new partialy transparent form and place it over our DX WinForm.
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 02/05/2008 at 14:40:11
This is how I add a DX window to my C# Form:


    public sealed class DXTarget : UserControl
    {
        public DXTarget()
        {
            SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint, true);
            UpdateStyles();
        }
    }


dxTarget3D = new DXTarget();
            dxTarget3D.BorderStyle = BorderStyle.Fixed3D;
            dxTarget3D.Location = new Point(250, 50);
            dxTarget3D.Size = new Size(1120, 600);
            mainForm.Controls.Add(dxTarget3D);
            device3D = AddDxControl(dxTarget3D);



private Device AddDxControl(DXTarget dxTarget)
        {
            PresentParameters parameters = new PresentParameters();
            parameters.Windowed = true;
            parameters.SwapEffect = SwapEffect.Discard;
            parameters.AutoDepthStencilFormat = DepthFormat.D16;
            parameters.EnableAutoDepthStencil = true;

            Device device = new Device(0, DeviceType.Hardware, dxTarget, CreateFlags.SoftwareVertexProcessing, parameters);

            device.RenderState.CullMode = Cull.None;
            device.RenderState.FillMode = FillMode.Solid;
            device.RenderState.Lighting = false;
            device.Transform.Projection = Matrix.PerspectiveFovLH((float)(Math.PI / 4.0), (float)dxTarget.Size.Width / (float)dxTarget.Size.Height, 1.0f, 1000.0f);
            device.Transform.View = Matrix.LookAtLH(new Vector3(0.0f, 0.0f, 20.0f), new Vector3(0.0f, 0.0f, 0.0f), new Vector3(0.0f, 1.0f, 0.0f));

            device.Clear(ClearFlags.Target, Color.Black, 1.0f, 0);
            device.BeginScene();
            device.EndScene();
            device.Present();

            return device;
        }


 Poster : Serendipity
 Posts: 27
 Country : Pakistan
 City: Rawalpindi

  
Posted by Serendipity on 12/05/2008 at 03:14:32
Hi!

Just adding as a hopefully helpful bit of info...

I used the approach that Riemers has mentioned. Even with this, main form's controls were not being painted again. And I din't want to used main form's OnPaint method, so that my UserControl would have a higher fps, so i just refresh main form's controls based on a timer, at a rate of 10 Hz. The response of mainform doesn't seem slow.

Anybody who thinks I could do this some better way, please comment.

Thanks.
 Poster : Serendipity
 Posts: 27
 Country : Pakistan
 City: Rawalpindi

  
Posted by Serendipity on 12/05/2008 at 03:16:42
<correction> din't want to *use* .... :)
 Poster : riemer
 Posts: 1392
 Country : Belgium
 City: Antwerp

  
Posted by riemer on 12/05/2008 at 05:44:02
When you use this code, make sure you don't override the OnPaint method of your Form class.

  
Post a new reply
 





Google
 
Web www.riemers.net
If you appreciate the amount of time I spend creating and updating
these pages, feel free to donate -- any amount is welcome !
- Website design & DirectX code : Riemer Grootjans -
©2006 Riemer Grootjans


News
Home
Forum
XNA 2.0 Recipes Book (8)
XNA 3.0 Recipes Book (8)
Downloads
Extra Reading (3)
Matrices: geometrical
Matrix Mathematics
Homogenous matrices
Community Projects (1)
Tutorials (160)
XNA 4.0 using C# (89)
DirectX using C# (54)
Series 1:Terrain (14)
Opening a window
Linking to the Device
Drawing a triangle
Camera
Rotation - Translation
Indices
Terrain creation
Terrain from file
DirectInput
Importing bmp files
Colored vertices
DirectX Light basics
Mesh creation
Mesh lighting
Series 2: Flightsim (19)
Series 3: HLSL (19)
Short Tuts (2)
Resizing problem
Checking Device caps
DirectX using C++ (15)
DirectX using VB (2)