WeSeeTips moving to new Home!

31 01 2010

Dears,

Its been a very long time, I know. But rejoice! WeSeeTips is moving to its new home. Due to several personal and technical reasons, the migration was a bit delayed. Anyway, We will be back soon in new style and new tips to rock you. Keep your fingers crossed!

For WeSeeTips,
Jijo.

Advertisements




How to generate XML Schema from XML file?

22 11 2009


Ever wondered how to generate XML schema from XML file?
Indeed, a lot of 3ed party tools can do it for you. But as usual, any easy way?


You can use Visual Studio IDE itself to generate XSD from XML file. Follow the steps.

1) Open the XML file in Visual Studio IDE.
2) Take View > Other Windows > Command Window.
3) Now type and execute command – XML.CreateSchema
4) See, the schema is generated.


A hidden pearl in VS IDE. Isn’t it?


Targeted Audience – Beginners.





Search for Symbols in Visual Studio more Easily

15 11 2009


Ever tried VisualAssist? Yes man, Its a killer product. The feature that I like most is its Symbol Search. You can specify words and it will list symbols that contain those words. Its very useful if you have a vague idea about the function name that you’re searching for. Have a look at the following screenshot.

Search3FindInVisualStudio

But is there any PoorMan’s SearchSymbols without VisualAssist?


Did you forget about the hidden gem in VisualStudio find window? Yes, the Regular Expressions. You can use .* to do the same search done by VisualAssist. For instance, to do the above search, search for Show.*Msg. Have a look at following screenshots.

Search4

Now look at the results. Cool! isn’t it?

Search5


Quite easy. nah? BTW, did you try to kill that bug. 😉


Targeted Audience – Beginners.





C++ Function Pointers Simplified!

18 10 2009

Background information
Pointer is a variable which holds the address of another variable. Where, function pointer is again a variable which holds the address of a function.

If you think pointers are evil, then function pointers must be Satan for you. 🙂 Well, is there any easy way to create function pointers from function prototype? Indeed, there is. Its the “BAT” technique. Never heard about it before? No problem. Its invented by me just now. After watching BatMan series from cartoon network.

FunctionPointers


The “BAT” technique is this –

  1. Put Bracket or parenthesis around the function name.
  2. Add Asterisk or star in-front of function name.
  3. Now Typedef it to create a new datatype. Means change the function name to new datatype name and add typedef infront of it.
  4. Now you can use the new function pointer datatype like ordinary variables.

For instance, Assume we want to make a function pointer for function – DWORD MyFunction( int a, int b).

1) Bracket
DWORD (MyFunction)( int a, int b);

2) Asterisk
DWORD (*MyFunction)( int a, int b);

3) Typedef
typedef DWORD (*MyFunctionPtr)( int a, int b);

Ah! you have created a function pointer – MyFunctionPtr for function type – ‘DWORD MyFunction( int a, int b)’
Now you can use it like any other variable in your code. For instance, just see the following code snippet with real world usage of function pointers.

// Callback function for progress notification.
bool NotifyProgress( int Percentage )
{
 // Display progress and return true to continue.
 return true;
}

// typedef function pointer.
typedef bool (*NotifyProgressPtr)( int Percentage );

// DVD Burning function with pointer to NotifyProgress
// to update progress.
void BurnDVD( NotifyProgressPtr FnPtr )
{
 for( int Progress = 0; Progress <= 100; ++Progress )
 {
 // Call the function.
 (*FnPtr)(Progress);
 }
}

// Main function.
int _tmain(int argc, _TCHAR* argv[])
{
 // Ummm... Burn one DVD.
 BurnDVD( NotifyProgress );
 return 0;
}


Function pointers are not that much evil. Isn’t it? 😉


Targeted Audience – Beginners.





How to Set Dialog as TopMost Window?

11 10 2009


I always wondered about popularity of Winamp. It has rich custom drawn UI, which made it stand out of the crowd. Did you noticed its “Always on top” feature and wondered about how its implemented? Its time to reveal the secret – How winamp implemented that feature – Staying at the top?

SetTopMostWindow


You can use – SetWindowPos() with HWND_TOPMOST flag. Have a look at the code snippet.

void CRabbitDlg::OnSetTopmost()
{
    // Set window position to topmost window.
    ::SetWindowPos( GetSafeHwnd(),
                    HWND_TOPMOST,
                    0, 0, 0, 0,
                    SWP_NOMOVE | SWP_NOREDRAW | SWP_NOSIZE );
}


Single line of code. But wowing feature. isn’t it?


Targeted Audience – Beginners.





Microsoft MVP for Visual C++ for 2009-2010

5 10 2009

Dear All,

With great pleasure, I would like to inform you that – with god’s grace, I’ve been awarded as Microsoft MVP (Most Valuable Professional) for Visual C++. At this moment I would like to thank all my readers for supporting me and making this happen! Please go through my MVP profile.

MicrosoftMvp

I really thank Microsoft for this wonderful MVP award and I really love their products. I really feel great about being a part of it. Well, I owe all this achievements to my fellow readers who motivated me to post more and more and atlast ended in being an MVP. So hearty thanks to you all, once again!

Best Regards,
Jijo. [Humble VC++ enthusiasit from Next Door]





How to Watch this Pointer – The Wizards Way!

30 07 2009


How to watch the this pointer? Just add ‘this’ to watch window. Everyone does like that. Isn’t it? But how Visual C++ wizards watch ‘this’ pointer? 😉

thiswizardway


The secret is, visual C++ compiler passes this pointer via ECX register. So add (ClassName*)(@ECX) to watch window will give you this pointer. Have a look at the screenshot.

thiswizardway2


Interesting, the internals of Visual C++. Isn’t it?


Targeted Audiance – Intermediate.