|
Hello !
Actually I am using PictureBox dynamically in the code I am getting image names from Dayabase and images from a folder I want to show these images against the specific Itemo No in Datagrid and also want to raise pictureBox1_MouseMove and pictureBox1_Click events but I don't know how can i do it Dynamically so please send me some code for it in C# I will be really really thankfull to your for your first attention plz..................................
Regards,
AbuBakar
|
|
|
|
|
Hi!
It is kinda quite easy to create dynamically objects and catch the events. First of all, create the object and set all properties:
// Create instance of PictureBox
System.Windows.Forms.PictureBox loPictureBox = new System.Windows.Forms.PictureBox();
// Set some properties
loPictureBox.Name = "NewPictureBox" + m_PictureBoxCount.ToString();
loPictureBox.BackColor = System.Drawing.Color.Blue;
loPictureBox.Location = new System.Drawing.Point(1, 40);
loPictureBox.Size = new System.Drawing.Size(120,40);
Add the new PictureBox to you formular:
// Add object to container
this.Controls.Add(loPictureBox);
Then link the events to functions:
// Add eventhandler to catch the events
loPictureBox.Click += new EventHandler(NewPictureBoxesClick);
loPictureBox.MouseMove += new MouseEventHandler(NewPictureBoxesMouseMove);
To catch the event, you just need to declare the functions like they should need to be declared:
private void NewPictureBoxesClick(object sender, EventArgs e)
{
// ... your code when clicked
}
private void NewPictureBoxesMouseMove(object sender, System.Windows.Forms.MouseEventArgs e)
{
// ... your code when mousemove
}
Try to understand the code and not just copy it. It is really quite simple and if you need more help to understand, just let me know!
Marcel Erz
|
|
|
|
|
Hello!
Thanks a lot for your quick and comprehensive answer of my question I would also like to tell you that I am developing a Desktop application not Web base application I want to show each image against each product Id in Datagrid, I studied your code throughly it is really easy but one thing i could not able to enhale which is this line
loPictureBox.Name = "NewPictureBox" + m_PictureBoxCount.ToString();
m_PictureBoxCount.ToString() it is really disturbing me,In this line I don't know how and why u used it and from where u got it " m_PictureBoxCount " please let me know about this point,
Regards,
AbuBakar
|
|
|
|
|
Hello,
Does anyone have any idea that how can I store extra information in an image. such as text, as a part of image. I don't want to show the text in an image but I want to store this information in it.
Actual I have to design an application which can embed and retrieve text messages from an image.
Something like message smuggler (software) does.
Any help in this regard?
TIA
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
Google for steganography.
Cheers,
Vikram. "When I read in books about a "base class", I figured this was the class that was at the bottom of the inheritence tree. It's the "base", right? Like the base of a pyramid." - Marc Clifton.
|
|
|
|
|
HI!
You can add information in the lowest significant bits of the color at each pixel. A human eye will not be able to see those minor differences. A simple example: You have two pixel and want to use the 2 lowest significant bits at each pixel of each color.
(3-colors * 2-bit) * 2-pixel = 12-bits
In an two pixel image with three colors and a use of 2 bits of each color, you can store 12-bits, so 1.5-byte in it. But usually you have bigger size picture , so you can store more data inside. For Example: 1024 x 768 pciture
(3-colors * 2-bit) * (1024 * 768)-pixel = (6 * 786432)-bits = 4718592-bits = 589824-byte = 576kb
So, in a normal wallpaper, you can store for example 576kb of data (that could be text or binary data). But take care of compression with data loose, like jpeg.
And remember, 3 colors is just an example, because it will just work if you use 24-bit color-depth images, but it is possible for other color depths too.
Marcel Erz
|
|
|
|
|
Thanks for the reply
Maqsood Ahmed - MCAD.net
Kolachi Advanced Technologies
http://www.kolachi.net
|
|
|
|
|
Hi!
An other possible way would be, to store it in comment fields of file formats. Not every file format has got this comment field, but i.e. gif has it! So, if you need more information about it, I saw an article on this page which describe how to save an exe file to the comment field of an gif:
http://www.codeproject.com/useritems/Steganography.asp[^]
Marcel Erz
|
|
|
|
|
I am using fileappender in the config file
<?xml version="1.0" encoding="utf-8" ?>
<!-- This section contains the log4net configuration settings -->
<log4net>
<!-- Define some output appenders -->
<appender name="LogFileAppender" type="log4net.Appender.FileAppender,log4net" >
<param name="File" value="c:\\temp\\error-log.txt" />
<param name="AppendToFile" value="true" />
<layout type="log4net.Layout.PatternLayout,log4net">
<param name="ConversionPattern" value="%d [%t] %-5p %c [%x] - %m%n" />
</layout>
</appender>
<!-- Setup the root category, add the appenders and set the default priority -->
<root>
<level value="All" />
<appender-ref ref="LogFileAppender" />
</root>
</log4net>
In class my code is
[assembly: log4net.Config.Domain("SimpleModule")]
// Configure logging for this assembly using the 'SimpleModule.dll.log4net' file
[assembly: log4net.Config.DOMConfigurator(ConfigFileExtension="log4net", Watch=true)]
namespace SimpleModule
{
/// <summary>
/// Summary description for Math.
/// </summary>
public class Math
{
// Create a logger for use in this class
//private static readonly log4net.ILog log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
private static readonly log4net.ILog log = log4net.LogManager.GetLogger("LogFileAppender");
//public Math()
public static void Main()
{
//if (log.IsDebugEnabled)
log.Debug("Math Constructor");
System.Console.Write("Press Enter");
System.Console.ReadLine();
}
<b>But there are no loggers created in my log file. Can anyone of you please give me the solutions</b>
-- modified at 4:01 Tuesday 13th December, 2005
|
|
|
|
|
string comm="CONTSCAN E:\\projects backup\\ankitclam backup\\Clamtest\\testing\\hello.txt\r\n"
int x=comm.Length;
x=x-7;
string path;
path=comm.Substring(9,x);
MessageBox.Show(path);
it works fine and give path as
E:\projects backup\ankitclam backup\Clamtest\testing\hello.txt
but when i give path
string comm="CONTSCAN E:\\projects backup\\ankitclam backup\\Clamtest\\testing\r\n"
int x=comm.Length;
x=x-7;
string path;
path=comm.Substring(9,x); //crashes here
MessageBox.Show(path);
crashes on line : path=comm.Substring(9,x);
throwing exception
System.Argument.OutOfRangeException:Index and length must refer to location within the string.
Parameter name:length
at System.String.Substring(Int32 startIndex,Int32 length)
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Both of the above blocks of code will throw an ArgumentOutofRange Exception. That's because the length you are trying to extract is more than the length of the string. The correct block of code would be:
string comm = @"CONTSCAN E:\projects backup\ankitclam backup\Clamtest\testing\hello.txt\r\n" ;
int x = comm.Length ;
x -= 9;
string path = comm.Substring(9,x) ;
Hope this helps.
Bikash Rai
|
|
|
|
|
This is code for case I
and running fine
if(string.Compare("SCAN",0,comm,0,4)==0)
{
int x=comm.Length;
x=x-7;
string path;
path=comm.Substring(5,x);
path=path.Trim();
}
//here comm is having value
//SCAN E:\projects backup\ankitclam backup\Clamtest\testing\hello.txt\r\n
and path=@"E:\projects backup\ankitclam backup\Clamtest\testing\hello.txt"
and also works when
comm = SCAN E:\projects backup\ankitclam backup\Clamtest\testing\r\n
thanks for ur help
i am checking for contscan
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
This obviously will work because the startpoint that you mention in Substring is less than the value you subtract from the length of the string.
In your previous post it was
x=x-7;
string path;
path=comm.Substring(9,x);
which will definately not work, but now its
x=x-7;
string path;
path=comm.Substring(5,x);
which will always work.
Seems like you are messing up the numbers. If you want the above to work with CONTSCAN then it should be something like
string comm = "CONTSCAN E:\\projects backup\\ankitclam backup\\Clamtest\\testing\r\n" ;
int x=comm.Length ;
x -= 11 ;
string path;
path=comm.Substring(9,x);
path=path.Trim();
You must subtract 11 from the string and not 7 because "CONTSCAN " is 9 and "\r\n" is 2. So 9 + 2 = 11.;)
Hope this helps.
Bikash Rai
|
|
|
|
|
thanks
it worked with following code
if(string.Compare("CONTSCAN",0,comm,0,8)==0)
{
int x=comm.Length;
x=x-9;
string path;
path=comm.Substring(9,x);
path=path.Trim();
result=res.loadDatabase("CONTSCAN",path);
}
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
Hi,
Change your code like this...
<br />
string comm="CONTSCAN E:\\projects backup\\ankitclam backup\\Clamtest\\testing\\hello.txt\r\n";<br />
<br />
<br />
<br />
comm = comm.Replace("CONTSCAN ","");<br />
comm = comm.Replace("\r\n","");<br />
System.Diagnostics.Debug.WriteLine(comm);<br />
Happy Programming!!!
Regards,
P.Anbuselvan
Sr. Software Engineer
Hyderabad
|
|
|
|
|
thanks
Ankit Aneja
"Nothing is impossible. The word itself says - I M possible"
|
|
|
|
|
I totally agree.
Bikash Rai
|
|
|
|
|
i am working with Windows control Library in C#. i have made one toolBar. which has one textfield like addressbar in IE. when i type for e.g " www.yahoo.com" in that textfield then website open in IE. i am using ShdocVw.dll in my project. My problem is that i want to handle the following events when a paritcular page is open in IE.
- DocumentComplete
- BeforeNavigate2
- DownloadBegin
- DownloadComplete
i have used following coding for getting handle of current instance of IE and to set the documentComplete Event
and put this code in Form Load
SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindowsClass();
string filename;
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filename = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();
if (filename.Equals("iexplore"))
{
ie.DocumentComplete +=
new DWebBrowserEvents2_DocumentCompleteEventHandler(ie_DocumentComplete);
break;
}
}
private void ie_DocumentComplete(Object o, ref Object ro)
{
MessageBox.Show("Document Complete");
}
but the above code is not working when i open any website this event would'nt be called
My problem is that i didn't know where to call these event and where to set these events so that when ever i open any website all the events would fire for web page.
Amit Grover
CDAC R&D
Gist Group
pune
|
|
|
|
|
Hi,
I have created a Windows Service which monitors certain directories on the local drives. Firstly, I created a service so that it would not be visible in the process list of the Task Manager. But I notice that when I start the service, the process name is being shown in the Process list. Is this normal or did I do anything wrong?
I was of the impression than a service would not be visible in the Process list of the Task Manager. Am I wrong? Did I change my application to a Windows Service for no reason?
Thanks,
Bikash Rai
|
|
|
|
|
Where does it say that a Windows service will be hidden from view?
Just about any process running on the system will show up in Task Manager.
Why do you need to 'hide' from Task Manager?
George Carlin wrote:
"Don't sweat the petty things, and don't pet the sweaty things."
Jörgen Sigvardsson wrote:
If the physicists find a universal theory describing the laws of universe, I'm sure the a**hole constant will be an integral part of that theory.
My Blog[^]
|
|
|
|
|
Hi,
Thanks for your reply.
Where does it say that a Windows service will be hidden from view?
Well it does say in most of the sites that since RegisterServiceProcess does not work with WinXP, creating a webservice would be the best bet.
Ok so I don't want to hide it from the process list. Seems like the moment someone talks about hiding a process, people start thinking in negative ways. I just don't want someone to kill my process. I have seem some processes in the process list of the task manager which cannot be killed like smss.exe. Can that be done?
Thanks.
Bikash Rai
|
|
|
|
|
I don't know about preventing a process from being killed, but you can configure a service to restart automatically if it is killed. See the recovery tab of the property dialog in the services management applet.
|
|
|
|
|
Is there any way to do this using code? I would want to do it during the installation process. And does a Servic failing include someone killing the process?
Thanks for your time.
Bikash Rai
|
|
|
|
|
Bikash Rai wrote: Firstly, I created a service so that it would not be visible in the process list of the Task Manager....Am I wrong?
Yep. All processes show up in the Task Manager, whether it's a Win Forms app or a Windows Service.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
hi,
how can i arrange my ownedforms.
IN this.addownedforms(sampleform)
thanks,
bye
tonato
|
|
|
|