How to convert integer to text string ? C# provides an excellerent static instance can convert various types. You can easily get the wanted reult by Convert Class. Because It's a static instance, you don't need to declare instance.Following is the example to example to convert from integer to te... |
URL Encode, Decode function for MFC Here's the good example for URL Encoding & Decoding. Above sample code use CString, so if you want to use it on another type of development environment such as gcc or something like that, you need to add some more stuffs because it may not suppo... |
How to load HTML resource on MFC ? I tried to load HTML resource that stored in the application for MFC based application programming. The resource name is IDR_KURAPA_COM_HTML_ROOT.Actually this is very convenient to reduce files for application package.You can load HTML resource as followi... |
How To Check If Your Printer Is Connected Using C# This code will test whether a printer is connected to your system or not. It works with USB and network printers (haven't tested LPT printers yet). Some printers (like my HP DeskJet 930c) is detected online even though I press the OFF b... |
KMP String Matching Algorithm KMP String Matching Algorithm is well-known algorithm for faster string search. KMP is, as you know, Knuth, Morris, and Pratt. It's complexity is O(n). n is the length of target string and O is big-O notation.Here's the implemented algorithm.//////////////... |
How to get process id in C# like windows task manager ? Following is simple example to get process name and add process name to listbox control.As you can see below, you can get working process by Process control. But most of the properties are supported on windows platform. If you want to access the similar pr... |
How to implement switch statement in C# ? Switch statement executes a set of logic depending on the value of a given parameter.The types of the values a switch statement operates on can be booleans, enums, integral types, and strings.Following is the example.switch( strName){ case "james":&n... |
How to implement while loop in C# ? A while loop will check a condition and then continues to execute a block of code as long as the condition evaluates to a boolean value of true. Its syntax is as follows: while ( |
How to delete file ? C# provides file utility as File Class. You don't need to create instance, because it's already created when you declare System.IO on top of your code.Following is the example to delete file.using System.IO;...File.Delete("c:\_bg.png");File.Delete("c:\_glo... |
How to convert text string to integer ? C# provides an excellerent static instance can convert various types. You can easily get the wanted reult by Convert Class. Because It's a static instance, you don't need to declare instance.Following is the example to example to convert from text string t... |
How to set an certain color as transparent color on bitmap In order to make an certain color as transparent color on bitmap, you can set as below way:Bitmap bmp = new Bitmap(w, h);// Set white as transparent colorbmp m_Img.MakeTransparent(Color.White); |
How to resize and save PNG or Jpeg Image file ? I tried to change image file with PictureBox control. Following is the example to convert image size.private void copy_to_resized_png(string tar, string src, int w, int h){ Image imgInput = Image.FromFile(src); Bitmap bitmapResized = new Bitmap... |
How to display message box in C# C# provides very simple message displaying interface as MessageBox.Here's the simple example.MessageBox.Show( "Isn't it great ?"); |
How to convert bitmap image to jpeg image ? C# provides easy interface to convert image.Following is the simple example.using System.Drawing.Imaging;...Image image = Image.FromFile("test.bmp");image.Save("test.jpg", ImageFormat.Jpeg);Above is PNG to jpeg. You can convert Jpeg to PNG as following.usi... |
To load image from file In order to load image from file in C#, you can load them as following way. The image type could be Jpeg, GIF, Bitmap(BMP), as well as PNG.Image m_source = Image.FromFile( 'the file name you need to load');Isn't it simple ? |
How to get GM Time as String ? Here's the simple example to get GMT string. |
Finding process name on OS Following function is very useful when checking currently working process based on name.using System.Diagnostics;...public bool IsProcessOpen(string name){ foreach (Process clsProcess in Process.GetProcesses) { if (c... |
Convert System.DateTime to UNIX timestamp In case of development in clinet/server application, datetime formation conversion is frequently required.Following is the simple example for datetime conversion.private double ConvertToTimestamp(DateTime value){ |
Retrieve system information When system information is required in application, SystemInformation global instance is very useful.In case of getting Monitor Size, Virtual Screen, Computer Name, Keyboard Delay, Network Connection, Power Status, and other system variables, SystemInforma... |
How to call SetTimer function on MFC CDialog class ? Hi, problem with MFC Dialog based app: In OnInitDialog: Code: SetTimer( WM_USER+100, 500, NULL ); In OnTimer: Code: MessageBox(... CDialog::OnTimer(nIDEvent); But OnTimer never reached. Why? When i call SendMessage( WM_TIMER, 0, 0); OnTimer calls succesful... |
How to rename(change file name) in C# ? Simplest way to change file name in C# is using File.Move() function.Here's the simple example change file name for Samsung Black Jack Phone. However it may work on another platform if it supports .NET compact framework.In addition, File creation time can ... |
Find Files in certain directory Following is the simple c# example to fins file in given directory. using System.IO; |
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 sim... |
How to detect resource leaks in a Form It is possible for Forms to have resource leaks even though they are running in managed code. To determine if a form is leaking resources: 1. Run the Windows Task Manager 2. Select the Processes tab. 3. Select the View /... |
The best way to enable and disable buttons, menu items and toolbar buttons Write an OnIdle method and put your GUI enable/disable code there. The OnIdle method is called every time your application's message queue becomes empty.Hook in the OnIdle method in a Form's constructor by instantiating an EventHandler and adding that hand... |
How to exit from a console application Use Environment.Exit to immediately return from a console application with a specified result code.using System;namespace ConsoleApplication1{ class Class1 { [STAThread] static void Main(string[] args) {&n... |
How to restrict a program to a single instance In the program's Main method, call ProcessUtils.ThisProcessIsAlreadyRunning() to determine if another instance of the program is already running. ThisProcessIsAlreadyRunning attempts to create a Mutex object with the same name as the program (Application.P... |
Compress and decompress strings in C# A couple of days ago, I had to store some very big strings in an XML file. To keep the file size down I wanted to compress the strings using a GZipStream and then decompress them later when needed.I modified the methods from Papenoo pa so they handled stri... |
Graphics in C# - Irregular Forms Quite frankly, I think this topic is a lot of fun...the thought of making an app look completely different from the usual rectangular-formed layout really appeals to me.Drawing an irregular form, like drawing anything, requires four things : a surface, a s... |
Extracting the Country from IP Address Notes: If you want to run this sample,you should copy the Ip address to driver c:. Using the codePart 1.using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Text;using System.Windows.... |