|
Are you talking about This.Topmost ?
|
|
|
|
|
No.If I keep that it always shows my application only.My requirement is it should be on desktop just like wallpaper .whenever we see wallpaper we should able to see our application.
Thank you.
Mahi
|
|
|
|
|
Wow, Lwin+D powerfull stuff. I have stopped all forms of minimizing / maximizing, but Lwin+D still gets the app out of the way.
And as for keeping it at the back... i'm not sure. Then again, you might be able to do something in WndProc to stop your window coming forward.
-- modified at 21:06 Tuesday 30th October, 2007
From what i can tell, an application gets no message when a user presses win+d. It just gets minimized.
From what i can tell of other things, the OS hides all windows, and draws the desktop over everything, and sets some active window property, or somthing similar to null. As a test for yourself, find a window you cannot minimize (try opening up the options for your browser). Do Lwin+D, now, restore or maximize any window other than your browser. As you can see, your browser is restored, though it will have received no message to maximize or restore.
And thats enough of my ramblings. I'm sure they're quite wrong, but who knows...
My current favourite word is: Waffle
Cheese is still good though.
|
|
|
|
|
hi everyone!
i used a stream to read a whole txt file into a string variable. this is a copy of a template where tokens have to be replaced by values.
but because i do not know how many pages there will be i have to get it "dynamic" meaning i have to store the page template in a string variable and then copy it once, twice, ... to another one.
the first copy is already there. but because i do not want to loose the original copy i do copy it to another string variable. thats a simple assignment, that's easy. but now i wonder if i do just have to do the following
<br />
string template;
string output = "";
<br />
output = template;<br />
<br />
output = output + template;<br />
but i am not sure if it is formated correctly or if there could be problems when doing the assignment in the last line.
when the info in the textfile looks like this
line 1
line 2
.....
line n-1
line n
then i want it to look like this after having added a second copy
line 1
line 2
.....
line n-1
line n
line 1
line 2
.....
line n-1
line n
but not
line 1
line 2
.....
line n-1
line n line 1
line 2
.....
line n-1
line n
for example. the second "page" should be append to the first one stored in the string variable. and a thrird or fourth copy etc.
but what i do once could be done n times, thats not the problem.
so to sumarize: my question is how do i have to add the streamed info for the second, thrid .... time to an existing and allready filled string without loosing the format during copying?
is there some kind of
string1.append(string2) or anything similar?
thanks.
stephan.
|
|
|
|
|
There should already be a line terminator at the end of each line. You just need to ensure that you append the text for the second file after the final line terminator in the text from the first file.
You can call Environment.NewLine to get the string representation of a newline construct for the current platform.
If you are working with large strings, you should consider using an instance of the System.Text.StringBuilder class. Strings in .NET are immutable, which means that the contents of a string once created cannot be altered. If 2 strings are concatenated, a new string object must be created to store the resulting data. The StringBuilder class provides a more memory-efficient way of manipulating string data.
Paul Marfleet
|
|
|
|
|
How would I edit the items in a tree view when i hit a button.
I'd have a list of codes in 5 different languages, but when i click C# button it'll switch all codes to C#, or C++ button change all text to C++ codes..
Thats not what i'm using it for though, just to change the items in it.
How would I be able to do that, from 2 different windows*
|
|
|
|
|
From the root node, write code to recursively traverse all child nodes in the tree.
For each node, alter the Text property appropriately.
Paul Marfleet
|
|
|
|
|
No, sorry let me make myself clearer
I want 1 Tree view, but i want 50 different text combinations.
I want to click a button and it will switch all the text and nodes.
Like making a form on different sallery's
Do you understand now?
|
|
|
|
|
C# Beginner Nick wrote: Like making a form on different sallery's
I don't understand what this sentence means.
Anyway, do you mean that the tree structure (nodes and text) will be different for each language? You could achieve this by storing a serialized representation of each tree structure in a series of XML files. The tree could then be populated by reading the tree definition from the appropriate file depending on which language the user has selected.
Paul Marfleet
|
|
|
|
|
Alright, i'll just say what i want it to do. Instead of an example
This right here.[^]
Then when i click on Choose game, it brings up a menu asking which console.
I click the console, choose the game, then i want it to change the information in the Tree View to that Gamed information.
Did i make that any clearer?
http://i84.photobucket.com/albums/k40/njk003/This-1.jpg
|
|
|
|
|
The image didn't really help. And, in your original post, you were talking about programming languages. Now you're talking about games. I'm having some difficulty following your train of thought...
However, as I understand it, the tree content should change for each different game that can be selected. You therefore need to persist the tree definition for each game somewhere so that it can be loaded dynamically depending on the user's selection. You could use XML files as I had previously suggested, or you could store the XML in a database. You then would need to write a routine to traverse an XML document and dynamically populate the treeview with nodes that follow the same structure.
Paul Marfleet
|
|
|
|
|
Alright thank you, and at first i was just giving an example for you to follow. Didn't tell you what i was really trying to make. Sorry for the confusion.
|
|
|
|
|
Would it be better for me to change the Tree View to a Text Box, and have the text change when i click the button.
System.windows.form1.Textbox("Text"); ?
|
|
|
|
|
If you just need to display a different paragraph of text depending on the game selected, a TextBox would be sufficient. A TreeView control would be inappropriate and unnecessary. As your previous posts specifically talked about populating a TreeView control, I had made the (reasonable) assumption that you were dealing with some sort of hierarchical data structure. However your requirements are actually less complicated than that!
Paul Marfleet
|
|
|
|
|
I have as a ListBox item a reference to a ScrollingLine class, in which I override ToString() to return the part of text currently visible in a scrolling window. How do I get my ListBox to update its display of that string? Does it make a copy of the ToString() result of each item when initialising, or does it just not know to update and maybe I could invalidate it?
|
|
|
|
|
Hi Brady,
AFAIK a ListBox does not copy data to some internal location, it holds a collection of items,
and works from there.
If you create a reason for repainting it, you should call Invalidate() on the listbox;
you can use optional arguments to restrict the repainted area, but there is no "index"
input available.
You could try and use ListBox.GetItemRectangle to feed ListBox.Invalidate().
Alternatively (I have not tried this!), you could cause a specific item to be repainted
by changing one of its properties, Selected comes to mind. So you could try:
myListBox.SetSelected(!myListBox.GetSelected(index));
myListBox.SetSelected(!myListBox.GetSelected(index));
which toggles the item's selection back and forth, causing two repaints of that one item.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Luc, that didn't even work with an Invalidate after those lines. Thanks anyway, but for something this small, where the ListBox will never have more than say ten lines, I've resorted to re-populating it after each scroll operation. It actually looks perfectly smooth at this scale.
|
|
|
|
|
Sorry, my mistake, it would not compile like that. This is what I meant:
myListBox.SetSelected(index, !myListBox.GetSelected(index));
myListBox.SetSelected(index, !myListBox.GetSelected(index));
I know changing the selection of an item in a userdrawn ListBox causes a DrawItem event
on that item; but I have no experience modifying ListBox items other than adding/removing
some.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Thanks, although that was an easy one to fix. Even after it compiled it didn't cause the control to refresh. It really looks quite OK just re-populating it each scroll event. These will only happen one character at a time, at the user's pace, not pixels at a machine pace.
|
|
|
|
|
I'm writing a geometic drawing program and thougt to be done, but as I started it and tried the functions nothing happened. Maybe it just a little problem I just don't see. The compiler says "built successfully". The functions should draw the named symbol on a white rect. The window is double buffered and is redrawn when the client size is changed.
Does anyone know a solution to this problem?
Thanks, and best wishes
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace Geo<br />
{<br />
public partial class Geo : Form<br />
{<br />
private System.Drawing.Image ImBuffer;<br />
private System.Drawing.Graphics GrDisplay;<br />
<br />
public Geo()<br />
{<br />
InitializeComponent();<br />
SetStyle(System.Windows.Forms.ControlStyles.UserPaint, true);<br />
SetStyle(System.Windows.Forms.ControlStyles.AllPaintingInWmPaint, true);<br />
SetStyle(System.Windows.Forms.ControlStyles.DoubleBuffer, true);<br />
ImBuffer = new System.Drawing.Bitmap(this.ClientSize.Width, this.ClientSize.Height);<br />
GrDisplay = System.Drawing.Graphics.FromImage(ImBuffer);<br />
SolidBrush SBWhite = new SolidBrush(Color.FromArgb(255, 255, 255));<br />
GrDisplay.FillRectangle(SBWhite, 0, 0, this.ClientSize.Width, <br />
this.ClientSize.Height);<br />
}<br />
protected override void OnClientSizeChanged(EventArgs e)<br />
{<br />
base.OnClientSizeChanged(e);<br />
ImBuffer = new System.Drawing.Bitmap(this.ClientSize.Width, this.ClientSize.Height);<br />
GrDisplay = System.Drawing.Graphics.FromImage(ImBuffer);<br />
SolidBrush SBWhite = new SolidBrush(Color.FromArgb(255, 255, 255));<br />
GrDisplay.FillRectangle(SBWhite, 0, 0, this.ClientSize.Width,<br />
this.ClientSize.Height);<br />
}<br />
protected override void OnPaint(PaintEventArgs e)<br />
{<br />
base.OnPaint(e);<br />
System.Drawing.Graphics g = e.Graphics;<br />
g.DrawImage(ImBuffer, 220, 25);<br />
}<br />
private void exitToolStripMenuItem1_Click(object sender, EventArgs e)<br />
{<br />
OnCancel(null, null);<br />
}<br />
private void OnCancel(object sender, CancelEventArgs e)<br />
{<br />
if (e != null)<br />
{<br />
e.Cancel = true;<br />
}<br />
}<br />
<br />
private void cbSelectDraw_SelectedIndexChanged(object sender, EventArgs e)<br />
{<br />
SetStat();<br />
SetLabels();<br />
}<br />
private void SetStat()<br />
{ <br />
if (cbSelectDraw.SelectedIndex == -1)<br />
{<br />
tbX1.Enabled = false;<br />
tbY1.Enabled = false;<br />
tbX2.Enabled = false;<br />
tbY2.Enabled = false;<br />
tbX3.Enabled = false;<br />
tbY3.Enabled = false;<br />
};<br />
if (cbSelectDraw.SelectedIndex == 0 || cbSelectDraw.SelectedIndex == 1 || cbSelectDraw.SelectedIndex == 2 ||<br />
cbSelectDraw.SelectedIndex == 5 || cbSelectDraw.SelectedIndex == 6)<br />
{<br />
tbX1.Enabled = true;<br />
tbY1.Enabled = true;<br />
tbX2.Enabled = true;<br />
tbY2.Enabled = true;<br />
tbX3.Enabled = false;<br />
tbY3.Enabled = false;<br />
};<br />
if (cbSelectDraw.SelectedIndex == 3 || cbSelectDraw.SelectedIndex == 4)<br />
{<br />
tbX1.Enabled = true;<br />
tbY1.Enabled = true;<br />
tbX2.Enabled = true;<br />
tbY2.Enabled = false;<br />
tbX3.Enabled = false;<br />
tbY3.Enabled = false;<br />
};<br />
if (cbSelectDraw.SelectedIndex == 7 || cbSelectDraw.SelectedIndex == 8 || cbSelectDraw.SelectedIndex == 9)<br />
{<br />
tbX1.Enabled = true;<br />
tbY1.Enabled = true;<br />
tbX2.Enabled = true;<br />
tbY2.Enabled = true;<br />
tbX3.Enabled = true;<br />
tbY3.Enabled = true;<br />
};<br />
}<br />
private void SetLabels()<br />
{<br />
if (cbSelectDraw.SelectedIndex == -1)<br />
{<br />
lbX1.Text="";<br />
lbY1.Text="";<br />
lbX2.Text="";<br />
lbY2.Text="";<br />
lbX3.Text="";<br />
lbY3.Text="";<br />
gbPoints.Text = "";<br />
gbPoint1.Text = "";<br />
gbPoint2.Text = "";<br />
gbPoint3.Text = "";<br />
};<br />
if (cbSelectDraw.SelectedIndex == 0)<br />
{<br />
lbX1.Text = "x_1=";<br />
lbY1.Text = "y_1=";<br />
lbX2.Text = "x_2=";<br />
lbY2.Text = "y_2=";<br />
lbX3.Text = "";<br />
lbY3.Text = "";<br />
gbPoints.Text = "Points";<br />
gbPoint1.Text = "Point 1";<br />
gbPoint2.Text = "Point 2";<br />
gbPoint3.Text = "";<br />
};<br />
if (cbSelectDraw.SelectedIndex == 1 || cbSelectDraw.SelectedIndex == 2)<br />
{<br />
lbX1.Text = "x=";<br />
lbY1.Text = "y=";<br />
lbX2.Text = "a=";<br />
lbY2.Text = "b=";<br />
lbX3.Text = "";<br />
lbY3.Text = "";<br />
gbPoints.Text = "Values";<br />
gbPoint1.Text = "Point";<br />
gbPoint2.Text = "Dimensions";<br />
gbPoint3.Text = "";<br />
};<br />
if (cbSelectDraw.SelectedIndex == 3 || cbSelectDraw.SelectedIndex == 4)<br />
{<br />
lbX1.Text = "x=";<br />
lbY1.Text = "y=";<br />
lbX2.Text = "d=";<br />
lbY2.Text = "";<br />
lbX3.Text = "";<br />
lbY3.Text = "";<br />
gbPoints.Text = "Values";<br />
gbPoint1.Text = "Point";<br />
gbPoint2.Text = "Diameter";<br />
gbPoint3.Text = "";<br />
};<br />
if (cbSelectDraw.SelectedIndex == 5 || cbSelectDraw.SelectedIndex == 6)<br />
{<br />
lbX1.Text = "x=";<br />
lbY1.Text = "y=";<br />
lbX2.Text = "d_x=";<br />
lbY2.Text = "d_y=";<br />
lbX3.Text = "";<br />
lbY3.Text = "";<br />
gbPoints.Text = "Values";<br />
gbPoint1.Text = "Point";<br />
gbPoint2.Text = "Diameters";<br />
gbPoint3.Text = "";<br />
};<br />
if (cbSelectDraw.SelectedIndex == 7 || cbSelectDraw.SelectedIndex == 8)<br />
{<br />
lbX1.Text = "x_1=";<br />
lbY1.Text = "y_1=";<br />
lbX2.Text = "x_2";<br />
lbY2.Text = "y_2";<br />
lbX3.Text = "x_3";<br />
lbY3.Text = "y_3";<br />
gbPoints.Text = "Points";<br />
gbPoint1.Text = "Point 1";<br />
gbPoint2.Text = "Point 2";<br />
gbPoint3.Text = "Point 3";<br />
};<br />
if (cbSelectDraw.SelectedIndex == 9)<br />
{<br />
lbX1.Text = "x=";<br />
lbY1.Text = "y=";<br />
lbX2.Text = "d_x";<br />
lbY2.Text = "d_y";<br />
lbX3.Text = "w_s";<br />
lbY3.Text = "w_e";<br />
gbPoints.Text = "Values";<br />
gbPoint1.Text = "Point";<br />
gbPoint2.Text = "Diameters";<br />
gbPoint3.Text = "Angles";<br />
};<br />
}<br />
<br />
private void btDraw_Click(object sender, EventArgs e)<br />
{<br />
Draw(PnUse(), SBUse());<br />
}<br />
<br />
private void Geo_Load(object sender, EventArgs e)<br />
{<br />
SetStat();<br />
SetLabels();<br />
SolidBrush UseBrush = new SolidBrush(Color.FromArgb(0,0,0));<br />
Pen UsePen = new Pen(Color.FromArgb(0,0,0));<br />
}<br />
private void Draw(Pen PnUse, SolidBrush SBUse)<br />
{<br />
switch (cbSelectDraw.SelectedIndex)<br />
{<br />
case -1:<br />
MessageBox.Show(this, "Select item you want to draw", "Geo", MessageBoxButtons.OK,<br />
MessageBoxIcon.Stop,<br />
MessageBoxDefaultButton.Button1);<br />
break;<br />
case 0:
this.GrDisplay.DrawLine(PnUse, ConvertX1(), ConvertY1(), ConvertX2(), ConvertY2());<br />
MessageBox.Show("A" + PnUse.Color.A.ToString() + <br />
"R" + PnUse.Color.R.ToString() + <br />
"G" + PnUse.Color.G.ToString() + <br />
"B" + PnUse.Color.B.ToString() +<br />
"X1" + ConvertX1().ToString()+<br />
"Y1" + ConvertY1().ToString()+<br />
"X2" + ConvertX2().ToString()+<br />
"Y2" + ConvertY2().ToString());<br />
break;<br />
case 1:
GrDisplay.DrawRectangle(PnUse, ConvertX1(), ConvertY1(), ConvertX2(), ConvertY2());<br />
break;<br />
case 2:
GrDisplay.FillRectangle(SBUse, ConvertX1(), ConvertY1(), ConvertX2(), ConvertY2());<br />
break;<br />
case 3:
GrDisplay.DrawEllipse(PnUse, ConvertX1(), ConvertY1(), ConvertX2(), ConvertX2());<br />
break;<br />
case 4:
GrDisplay.FillEllipse(SBUse, ConvertX1(), ConvertY1(), ConvertX2(), ConvertX2());<br />
break;<br />
case 5:
GrDisplay.DrawEllipse(PnUse, ConvertX1(), ConvertY1(), ConvertX2(), ConvertY2());<br />
break;<br />
case 6:
GrDisplay.FillEllipse(SBUse, ConvertX1(), ConvertY1(), ConvertX2(), ConvertY2());<br />
break;<br />
case 7:
Point[] ptDrawTriangle = {new Point(ConvertX1(), ConvertY1()), <br />
new Point(ConvertX2(), ConvertY2()), <br />
new Point(ConvertX3(), ConvertY3())};<br />
GrDisplay.DrawPolygon(PnUse, ptDrawTriangle);<br />
break;<br />
case 8:
Point[] ptFillTriangle = {new Point(ConvertX1(), ConvertY1()), <br />
new Point(ConvertX2(), ConvertY2()), <br />
new Point(ConvertX3(), ConvertY3())};<br />
GrDisplay.FillPolygon(SBUse, ptFillTriangle);<br />
break;<br />
case 9:
GrDisplay.DrawArc(PnUse, ConvertX1(), ConvertY1(), <br />
ConvertX2(), ConvertY2(), <br />
ConvertX3(), ConvertY3());<br />
break;<br />
default:<br />
break;<br />
<br />
}<br />
<br />
}<br />
private void Use()<br />
{<br />
switch (cbSelectDraw.SelectedIndex)<br />
{<br />
case 0:
case 1:
case 3:
case 5:
case 7:
case 9:
PnUse();<br />
break;<br />
case 2:
case 4:
case 6:
case 8:
SBUse();<br />
break;<br />
default:<br />
break;<br />
}<br />
<br />
}<br />
private short ConvertAlpha()<br />
{<br />
short sAlpha;<br />
short.TryParse(tbAlpha.Text, out sAlpha);<br />
return sAlpha;<br />
}<br />
private short ConvertRed()<br />
{<br />
short sRed;<br />
short.TryParse(tbRed.Text, out sRed);<br />
return sRed;<br />
}<br />
private short ConvertGreen()<br />
{<br />
short sGreen;<br />
short.TryParse(tbGreen.Text, out sGreen);<br />
return sGreen;<br />
}<br />
private short ConvertBlue()<br />
{<br />
short sBlue;<br />
short.TryParse(tbBlue.Text, out sBlue);<br />
return sBlue;<br />
}<br />
private short ConvertX1()<br />
{<br />
short sX1;<br />
short.TryParse(tbX1.Text, out sX1);<br />
return sX1;<br />
}<br />
private short ConvertY1()<br />
{<br />
short sY1;<br />
short.TryParse(tbY1.Text, out sY1);<br />
return sY1;<br />
}<br />
private short ConvertX2()<br />
{<br />
short sX2;<br />
short.TryParse(tbX2.Text, out sX2);<br />
return sX2;<br />
}<br />
private short ConvertY2()<br />
{<br />
short sY2;<br />
short.TryParse(tbY2.Text, out sY2);<br />
return sY2;<br />
}<br />
private short ConvertX3()<br />
{<br />
short sX3;<br />
short.TryParse(tbX3.Text, out sX3);<br />
return sX3;<br />
}<br />
private short ConvertY3()<br />
{<br />
short sY3;<br />
short.TryParse(tbY3.Text, out sY3);<br />
return sY3;<br />
}<br />
public void btUse_Click(object sender, EventArgs e)<br />
{<br />
Use();<br />
}<br />
private Pen PnUse()<br />
{<br />
Pen PnUse = new Pen(Color.FromArgb(ConvertAlpha(),<br />
ConvertRed(),<br />
ConvertGreen(),<br />
ConvertBlue()));<br />
return PnUse;<br />
}<br />
private SolidBrush SBUse()<br />
{<br />
SolidBrush SBUse = new SolidBrush(Color.FromArgb(ConvertAlpha(),<br />
ConvertRed(),<br />
ConvertGreen(),<br />
ConvertBlue()));<br />
return SBUse;<br />
}<br />
public void btDialog_Click(object sender, EventArgs e)<br />
{<br />
ColorDialog dialog = new ColorDialog();<br />
dialog.Color = Color.FromArgb(255, 255, 255);<br />
dialog.ShowDialog();<br />
tbAlpha.Text = dialog.Color.A.ToString();<br />
tbBlue.Text = dialog.Color.B.ToString();<br />
tbGreen.Text = dialog.Color.G.ToString();<br />
tbRed.Text = dialog.Color.R.ToString();<br />
}<br />
}<br />
}
|
|
|
|
|
someControl.InvalidateRegion();
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
If you mean, that some function definitions are made in the worng region, I checked that, but didn't find anything. May you tell me what do you exactly mean, so that I can check that again?
Thanks and best wishes
|
|
|
|
|
usually when you draw by overriding paint you need to tell the application when painting is required. This is done view the Invalidate and InvalidateRegion method that is inherited from the base class control. I was just throwing it out there as a possible avenue to consider since many of the custom drawing methods I do require calls to InvalidateRegion to work correctly and efficiently.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
I tried the invalidate methode but it didn' change anything expect for the fact that the drawn rect didn't fill up the client size as I want it. I don't think that this is the problem, I already used the double buffer in other projects without any problems.
|
|
|
|
|
I tried the invalidate method in another way and now it works
Thanks much
|
|
|
|
|