How to drag forms by using the client area with Visual C++ 2005 or with Visual C++ .NET

This step-by-step article describes how to permit a user to move a form by dragging the client area of the form. This article describes how to override the WndProc method of the form to enable the client area dragging.

Requirements

The following list outlines the recommended hardware, software, network infrastructure, and service packs that you need:

  • Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET 2003
  • Microsoft .NET Framework 1.1 or later

This article assumes that you are familiar with the following topics:

  • Microsoft Visual C++ 2005 or Microsoft Visual C++ .NET 2003

Introduction

When you design an application, you may want to permit the user to move the form of an application by dragging the client area of the form. For example, you may want to do this if the form does not have a title bar or if the form has an irregular (that is, non-rectangular) shape.

An example of an application that provides this type of functionality is the Microsoft Windows Media Player. The Media Player permits you to select a “skin” to provide a customized look for the player. When you select a skin, the title bar is hidden, and you can move the window by dragging the form itself.

When Microsoft Windows handles mouse activity on a form, Windows sends the WM_NCHITTEST message to the form to determine where mouse events occur. For example, if you click the title bar of a form, the form returns an HTCAPTION value that indicates that the mouse event occurs on the title bar. If you click the client area of the form, the form returns an HTCLIENT value that indicates that the mouse event occurs in the client area of the form.

When you override the WndProc method of the form, you can intercept the WM_NCHITTEST message and determine where mouse activity on the form occurs. If the activity occurs in the client area, you can return an HTCAPTION value that causes Windows to handle the activity as if the activity actually occurs in the title bar.

The following sample code overrides the WndProc method of the form. The code intercepts the WM_NCHITTEST message and determines whether the mouse activity occurs in the client area of the form. If the mouse activity occurs in the client area, the procedure returns an HTCAPTION value that causes Windows to handle the event as if it occurs in the title bar.

Note If you override the WndProc method of the form in this manner, the mouse events for the form are also overridden, and any code that those event handlers contain does not run.

Create the Sample

  1. Start Microsoft Visual Studio 2005 or Microsoft Visual Studio .NET 2003.
  2. On the File menu, point to New, and then click Project.
  3. Click Visual C++ Projects under Project Types, and then click Windows Forms Application (.NET) under Templates.

    Note In Visual Studio 2005, click Visual C++ under Project Types, and then click Windows Forms Application under Templates.

  4. In the Name box, type DragForm, and then click OK.

    By default, the Form1 form is created and is opened in design mode.

  5. Right-click Form1, and then click View Code.
  6. Add the following code before the Form1 class constructor code.
    private:
    static const int WM_NCHITTEST = 0x84;
    static const int HTCLIENT = 0x1;
    static const int HTCAPTION = 0x2;
  7. Add the following method to the Form1 class.
    protected:
    	void WndProc(Message * m)
    	{
    		switch(m->Msg)
    		{
    			case WM_NCHITTEST:
    				__super::WndProc(m);
    				if ((int)m->Result == HTCLIENT)
    					m->Result = (IntPtr)HTCAPTION;
    				break;
    
    			default:
    				__super::WndProc(m);
       				break;
    		}
    
    		return;
    	}

    Note You must add the common language runtime support compiler option (/clr:oldSyntax) in Visual C++ 2005 to successfully compile the previous code sample. To add the common language runtime support compiler option in Visual C++ 2005, follow these steps:

    1. Click Project, and then click <ProjectName> Properties.

      Note <ProjectName> is a placeholder for the name of the project.

    2. Expand Configuration Properties, and then click General.
    3. Click to select Common Language Runtime Support, Old Syntax (/clr:oldSyntax) in the Common Language Runtime support project setting in the right pane, click Apply, and then click OK.

    For more information about the common language runtime support compiler option, visit the following Microsoft Web site:

    /clr (Common Language Runtime Compilation)
    http://msdn2.microsoft.com/en-us/library/k8d11d4s.aspx (http://msdn2.microsoft.com/en-us/library/k8d11d4s.aspx)
  8. Press the CTRL+SHIFT+S key combination to save the project.
  9. Press the CTRL+SHIFT+B key combination to build the solution.
  10. Press the CTRL+F5 key combination to run the project.
  11. Click anywhere in the client area of the form, and then try to drag the form. Notice that you can successfully move the form by dragging it from anywhere in the client area or title bar of the form.

