|
So you want to put your application in start up? Here is an example how to do it: Managing Start-up[^]
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
Hi i have one doubt regarding creating a object.
I have one class name as Employees. Now i want to create an object for this class. what is the difference between the below two?
1. Employees obj;
2. Employees obj = new Employees()
G. Satish
|
|
|
|
|
Look here[^].
You seem to be asking a lot of entry level questions, do you own a C# book / I hope no-one is paying for you to write code at this time ?
1 does not create an object, it creates space for an object. obj remains null in example 1.
Please buy a book.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi There,
I am trying to watermark an image with Embossed text & with opacity of color. Here is code which i am using.
Problem Description: Watermark & embossed look works K , but i want same color of text (little darker), as the source image have, any idea how to use color pellete of indexed image to draw text with its colors or any other solution, any tip will be highly appreciated.
Image watermarkImage = null;
using (watermarkImage = Image.FromFile(@"C:\NYDN 2008-02-18E\ENV13614\ENV13614 002P.tif"))
{
System.Drawing.Font myFont = new Font("Arial", 58, FontStyle.Bold);
System.Drawing.Color myWatermarkColor = Color.FromArgb(120, 120, 120);
Bitmap btmImage = new Bitmap(watermarkImage.Width, watermarkImage.Height);
// Get a graphics context
Graphics g = Graphics.FromImage(btmImage);
g.DrawImage(watermarkImage, new Rectangle(0, 0, btmImage.Width, btmImage.Height), 0, 0, watermarkImage.Width, watermarkImage.Height, GraphicsUnit.Pixel);
watermarkImage = btmImage;
// Create a solid brush to write the watermark text on the image
Brush blackBursh = new SolidBrush(Color.FromArgb(58, Color.Gray));
Brush whiteBursh=new SolidBrush(Color.FromArgb(58,Color.Black));
//Brush shadowBursh = new SolidBrush(Color.FromArgb(45, Color.Black));
int numofLayers = (int)(watermarkImage.Height / 100);
int lineHeight = 0;
for (int i = 0; i < numofLayers; i++)
{
g.DrawString("© Property of the New York Daily News.© Property of the New York Daily News.© Property of the New York Daily News..© Property of the New York Daily News.", myFont, blackBursh, 1, lineHeight+1);
g.DrawString("© Property of the New York Daily News.© Property of the New York Daily News.© Property of the New York Daily News..© Property of the New York Daily News.", myFont, whiteBursh, 0, lineHeight);
lineHeight += 100;
}
watermarkImage.Save(@"C:\temp.jpg");
}
Regards,
adnan
Many Thanks,
Adnan Rafiq
muhammadadnanrafiq@gmail.com
|
|
|
|
|
Hi i am using this code this some time gives me an error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."
My code:
class PrivateFonts<br />
{<br />
[DllImport("Gdi32.dll", CharSet = CharSet.Auto, SetLastError = true, ExactSpelling = true)]<br />
private static extern IntPtr AddFontMemResourceEx(IntPtr pbFont, int cbFont, int pdv, ref int pcFonts);<br />
public System.Drawing.Text.PrivateFontCollection GetFont(string[] FontResource)<br />
{<br />
string NameSpc = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString();<br />
System.IO.Stream FntStrm;<br />
System.Drawing.Text.PrivateFontCollection FntNc = new System.Drawing.Text.PrivateFontCollection();<br />
int i;<br />
for (i = 0; i <= FontResource.GetUpperBound(0); i++)<br />
{<br />
FntStrm = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(NameSpc + "." + FontResource[i]);<br />
byte[] ByteStrm = new byte[(int)FntStrm.Length];<br />
FntStrm.Read(ByteStrm, 0, Convert.ToInt32((int)FntStrm.Length));<br />
IntPtr FntPtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(System.Runtime.InteropServices.Marshal.SizeOf(typeof(byte)) * ByteStrm.Length);<br />
System.Runtime.InteropServices.Marshal.Copy(ByteStrm, 0, FntPtr, ByteStrm.Length);<br />
FntNc.AddMemoryFont(FntPtr, ByteStrm.Length);<br />
Int32 pcFonts;<br />
pcFonts = 1;<br />
AddFontMemResourceEx(FntPtr, ByteStrm.Length, 0, ref pcFonts); System.Runtime.InteropServices.Marshal.FreeHGlobal(FntPtr);<br />
}<br />
return FntNc;<br />
}<br />
}
|
|
|
|
|
Hi,
I have a requirement to remove some data from the Excel sheet which is located on a remote computer. Afer removing the data, the Excel should be saved on same name only. The problem here is I'm not able to delete the data. It is giving me the error message that "could not access the remote computer....". I have mapped the network drive correctly which gives the access. Please any body help me where I'm going wrong. Do I need to do anything more? Thanks.
Meeram395
|
|
|
|
|
How can i generate a automatic number each time in c#
sandip chandra
|
|
|
|
|
I recommend you read this[^], and the guide on asking questions. I *think* your question is easily answered by google, but it's hard to know for sure, because I'm not entirely sure what you're asking. You want to generate what sort of number ? How does it change ? How long does the sequence maintain state ? What for ?
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
What about Random class?
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Following is the code that illustrates the use of events and delegates.
There is a common thing that is use by both the event and delegates.
I know the basic differece between them (events can be declared in the interfaces.)
But in the following example , I think , I can simply go with only delegates , and no need to use the events
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Data;<br />
using System.Drawing;<br />
using System.Text;<br />
using System.Windows.Forms;<br />
<br />
namespace WindowsApplication1<br />
{<br />
public partial class Form1 : Form<br />
{<br />
public Form1()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
private void Form1_Load(object sender, EventArgs e)<br />
{<br />
d ddd = new d();<br />
ddd.sd(20);<br />
ddd.fireevent(10);<br />
}<br />
} <br />
}<br />
<br />
namespace WindowsApplication1<br />
{<br />
public delegate void smartdelegate(int i);<br />
public class d<br />
{<br />
public smartdelegate sd;<br />
public event smartdelegate smartEvent;<br />
public void fireevent(int i)<br />
{<br />
smartEvent(i);<br />
}<br />
public d()<br />
{<br />
sd = new smartdelegate(aa);<br />
smartEvent = new smartdelegate(aa);<br />
}<br />
<br />
private void aa(int i)<br />
{<br />
System.Windows.Forms.MessageBox.Show(i.ToString());<br />
}<br />
}<br />
}
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
Pankaj Garg wrote: public d()
{
sd = new smartdelegate(aa);
smartEvent = new smartdelegate(aa);
What is the point of this ?
Pankaj Garg wrote: d ddd = new d();
ddd.sd(20);
ddd.fireevent(10);
If you're not going to hook up your delegates on this level, you're wasting your time. If the event is inside the class that fires it, then you can just call it from there.
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi All,
I have written a code in C# win form that will browse all network, domain in that network, machine in the selected domain and share and folder under the selected machine. But the problem is the code runs under the logged on user credentials. If the logged on user does not have permission on the given folder it shows access denied. I want to pop up "connect to" dialog box which windows shows when we try to connect to different machine? Can anybody tell me how to do this? How to pop up the connect as box?
Jayant D. Kulkarni
|
|
|
|
|
Hi,
i have tried this line in my project so i can get the path of the
images for storing them later in the SQL table but it did not work:
byte[] imageData = ReadFile(txtImagePath.Text);
I get an error 'ReadFile' does not exist in the current context.
In which class does this method belong?
Thanks..
|
|
|
|
|
|
Read this[^].
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Hi ReadFile is method man,
but u miss that signature in ur class.
check ur code
|
|
|
|
|
I know it's a method and i'm asking if it's a predefined
method in one of the imported namespaces and if yes
which one?
|
|
|
|
|
|
I skipped the ReadFile method and used something else instead. This is my code so far:
try
{
byte[] image = new byte[4];
string qry = "insert into ITEM(item_picture) values(@OriginalPath)";
command = new SqlCommand(qry,connection);
command.Parameters.Add(new SqlParameter("@OriginalPath","~/images/app1.jpg"));
}
finally
{
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
I'm trying to execute this within a method every time i add a picture in the table.
The table is called ITEM and the column with the type image is called item_picture.
And the application root is ~/images/ where i have stored all the images.
I get the following error:
Operand type clash: nvarchar is incompatible with image
Thanks
|
|
|
|
|
I need the start menu to appear when a use clicks on a button. The thing is that it needs to appear where the button that the user clicked is.
I have looked at making it so that when the button is clicked it spawns a keypress event for the window button but that would act like just pressing the button. It would appear down in the corner.
Can anyone help me here?
modified on Sunday, March 16, 2008 7:43 PM
|
|
|
|
|
Rewrite the OS. Good luck, let us know how that turns out.
only two letters away from being an asset
|
|
|
|
|
hehe
I've seen it done before though in multiple programs where you click a button and the start menu appears wjere you clicked it.
|
|
|
|
|
I have never seen it. Nor can i imagine it being done easily... or in C#. Thats even if it really is possible.
What you could do on the other hand, is re-create the start menu. You can find through the windows registry, all of the shortcuts and things that are in the start menu, and look up the start menu folders to see what shortcuts are there.
Then, you could get the users current theme and use that to draw up your own start menu. How you would go about getting and using graphics from the currently applied theme is beyond my knowledge.
My current favourite word is: Nipple!
-SK Genius
|
|
|
|
|
here is what I want in action:
http://i86.photobucket.com/albums/k93/tadadalol/untitled-1.jpg
I know of one more program that can do the same thing.
P.S. Yes I know it all looks pretty.
P.P.S. I am very into the customizing the look of XP. The program being showed is one I've picked up in my adventures of customizing. The other program I be talking about has also come onto my computer throught the same way.
|
|
|
|