Overriding WndProc
Before we leave Windows Forms, readers who have programmed in C with the original Windows SDK, may be wondering if Windows Forms provides access to underlying Windows messages. The answer is yes. For example, you may be familiar with C SDK idiom for processing Windows messages LRESULT CALLBACK WndProc HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam Typically WndProc contained a long switch statement to identify and process individual messages. Of course, with Windows Forms, this type of...
Enabling Web service discovery
The process of locating Web services and retrieving their WSDL contracts is known as Web service discovery. Discovery can be facilitated by storing a so-called DISCO file with the service, or at an appropriate URL such as in a UDDI registry. The DISCO file is a regular XML document which provides links to the WSDL contract and associated documentation. The XML Web services infrastructure will automatically generate a bare-bones DISCO file for your service. Point your browser to to generate the...
The DataSets GetXml and GetXmlSchema methods
We can display both the XML data and schema for the ds DataSet created in the pubscount program, as follows display DataSet as XML display DataSet schema as XML Listing 4.2 shows what the XML schema looks like. lt xsd schema id PubsDataSet targetNamespace xmlns xmlns xsd http www.w3.org 2 0 01 XMLSchema lt xsd element name PubsDataSet lt xsd choice maxOccurs unbounded gt lt xsd element name a_count gt lt xsd complexType gt lt xsd sequence gt lt xsd element name cnt type xsd int minOccurs 0 gt...
Understanding types and assemblies
2.2 Value vs. reference types 18 2.4 Understanding finalization 23 2.6 Private vs. shared assemblies 29 2.9 Types, assemblies, and reflection 41 2.10 Building a simple compiler 44 Creating a .NET application involves coding types, and packaging them into assemblies. .NET types are similar to data types in non-object-oriented languages except that they contain both data, in the form of fields, and behavior in the form of methods. .NET types are also language-neutral. An assembly containing types...
ConPok 3tier clientserver poker
Now we can pull all the pieces together with a console poker game with full database support, statistics, and payout control. Listing 4.15 presents ConPok, the client server console poker game. Listing 4.15 ConPok client server console video poker compile csc r poker.dll conpok.cs machine Machine.Instance uiBet minBet machine.MinBet maxBet machine.MaxBet uiCredits machine.StartCredits play until our opponent is wiped out while uiCredits gt minBet nextGame Console.WriteLine Loser - private void...
Installing the poker Windows service
We compile svcpokservice.cs and install it as a Windows service using the installutil.exe utility, as shown in figure 5.20. C DotNet pokerNSucPok gt csc r poker.dll sucpokseruice.cs Microsoft lt R gt Uisual Cft Compiler Uersion 7.00.9254 CLR uersion ul.0.2914 Copyright lt C gt Microsoft Corp 2000-2001. All rights reserued. LogToConsole false sucpokseruice.exe Microsoft lt R gt .NET Framework Installation utility Copyright lt C gt Microsoft Corp 2001. All rights reserued. Figure 5.20 Installing...
Console poker using COM and VBScript
Listing 3.5 presents a VBScript client which plays a COM-based version of our simple poker game. ' description VBScript poker game ' execute cscript compok.vbs wscript.stdout.writeLine A simple poker game wscript.stdout.writeLine Hit Ctrl-c at any time to abort wscript.stdout.writeLine set machine do while true ' play forever set dealHand machine.Deal wscript.stdout.writeLine dealhand.Text wscript.stdout.write Enter card numbers 1 to 5 to hold holdCards wscript.stdin.readLine set drawHand...
Creating the WSPok client
As usual, run the wsdl.exe utility to generate the client proxy wsdl namespace Poker This will generate the wspokservice.cs file containing definitions for both the Poker.WSPokService and Poker.GameResult classes. All that remains is to code the simple client shown in listing 6.18. compile csc out WSPok.exe WSPokService.cs WSPok.cs namespace Poker using System public static void Main new WSPok start game Console.WriteLine A WebService-based poker game Console.WriteLine Hit Ctrl-c at any time to...
A Visual Basic NET Hello program
For comparison, listing 1.2 shows the same program coded in Visual Basic .NET. ' file hello.vb ' compile vbc hello.vb Console.WriteLine Hello from VB.NET end sub You can see that the Visual Basic .NET version of the program is very similar. Specifically, the Visual Basic .NET program uses the same Console class from the System namespace. The Framework class library is part of the .NET platform and is not the preserve of a particular programming language. In general, there is less difference...
Compiling the C Hello program
To compile and test this example, you'll need a copy of the .NET SDK, or Visual Studio .NET. At the time of writing, the SDK could be downloaded from the Microsoft Developer Network site, http www.msdn.com. To compile and run this program, open a command window, and use the C command-line compiler, as shown in figure 1.2. Microsoft lt R gt Uisual CK Compiler Uersion 7.00.9254 CLP version ul.0.2914 Copyright C gt Microsoft Corp 2000-2001. All rights reserved. C Do t Ne t c ha_l gt he 1 lo Hello...
A43 Logical operators
The logical operators also owe their heritage to C C .
Example logging into a Web service
You could use the stateful approach to provide application-level login logout for a service. Listing 6.10 presents a StringCaseService service which requires the client to login in order to call the ToUpper and ToLower Web methods. In contrast, the GetLength method can be executed without logging in. lt WebService Language C Class StringCaseService gt file stringcaseservice.asmx description A web service to change string case. Requires user to login first. using System.Web.Services using...

