JavaScript to launch the browser Favorites window to bookmark the current page.
function bookmarkThisSite(url, bookmarkName)
{
if (sidebar)
{
sidebar.addPanel(bookmarkName, url,"");
}
else if( document.all )
{
external.AddFavorite(url, bookmarkName);
}
else if( window.opera && window.print )
{
return true;
}
else
{
return true;
}
}
My shared items
Thursday, August 30, 2007
"Add To Favorites" Dialog in JavaScript
Posted by Ramesh 0 comments
Labels: AddToFavorites, JavaScript
Tuesday, August 28, 2007
DLL Register And UnRegister in Mouse Context Menu
Normal Case:
For register DLL or OCX:
rundll32 yourdll.dll,DLLRegisterServer
rundll32 yourocx.ocx,DLLRegisterServer
For unregister DLL or OCX:
rundll32 yourdll.dll,DLLUnregisterServer
rundll32 yourocx.ocx,DLLUnregisterServer
For Mouse Context Menu:
If do you want make a "Right mouse-click" option, enter in the REGEDIT and make the options:
For DLL Register:
HKEY_CLASSES_ROOT\dllfile
Make a new key "Shell":
HKEY_CLASSES_ROOT\dllfile\shell
Make a new key "Register":
HKEY_CLASSES_ROOT\dllfile\shell\register
In the "Default" value, type: "DLL Register"
And make a new key "Command":
HKEY_CLASSES_ROOT\dllfile\shell\register\command
In the "Default" value, type:
rundll32.exe "%1",DllRegisterServer
For DLL Unregister:
HKEY_CLASSES_ROOT\dllfile
Make a new key "Shell":
HKEY_CLASSES_ROOT\dllfile\shell
Make a new key "Unregister":
HKEY_CLASSES_ROOT\dllfile\shell\unregister
In the "Default" value, type: "DLL Unregister"
And make a new key "Command":
HKEY_CLASSES_ROOT\dllfile\shell\unregister\command
In the "Default" value, type:
rundll32.exe "%1",DllUnregisterServer
For OCX Register:
HKEY_CLASSES_ROOT\ocxfile
Make a new key "Shell":
HKEY_CLASSES_ROOT\ocxfile\shell
Make a new key "Register":
HKEY_CLASSES_ROOT\ocxfile\shell\register
In the "Default" value, type: "OCX Register"
And make a new key "Command":
HKEY_CLASSES_ROOT\ocxfile\shell\register\command
In the "Default" value, type:
rundll32.exe "%1",DllRegisterServer
For OCX Unregister:
HKEY_CLASSES_ROOT\ocxlfile
Make a new key "Shell":
HKEY_CLASSES_ROOT\ocxfile\shell
Make a new key "Unregister":
HKEY_CLASSES_ROOT\ocxfile\shell\unregister
In the "Default" value, type: "OCX Unregister"
And make a new key "Command":
HKEY_CLASSES_ROOT\ocxfile\shell\unregister\command
In the "Default" value, type:
rundll32.exe "%1",DllUnregisterServer
Posted by Ramesh 1 comments
Labels: DLL Register, UnRegister
Client-Side JavaScript Reference
Client-Side JavaScript Reference:
"Client-Side JavaScript Reference This book is a reference manual for the JavaScript language, including both core and client-side JavaScript for version 1.3. JavaScript is Netscape's cross-platform, object-based scripting language for client and server applications."
http://docs.sun.com/source/816-6408-10/contents.htm
Posted by Ramesh 0 comments
Saturday, August 25, 2007
Delegates and Events in C# / .NET
Overview
All of us have been exposed to event driven programming of some sort or the other. C# adds on value to the often mentioned world of event driven programming by adding support through events and delegates. The emphasis of this article would be to identify what exactly happens when you add an event handler to your common UI controls. A simple simulation of what could possibly be going on behind the scenes when the AddOnClick or any similar event is added to the Button class will be explained. This will help you understand better the nature of event handling using multi cast delegates.
Delegates
A delegate in C# is similar to a function pointer in C or C++. Using a delegate allows the programmer to encapsulate a reference to a method inside a delegate object. The delegate object can then be passed to code which can call the referenced method, without having to know at compile time which method will be invoked.
Events
The Event model in C# finds its roots in the event programming model that is popular in asynchronous programming. The basic foundation behind this programming model is the idea of "publisher and subscribers." In this model, you have publishers who will do some logic and publish an "event." Publishers will then send out their event only to subscribers who have subscribed to receive the specific event.
More Information:
http://www.akadia.com/services/dotnet_delegates_and_events.html
Posted by Ramesh 0 comments
Thursday, August 9, 2007
enum at C# Online.NET (CSharp-Online.NET)
enum at C# Online.NET (CSharp-Online.NET)
enum
The Basics
An enum
is a value type with a set of related named constants often referred to as an enumerator list. They allow code to look a lot cleaner and easier to read by getting rid of "magic numbers", that is to say, they get rid of numbers which have a purpose within a module of code, but make the code harder to read. If a single number needs a definition to make it easier to read then use a constant as shown below.
public const int North = 0;
However, if more than one related number needs a definition, then use an enumeration.
Declaration
An enum
is declared as follows:
[attributes] [modifiers] enum identifier [:base-type]
{
enumerator-list [,]
}
The attributes is optional and is used to hold additional declarative information.
The modifier is optional. The allowed modifiers are new
, public
, protected
, internal
and private
.
The keyword enum
must be followed by an identifier that names the enum.
The base-type of an enumeration may be one of the following; byte
, sbyte
, short
, ushort
, int
, uint
, long
or ulong
. If no base-type is declared, than the default of int
is used.
The enumerator-list contains the identifiers which are separated by commas (optionally including a value assignment).
The first enumerator begins at zero by default and each enumerator following is increased by 1. This can be overridden so that each member of the enumerator-list contains its own unrelated value (see second example below). Two items in an enumeration can hold the same value, however, this will cause problems if you use an automated switch statement where all elements are added.
Example 1 – A simple enumeration
An application may need to work with directions. Instead of using four numbers to represent the major directions, an enumeration works better. The numbers then become irrespective as the directions are named.
enum Direction
{
North,
East,
South,
West
}
Example 2 – Number specific
Now consider the same enumeration, but with each direction holding the value clockwise that they are from North.
enum Direction
{
North = 0,
East = 90,
South = 180,
West = 270
}
We would use the enumeration in the same manner, but the values have different meanings.
Casting
To get the underlying value of an item in an enumerator-list, you need to have an explicit cast to convert it from the enum
type to its integral type. The following code displays this and makes use of the enum
in example 2.
static void Main(string[] args)
{
Console.WriteLine("-------------------------------");
Console.WriteLine("Direction Enum Members by Name:");
Console.WriteLine("-------------------------------");
// get a list of member names from Direction enum,
// figure out the numeric value, and display
foreach (string direction in Enum.GetNames(typeof(Direction)))
{
Console.WriteLine("Direction Member: {0}\n Value: {1}",
direction, (int)Enum.Parse(typeof(Direction), direction));
}
}
And here is the output
-------------------------------
Direction Enum Members by Name:
-------------------------------
Direction Member: North
Value: 0
Direction Member: East
Value: 90
Direction Member: South
Value: 180
Direction Member: West
Value: 270
Some useful methods
Enum.GetName
- retrieves the name of the constant in the enumeration that has a specific value.
Enum.GetNames
- retrieves an array of the names of the constants in the enumeration.
Enum.GetValues
- retrieves an array of the values of the constants in the enumeration.
Enum.IsDefined
- returns an indication whether a constant with a specified value exists in a specified enumeration.
MSDN references
Posted by Ramesh 0 comments
Labels: enum, enumeration in C#, enumerators in C#
Tuesday, August 7, 2007
RegExLib.com Regular Expression Cheat Sheet (.NET Framework)
RegExLib.com Regular Expression Cheat Sheet (.NET Framework): "RegExLib.com Regular Expression Cheat Sheet (.NET)"
RegExLib.com Regular Expression Cheat Sheet (.NET)
|
|
Character Escapes http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconcharacterescapes.asp | |
Escaped Char | Description |
ordinary characters | Characters other than . $ ^ { [ ( | ) ] } * + ? \ match themselves. |
\a | Matches a bell (alarm) \u0007. |
\b | Matches a backspace \u0008 if in a []; otherwise matches a word boundary (between \w and \W characters). |
\t | Matches a tab \u0009. |
\r | Matches a carriage return \u000D. |
\v | Matches a vertical tab \u000B. |
\f | Matches a form feed \u000C. |
\n | Matches a new line \u000A. |
\e | Matches an escape \u001B. |
\040 | Matches an ASCII character as octal (up to three digits); numbers with no leading zero are backreferences if they have only one digit or if they correspond to a capturing group number. (For more information, see Backreferences.) For example, the character \040 represents a space. |
\x20 | Matches an ASCII character using hexadecimal representation (exactly two digits). |
\cC | Matches an ASCII control character; for example \cC is control-C. |
\u0020 | Matches a Unicode character using a hexadecimal representation (exactly four digits). |
\* | When followed by a character that is not recognized as an escaped character, matches that character. For example, \* is the same as \x2A. |
Character Classes http://msdn.microsoft.com/library/en-us/cpgenref/html/cpconcharacterclasses.asp | |
Char Class | Description |
. | Matches any character except \n. If modified by the Singleline option, a period character matches any character. For more information, see Regular Expression Options. |
[aeiou] | Matches any single character included in the specified set of characters. |
[^aeiou] | Matches any single character not in the specified set of characters. |
[0-9a-fA-F] | Use of a hyphen (–) allows specification of contiguous character ranges. |
\p{name} | Matches any character in the named character class specified by {name}. Supported names are Unicode groups and block ranges. For example, Ll, Nd, Z, IsGreek, IsBoxDrawing. |
\P{name} | Matches text not included in groups and block ranges specified in {name}. |
\w | Matches any word character. Equivalent to the Unicode character categories [\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \w is equivalent to [a-zA-Z_0-9]. |
\W | Matches any nonword character. Equivalent to the Unicode categories [^\p{Ll}\p{Lu}\p{Lt}\p{Lo}\p{Nd}\p{Pc}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \W is equivalent to [^a-zA-Z_0-9]. |
\s | Matches any white-space character. Equivalent to the Unicode character categories [\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \s is equivalent to [ \f\n\r\t\v]. |
\S | Matches any non-white-space character. Equivalent to the Unicode character categories [^\f\n\r\t\v\x85\p{Z}]. If ECMAScript-compliant behavior is specified with the ECMAScript option, \S is equivalent to [^ \f\n\r\t\v]. |
\d | Matches any decimal digit. Equivalent to \p{Nd} for Unicode and [0-9] for non-Unicode, ECMAScript behavior. |
\D | Matches any nondigit. Equivalent to \P{Nd} for Unicode and [^0-9] for non-Unicode, ECMAScript behavior. |
Posted by Ramesh 1 comments
Blog Archive
-
▼
2007
(15)
-
▼
August
(8)
- "Add To Favorites" Dialog in JavaScript
- The JavaScript Programming Language
- How Do I Get Paths and URL fragments from the Http...
- DLL Register And UnRegister in Mouse Context Menu
- Client-Side JavaScript Reference
- Delegates and Events in C# / .NET
- enum at C# Online.NET (CSharp-Online.NET)
- RegExLib.com Regular Expression Cheat Sheet (.NET ...
-
▼
August
(8)