Search results for 'Delphi for .NET'. 6 post(s) found.

  1. 2007/10/04 Sending email messages in .Net
  2. 2007/10/04 Implementing C#'s foreach loop in Delphi 8
  3. 2007/10/04 Delphi for .Net Code Folding keyboard shortcuts
  4. 2007/10/04 How to encrypt a string
  5. 2007/10/04 Creating thumbnail images
  6. 2007/10/02 Technology sharing related with software development. Specially content will be focused to programming language, and embedded systems.
2007/10/04 08:20

Sending email messages in .Net


Sending an e-mail message (even with attachments) in Delphi for .NET (ASP.NET or WinForms) is very simple. You don't have to learn complicated syntaxes and other commands to achieve the task. The System.Web.Mail namespace provides the classes for sending email in .NET. MailMessage class manages the mail message contents; SmtpMail class sends email to the mail server.

Here's a sample code:

uses System.Web.Mail;
...

var
   MailMessage : System.Web.MailMessage;
begin
   MailMessage := MailMessage.create;
   try
     with MailMessage do
     begin
       From := 'delphi.guide@about.com';
       &To := 'someone@somewhere.net';
       Subject := 'This is the subject line';
       Body := 'this is the mail body text;
       BodyFormat := System.Web.Mail.MailFormat.Text;
     end;
     SmtpMail.SmtpServer := 'SmtpServer NAME';
     SmtpMail.Send(MailMessage) ;
   except on e : Exception do
     MsgResult.Text := 'Error occured!';
   end;
end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 05:56 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 14:30 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/10/04 08:18

Implementing C#'s foreach loop in Delphi 8


In C# the foreach statement repeats a group of embedded statements for each element in an array or an object collection. Delphi 8 does not have an eqivalent of the foreach statement. Let's see how to code a foreach statement in Delphi...

First, here's a simple sample C# code:

foreach (TMyObject myObject in AnArrayList) {
  AnIntValue = MyObject.MyValue;
}
Where TMyObject class is declared as:
TMyObject = Class(TObject)
  public
    MyField : integer;
    constructor Create(AValue:integer) ;
end;

constructor TMyObject.Create(AValue: integer) ;
begin
   inherited Create;
   MyField := AValue;
end;


Here's the "same code" in Delphi:

var
   MyObject : TMyObject;
   AnArrayList : ArrayList;
   Enum: IEnumerator;
   j:integer;
begin
   AnArrayList := ArrayList.Create;
   AnArrayList.Add(TMyObject.Create(2004)) ;
   AnArrayList.Add(TMyObject.Create(1973)) ;
   AnArrayList.Add(TMyObject.Create(2000)) ;
   AnArrayList.Add(TMyObject.Create(1998)) ;


   //FOR EACH
   Enum := AnArrayList.GetEnumerator;
   while Enum.MoveNext do
   begin
     MyObject := TMyObject(Enum.Current) ;
     Response.Write(MyObject.MyField.ToString + '<br>') ;
   end;

   // OR USING ITERATION
   for j:= 0 to -1 + AnArrayList.Count do
   begin
     MyObject := TMyObject(AnArrayList[j]) ;
     Response.Write(MyObject.MyField.ToString + '<br>') ;
   end;
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 00:51 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 09:22 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/10/04 08:15

Delphi for .Net Code Folding keyboard shortcuts


Privately I don't think this shortcut is not easy to memory and frequently used so not practical.

However Delphi for .NET's Code Editor introduced Code folding. Code folding lets you collapse (hide) and expand (show) sections of your code to make it easier to navigate and read. Code folding is enabled by default for methods/routines, code blocks (regions) and structured types.

When using the mouse, click the plus (+) sign to the left of a code block to collapse the code; click the minus (-) sign to expand the code block.

Here are a few handy code folding keyboard shortucts:

    * CTRL + SHIFT + K + E : Collapses the nearest block (+)
    * CTRL + SHIFT + K + U : Expands the nearest block (-)
    * CTRL + SHIFT + K + A : Expand all code in a unit (- "all")
    * CTRL + SHIFT + K + T : Toogle block (+/-)
    * CTRL + SHIFT + K + O : Turn on/off code folding for the current document
Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/28 23:05 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 07:19 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/10/04 08:13

How to encrypt a string


If you need to encrypt a string in Delphi for .NET you can use the System.Security.Cryptography namespace. Here's a sample function:

Note: the example below uses MD5 algorithm implementation, for a list of possible implementations read MSDN help for System.Security.Cryptography namespace.

uses System.Security.Cryptography, System.Text;

function Encrypt(const cleanString: string): string;
var
   ue : UnicodeEncoding;
   clearBytes, hashedBytes : array of Byte;
begin
   ue := UnicodeEncoding.Create;
   clearBytes := ue.GetBytes(cleanString) ;
   hashedBytes := (CryptoConfig.CreateFromName('MD5') AS HashAlgorithm).ComputeHash(clearBytes) ;
   Result := BitConverter.ToString(hashedBytes) ;

   //Remove "-"'s
   Result := Result.Replace('-',System.String.Empty) ;
