|
Is this a Windows or a Web application?
|
|
|
|
|
|
Since this is a Windows app, you can do it (would be impossible using the Web controls unless you developed a completely custom list control). In fact, the first reply you received mentioned the functions you need to do it.
|
|
|
|
|
But how am I going to show an I-horizantal Bar or Bliking cursor within the listbox.
|
|
|
|
|
netJP12L wrote: But how am I going to show an I-horizantal Bar or Bliking cursor within the listbox.
First, what do you mean by "I-horizontal bar"?
Second, draw the listbox then draw your bar or cursor OVER the listbox. This is best done with a control derived from the list box with an overridden Paint method.
|
|
|
|
|
I meant control focused cursor. Usually we have it vertially. Same like in Power Point. Or similiar like when a TextBox or TextField recieve focus, that's the cursor I am refereing too
|
|
|
|
|
netJP12L wrote: I meant control focused cursor. Usually we have it vertially. Same like in Power Point. Or similiar like when a TextBox or TextField recieve focus, that's the cursor I am refereing too
Ah!! You need to create a cursor.
1. First, create the cursor in Visual Studio. This can be done easily by right-clicking your project, selecting Add New Item, select Local Project Items\Resources\Cursor File, then edit and save your cursor (we'll call it Horizontal.cur).
2. To create the cursor in C# and make it the current cursor:
Cursor.Current = new Cursor("Horizontal.cur");
|
|
|
|
|
netJP12L wrote: First of all thanks for answering to my question. I am already using context menu either (Addup or below). But I have realized, that I don't like this kind of feature. Wouldn't it be nice to display a blinking cursor (I-horizontal bar) within the listbox or may be in between the listbox items. Any insight would be kindly appreciated.
Truthfully, twenty one years of experience developing user interfaces gives me the feeling that this idea reads much better than it will look two years into the application's deployment. Is this simply a play application not intended for serious use by a lot of people, or is this intended for commercial use?
|
|
|
|
|
I am trying to develop a free-ware photo album.
|
|
|
|
|
Currently I have some code that does some searches via the reg expression in c#. I have a fuynction that returns a reg expression that simply strings and clean the string from HTML tags and the function is below(1). This function works just fine. Recently the code has a bug and the bug seems to be related with the following:
- between words there are multiple spaces and/or multiple nbsp so if the user searches for the "this is" it does not give the right matches if in between "this" and "is" may be multiple spaces, combination of amp;nbsp; and spaces and carriage returns. I am trying to do a test and do the code below which works as a test:
string str = "This is a test sentese.";
str = Regex.Replace(str, @" ", " "); //Remove nbsp
str = Regex.Replace(str, @"\s+", " "); //Remove duplicate spaces.
but how can I add the above logic in one sentese? how can I add the above logic part of the regular expression that strips the HTML below? Please help.
1. Function that cleans from html:
public static Regex GetRegExpStripHTML()
{
Regex r = new Regex(@"(<\/?)(?i <element>a(bbr|cronym|ddress|pplet|rea)?|b(ase(f" +
@"ont)?|do|ig|lockquote|ody|r|utton)?|c(aption|enter|ite|(o(de" +
@"|l(group)?)))|d(d|el|fn|i(r|v)|l|t)|em|f(ieldset|o(nt|rm)|ra" +
@"me(set)?)|h([1-6]|ead|r|tml)|i(frame|mg|n(put|s)|sindex)?|kb" +
@"d|l(abel|egend|i(nk)?)|m(ap|e(nu|ta))|no(frames|script)|o(bj" +
@"ect|l|pt(group|ion))|p(aram|re)?|q|s(amp|cript|elect|mall|pa" +
@"n|t(r(ike|ong)|yle)|u(b|p))|t(able|body|d|extarea|foot|h|itl" +
@"e|r|t)|u(l)?|var))(\s(?<attr>.+?))*>");
return r;
}
|
|
|
|
|
A regex just searches for a pattern. Assuming the strip regex below is used to replace html tags with the empty string, you cannot use it to replace anything with a space.
You can combine two patterns like this:
str = Regex.Replace(str, @"( |\s)+", " ");
Also, your GetRegExpStripHTML doesn't work. It strips only a few well-formed known tags - that's not enough to prevent cross-site scripting exploits.
What about <SCRIPT> or < SCRIPT> ?
What about tags you forgot, like <BODY onload="...">?
What about encoding the characters using some far-east codepage that your app doesn't understand? The codepage auto-detection of the browser might detect the codepage and execute the scripts.
What about null bytes like <SCR\0IPT>? Your regex won't see the script tag, but Internet Explorer still does.
What about any of a huge number of other tricks to evade XSS filters?
You need to encode any < > &, a blacklist won't get you anywhere as browsers have lots of ways to execute code that you never heard about. And even that isn't 100% safe when playing with the charset tricks.
See http://ha.ckers.org/xss.html[^] to get an idea about what kind of attacks on XSS filters are possible.
|
|
|
|
|
the one that strips html is used only for some internbat clean up. that;'s fine. is there anyway I can add the patern you added above to that reg expression? please help?
|
|
|
|
|
You could take the huge pattern and append |( |\s)+ . But you cannot control what the pattern is replaced with - that's in some other place in the code, where the GetRegExpStripHTML().Replace method is called.
I would suggest removing the GetRegExpStripHTML() method and instead providing a CleanupHTML(string) method - that way, you can apply multiple regular expressions and don't have to do everything with a single replacement using a monster pattern.
|
|
|
|
|
Hi all, I am reposting this.Yesterday Mika had given me a solution, but for some reasons I can't do it that way because of some design constraints, and I have to do it this way only.
I have a form 'frmProgressBar', which is shown as popup using objfrmProgressBar.showDialog() from a class AppGlobals (AppGlobals.prpgressbar.show() method). frmProgressBar has a backgroundworker thread running, which keeps running till the processing in other forms is not compleated. I want to hide popup whenever the main form, on which other controls are loaded, is minimised and the popup is getting hidden also. But the problem is, when the main form is maximized, I want to show the popup form again. I checked !IsDestroyed for frmProgressBar which returns false, so the backgroundworker thread is still running, but the popup is not displayed in the foreground, only main form is shown. I tried Show(), BringToFront(), TopLayer = True, but nothing seems to work. Any help please.It is very urgent.
Following is my code :
bool bContinue = true;
public frmProgressBar(string Message)
{
InitializeComponent();
this.ShowInTaskbar = false;
lblMessage.Text = Message ;
backgroundWorker = new BackgroundWorker();
backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler (backgroundWorker_RunWorkerCompleted);
}
private void setWindowStateAccordingToMainForm(FormWindowState State)
{
if (this.InvokeRequired)
{
setWindowState d = new setWindowState(setWindowStateAccordingToMainForm);
this.Invoke(d, new object[] { State });
}
else
{
if ((State == FormWindowState.Maximized) || (State == FormWindowState.Normal))
{
if (!this.IsDisposed)
{
WindowState = FormWindowState.Maximized;
Show();
}
}
else if (State == FormWindowState.Minimized)
{
if (!this.IsDisposed)
{
WindowState = FormWindowState.Minimized;
Hide();
}
}
}
}
void backgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.Close();
this.Dispose();
}
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
while (bContinue)
{
}
}
|
|
|
|
|
First off, do not repost a question when the other thread is still active and less than a month old. It just clutters up the forum more than necessary.
As for everything else, you may want to look into window manipulation through windows API. Their are a few commands that might be able to help you.
Regards,
Thomas Stockwell
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.
Visit my Blog
|
|
|
|
|
PrashantGadhave wrote: I am reposting this.
Don't do that. Just continue with the original thread.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
I have added some more description to the original post. Could you please reply to that? It was posted yesterday with heading 'Popup shown in background worker thread'
regards
Prashant.
|
|
|
|
|
Hi, all.
i hope this is the right forum, if not please advise.
i'm trying to work with a ssh connection, for that i use the
Terminal Control Project (C# VT100 SSH Telnet)
By Sardaan Frostreaver from this site.
I need to work programmatically, send commands and check the results that the ssh connection gives. i can connect to the ssh server but i can't find how to work programmtically with this Terminal Control Project. i mean, how to catch the text from the connection that project makes and send commands.
if someone know this issue please help.
Thanks.
|
|
|
|
|
You may want to try contacting the author of the article you mentioned. There is a message board at the bottom of the article, and they may reply to you.
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
i will try, thanks, but it's not a new article and the last messages there have no answers. anyway a will try.
|
|
|
|
|
I have parent and a child form. When the child form is shown, I want it to appear in the middle of the parent form. If I set the Location property before I call Show() on the child form, the location will not be what I specified. If I set the location after I've called Show(), then for a fraction of a second I can see the form showing up at its default location and then it very quickly moves to the location I specified. This is now very professional looking I would like to avoid it. How can I do that? Why doesn't it work to set the Location property before calling Show()? Thanks in advance for any help!
|
|
|
|
|
Try changing the StartPosition of the form to CenterParent instead of changing its location property
Intelligence is almost useless for those who have nothing else!
Email: caiokf@gmail.com
|
|
|
|
|
This code works if you want to do it from the parent as you asked. It may be better if ammended an placed in the child form's Load methd (after InitializeComponent()).
Form2 form2 = new Form2();
form2.MdiParent = this;
form2.Location = new Point(
this.ClientRectangle.Width / 2 - form2.Width / 2,
this.ClientRectangle.Height / 2 - form2.Height / 2);
form2.Show();
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Expect everything to be hard and then enjoy the things that come easy. (code-frog)
|
|
|
|
|
if you have a MDI parent from then just set the startposition of your child form to centerparent as mentioned by other guy.
not sure if it works with non MDI parent form or not
|
|
|
|
|
If I set StartPosition to FormStartPosition.Manual then the location is determined by the Location property and it work great even if I set the Location property before I call Show(). Thanks y'all for your tips and suggestions.
|
|
|
|