Tuesday, August 25, 2009

Visual c++

Mouse Programming

Handler functions are mainly used for handling messages .Messages are of two types Client and non-client messages .When double clciking ,draging from windows title bar Non Client message is generated.

Client message
---------------
Message Handler Sent When
-------------------------------------------------------------
WM_LBUTTONDOWN OnLButtonDown Left button is pressed
WM_LBUTTONUP OnLButtonUp Left button is released
WM_LBUTTONDBCLCICK OnLButtonDblClk Left button double clicked

WM_MBUTTONDOWN OnMButtonDown Middle button is pressed
WM_MBUTTONUP OnMButtonUp Middle button is released
WM_MBUTTONDBCLICK OnMButtonDblClk Middle button double clicked

WM_RBUTTONDOWN OnRButtonDown Right button is pressed
WM_RBUTTONUP OnRButtonUp Right button is released
WM_RBUTTONDBCLCICK OnRButtonDblClk Right button double clicked

WM_MUSEMOVE OnMouseMove Mouse is Moved Over Window's client area


Non-Client message
---------------
Message Handler Sent When
-------------------------------------------------------------
WM_NCLBUTTONDOWN OnNcLButtonDown Left button is pressed
WM_NCLBUTTONUP OnNcLButtonUp Left button is released
WM_NCLBUTTONDBCLCICK OnNcLButtonDblClk Left button double clicked

WM_NCMBUTTONDOWN OnNcMButtonDown Middle button is pressed
WM_NCMBUTTONUP OnNcMButtonUp Middle button is released
WM_NCMBUTTONDBCLICK OnNcMButtonDblClk Middle button double clicked

WM_NCRBUTTONDOWN OnNcRButtonDown Right button is pressed
WM_NCRBUTTONUP OnNcRButtonUp Right button is released
WM_NCRBUTTONDBCLCICK OnNcRButtonDblClk Right button double clicked

WM_NCMUSEMOVE OnNcMouseMove Mouse is Moved Over Window's client area


Code to check wether mouse is present or not ,if present display the count of buttons.


#include
class mousestatus:public CFrameWnd
{
public:
mousestatus()
{
Create (0,"Mouse status");
}
void checkmouse()
{
int status,count;
char message;
status=::GetSystemMetric(SM_MOUSEPRESENT);
if (status==1)
{
MessageBox("Mouse present","User");
Count=::GetSystemMetric(SM_CMMOUSEBUTTONS);
Sprintf(Message,"%d",Count);
MessageBox(message,"Number of buttons");
}
else
{
MessageBox("Mouse absent","User");
}
}//end of checkmouse
};

class MS : public CWinApp
{
public:
int InitInstance()
{
mousestatus *ptrms =new mousestatus ( );
ptrms -> ShowWindow(1);
ptrms -> checkmouse();
m_pMainWnd =ptrms;
return(1);
}
};
MS myobject;


Program to swap mouse buttons


#include
class Swapmouse:public CFrameWnd
{
public:
Swapmouse()
{
Create (0,"Swapping Mouse button");
}
void swap()
{
int status;
status=::GetSystemMetric(SM_SWAPBUTTON);
if (status==1)
{
MessageBox("Mouse Buttons are swapped","User");
}
else
{
MessageBox("Mouse Not Swapped","User");
}
}//end of checkmouse
};

class Swpms : public CWinApp
{
public:
int InitInstance()
{
Swpms *ptrms =new swpms ( );
ptrms -> ShowWindow(1);
ptrms -> Swap();
m_pMainWnd =ptrswpms;
return(1);
}
};
Swpms myobject;


File Programming
-----------------
Storing of application data into computer drives is called Serialisation and viceversa is known as deserialisation.

For serialisation there are two MFC class CArchive and CFile


CArchive is given in Serialize named function as argument .In CArchive class there are two functions for read and write ; IsLoading and IsStoring.

Eg : Void CFileDemo :: Serialize ( CArchive &obj)

For object Serialization what all steps are followed
----------------------------------------------------
Macro statements like DECLARE_SERIAL and IMPLEMENT_SERAIL are to be defined in class declaration and class implementation.In DECLARE_SERAIL macro one argument should be passed ;the agrument is the name of the class for which serialization should be attained.
In IMPLEMENT_SERAIL macro three arguments should be passed ,first one is same we used in DECLARE_SERAIL macro second one is super base class of our class and third one is version number of our file.

//Class declaration


