|
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.
|
|
|
|
|
What, you don't think he intended to have "0-99" as one of his integer strings? Yes, but in an if statement, (0-99) == -99, so I think this is exactly what he was looking for!
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Hi,
I have a xml file.I am trying to display the specific contends in a list box. for example::this is my xml contend.In the below items i want my list box to display only whatever is in "connection name".
connectionname>Anet
subnetmask>x.x.x.x
defaultgateway>x.x.x.x
dns1>x.x.x.x
dns2>x.x.x.x
dns3>x.x.x.x
dns4>
<con>
connectionname>BL
subnetmask>x.x.x.x
defaultgateway>x.x.x.x
dns1>x.x.x.x
dns2>x.x.x.x
dns3>x.x.x.x
dns4>
/con>
My code is displaying the full contend.
XmlTextReader textreadobj = new XmlTextReader(@"C:\Documents and Settings\j\My Documents\Visual Studio 2005\Projects\InternetApp\InternetApp\XMLFile1.xml");
textreadobj.Read();
while (textreadobj.Read())
{
lstProvider.Items.Add(textreadobj.ReadString());
}
So how can i make it display the items in connection name only.
Thanks in advance
|
|
|
|
|
|
string sPattern = @"[^\p{Cc}\\r\\n\\a\\e\\b\\t][\S]*[\w\p{Po}\s-`\p{Sm}]*[^\p{Cc}\\r\\n\\a\\e\\b\\t]";
try
{
if (Regex.IsMatch(txtText.Text, sPattern, RegexOptions.Multiline | RegexOptions.IgnoreCase))
{
objMatch = Regex.Match(txtText.Text, sPattern, RegexOptions.ECMAScript | RegexOptions.Compiled
| RegexOptions.Multiline | RegexOptions.IgnoreCase);
if (objMatch.Success)
lblDone.Text = objMatch.Value;
}//end (if (Regex.IsMatch...)
}//end(try)
finally
{
sPattern = null;
}//end (finally)
input string is :-- \r\nloadplayer "playername=test_1"\r\n
output string should be :-- loadplayer "playername=test_1"
want to neglect all newline,tabs.. etc from the input string.
Now its doing fine, but also removing "r,n,a,e,b,t" from the starting of the input string.
Means, if the input string is:-- roadplayer "playername=test_1"\r\n
output becomes:-- oadplayer "playername=test_1"
it should be:-- roadplayer "playername=test_1"
so, tell me what i should do for better working.
Thxx...
Enjoy!!
|
|
|
|
|
The 'escape characters' are all in the format '\x'.
\n is new line... etc.
'\\' in a string represents a '\', a single '\' will look like an escape character.
So you need to use: \n \r etc instead of \\n \\r.
I've never use Regex before but I assume this is right.
Hope it helps.
Matthew Butler
|
|
|
|
|
Hi!
I've asked a similar question some time ago, but unfortunately without usable results, so I try again.
I put some text into the clipboard and want to trigger a paste action inside a terminal server session (i.e. programmatically do what happens when you press Ctrl+V inside a mstsc window).
Yes, I know that you can't programmatically see the different windows inside the WTS session and that the currently active application will be the target for my paste, but that's exactly what I want.
So far I tried using SendKeys , P/invoke to SendInput and keybd_event , posting WM_PASTE or even WM_KEYDOWN and WM_KEYUP with the exact parameters Spy++ reports, but I can't get it to work.
The first 4 ways simply give no visible result at all, with WM_KEYDOWN/UP I get a plain "v" instead of Ctrl+V.
Does anyone have any further idea?
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
mav.northwind wrote: So far I tried using SendKeys,
Like this?
SendKeys.SendWait("[Clipboard content here]");
or like this:
SendKeys.SendWait("^a^v");
If you've tried the second one, it wont work - as you probably have noticed. Console windows doesn't accept pasting of text. Try getting the content of the clipboard somehow, store it in a string and then write it out like this:
SendKeys.SendWait(clipboardContent);
Kristian Sixhoej
"Failure is not an option" - Gene Kranz
|
|
|
|
|
Hi!
First of all, thanks for you reply.
Unfortunately, neither the first nor the second version has any visible effect on the mstsc window.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Why not do the following, where you know how to write a single char to the console (as indicated in your question where you said you can send a 'v' character):
if (Clipboard.ContainsText()) {
string ct = Clipboard.GetText();
foreach (char c in ct)
WriteCharToConsole(c);
} I know it is a hack, but it will work. Sorry for not getting back to you on your original post, but I got kind of sidetracked. I still plan to look into how to do this the "right" way, but this will suffice until then.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Thanks, Jeff.
Skippums wrote: Sorry for not getting back to you on your original post,
No problem here - you're not obliged to solve my problems
The main reason why this "hack" won't do, I'm afraid, is that the clipboard contains RTF...
Nevertheless, thanks for the suggestion.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
What if you read the RTF into the RichTextBox.Rtf property, then read it back out from the RichTextBox.Text property? This raises the hack level to about a 9 out of 10, but again, I think it may work for you. Also, isn't there a way to get RTF text from the clipboard without the formatting? You may want to check into that as well.
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
Sure, there are easy ways to retrieve plain text from RTF, but that's not the point.
The requirement is to paste the contents of a RichTextBox into the terminal server session, just like one would with a local application. Formatting etc. has to be retained.
What I cannot understand is that I don't get the same results when sending the same messages with the same parameters Spy++ is recording...
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
Victory is mine! (as Stewie Griffin would say)
Finally, I got some code from a guy in an MCE forum who was sending keystrokes to an mstsc window in response to IR remote control events.
He also used keybd_event (which didn't work in my tests), but also used AttachThreadInput , so I think this was the missing piece.
With this code I was able to send Ctrl+V to mstsc, thus triggering paste into the current application. Works like a charm!
Anyway, thanks for your support!
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|