end; (* Encrypt *)


Usage sample:
HashedString := Encrypt('http://delphi.about.com') ;
// HashedString = DC31A33D559C4B6609EEA9A6DA137486

Trackback 3 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 06:08 delete

    moneyideas

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 14:38 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/10/04 08:11

Creating thumbnail images


Suppose you have a Web Form where uploading of files is enabled, using the HtmlInputFile HTML control, and a user is uploading an image. If you accept only images of a specified size, you might need to shrink the uploaded image / create a thumnail.
Here's how to create thumbnail images in ASP.NET Delphi web applications.

procedure Generatethumbnail(const FileName : string; const ImageStream : Stream; const tWidth, tHeight : Double) ;
var
   g : System.Drawing.Image;
   thumbSize : Size;
   imgOutput : Bitmap;
   imgStream : MemoryStream;
begin
//This function creates the thumbnail image and returns the
//image created in Byte() format

   g := System.Drawing.Image.FromStream(ImageStream) ;
   thumbSize := NewThumbSize(g.Width, g.Height, tWidth, tHeight) ;

   imgOutput := Bitmap.Create(g, thumbSize.Width, thumbSize.Height) ;
   imgStream := MemoryStream.Create;
   imgOutput.Save(imgStream, g.RawFormat) ;
   imgOutput.Save(Path.Combine('c:\LocationOnServer',FileName)) ;
   g.Dispose;
   imgOutput.Dispose;
end;

function NewThumbSize(const currentwidth, currentheight, newWidth, newHeight : Double) : Size;
var
   tempMultiplier : Double;
   NewSize : Size;
begin
   if currentheight > currentwidth Then
    tempMultiplier := newHeight / currentheight
   else
    tempMultiplier := newWidth / currentwidth;

   NewSize := Size.Create(Convert.ToInt32(currentwidth * tempMultiplier), Convert.ToInt32(currentheight * tempMultiplier)) ;
   Result := NewSize;
end;

//Usage:
Generatethumbnail('ThumbnameOnServer', ImageFile.PostedFile.InputStream, thumbWidth, thumbHeight) ;

//Where
//ImageFile : System.Web.UI.HtmlControls.HtmlInputFile;
Trackback 6 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject Buy xanax with no prescription.

    Tracked from Xanax. 2009/02/13 22:34 delete

    Buy 180 xanax. Xanax. No prescription xanax. Xanax cocktail. Buy cheap xanax without prescription. Side effects of xanax.

  2. Subject Fetish town free scat porn and fetish sex sites.

    Tracked from Scat porn. 2009/03/31 14:17 delete

    Scat porn archive cringe humor forum. Scat porn. Porn movie scat sex. Scat porn galleries.

  3. Subject Free zoo porn movies.

    Tracked from Free zoo porn vids. 2009/03/31 17:59 delete

    Animal sex zoo free porn bestiality horse.

  4. Subject different money making ideas

    Tracked from moneyideas 2010/01/28 23:26 delete

    moneyideas

  5. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 07:43 delete

    moneyideas

  6. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas

2007/10/02 08:53

Technology sharing related with software development. Specially content will be focused to programming language, and embedded systems.


Delphi 2005's Welcome Page can easily be modified by adding your favorite links and/or blog RSS feeds. You can add your favorite link to the left column of the page, and add an item in the "Headlines" combobox that (already) contains a list of various blogs

Adding About Delphi Programming to favorite links

   1. Locate the Delphi 2005 installation folder, and the "Welcome page" subfolder
   2. Open the "XML" subfolder
   3. Open the "menuBar.xml" document. Use Notepad or your favorite XML editor
   4. Inside the "menuBar.xml" locate the <title>Resources</title>
   5. Add a new section, like:
      <item>
        <title>About Delphi Programming</title>
        <link>http://strcpy.com</link>
      </item>


Adding About Delphi Programming blog RSS feed

   1. Locate the Delphi 2005 installation folder, and the "Welcome page" subfolder
   2. Open the "XML" subfolder
   3. Open the "defaultProviders.xml" document.
   3. Use Notepad or your favorite XML editor
   4. Inside the "defaultProviders.xml" locate the last line "</rss>"
   5. Above the last line, add a new section, like:
      <group>
        <title>Favorite Blogs</title>
        <item>
          <title>About Delphi Programming</title>
          <link>http://strcpy.com/</link>
        </item>
      </group>


Finally, reload/refresh your Delphi 2005 Welcome Page and the new items will appear in the feed combobox and in the left column.
Trackback 4 Comment 0

Trackback : Cannot send a trackbact to this post.

  1. Subject Cocaine and codeine.

    Tracked from How codeine effects the brain. 2009/05/07 03:35 delete

    Withdrawal symptoms from codeine. Codeine. Codeine can ada. Codeine pvtussin.

  2. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 04:36 delete

    moneyideas

  3. Subject different money making ideas

    Tracked from moneyideas 2010/01/29 13:30 delete

    moneyideas

  4. Subject different money making ideas

    Tracked from moneyideas 2010/01/31 16:41 delete

    moneyideas