November 2003 - Posts
Microsoft ActiveSync 3.7.1
Microsoft® ActiveSync® 3.7.1 is the latest synchronization software for Windows Mobile-based Pocket PCs and Smartphones. ActiveSync 3.7.1 contains fixes making synchronization more trouble free than ever before and includes all the significant improvements brought to you in ActiveSync 3.5, 3.6 and 3.7: it is easy to install and use while offering the best levels of reliability. If you had not already installed ActiveSync 3.5, ActiveSync 3.7.1 will also bring you up to date with compatibility to Microsoft Office XP and Windows XP.
EngLish:download Chinese: Download
Code Advisor for Visual Basic 6.0
If you are programming in Visual Basic 6.0 and planning to move to Visual Basic .NET, then the Visual Basic 6.0 Code Advisor is for you.
The Code Advisor for Visual Basic 6 is an add-in used to review your code to ensure that it meets predetermined coding standards. The coding standards are based on best practices developed by Microsoft to produce robust and easy-to-maintain code.
EngLish Download Chinese Download
Some articles in web just demonstrate how to set the bgcolor of a listitem with equal space,but some time ,we need set the color with the value of the listitem.
the following code demonstrate how can i do it.
Private Sub SetListItemColor(lv As ListView, picBg As PictureBox)
Dim i As Integer
Dim mItem As ListItem
picBg.BackColor = lv.BackColor
lv.Parent.ScaleMode = vbTwips
picBg.ScaleMode = vbTwips
picBg.BorderStyle = vbBSNone
picBg.AutoRedraw = True
picBg.Visible = False
picBg.Width = lv.Width
picBg.Height = lv.ListItems(1).Height * (lv.ListItems.Count)
picBg.ScaleHeight = lv.ListItems.Count
picBg.ScaleWidth = 1
picBg.DrawWidth = 1
For i = 1 To 33
Set mItem = lv.ListItems(i)
If mItem.Checked = False Then
If i Mod 2 = 0 Then
picBg.Line (0, i - 1)-(1, i), RGB(254, 209, 199), BF
Else
picBg.Line (0, i - 1)-(1, i), RGB(20, 54, 199), BF
End If
Else
picBg.Line (0, i - 1)-(1, i), RGB(254, 200, 100), BF
End If
Next
lv.Picture = picBg.Image
End Sub
Screensnap:
Download Sample Project
The day before yesterday ,I had bought a new PPC mio 528 from www.tngshop.com