10 Reasons To Launch A Website :

Change is constant, an appropriate adage for today’s scenario. There is a vast competitive market where you want to establish your enterprise. You should be more forward thinking if you wish to stand out in your business. Being in the market is just not enough, people should mark your presence then only your business will be successful.
One of the easiest ways of reaching masses is through Internet. For this your business needs a website, which can represent you on web giving you a web presence.
This isn’t that expensive, if done properly can give you better ROI (Return on Investment) than any advertisement or promotion. If these reasons are not enough for you then let’s discuss 10 more reasons why your business needs a website.

Professional Image
A website helps you to create a professional image. A professionally designed website can attract visitors which can convert into new customers. This gives an impression that the company is credible and trustworthy. Your well made website gives you a professional touch.

Business Information
Your website makes you easily accessible and reachable. You can provide your business information in your website like phone number, fax number, clients and special offerings. People can get a brief about you just by visiting your company website

Promotional Tool
Website is the most convenient and professional promotional tool. It ensures a less expensive and continuous promotion to your business. It is easy to update than yellow pages or brochures. It can save your printing expenditure.

Establishes E – Commerce
Millions of customers log on to the Internet everyday to expand web business or E- Commerce. Once you are in the web the transactions the business you generate becomes a part of the E-Commerce, where you deal in a virtual market. Your single website becomes your active tool in generating business by E-Commerce businesses.

Research Information
Your website provides the required research information to your visitors. Many people spend hour in Internet searching articles, information for educational purpose. You can be referred by many visitors if your website has information about any product or service.

Demographic Market

The World Wide Web or WWW is the highest virtual market having the highest percentage of demographic market available. This mostly consists of educated mass that can spend more on the web. You can target a large mass of affluent customers through Internet.

Global Market

Internet is a global medium. If you have a website it can be visited from any part of the globe. People can visit your website for information and offerings. This gives your business a global presence.

Round the Clock Availability

Your business hour can have a proper timing but your website is not bound of timings. People can visit your website anytime any day. Your webpage can serve your client round the clock without charging any overtime

Feedback – Room for improvement
Website can give you instant feedback which is not possible for print. Visitors can give you proper feedback by e mail. You can even generate an instant feedback form in your website, where visitors can express their views about your website.

Persuasive
People believe in what they see. When you will have a visible web presence you can allure visitors and show confidence on your expertise and work. By providing service and product information you can get instant orders from your visitors. This can effortlessly attract new business for you.

———————————————————————————————

Author:

Award Winning Author, Motivator And Public Speaker Who Had Quietly Been Making Over $20,000 Per Month Just From Home Based part time Online Freelance Jobs.

SEE THE FUTURE OF DEVELOPER TECHNOLOGY

Since 1991, the Professional Developers Conference (PDC) has been Microsoft’s premier gathering of leading-edge developers and architects. Attendees come from around the world to learn about the future of Microsoft’s platform, exchange ideas with Microsoft technology experts and network with fellow professionals.

What you’ll get at the PDC

  • Hear from keynote speakers who help set the direction for Microsoft and the industry, and see them unveil our new products and technologies
  • Immerse yourself in 4 days of deep, technical session and workshop content delivered by Microsoft and industry luminaries
  • Get one-on-one access to over 1,000 Microsoft experts at the Ask The Experts reception and onsite throughout the conference
  • Try out the latest platform technologies in our Hands-on-Labs and get a jump start on planning your company’s products and technology investments
  • Network with other leading-edge developers and architects
  • Walk away with the pre-release bits

Since the beginning, the PDC has been the epicenter of Microsoft’s biggest platform announcements, including Microsoft .NET, Windows® XP, Windows Vista®, and Windows 7®. This year, you’ll hear more details about our services platform, the future of Windows, the web, devices, and our next generation of developer tools. And as always, some of the most exciting announcements are closely-guarded secrets until the event. Join us at PDC09 and be among the first to see the future of Microsoft’s developer platform.

