|
Perhaps if we knew why you wanted to do this. It doesn't make much sense to me.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
Sorry,I didn't give all the details. My controls are all image-based, but I wan't to also use them as sprites(I'm developing 2D games). I can't use the control's painting, because I will never get rid of flickering. Now..the form in it's onpaint already has access to all this control, so it's not hard to call child.GetImage() for example. That is what manual double buffering means..all painting is done in one place(form.onpaint)
I don't now how to stop the controls from using their default-painting.
Here is what I have at this moment for the control:
<br />
public class MyControl : Control<br />
{<br />
...<br />
private bool visible = true;<br />
<br />
public bool isValid;<br />
<br />
...<br />
public Image GetImage()
...<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
isVisible = false;
Parent.Invalidate()
ValidateRect(this.Handlde) <br />
}<br />
Now..this is what the form should do:
<br />
public partial class TestForm : Form<br />
{<br />
...<br />
protected override void OnPaint(PaintEventArgs e)<br />
{ <br />
for (int i = Controls.Count - 1; i >= 0; i--)<br />
{<br />
if (Controls[i] is MyControl)<br />
{<br />
if (!((MyControl)Controls[i]).IsValid && ((MyControl)Controls[i]).GetImage() != null)<br />
{<br />
grafx.Graphics.DrawImageUnscaledAndClipped<br />
(((MyControl)Controls[i]).GetImage(),<br />
((MyControl)Controls[i]).ImageRect);<br />
((MyControl)Controls[i]).IsValid = true;
}<br />
}<br />
}<br />
grafx.Render(e.Graphics);
}<br />
Using this code..will invalidate the form continuously... blocking the form
What have I left out?
If I don't make MyControl derive from Control will not give me design-time support..but Control
implements IWin32Window so it get's messages fron the system..not the form.
Thanks very much for your patience..sorry I'm not very good at explaining
|
|
|
|
|
If your making a 2D game, then it would be best to stop using controls for your sprites at all, make a struct or class to contain the location, size, image and any other necessary properties, and do the drawing yourself, that would be much better.
But, if you want to continue using controls, try adding Application.DoEvents(); to give time back to the application for updating and whatnot.
My current favourite word is: Bauble!
-SK Genius
|
|
|
|
|
I can't use DoEvents()..that method processes all the messages in the message queue, so if I use that before the painting, my framerate would depend on what the client does with the mouse\keyboard.
My present games are like you said, a class with all the information, but I could develop them in..Notepad
I need the design-time support of Visual Studio, that's why I choose controls.
If I use controls I don't need to whorry about when the mouse enters,leaves etc..
No..again..I have only one problem with controls...I don't want them do do painting att all, but still..when the control receives a WM_PAINT..it should tell the Parent that it's Image it's no longer updated. I don't know 100% how paint messages work, but I think windows keeps sending WM_PAINT if the wnidows update region is not NULL.
|
|
|
|
|
Hi guys
I am going to reuse vnchook.dll in c#.net application.
Please any body has any idea?
thanks in advance.
naresh is testing the site.
|
|
|
|
|
I have a UI with text fields, I want them to be filled with the data from the access database. I want it to go in a order, so each time I run it, I want it to read the next column values and print it to the textfields.
Whats the way to do it?
UI, project is in C# .NET2005
|
|
|
|
|
What have you tried that hasn't worked for you?
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
|
Do you have this working yet?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hy,I have a bing problem. I am developing an application that refreshes itself very-very fast, this is why I am using manual double buffering for drawing(i.e a memory graphics). I want to develop my app at design-time,that is why I place a lot of controls on the form(they all have an Image that they want to display).
But I need to draw them all in one place(i.e Form.OnPaint()).
How can I completely remove paint messages sent to the controls, and still give feedback to the form, whenever a control receives a paint message?
I need something like this:
Control.Onpaint()
{
//tell the parent that it should ask me for my image and draw it
//validate my update region,sa I don't get paint messages until I am invalidated
}
If anyone can help me..thank you in advance, it's a big problem for me.
|
|
|
|
|
make them invisible.
Greetings from Germany
|
|
|
|
|
Well..this doesn't help me as i need to use the same double buffering at design-time and run-time. First, Visible is always true at design-time you can't set it to false. Second, if i don't draw all the controls in the same place, I can't toggle from Visible=true\false,as transparency for the control(this.BackColor) means what's under all the controls(i.e. the background). I wan't the controls to look at design-time like layers.
Again..I need the controls to do no painting at all..the form does everything in one place
|
|
|
|
|
I have absolutely no idea what you are asking here. I have read this post multiple times, and cannot for the life of me figure out your problem. Do you think you could restate the problem another way, and additionally give a broad overview of what you are trying to accomplish? Thanks,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Please read my answer in the upper thread..I accidentally started 2 threads.Sorry
|
|
|
|
|
This sounds like an absolute disaster. You want to add a layer where the controls paint event sends a message telling someone else to paint it ( which you can do just by handling the paint event BTW ), and you think this will make it faster ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Sorry,I didn't give all the details. My controls are all image-based, but I wan't to also use them as sprites(I'm developing 2D games). I can't use the control's painting, because I will never get rid of flickering. Now..the form in it's onpaint already has access to all this control, so it's not hard to call child.GetImage() for example. That is what manual double buffering means..all painting is done in one place(form.onpaint)
I don't now how to stop the controls from using their default-painting.
Here is what I have at this moment for the control:
<br />
public class MyControl : Control<br />
{<br />
...<br />
private bool visible = true;<br />
<br />
public bool isValid;<br />
<br />
...<br />
public Image GetImage()
...<br />
protected override void OnPaintBackground(PaintEventArgs pevent)<br />
{<br />
}<br />
<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
isVisible = false;
Parent.Invalidate()
ValidateRect(this.Handlde) <br />
}<br />
Now..this is what the form should do:
<br />
public partial class TestForm : Form<br />
{<br />
...<br />
protected override void OnPaint(PaintEventArgs e)<br />
{ <br />
for (int i = Controls.Count - 1; i >= 0; i--)<br />
{<br />
if (Controls[i] is MyControl)<br />
{<br />
if (!((MyControl)Controls[i]).IsValid && ((MyControl)Controls[i]).GetImage() != null)<br />
{<br />
grafx.Graphics.DrawImageUnscaledAndClipped<br />
(((MyControl)Controls[i]).GetImage(),<br />
((MyControl)Controls[i]).ImageRect);<br />
((MyControl)Controls[i]).IsValid = true;
}<br />
}<br />
}<br />
grafx.Render(e.Graphics);
}<br />
Using this code..will invalidate the form continuously... blocking the form
What have I left out?
If I don't make MyControl derive from Control will not give me design-time support..but Control
implements IWin32Window so it get's messages fron the system..not the form.
Thanks very much for your patience..sorry I'm not very good at explaining
|
|
|
|
|
ctoma2005 wrote: My controls are all image-based, but I wan't to also use them as sprites(I'm developing 2D games).
OK - moving controls around to represent the characters in your game is the point at which your design is broken. Fix this, and I'm sure you'll find everything works just fine. Even then tho, getting a good framerate without using DirectX is a challenge.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Well..most of the time I don't move them around, I just alter the control's image.
I know that control's might not be the best choice..but if I take out the control's painting,it would just be a container for my images + it keeps track of all thoe mouse\keyboard events.
If I don't use controls,it's easy, but I might as well develop my games in..Notepad
|
|
|
|
|
hi,
i have little problem about int.......like
int i=0;<br />
int j=1;<br />
int k=10;<br />
int l=100;
i want display the int value as
i=0000
j=0001
k=0010
l=0100
....
tell me any hint or solution
I AM WORKING ON "PLOTTER ROBOT"(FYP).
|
|
|
|
|
Make a string and check the length and add the missin "0".
Greetings from Germany
|
|
|
|
|
GOOD
I AM WORKING ON "PLOTTER ROBOT"(FYP).
|
|
|
|
|
Use the formatting options in ToString():
j.ToString("000#");
|
|
|
|
|
similar to "X4" there is also j.ToString("D4");
|
|
|
|
|
Take your pick from the following (result == "0010" in all cases)...
int j = 10;
string result;
result = j.ToString().PadLeft(4, '0');
result = j.ToString("D4");
result = j.ToString("0000");
result = string.Format("{0:D4}", j);
result = string.Format("{0:0000}", j);
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Skippums wrote: result = j.ToString().PadLeft(4, '0');
not very good for [-99,-1] tho.
|
|
|
|