It has Intel StrongARM 32-bit RISC CPU .It's my first time use PPC,So I almost don't known to use it rightly.
In order to that I can read book , study English and note message everywhere and anytime ,i decided to buy a ppc two months ago.by thinking over the price and the function of ppc ,finally i decided to by Mio 528.
I think that it's enough for my requirement.
In some circumstances, you use the CreateObject
function to create an object from an ActiveX
class. The CreateObject
function receives the
class name
as argument,
and creates the object
for you. In order to create the object, it loads
and uses the right library
or executable file that contains the interface
for that object.
For Example:
set objApplication = CreateObject("Word.Application")
When you run the above code, the CreateObject will use the winword.exe in order to interact with the objects of Microsoft Word.
The following code snippet shows how to reveal the filename that will be used
for a specific ActiveX
class. It does it by reading the
class definitions from the Registry.
Private Declare
Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey
As Long, ByVal lpSubKey
As String, ByVal ulOptions
As Long, ByVal samDesired
As Long, phkResult
As Long)
As LongPrivate Declare
Function RegCloseKey Lib "advapi32.dll" (ByVal hKey
As Long)
As LongPrivate Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Const HKEY_CLASSES_ROOT = &H80000000
Private Const SYNCHRONIZE = &H100000
Private Const KEY_NOTIFY = &H10
Private Const KEY_ENUMERATE_SUB_KEYS = &H8
Private Const KEY_QUERY_VALUE = &H1
Private Const STANDARD_RIGHTS_ALL = &H1F0000
Private Const READ_CONTROL = &H20000
Private Const STANDARD_RIGHTS_READ = (READ_CONTROL)
Private Const KEY_READ = ((STANDARD_RIGHTS_READ
Or KEY_QUERY_VALUE
Or KEY_ENUMERATE_SUB_KEYS
Or KEY_NOTIFY)
And (
Not SYNCHRONIZE))
Private Const ERROR_SUCCESS = 0&
Private Const REG_SZ = 1
Private Const BUFFER_SIZE = 1024
Private Function TrimZero(str
As String)
As String Dim lngPos
As Long lngPos = InStr(str, Chr$(0))
If lngPos > 0
Then TrimZero = Mid$(str, 1, lngPos - 1)
Else TrimZero = str
End IfEnd FunctionPrivate Sub GetFilenameFromClass(strActiveXClass
As String)
Dim hKeyCLSID
As Long Dim hKeyClassFile
As Long Dim strCLSID
As String Dim strBuffer
As String * BUFFER_SIZE
Dim blnError
As Boolean
Dim blnFound
As Boolean
If RegOpenKeyEx(HKEY_CLASSES_ROOT, strActiveXClass & "\CLSID", 0, KEY_READ, hKeyCLSID) = ERROR_SUCCESS
Then
If RegQueryValueEx(hKeyCLSID, "", 0, REG_SZ, ByVal strBuffer, BUFFER_SIZE) = ERROR_SUCCESS
Then strCLSID = TrimZero(strBuffer)
If RegOpenKeyEx(HKEY_CLASSES_ROOT, "CLSID\" & strCLSID & "\InprocServer32", 0, KEY_READ, hKeyClassFile) = ERROR_SUCCESS
Then blnFound =
True ElseIf RegOpenKeyEx(HKEY_CLASSES_ROOT, "CLSID\" & strCLSID & "\LocalServer32", 0, KEY_READ, hKeyClassFile) = ERROR_SUCCESS
Then blnFound =
True End If If blnFound
Then
If RegQueryValueEx(hKeyClassFile, "", 0, REG_SZ, ByVal strBuffer, BUFFER_SIZE) = ERROR_SUCCESS
Then MsgBox "The
class filename is " & TrimZero(strBuffer)
Else blnError =
True End If
RegCloseKey hKeyClassFile
Else blnError =
True End If Else blnError =
True End If
RegCloseKey hKeyCLSID
Else blnError =
True End If If blnError
Then MsgBox "The " & strActiveXClass & " class doesn't exist in your registry", vbOKOnly Or vbExclamation
End IfEnd SubPrivate Sub cmdGetFilename_Click()
GetFilenameFromClass txtClass.Text
End Sub
Using OLE Drag and Drop, this control enables you to drag and drop any link from Internet Explorer (IE) directly to a list control. You can even drag the icon from the IE address bar so that the current Web page's URL is inserted into the list control!
Here is sample list control that get the Internet link from Internet Explorer.
1.Start a new Visual Basic Standard EXE project. Form1 is created by default.
2.Add a ListBox (List1) to Form1.
3.Add the following code to the Form1:
Private Sub Form_Load()
List1.OLEDropMode = 1
End Sub
Private Sub List1_OLEDragDrop(Data As DataObject, Effect As Long, Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim str As String
str = Data.GetData(vbCFText)
If Data.GetFormat(vbCFText) And UCase(Left(Data.GetData(vbCFText), 7)) = "HTTP://" Then _
List1.AddItem Data.GetData(vbCFText)
End Sub
4.Start the program or press the F5 key,and try to drag a link from Internet Explorer to List1.
C# 2.0 Specification
This set of documentation describes the new features of the C# language, including Generics, Anonymous Methods and Partial Types. Please note that this is a draft document intended to give you a preview of the "Whidbey" release of the C# language.
C# is a simple, modern, object oriented, and type-safe programming language derived from C and C++. C# (pronounced "C sharp") is firmly planted in the C and C++ family tree of languages, and will immediately be familiar to C and C++ programmers. C# aims to combine the high productivity of Visual Basic and the raw power of C++.
By request, O'Reilly and Assoc. has posted the Format Specifiers appendix from C# in a Nutshell by Drayton et al. It's a wonderful reference to the String.Format/ToString format specifiers
Join extreme programming luminaries and learn the basic fundamentals of extreme programming and how C# is an ideal language for XP.
Get tips, tricks, and best practices for building .NET-connected solutions using the C# language.
Learn how to build robust and scalable server solutions using C# and the .NET Framework. See how to develop XML Web services, Windows services, and Windows server applications using the Visual Component Designer.
Learn how to build robust and scalable server solutions using C# and the .NET Framework. See how to develop XML Web services, Windows services, and Windows server applications using the Visual Component Designer.
In this paper we will know about type construction, types at runtime, delegates and events in C#.
Between VS.NET 2003 and VS.NET 2002 has i different format (actually some new tags and version identifiers.)
so we can't open those projects/solutions that created/modified by VS.NET 2003 with VS.NET 2002.
but we can make VS. net 2003 back to vs. net 2002 by modifying the solution files and the project files .
Step 1: Modify the Solution Files
Change the first line of the solution files from “Microsoft Visual Studio Solution File, Format Version 8.00” to “Microsoft Visual Studio Solution File, Format Version 7.00”
Step 2: Modify the Project Files
A. For C Sharp:
ProjectType = "Local"
ProductVersion = "7.10.3707"
SchemaVersion = "2.0"
ProjectGuid = "{20502969-7071-4065-BDB5-09EDB3C31E3C}"
>
Change the above lines to the following lines:
ProjectType = "Local"
ProductVersion = "7.0.9466"
SchemaVersion = "1.0"
ProjectGuid = "{20502969-7071-4065-BDB5-09EDB3C31E3C}"
>
Beaware of the ProjectGuid, it should be same with actual ones.
B. For Visual Basic.NET
ProjectType = "Local"
ProductVersion = "7.10.3707"
SchemaVersion = "2.0"
ProjectGuid = "{6E100C4A-A121-4C1F-83BF-BE639BC59CF1}"
>
Change the above lines to the following lines:
ProjectType = "Local"
ProductVersion = "7.0.9466"
SchemaVersion = "1.0"
ProjectGuid = "{6E100C4A-A121-4C1F-83BF-BE639BC59CF1}"
?>
?>
?>
?>
Use EM_GETRECT and EM_SETRECTNP will come it true:
At fisrt put a commandbutton and a TextBox to form and set multiLine property of that textbox to true.
then paste the following code to a fome:
Code:
Private Declare Function SendMessage Lib "user32" _
Alias "SendMessageA" _
(ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
lParam As Any) As Long
Private Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Private Const EM_SETRECT As Long = &HB3
Private Const EM_GETRECT As Long = &HB2
Private Const EM_SETRECTNP As Long = &HB4
Private Sub Command1_Click()
Dim rc As RECT
Dim tmpTop As Long
Dim tmpBot As Long
Text1.Text = "Centre this text"
Call SendMessage(Text1.hwnd, EM_GETRECT, 0, rc)
With Me.Font
.Name = Text1.Font.Name
.Size = Text1.Font.Size
.Bold = Text1.Font.Bold
End With
tmpTop = ((rc.Bottom - rc.Top) - (Form1.TextHeight("H") \ Screen.TwipsPerPixelY)) \ 2
tmpBot = ((rc.Bottom - rc.Top) + (Form1.TextHeight("H") \ Screen.TwipsPerPixelY)) \ 2
rc.Top = tmpTop
rc.Bottom = tmpBot
Text1.Alignment = vbCenter
Call SendMessage(Text1.hwnd, EM_SETRECTNP, 0&, rc)
Text1.Refresh
End Sub
Reference “Tip 135: Preventing a User from Editing the Contents of a Text Box Control“ and “Knowledge Base Q110403“
We can get the fellowing information in that articles :
you might not want your user to be able to edit the text that is stored in the Text Box control. You can set the contents of a Text Box control to read-only status by using the Microsoft Windows® programming application interface (API) SendMessage function.
The SendMessage function can be used to send an EM_SETREADONLY message to the Text Box control. This makes the Text Box control read-only.
Code Example:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA"
(ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer,
ByVal lParam As Long) As Long
Private Const EM_SETREADONLY = &HCF
Private Sub Command1_Click()
Dim RetVal As Long
RetVal = SendMessage(Text1.hwnd, EM_SETREADONLY, True, ByVal 0&)
End Sub
Run this example,the Text of Text1 will can't be edited,but it has a bug ,in this time ,user still can edit the text of Text1 by clicking the “Paste”submenu in Context Menu to paste text in clipboard to this Textbox .
|
|
From http://weblogs.asp.net/pgreborio/ by Gregorio IsNumeric To test if the string content is a valid integer we can use the VB function IsNumeric. C# doesn't provides such a function then we have to write our own helper function to do so. One of the most common approach I've seen on the newsgroups is the following code:
public static bool IsNumeric(string inputData) { try { int.Parse(inputData); return true; } catch { return false; } }
If the string isn't a valid integer I'll get a FormatException or OverflowException if it is valid but out of the integer domain. Another approach is to use Convert.ToInt32() instead of Parse. From a performance point of view the two solutions are pretty the same.
A very competitive way is to use Regular Expressions checking if the string data contains really only digits:
private static Regex _isNumber = new Regex(@"^\d+$");
public static bool IsNumeric(string inputData) { Match m = _isNumber.Match(inputData); return m.Success; }
In this case, the regular expression is compiled once and then the solution is, more or less, 4 times faster than the previous ones. |
MS recently posted
23 C# Code Samples on MSDN for your development pleasure.
you could find here
http://msdn.microsoft.com/vcsharp/downloads/samples/23samples/default.aspx