The Evolution of Search Engines

The history of search engines is the account of university students’ projects growing into marketable enterprise and revolutionizing the field as they went. The initial effort at creating a search engine was called Archie, and it was fashioned in 1990 by a student at McGill University, Alan Emtage. This very primordial search engine did not utilize in the least automaton skill.
The next evolutionary pace of the search engine was the prologue of “robots.”Basically what robots would execute is to examine the internet for URL’s, starting at a single spot and via the links in the preceding site to locate additional sites.
Nevertheless, soon after, in December 1993, a fresh robot was born and was called the “spider.”. The older robots barely indexed the URL and titles of a sheet, which destined to some related keywords, might not be indexed. This significantly enhanced the relevancy rankings of their consequences, and thus was the primary key step in forming the chief search engines that we have all turn out to be so worn to using these days.
Search engines encompass a vast effect on the American standard of living. They fundamentally will donate you just regarding any information you wish for, all you comprise to do is type into the explore box the subject matter you would like to find more information on. Human beings are normal instinctive information junkies, we constantly would like to know more and find out more and search engines have prepared this advocate of ours really easy to heal.

What is ASP?

Active Server Pages is a programming environment that gives the ability to generate dynamic html pages with the help of server side scripting.

VBScript is the default scripting language for ASP, but if you like you can use VBScript, JScript, Perl or any other scripting language for server side scripting in an ASP page. An ASP page is almost the same as a HTM or HTML page… the only difference is that an ASP page has the ‘.asp’ extension. Active Server Page can include both client side and server side scripts. In an ASP page VBScript is usually used as the server side and Java Script as the client side scripting language.

Do i need any special software to write ASP?
You don’t need any special software to write an ASP page. An ASP page can be written with any HTML editor… even in Windows Notepad. If you are looking for some special software to write an ASP page, Microsoft Visual InterDev is the best tool for you. InterDev helps you to easily develop ASP applications because it simplifies the process of developing and debugging ASP applications.

Browser independent.
ASP is browser independent because all the scripting code runs on the server and the browser only gets a normal HTML page as a result of server side scripting.

How ASP work?

In Case of a HTM or HTML page.