class CFileClass::public CObject
{
DECLARE_SERIAL(CFileclass)
public :
Virtual void Serialize (CArchive obj);
CFileClass();
virtual `CFileClass();
};

// class implementation

#include "stdafx.h"
#include "FileClass.h"
#ifdef_DEBUG
#undef THIS_FILE
static char THIS_FILE[]=FILE_;
#define new DEBUG_NEW
#end if;
IMPLEMENT_SERAIL(CFileClass,CObject,1)


// Construction

CFileClass:: CFileClass()
{

//add code
}

// distruction

CFileClass::`CFileClass()
{
//add code
}

Visual Basic

Shell function to call executable files from your application.In this function two arguments are accepted one is program name and other is window state of program (1- for normal mode ie: VbNormal ; VbMaximized,VbMinimized)

Private Sub Form_Load( )
Dim r as variant
r =Shell ("Calc.exe,1);
End Sub


AppActivate Statement


Send Keys

Values to submitted in sendkeys

Shift ------ +
Control ----- ^
Alt ------ %
Backspace ---- {BACKSPACE}
Break ---- {BREAK}
Caps ---- {CAPSLOCK}
Clear -------- {CLEAR}
Del --------- {DELETE}
DownArrow ---- {DOWN}
End ---- {END}
Enter -------- {ENTER}
Esc ---------- {ESCAPE}
Help --------- {HELP}
etc.................................

Five arguments for MessageBox

MessageBox(Message,style,heading,helpfile,helpcontextid);

C Sharp

Web.cs
--------
using System;
class webclass
{ public static void Main ()
{
Console.WriteLine("Content_Type :text/html|\n");
Console.WriteLine("First web program ");
}
}

After compiling this web.exe file will be generated .Copy this file into apache\cgi-bin named folder.


Then create a html file

web1.html
----------






<html>
<form action =http://127.0.0.1/cgi-bin/web.exe>
<input type=submit value=Display>
</form>
</html>


then after starting apache

cmd>apache (command to start apache web server)

Then in browser type this hht://127.0.0.1/web1.html and press enter your first C# program got executed.


Thread synchronization
----------------------

Thread synchronization is attained by lock .In common language Runtime (CLR) there are three different types Thread synchronization .

Inter Lock class, Monitor class, Lock statement

In Inter lock class there are there are two threads Increment and Decrement

Interlocked.Increment( )

Thursday, July 9, 2009

WINDOWS Shortcut Key

• Windows: Display the Start menu
• Windows + D: Minimize or restore all windows
• Windows + E: Display Windows Explorer
• Windows + F: Display Search for files
• Windows + Ctrl + F: Display Search for computer
• Windows + F1: Display Help and Support Center
• Windows + R: Display Run dialog box
• Windows + break: Display System Properties dialog box
• Windows + shift + M: Undo minimize all windows
• Windows + U: Open Utility Manager

Monday, July 6, 2009

Registry

Registry is a database which stores the s/w and hardware information of a computer.This resides(contains) in the file user.dat and system.dat from windows 95 version onwards ; before that there was no concept of registry apart from this all informations are stored in the following files Config.sys,autoexec.bat,system.ini,control.ini,win.ini. For editing the registry files windows supplies 'Regedit' named tool .Registry details can be exported and imported .Exported registry files with be .reg extension ;its a text based file.

REGEDIT4
[HKEY_LOCAL_MACHINE\SYSTEM\Setup]
"setup type"=dword.00000000
"cmdline"=setup_new setup
"System Perfix"=hex:c5,0b,00,00,40,36,02

In registry the hyphone symbol '-' is used for commenting.

Based upon the information registry is divided into 6 sections.

HKEY_CLASSES_ROOT
--------------------
This section contains the information of different type of file extensions,OLE related details,Drag & drop features ,Windows shortcut ,User interface etc.


HKEY_CURRENT_USER
-----------------
Contains the information of login user detials and their desktop and start menu settings.

HKEY_LOCAL_MACHINE
-------------------
This stores information about hardware and s/w details .There are many subkeys in this section

Config :
--------
Contains information about assemblence of different hardwares .

Enum :
------
It contains all details about device drivers in the PC.

Hardware :
---------
It contains information about Serial Port ,Processors,Floating Point Processers etc

Network :
--------
Network related details .

Software :
---------
Information about What all Softwares installed in the PC.

System :
--------
It deals with information about the device drivers which is uesd in the Pcand its assembly details.

HKEY_USERS
----------
Contains the information of all user detials and their desktop and start menu settings.


HKEY_CURRENT_CONFIG

-------------------
Details about Hardware Configuration.

HKEY_DYN_DATA
--------------


In registry there are 5 different datatypes

1) REG_BINARY : This datatypes are used for mainly storing hardware related informations .Its value is shhown in hexadecimal format.
2) REG_DWORD : This is 4 byte in length ,consist of boolean data 0 and 1 .Its value can be seen in hexadecimal or in decimal format .
3) REG_SZ : String datatype.
4) REG_EXPAND_SZ :
5) REG_MULTI_SZ :