| Topic: this.Invalidate(); buttons problem
|
|
 | 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. | |
|
|
 | | |  |
|
|
|
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
|
|