•  A user requests a web page in the browser (i.e., ‘http://www.devasp.com/test.htm’)

•  Browser requests the required page from the server (like IIS or PWS).

•  Server reads the required file from memory or the file system and sends it back to the Browser.

•  Browser executes the client side scripting (i.e., Java scripts) and displays the results.

In case of Active Server Page.

•  A user requests a web page in the browser with a file extension .asp
(i.e., ‘http://www.devasp.com/test.asp’)

•  Browser requests the page from the server (like IIS or PWS).

•  Server reads the required file from memory or the file system and recognizes that the file has
an ‘.asp’ extension.

•  Server sends that file to ASP.dll.

•  ASP.dll reads the file with the ‘.asp’ extension from top to bottom and executes all the codes
within the <% and %> tags and produces a standard HTML page.

•  The server sends that HTML page back to browser.

•  Browser executes the client side scripting (i.e., Java scripts) and displays the results to the
user in the browser window.

Let us take a look at this simple ASP example to get a better idea how ASP works.

File: HelloWorld.asp

<head>
<title>Hello World</title>
</head>
<body>
<h2>
My First ASP Page.</h2>
<%  For I = 1 To 5  %>
<font size=”<%=I%>”>Hello World </font>
<br>
<% Next %>
</body>
</html>

If you request this page in browser this is the result what you will see in the browser as output of this page.

Now if you check “View Source” behind this page you will see something like this.

What happend actually when you requests this page in web browser.
Server reads the file extension and recognize that this is an ASP file and need to execute before send back to browser. ASP.dll reads the file from top to bottom and the executes the code written in between <% and %> tags and browser only gets a result of that server side scripting.

ASP Server Variables

This simple example will show you some commonly used server variables and a small script that can be used to retrieve the list of server variables and their values.

  • HTTP_REFERER
    Request.ServerVariables(”HTTP_REFERER”)
    Give you the URL of the referring page.
  • HTTP_USER_AGENT
    Request.ServerVariables(”HTTP_USER_AGENT”)
    Returns the information of the browser requesting the page.
  • QUERY_STRING
    Request.ServerVariables(”QUERY_STRING”)
    Returns the Query information from the URL after the question mark (?).
  • REMOTE_ADDR
    Request.ServerVariables(”REMOTE_ADDR”)
    Returns the The IP address of the remote host who has requested the page.

<%

Dim VariableName

Response.Write “<TABLE Border=1 BorderColor=”"BBBBBB”">”
Response.Write “ <TR>”
Response.Write “  <TD><B>Server Variable Name</B></TD>”
Response.Write “  <TD><B>Server Variable Value</B></TD>”
Response.Write “ </TR>”

For Each VariableName In Request.ServerVariables

Response.Write “<TR>”
Response.Write “ <TD>&nbsp;” & VariableName & “</TD>”
Response.Write “ <TD>&nbsp;”
Response.write   Request.ServerVariables(VariableName)
Response.Write “ </TD>”
Response.Write “</TR>”

Next

Response.Write “</TABLE>”

%>


Ten Things to Do With IIS

As an IIS administrator it sometimes gets downright annoying having to fend off all the insults from Apache admins I meet claming innate server superiority. Generally the discussion about Web administration starts first with all the various security holes plaguing IIS and the negative press the platform garnered over the last year. Then it invariably moves to a discussion about how Netcraft and other stats sites show Apache as the dominant server on the Web, or how a certain big site uses Apache, or how there are so many cool modules to add to Apache. Pointing out that scads of non-identified corporate in-house servers run IIS, or that it too is a free server (since it comes with the operating system), or that there are in fact plenty of cool add-ons for IIS (including many that provide source code) — all this does little to dissuade these server chauvinists of their opinion. Rather than whining about rude Apache admins, however, I thought it would be a more useful response simply to write down some of the ways I’ve found of improving IIS. So without further delay here are my top ten tips for making the most of your IIS.

Tip 10: Customize Your Error Pages

Although this is quite simple to do, few people seem to take advantage of it. Just select the “Custom Errors” tab in MMC and map each error, such as 404, to the appropriate HTML or ASP template. Full details can be found here. If you want an even easier solution — or if you want to let developers handle the mapping without giving them access to the MMC — use a product like CustomError.

Tip 9: Dive into the MetaBase

If you think Apache is powerful because it has a config file, then take a look at the MetaBase. You can do just about anything you want with IIS by editing the MetaBase. For example, you can create virtual directories and servers; stop, start and pause Web sites; and create, delete, enable and disable applications.

Microsoft provides a GUI utility called MetaEdit, somewhat similar to RegEdit, to help you read from and write to the MetaBase. Download the latest version here. But to really impress those UNIX admins — and to take full advantage of the MetaBase by learning how to manipulate it programmatically — you’ll want to try out the command-line interface, officially called the IIS Administration Script Utility. Its short name is adsutil.vbs and you’ll find it in C:\inetpub\adminscripts, or else in %SystemRoot%\system32\inetsrv\adminsamples, together with a host of other useful administrative scripts.

A word of caution though: Just like Apache conf files, the MetaBase is pretty crucial to the functioning of your Web server, so don’t ruin it. Back it up first.

Tip 8: Add spell checking to your URLs

Apache folks always brag about cool little tricks that Apache is capable of — especially because of the wealth of modules that can extend the server’s basic functionality. One of the coolest of these is the ability to fix URL typos using a module called mod_speling. Well, thanks to the folks at Port80 Software, it now appears that IIS admins can do this trick too, using an ISAPI filter called URLSpellCheck. You can check it out right on their site, by trying URLs like www.urlspellcheck.com/fak.htm, www.urlspellcheck.com/faq1.htm — or any other simple typo you care to make.

Tip 7: Rewrite your URLs

Cleaning your URLs has all sorts of benefits — it can improve the security of your site, ease migration woes, and provide an extra layer of abstraction to your Web applications. Moving from a ColdFusion to an ASP based site, for example, is no big deal if you can remap the URLs. Apache users have long bragged about the huge power of mod_rewrite — the standard Apache module for URL rewriting. Well, there are now literally a dozen versions of this type of product for IIS — many of them quite a bit easier to use than mod_rewrite, which tends to presume familiarity with regular expression arcana. Check out, for example, IIS ReWrite or ISAPI ReWrite. So brag no more, Apache partisans.

Tip 6: Add browser detection

There are a lot of ways to build Web sites, but assuming everybody has a certain browser or screen size is just plain stupid. Simple JavaScript sniff-scripts exist for client-side browser detection, but if you are an IIS user you can do better with a product called BrowserHawk from CyScape. The Apache world doesn’t really have something comparable to this popular, mature and well-supported product. Speaking of CyScape, they’ve recently added an interesting-looking related product called CountryHawk that helps with location detection, but so far I haven’t had the language- or location-sensitive content to warrant trying it out.

Tip 5: Gzip site content

Browsers can handle Gzipped and deflated content and decompress it on the fly. While IIS 5 had a gzip feature built-in, it is pretty much broken. Enter products like Pipeboost to give us better functionality — similar to what Apache users have enjoyed with mod_gzip. Don’t waste your bandwidth — even Google encodes its content, and their pages are tiny.

Tip 4: Cache your content

While I’m on the topic of improving performance, remember to make your site cache friendly. You can set expiration headers for different files or directories right from the MMC. Just right click on an item via the IIS MMC, flip to the “HTTP Headers” tab, and away you go. If you want to set cache control headers programmatically — or even better, let your site developers do it — use something like CacheRight. If you want to go further and add reverse proxy caching, particularly for generated content, use a product like XCache — which also throws in compression.

It might involve more time and expense to take full advantage of caching, but when you watch your logs shrink because they don’t contain tons of pointless 304 responses, and your bandwidth consumption drop like a stone, even while your total page views increase over the same period, you’ll start to understand why this particular tip was so important. Cache friendly sites are quite rare, but there is plenty of information available online about the enormous benefits to be had by doing it right: Check out Brian Davidson’s page, this nifty tutorial from Mark Nottingham, and what AOL has to say on the subject.

Tip 3: Tune your server

Tuning IIS is no small topic — whole books and courses are dedicated to it. But some good basic help is available online, such as this piece from IIS guru Brett Hill, or this Knowledge Base article from Microsoft itself. However, if you don’t feel like getting your hands dirty — or can’t afford the time and expense of turning yourself into an expert — take a look at XTune, from the makers of XCache. It’s performance tuning wizards step you through the process of tuning your IIS environment, making expert recommendations along the way.

Tip 2: Secure your server with simple fixes

Sure people are going to attack sites, but you don’t have to be a sitting duck if you’re willing to make even a small effort. First off, don’t advertise the fact that you are running IIS by showing your HTTP server header. Remove or replace it using something like ServerMask — probably the best twenty-five bucks you’ll ever spend. You can go farther than this by removing unnecessary file extensions to further camouflage your server environment, and scanning request URLs for signs of exploits. There are number of commercial products that do user input scanning, and Microsoft offers a free tool called URLScan which does the job. URLScan runs in conjunction with IISLockDown, a standard security package which should probably be installed on every IIS server on the planet. These are simple fixes that could pay off big, so do them now.

Tip 1: Patch, patch, patch!

Okay, we in the IIS world do have to patch our systems and make hotfixes. However, as a former Solaris admin I had to do the same thing there, so I am not sure why this is a big surprise. You really need to keep up with the patches, Microsoft is of course the definitive source, but if you can also use the highly-regarded www.cert.org. Simply search on “IIS”.

Well there you have it: 10 tips for IIS admins to improve their servers. Some of the tips might become obsolete once IIS 6 is gold, but, for now at least, W2K and NT IIS admins should apply a few of these today and sleep a little better at night.