|
'This get from image saved in ur pc.I am 'using picture box mouse click event in visual basic.Net '2010 .Add pic box to ur form & add these lables to y 're form thanks
'Enjoy this
' Yohan & Laleen From Sri Lanka
Dim TempBitmap As New Bitmap(PictureBox1.Image)
Dim MyColor As Color
MyColor = TempBitmap.GetPixel(e.X, e.Y)
' MessageBox.Show("Pixel x=" & e.X & ", y=" & e.Y & ", color=" & MyColor.ToString, "Color", MessageBoxButtons.OK, MessageBoxIcon.Information)
Label5.Text = MyColor.R.ToString()
Label6.Text = MyColor.G.ToString()
Label7.Text = MyColor.B.ToString()
Label8.Text = e.X.ToString()
Label10.Text = e.Y.ToString()
Dim r1 As String = Hex(MyColor.R)
Dim g1 As String = Hex(MyColor.G)
Dim b1 As String = Hex(MyColor.B)
'MessageBox.Show(r1 & g1 & b1)
Label12.Text = r1 & g1 & b1
|
|
|
|
|
Not sure what this is called exactly. I am after creating a method or class you can pass variables to. I want to be able to give them a pre-set list of what variables they can pass e.g. "txtOutcomes.TextMode = " automatically brings up "TextBoxMode", where you can select ".MultiLine;". Hope this makes sense. Many thanks.
Ric
|
|
|
|
|
Its not very clear what you are trying to achieve, but I'm fairly certain you are going to be way out of your depth.
Bob
Ashfield Consultants Ltd
|
|
|
|
|
its called an enum, you define one as follows:
public enum MyEnumeratedValues
{
MyValue1,
MyValue2,
MyValue3
}
You can then have a property of this type on your class
public class MyClass
{
private MyEnumeratedValues aProperty;
public MyEnumeratedValues AProperty
{
get{ return aProperty; }
set{ aProperty = value; }
}
}
now when somebody creates an instance of your class and sets the AProperty property, intellisense will show them the 3 values defined.
I think thats what you're after
|
|
|
|
|
Fantastic! That's loads of help. Many thanks.
|
|
|
|
|
I have populated a treeview (tvwResults) with some data such as:
item1
subitemA1
subitemB1
item2
subitemA2
subitemB2
subitemB3
subitemB4
item3
subitemA3
...
...
...
I have added an imagelist control with three images with indexes 0, 1, 2
for error, fail, warning
I am tying to assign the correct image to each item and subitem accordingly...
For example, if there is an error in one of the subitems, then that subitem will have the image of error which is index 0 and so the image for that item i.e. the item will be warning i.e. index 2
And if all the subitems of an item have fail in the text then the image for the item will be error too.
I have started working on the following code.
Question:
can you please see if what i am trying to do in this code is correct based on the above request?
Thanks
foreach (TreeNode n in tvwResults.Nodes[0].Nodes)
{
foreach (TreeNodeCollection nc in tvwResults.Nodes[0].Nodes)
{
if (nc.ToString().ToLower().Contains("error"))
{
nc.ImageIndex = 0 // error...
????
}
}
}
|
|
|
|
|
Put your image in ImageList.
Then use : nc.StateImageIndex = 0; // or 1, or 2, ...
|
|
|
|
|
If I resizes/increases the size of a column, then grid should show scroll bars instead of reducing size of other columns?
How should i do it?
|
|
|
|
|
|
Hello everyone,
I am developing an Http client which could collect data from external web sites. Currently, I want to test with the web sites which needs certificate to access (either needs client to accept its certificate or needs client to provide client's certificate).
I am suffering from finding a number of such web sites, could anyone provide some such types of web sites please?
(most web site I investigated are using ActiveX control to provide secure access, not using certificate)
thanks in advance,
George
|
|
|
|
|
George_George wrote: I am suffering from finding a number of such web sites, could anyone provide some such types of web sites please?
You mean HTTPS? Then just prefix CP's url
|
|
|
|
|
Thanks leppie,
Three more questions,
1. when using https, always using certificate? If yes, does it mean using client's certificate or using server's certificate?
2. when accessing a web site, how can see which certificate is using, e.g. when accessing hotmail?
3. What do you mean "CP's url"?
regards,
George
|
|
|
|
|
Hi,
can we create POP server of our own? How can we use the POP server to read messages from a Mail Box?
Thanks and regards,
Kathir
|
|
|
|
|
kathiresanmoorthy wrote: can we create POP server of our own?
Do you mean a mail server that supports the POP3 protocol?
kathiresanmoorthy wrote: How can we use the POP server to read messages from a Mail Box?
The question doesn't really make sense. You use the POP3 protocol to access the messages of an account on the mail server.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
Hi i am having lot of tables in my dataset...,
Based on datatable first row first cell i am creating folder and creating excel file and export my datatble to that excel file...,
Everything is going on well...,
But during this perios lot of alert msg coming from excel side:
Do you want to save changes in "Book 61"
Like this upt o Book 73 or 73...,
Its coming on each folder creation time...,
This is my code:
for (int i = 0; i < DS.Tables.Count - 1; i++)
{
oXL = new Microsoft.Office.Interop.Excel.Application();
oWB = oXL.Workbooks.Add(System.Reflection.Missing.Value);
oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;
oRng = oSheet.Cells;
oSheet.Activate();
try
{
foreach (DataRow dr1 in DS.Tables[i].Rows)
{
foreach (DataRow dr2 in DS.Tables[i + 1].Rows)
{
if (dr1["MID"].ToString() == dr2["MID"].ToString())
{
DirectoryInfo dr = new DirectoryInfo("C:\\Test\\" + dr1["MID"].ToString() + @"\");
if (!dr.Exists)
{
dr.Create();
System.Data.DataTable dtToExport = DS.Tables[i];
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
else
{
System.Data.DataTable dtToExport = DS.Tables[i + 1];
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
}
else
{
DirectoryInfo dr = new DirectoryInfo("C:\\Test\\" + dr2["MID"].ToString() + @"\");
if (!dr.Exists)
{
dr.Create();
System.Data.DataTable dtToExport = DS.Tables[i + 1];
//oSheet.Activate();
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr2["MID"].ToString() + "\\" + dr2["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
else
{
System.Data.DataTable dtToExport = DS.Tables[i];
GenerateExcelFile(ref dtToExport, oRng, 1);
FileInfo fi = new FileInfo("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls");
if (!fi.Exists)
{
oSheet.SaveAs("C:\\Test\\" + dr1["MID"].ToString() + "\\" + dr1["Name Of Employee"].ToString() + ".xls", Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing
, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
}
oXL.Quit();
}
}
}
}
}
catch (Exception theException)
{
MessageBox.Show(theException.ToString(), "Error");
}
}
Plz guideme whats wrong in that?
Thanks & Regards,
NeW OnE,
please don't forget to vote on the post
|
|
|
|
|
Try this change in bold
oXL = new Microsoft.Office.Interop.Excel.Application();
oWB = oXL.Workbooks.Add(System.Reflection.Missing.Value);
oXl.DisplayAlerts = false;
oSheet = (Microsoft.Office.Interop.Excel._Worksheet)oWB.ActiveSheet;
oRng = oSheet.Cells;
oSheet.Activate();
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Hi Everyone,
I ve one Desktop application and I ve created its setup project also.
In setup project I ve added a dialog box(TextBoxes (A)) before Welcome screen and
used Custom Action.
The problem is when setup starts, the default focus in on Next button.
I want the focus in TextBox.
Is there any way to do it?
Regards,
SIFAR.
|
|
|
|
|
i m using unsafe code in my function like this...
public unsafe void swap(int* p_x, int* p_y)
{
int temp = *p_x;
*p_x = *p_y;
*p_y = temp;
}
but when I compile my application i get error
"Unsafe code may only appear if compiling with /unsafe"
please help me
|
|
|
|
|
Go to :
Project -> Properties -> Build -> Allow Unsafe Code
|
|
|
|
|
|
hi
plz tell me the way to convert the Bitmap object to ByteArray in C#?
I don't want to use the Memory stream as it causes problem with my System memory.
reply me ASAP
Regardz
Shanzay
|
|
|
|
|
try:
bitmap.Save("picture.bmp");
byte[] data = File.ReadAllBytes("picture.bmp");
|
|
|
|
|
DeepOceans wrote: plz tell me the way to convert the Bitmap object to ByteArray in C#?
Do you want the object serialised, the raw image data, or compressed as an image format?
DeepOceans wrote: I don't want to use the Memory stream as it causes problem with my System memory.
What kind of problem?
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
You should find out what problem using a MemoryStream is causing, because there shouldn't be any.
And i thought that first reply was a good way to get it into a byte array without using a stream in memory (which would probably be the best solution)
Apart from that you could write the data yourself, reading the colour of each pixel and then writing this data into an array - of course you'd need to check the bit-depth of the image and make sure you write the data correctly, plus you'd probably want to write the bitmap header as well... it's a fair bit of effort.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|
|
Use a LockBits method.
You should get something like this:
unsafe static byte[] getBytes(BitmapData data)
{
byte* firstByte = (byte*)data.Scan0.ToPointer();
int size = data.Stride * data.Height;
byte[] bytes = new byte[size];
for (int i = 0; i < size; i++)
bytes[i] = firstByte[i];
return bytes;
}
unsafe static void setBytes(BitmapData data, byte[] bytes)
{
byte* firstByte = (byte*)data.Scan0.ToPointer();
int size = data.Stride * data.Height;
for (int i = 0; i < size; i++)
firstByte[i] = bytes[i];
}
static void Main()
{
using (Bitmap bmp = (Bitmap)Bitmap.FromFile(@"test.bmp")) {
BitmapData data = bmp.LockBits(new Rectangle(new Point(0), bmp.Size),
ImageLockMode.ReadOnly, bmp.PixelFormat);
byte[] bytes = getBytes(data);
bmp.UnlockBits(data);
using (Bitmap copy = new Bitmap(data.Width, data.Height, bmp.PixelFormat)) {
data = copy.LockBits(new Rectangle(new Point(0), copy.Size),
ImageLockMode.WriteOnly, copy.PixelFormat);
setBytes(data, bytes);
copy.UnlockBits(data);
copy.Save(@"test - copy.bmp");
}
}
}
Compile with /unsafe .
This code copies a BMP file. Insted getBytes and setBytes you may want to use System.Runtime.InteropServices.Marshal.Copy method, but it has many function we don't need here so it's better to stick to a simplier version.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|