Thursday, June 29, 2006

Recursion

yes recursion ,thinking iam mad iam not .

Recussion are of two types:-
1.General Recursion .
2.TailEnd Recursion .

1.General Recursion :- This is the one in which the whole part of the function needs to be activate till the last function call:
// For the Factorial
int Generalrecusrion(int iVal)
{
if (iVal==0)
return 0;
else if (iVal==1) return 1;
else return iVal * Generalrecusrion(iVal-1);
}

2. Tail Recursion :-
The function will not be active bcoz the function call to the next recursion will take off and terminate the prev Function .
// For the Factorial
int Tailrecursion(int n, int a )
{
if (n < 0)
return 0;
else if (n == 0)
return 1;
else if (n == 1)
return a;
else return Tailrecursion(n - 1, n * a);
}
// For the harmonic Progression// 1 + 1/2 + 1/3 + 1/4+...
float Harmonic(float n ,float iii )
{
if (n < 0) return 0;
else if (n == 0) return 1;
else if (n == 1) return iii;
else {
float fVal = iii + float (1/n );
return Harmonic(n - 1, fVal );
}
}
Even the compiler will help us in optimizing the following code to more level.

Monday, June 26, 2006

Microsoft .NET Mania

I have started studying the .Net , it really hooked me .

Friday, June 23, 2006

Bad Week

This whole week was bad for me lets see wats there for me in this last day of the week .
I feel iam geting saturated , i need to move on ,YES i need to move on ,HUMM how i wish i knew how i could .

Wednesday, June 21, 2006

Calling delete this in the destructor

When you call delete this in the destructor of the coressponding class it goes into an recursion and an stack overflow hapens .

RULE:-
new :- calls the constructor
delete :- calls the destructor .
malloc,calloc, realloc :- nothing hapens only alloacation hapens
replacement new :- has to be used to call the coresponding constructor of the class allocated through malloc.

Monday, June 19, 2006

Customizing MessageBox

The different ways of customizing the messagebox are mentioned below :
1.MessageBoxEx
2.MessageBoxIndirect.
The third way is to write a hook for WH_CBT(Computer Based training ) and get the nCode value for HCBT_ACTIVATE ,This method is useful for many purpose like adding new controls on the messagebox.

Friday, June 09, 2006

Going on Holiday

Hi ,
Iam going on holiday for three days and iam gonna enjoy after one whole year ,So see you guys after 3days and thats on Monday.

Wednesday, June 07, 2006

Geting Xp Theme in MSDEV

Hi ,
Have you ever noticed that the msdev we are using is not having an XP theme by default ,so how to add theme to msdev .
Its simple if you search for manifest files in your xp system you get a long list of manifest files , copy one of them to the directory were msdev is residing and rename the file as msdev.exe.manifest and you can have an XP theme for your msdev.

This trick works for all the application may be i should say it as a shortcut rather than adding the masnifest file in the resource of the exe and writing code to load them .

Tuesday, June 06, 2006

Resource Hacker

Hi ,

As i was googling today i found an intresting tool called the ResourceHacker, using which we can see the resource used inside dll,exe etc .You can modify it and compile thereby inducing the changes to the coressponding module you can download it from the following site http://www.angusj.com/resourcehacker/ the following tool is made in delphi.
We can also open the exe in our VisualStudio by making the " OpenAs+ Resources ".
I usually use it to export or extract the images,bmp etc .

That all for today.

Monday, June 05, 2006

Hack a EditBox with just a ES_PASSWORD style set

This is the Workingcode for it

BOOL CALLBACK EnumWindowsProc(HWND hwnd, // handle to parent windowLPARAM lParam // application-defined value);

BOOL CALLBACK EnumChildProc1(HWND hwnd,LPARAM lParam );

//BN_CLICKED handler
void CTrwDlg::OnButton1() {
::EnumWindows (EnumWindowsProc,0);
}

BOOL CALLBACK EnumWindowsProc(HWND hwnd, // handle to parent windowLPARAM lParam // application-defined value)
{
::EnumChildWindows (hwnd,EnumChildProc1,0);
return TRUE;
}

BOOL CALLBACK EnumChildProc1(HWND hwnd, // handle to parent windowLPARAM lParam // application-defined value)
{
::SendMessage (hwnd,EM_SETPASSWORDCHAR,0,0);
HDC hDC = ::GetDC (hwnd);
::SendMessage (hwnd,WM_PAINT,WPARAM(hDC) ,0); // to create invalidation
return TRUE;
}

Sunday, June 04, 2006

Sorry For The Delay

Hi Guys ,
Iam sorry for the delay in posting the matertials in the blog , i was very much preoccupied with some office work and my home PC was dead , now any way its up and working , i had to replace the monitor.
SO LETS GET THE PARTY STARTED .