|
hi all
I was making a non rectangular form in C# using a bitmap with a white background and set the transparency key property of the form to white and it works but when I color quality from the system properties to 32bit it didn't work
is there any way to overcome this
or is there a different method for drawing a non rectangular form using images
thx for your interest
|
|
|
|
|
The problem is that you may be using a 24bit image and it has some problems (I don't know why?) with 32bit color quality. Anyway there is a solution for this problem:
1) Load the image manually in the Load event(or wherever you want):
Bitmap bg;<br />
bg=(Bitmap)Bitmap.FromFile(@"Your image.bmp");<br />
bg.MakeTransparent(Color.White);
Instead of this you can use an ImageList and don't forget to set the TransparentColor property
2) Draw the image in the Paint event:
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
e.Graphics.DrawImage(bg,0,0,this.Width,this.Height);<br />
<br />
}
Another approach to this could be using regions, but it is more complicated, if you want to learn more about this please let me know and I'll try to show you an example
Pablo Hernandez Valdes
|
|
|
|
|
Hi Pablo Hernandez
Many thx for your efforts to help me and others, i had used the code that u send to me and it didnt work see the code
Bitmap bg;<br />
private void Form1_Load(object sender, System.EventArgs e)<br />
{<br />
bg=(Bitmap)Bitmap.FromFile(@"C:\Documents and Settings\sabry\Desktop\tt.bmp");<br />
bg.MakeTransparent(Color.White);<br />
}<br />
private void Form1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)<br />
{<br />
e.Graphics.DrawImage(bg,0,0,this.Width,this.Height);<br />
}
and also i changed the transparency color to white
i want to know why it didn't work in all color qualities
and i want to know about the other methods
again many thx
|
|
|
|
|
Maybe it didn't work because the BackColor must be set to the color you want to make transparent, if not it does nothing at all. In my computer it works fine with this. If it still doesn't work please tell me and I'll try to send you my full code.
If you want to do something like this using regions, for example, if you want a triangular window you can do
System.Drawing.Drawing2D.GraphicsPath gp=new System.Drawing.Drawing2D.GraphicsPath(new Point[]{new Point(0,0),new Point(200,0),new Point(100,200)},new byte[]{(byte)PathPointType.Start,(byte)PathPointType.Line,(byte)PathPointType.Line});<br />
this.Region=new Region(gp);
Now you get a triangular window. You can intersect, join, complement different regions to obtain more complex shapes and even use non polygonal regions with bezier curves (PathPointType.Bezier ). With a litte effort you can make a region that conform to your bitmap and use it for the form.
Any problems please let me know.
Pablo Hernandez Valdes
|
|
|
|
|
see this it works greet
another good one like u helped me to do it
public Form1()<br />
{<br />
InitializeComponent();<br />
Bitmap Img = new System.Drawing.Bitmap(@"C:\myPic.bmp");<br />
Img.MakeTransparent(Img.GetPixel(1,1));<br />
this.BackgroundImage = Img; <br />
this.TransparencyKey = Img.GetPixel(1,1);<br />
}
thx for ur interest
|
|
|
|
|
Is there an event or function that is fired when the user clicks the close button at the upper right portion of the screen of a WEB PAGE? And if there is, what is it? I am working on this ASP.NET project, and I want to output a message box when that button is clicked.
Thank you,
The Major Rager
|
|
|
|
|
Maybe this should be in the Web Development forum...
I think (not sure) the <body> tag has a onClosing event or something:
<html onClosing="DoSomethingWithJavascriptOrSomething">
How you can use this with Asp.Net i have no idea .
Pompiedompiedom...
"..Commit yourself to quality from day one..it's better to do nothing at all than to do something badly.."
-- Mark McCormick
|
|
|
|
|
Hi there,
You can hook on OnUnload event of the web form by using js....
<< >>
|
|
|
|
|
Just as the other two people have said. But, this event can't be handled server-side in ASP.NET. There is no event for it. You can only handle this event in client-sie JavaScript.
But, this is really a question for the ASP.NET or Web Development forums.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Am writing some code for en editor. Main problem here is; when I load large files ( > 10mb ) the GUI hangs.
User chooses which file to open with the built-in OpenFileDialog. When user press "OK" ( or "Open") I run a read-method, that passes file data to a byte-array. After that a new method is called, this one translates the byte-array and puts the output into a textbox. However, not the entire content is passed to the textbox, only the amount of content that can fit in the textbox ( depending on how the user has resized it) is added. Textbox is scrolled with external scrollbar
(this is not the exact code, just a hint of how the code looks like. If it can help, I'll gladly post the exact code too, but right now I don't have the code available)
Read_File(string FileName)
{
FileStream FS = new FileStream(options);
byte[] byteBuffer = new byteBuffer[FS.filelength];
Passes the bytes from the file into the byteBuffer
FS.Close
}
Write_text(int scrollbarvalue)
{
Starts textwriting from byteBuffer[scrollbarvalue*16]
Stops adding text when the texdtbox-control is full
}
both ReadFile() and write_text() works fine, point is, I want them to run simoultanoiusly. Preferable, write_text() should be launched when Read_File has read enough data to fill up the textbox-controller
The amount of data that can fit in the textbox is calculated by a formula containing Fontheight, and Textbox.ClientSize.Height ( Locked Width)
|
|
|
|
|
Designing a real editor is a fairly complicated proposition. Take a look at http://www.gnu.org/ to get a feel for what you are diving into.
Mike
|
|
|
|
|
It's not an editor like Emacs I am trying to make. It's a hex editor. It simply reads a file, displays the content in hex and ascii format and allows the user to change byte-values
|
|
|
|
|
Under .net framework, we can use reflection to get a object's all properties,such as:
PropertyInfo[] p= label1.gettype().getproperties();
But, if the object is office application object, we donot get the properties using same reflection, such as:
Word.BookMark wdbk=word_applicationclass.ActiveDocument.bookmark[1]
PropertyInfo[] p= wdbk.gettype().getproperties();
why? how to get the all properties?
thank you very much.
|
|
|
|
|
Hello
I am having a lot of trouble with binding a ds to a text box control.
I have a query SELECT Name, Address, PostCode FROM Customer
This query fills the dataset. This works fine as l have tested this in my web service. The xml displays the name, address, and postcode.
But l get my error message when l try and bind this to the text box control. I have tried many things and l now that the syntax is right. Am l missing something.
//Error Message - Cannot create a child list for field Customer
txtName.DataBindings.Add("Text",ds,"Customer.Name");
txtAddress.DataBindings.Add("Text",ds,"Customer.Address");
txtPostcode.DataBindings.Add("Text",ds,"Customer.PostCode");
many thanks in advance,
Steve
|
|
|
|
|
I'm trying to import a csv text file into a datagrid. when i get it done, only the first field in the text file appears. i'm not sure why. am i only getting one field into the data set? or are all the fields getting into the data set and i'm only transfering one field to the data grid?
here's my code:
string strConnection = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\DataFiles;Extended Properties=""text;HDR=Yes;FMT=TabDelimited""";
OleDbConnection conn = new OleDbConnection(strConnection);
string selectString = "Select * From [sellerEngine_1.txt]";
OleDbCommand cmd = conn.CreateCommand();
cmd.CommandText = selectString;
OleDbDataAdapter da = new OleDbDataAdapter();
da.SelectCommand = cmd;
DataSet ds = new DataSet();
conn.Open();
string dataTableName = "SellerEngine";
da.Fill(ds, dataTableName);
DataTable dt = ds.Tables[dataTableName];
dataGrid1.DataSource = dt.DefaultView;
conn.Close();
thanks!
Thomas Barker
|
|
|
|
|
Hi
Does anybody know if there is any format that I can use in the String.Format(..) method to write an integer appended with the "st" or "nd" or "rd" or "th" without having to write custom code?
Thanks
|
|
|
|
|
|
Adding a ICON to a Statusbar is catered for in C# through the Statusbar property. So... I created a couple icons and then used the following code:
Icon myIcon = new Icon(@"..\..\Stop.ico");<br />
statusBar1.Panels.Add(String.Empty);<br />
statusBar1.Panels.Add(" ");<br />
.<br />
.<br />
.<br />
statusbar1.Panels[0].Icon = myIcon;
Compiles fine but the icon does not display. The icon is a 32x32 icon created thru Add New Item.../Icon file. Any ideas here?
Thanks in advance
Mike
|
|
|
|
|
The only thing you need to do is to set the ShowPanels property of the StatusBar to true.
Hope this works!
Pablo Hernandez Valdes
|
|
|
|
|
Hey,
I'm trying to search for a string in a datatable using DataView.Find, and ran across the Regex class. I got the find and select to work when the whole string is found, but now I need it to work for just part of the string.
Here's what I have so far:
// tCat - the table name
// searchThis - the string I want to find
// dg - the datagrid
DataView dv = tCat.DefaultView; <br />
Regex reg = new Regex(searchThis,RegexOptions.IgnoreCase);<br />
if (searchBy == "cust")<br />
{<br />
dv.Sort = "Customer ASC";<br />
int i = dv.Find(reg);<br />
if(i > dv.Table.Rows.Count || i < 0){MessageBox.Show("No file found");}<br />
else {dg.CurrentRowIndex = i; dg.Select(i);}<br />
}
I saw that IsMatch finds parts of strings, but I need to be sure that only the beginning of a string will partially match, i.e. searching for "rich" will match "Richard", but not "Fredrich".
So at the moment I'm not sure how to incorporate the IsMatch into the code above, as well as make sure that only the beginning of the string is searched.
Thanks again for any help!!!!!
Mel
|
|
|
|
|
Just add the ^ modifier at the beginning of the regex.
searchThis = @"^rich";
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi again,
I tried this:
searchThis = @"^" + s.SearchThis;
since I'm transferring searchThis over from another class. It didn't work so I changed the line:
int i = dv.Find(@"^Rich");
to test and see if the row containing Richard would highlight, and it didn't.
Is there anything else I may be doing wrong?
Thanks again!
Mel
|
|
|
|
|
Well, the regex matches only if Rich is at the beginning of the string. Like
string x = "Richard rocks";
string y = "I am rich;"
Are you sure if the string starts with Rich? Maybe you are dealing with a multiline string? Could you post a sample string?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
The string definitely seems to start with Rich. I tried substituting the entire name
int i = dv.Find("Richard Chalmers");
and it worked fine. I also tried another test name "Penske", and it again worked ok if "penske" was typed in, but not if I tried @"^Pen".
Mel
|
|
|
|
|
I'm confused now. What does dv.Find do? Could you try out this little code snippet and tell me what it prints and if that's what you expect?
string x = "Richard Rocks";
string y = "My rich uncle";
Regex regex = new Regex(@"^Rich");
Console.WriteLine(regex.IsMatch(x));
Console.WriteLine(regex.IsMatch(y));
It should print True and False. Is that what you expect?
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|