|
Hi, I'm writing a custom scroll bar control. My custom scroll bar control uses transparency, and has two button children that also have transparency. The background of the main window beneath my button located at (0,0) on the scroll bar and the background beneath the main scroll bar are fine. For some reason however, the background of the button at (0,30) in the scroll bar (the down button) has the main window background behind it offset by 30 pixels downward! It seems that a transparent window within a transparent window will have the shown background offset by its position within the parent transparent window.
I think I have located the source of this problem.. In the OnPaint method that is called to draw the background behind the transparent scroll bar which is behind the transparent button, somehow the e.Graphics.Transform.OffsetY is 0 when in the corresponding OnPaintBackground that was called just before it the e.Graphics.Transform.OffsetY was -30! I believe this is why my image is being offset, but I don't know why it's happening?
I know it's a complex problem, but can anyone help me? I've been working at it for about 6 hours now!
Thanks!
|
|
|
|
|
Ok, well, I've found a solution to my problem. After my hours and hours of debugging I've concluded that it's either a bug with the framework or something else beyond the scope of my code that is happening.
I have solved the problem by drawing the background of the scroll bar control manually rather than calling the default OnPaintBackground.
Here is the code that fixed it in case anyone is interested:
protected override void OnPaintBackground(PaintEventArgs e)<br />
{<br />
GraphicsContainer container = e.Graphics.BeginContainer(e.ClipRectangle, e.ClipRectangle, GraphicsUnit.Pixel);<br />
<br />
Rectangle rectBg = e.ClipRectangle;<br />
rectBg.Offset(this.Bounds.Left, this.Bounds.Top);<br />
e.Graphics.TranslateTransform(-this.Bounds.Left, -this.Bounds.Top);<br />
InvokePaintBackground(this.Parent, new PaintEventArgs(e.Graphics, rectBg));<br />
InvokePaint(this.Parent, new PaintEventArgs(e.Graphics, rectBg));<br />
<br />
e.Graphics.EndContainer(container);<br />
}
Any improvements to this method are appreciated.
|
|
|
|
|
How can I request a web page using POST while passing some variables? Like I want to access
http://www.localhost.com/info.aspx
with POST and with variables info=0 and set=1 ?
I have tried stupid HttpWebRequest BUT it is NOT WORKING ... I posted the question few days back BUT nobody answered it... GURU PPL where ARE YOU???
me doing this..
<br />
string lcUrl = "http://localhost/test.php";<br />
HttpWebRequest loHttp = (HttpWebRequest) WebRequest.Create(lcUrl);<br />
<br />
<br />
string lcPostData = "info=" + System.Web.HttpUtility.UrlEncode("0") + "&set=" + System.Web.HttpUtility.UrlEncode("1");<br />
<br />
loHttp.Method="POST";<br />
<br />
byte [] lbPostBuffer = System.Text.Encoding.GetEncoding(1252).GetBytes(lcPostData);<br />
<br />
loHttp.ContentLength = lbPostBuffer.Length;<br />
<br />
Stream loPostData = loHttp.GetRequestStream();<br />
loPostData.Write(lbPostBuffer,0,lbPostBuffer.Length);<br />
loPostData.Flush();<br />
loPostData.Close();<br />
<br />
HttpWebResponse loWebResponse = (HttpWebResponse) loHttp.GetResponse();<br />
System.Text.Encoding enc = System.Text.Encoding.GetEncoding(1252);<br />
StreamReader loResponseStream = new StreamReader(loWebResponse.GetResponseStream(),enc);<br />
<br />
string lcHtml = loResponseStream.ReadToEnd();<br />
Console.Write(lcHtml);<br />
loWebResponse.Close();<br />
loResponseStream.Close();<br />
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
Hmmm... Strange. This looks nothing like mine did...
Well, this worked for me:
Encoding enc = Encoding.GetEncoding("ISO-8859-1");
WebClient wc = new WebClient();
wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded; charset=ISO-8859-1");
string request = "input_name=the_value";
byte[] requestBytes = enc.GetBytes(request);
byte[] responseArray = wc.UploadData(uriString, "POST", requestBytes);
string responseString = enc.GetString(responseArray);
Have a look at my latest article about Object Prevalence with Bamboo Prevalence.
|
|
|
|
|
ahhh... you don know what you have just done! Gave me life... YES...Thank you very much... a thousand for you; to fill your room with fregrence...
mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
do you know how to tell what webserver a site is running?
/\ |_ E X E GG
|
|
|
|
|
<code>public string[] twoCharArray;</code>
public buffer(string file)
{
guid.button1.Enabled=false;
FileInfo fi = new FileInfo(file);
string rs = null;
if (fi.Exists)
{
StreamReader sr = new StreamReader(file);
while ((rs = sr.ReadLine()) != null)
{
stringFromFile += rs;
}
if (stringFromFile == null)
MessageBox.Show("No text in bitfile.txt");
else
{
<code>this.twoCharArray = stringFromFile.Split();</code>
}
}
Ok, check out that code. All it does is load a .txt file and then separate it into an array. The particular file it's processing is composed as follows...
81 09 0f f0 04 1a 0f f0 0f f0 09 0f f0 0f f0 0f f0 0f f0 09 0f f0 0f
f0 0f f0 0f f0 09 0f f0 0f f0 0f f0 0f f0 09 0f f0 0f f0 0f f0 0f f0 09 0f
f0 0f f0 0f f0 0f f0 09 0f f0 0f f0 0f f0 0f f0 09 0f f0 0f f0 0f f0 0f f0
09 0f f0 0f f0 0f f0 0f f0 09 0f f0 0f f0 0f f0 0f f0 ff 00 ff and so on...
So, it takes all of that and saves it into the string "stringFromFile ". Then after it's all saved into the string it goes to...
this.twoCharArray = stringFromFile.Split();
Where it is spit up by at every space, so we get an array that "would look like this..."
"twoCharArray"
0| 81
1| 09
2| 0f
3| f0
4| 04
5| 1a
...
Now, here's what I need....
I need to add two things (00, ff ) before every cell in the array. SO... the "twoCharArray ", "will look like" this now... observe the pattern.
"twoCharArray"
00| 00
01| ff
02| 81
03| 00
04| ff
05| 09
06| 00
07| ff
08| 0f
09| 00
10| ff
11| f0
12| 00
13| ff
14| 04
15| 00
16| ff
17| 1a
...
...
I would believe this is quite simple, but yet again I cannot figure out how to do it...
Would someone please assist me with this roadblock?
/\ |_ E X E GG
|
|
|
|
|
Try:
private string[] Splitsville(string file, params string[] fill)
{
string finalFill = (" " + string.Join(" ", fill) + " ").Replace(" ", " ");
string[] twoCharArray = null;
string stringFromFile = null;
FileInfo fi = new FileInfo(file);
string rs = null;
if (fi.Exists)
{
StreamReader sr = new StreamReader(file);
while ((rs = sr.ReadLine()) != null)
{
stringFromFile += " " + rs + " ";
}
if (stringFromFile == null)
{
MessageBox.Show("No text in bitfile.txt");
}
else
{
string workarea = stringFromFile.TrimEnd(' ');
while (workarea.IndexOf(" ") != -1)
{
workarea = workarea.Replace(" ", " ");
}
workarea = workarea.Replace(" ", finalFill).TrimStart(' ');
twoCharArray = workarea.Split(' ');
}
}
return twoCharArray;
}
The call for your particular case is Splitsville(file, "00", "FF")
|
|
|
|
|
small prob...
I called the method like this...
split sp=new split("C:\\asdf.txt", "00", "FF");
THen the program gets stuck in a neverending loop right here...
while (workarea.IndexOf(" ") != -1)
{
workarea = workarea.Replace(" ", " ");
}
I'm I calling it wrong or somehting... what's up?
/\ |_ E X E GG
|
|
|
|
|
Actually, let me rephrase the question...
How can I make this code add a "00" then an "FF" to the array before each string?
public buffer(string file, int delay)
{
FileInfo fi = new FileInfo(file);
string rs = null;
if (fi.Exists)
{
StreamReader sr = new StreamReader(file);
while ((rs = sr.ReadLine()) != null)
{
stringFromFile += rs;
}
if (stringFromFile == null)
MessageBox.Show("No text in bitfile.txt");
else
{
this.twoCharArray = stringFromFile.Split();
}
}
else
{
MessageBox.Show("Cannot find bitfile.txt.");
}
Does this make better sense???
/\ |_ E X E GG
|
|
|
|
|
If you mean for each ReadLine the answer is easy:
stringFromFile += rs;
becomes
stringFromFile += " 00 FF " + rs;
otherwise what do you mean by "string"?
|
|
|
|
|
If I replace the code with your's it only adds 00 FF to the beginning of the array...
I need it before each string.
And by sting I mean each "cell" in the string array twoByteArray .
with you code it's like this...
00 FF 1a 12 21 1f etc....
do you think you can make it everyother one like this...
00 FF 1a 00 FF 12 00 FF 21 00 FF 1f .....
/\ |_ E X E GG
|
|
|
|
|
Did you try the Splitsville function in my first response?
It accepts the file name, and a list of values to insert before each value in the file, which is what you area trying to do.
|
|
|
|
|
I havn't forgot about yours yet... give me a few to figure it out. thanks for your effort.
/\ |_ E X E GG
|
|
|
|
|
Hello,
sorry if this is a newbie question but here goes anyway.
I want to write a simple windows application, that opens an external program (.exe) after clicking on a Button.
Can you post the code?
How can I find these infos in the MSDN documentation?
Thank you
|
|
|
|
|
using System;
<code>using System.Diagnostics;</code>
namespace ConsoleApplication6
{
class Class1
{
[STAThread]
static void Main(string[] args)
{
<code>Process.Start("iexplore.exe");</code>
Console.WriteLine("Internet Explorer should have started...");
}
}
}
The things in "code " are what you should take note of, in order to answer your question.
/\ |_ E X E GG
|
|
|
|
|
To the original poster, don't forget the value of the documentation - it's where the people that answer your questions learn things. Read the documentation about the System.Diagnostics.Process class and see what else you can do, like provide command line arguments, redirect stdout, stderr, and stdin, and pass shell command verbs for non-executable files (like opening HTML documents with the user's default browser without knowing what their default browser is).
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
thank you very much for the code.
I think the MSDN help is great to learn how to use classes/components, but it doesn't explains which class has to be used for a certain purpose.
where can I find a handbook that can guide me on finding help on the msdn documentation?
I'm looking for help on finding help: weird,isn't it?
|
|
|
|
|
You simply have to review the documentation on MSDN. Get to know what classes there are. It's not like you have to memorize the whole library, just become familiar with what certain namespaces cover (ex, obviously System.IO is for input/output, which includes files and other streams) and you can always lookup stuff when you need to. API documentation is not to teach you how to do things - that's your job and what development is all about.
Besides, nothing says you have to use one class over another, or that you couldn't even write your own. Some classes may be better than others for particular uses, but your understanding of those classes and your imagination in how that functionality can be derived is what dictates which classes you should use.
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
can there be same control for both windows and web if it is how can we develop it in c# please guide me
Thanks
|
|
|
|
|
NOP... coz windows controls are rendered by the windows engine... and while web controls are rendered into HTML and which in turn in, is rendered by a browser.
mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
You're wrong - I've done it countless times. To the original poster, see my article I'll be updating for CP on DevHood at http://www.devhood.com/Tutorials/tutorial_details.aspx?tutorial_id=388[^].
-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
|
|
|
|
|
My apologies - Actually me too tried to do this with ActiveX controls. Your article seems great; I hope it would be very helpful.
Once again my apologies;
Heath, Keep up the good work;
mE
---------------------
A gasp of breath,
A sudden death:
The tale begun.
A rustled page
Passes an age:
The tale is done.
|
|
|
|
|
Hi,
Ive been looking around at various projects on gotdotnet and whatnot and most of the good applications seem to not sure the windows forms designer. I was wondering is this standard practice for a company that would sell a windows form application? Is there any books or web sites that describe the process of making a windows form application with out using the designer? Thanks in advance.
xarx
|
|
|
|
|