Posts

Showing posts from February, 2005

IT conversation

http://www.itconversations.com/ Listener-supported audio programs, interviews and important events.

Viewing STL container in VS.NET 2003 watch windows

For a vector, you can start with these examples: "v._Myfirst" -> the first element "v._Myfirst, 10" -> 10 elements "v._Myfirst[1]" -> the element at index 1 "v.size()" -> number of elements For a list: "l._Mysize" -> number of elements "l._Myhead->_Next->_Myval" -> the first element "l._Myhead->_Next->_Next->_Myval" -> the second element "l._Myhead->_Next->_Next->_Next->_Myval" -> the third element, etc.

MFC Windows Message Processing - yield control

(Refering Programming Ms Visual C++ fifth edition - Ms Press) A workaround which works with both Win16 and Win32. Yield control once in a while by inserting the following instructions inside the time consuming function: MSG message; if (::PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) { ::TranslateMessage(&message); ::DispatchMessage(&message); } The PeekMessage function works like GetMessage , except that it returns immediately even if no message has arrived for your program. In that case, the function keeps on processing. If there is a message, however, the function pauses, the handler is called, and the function starts up again after the handler exits. E.g. void CMyClass::LengthyFunction() { MSG message; volatile int nTemp; for (m_nCount = 0; m_nCount for (nTemp = 0; nTemp // processing here. } if (::PeekMessage(&message, NULL, 0, 0, PM_REMOVE)) { ::TranslateMessage(&message); ::D...

Recover HDD after format

SystemRescueCd is an improvement of the gentoo live cd. It aims to provide an high quality bootable CD-Rom, with all system utilities that can be required to repair your system. http://sourceforge.net/projects/systemrescuecd There seems to be some utilities for FAT16/32 ( dosfstools [ ^ ]) and NTSF ( NTSFProgs [ ^ ]) included on the bootable linux CD There is also this tool R-Studio 2.0 [ ^ ] http://www.grc.com/sr/spinrite.htm [ ^ ]

Merging menu items for MDI container and MDI child forms

Say, if MDI container has a "About" Menu that the MDI child forms need to merge with. Set the MDI container menu in such manner. (In the InitializeComponent or change it using the IDE property window) this.menuItemAbout.Index = 1; this.menuItemAbout.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] { this.menuItemMainHelp}); this.menuItemAbout.MergeOrder = 1; this.menuItemAbout.MergeType = System.Windows.Forms.MenuMerge.MergeItems; this.menuItemAbout.Text = "Help"; this.menuItemMainHelp.Index = 0; this.menuItemMainHelp.MergeOrder = 1000; //this need to be larger than the child so that it appear //underneath the child menu items. this.menuItemMainHelp.Text = ...

Integrate help to .NET apps

Help.ShowPopup(this, "Enter Phone number here. Valid input characters are 0-9,space,'-','(', and ')'", Cursor.Position); //this will show an unconventional popup message box on the cursor position. Nicer than standard //messagebox Can also use the HelpProvider object HelpString properties to achieve the same effect but seems to have less control over. when drag a System.Windows.Forms.HelpProvider to a form. All the controls in the form will have the option HelpNavigator on myHelpProvider avail in the properties windows. For directing the F1 key press to index of the CHM. The helpprovider need to set HelpNamespace to "Help\VB.chm" (to chm appropriate). Then, in the needed control, HelpNavigator on myHelpProvider option, choose keyword index, and then key in the helpkeyword. This will automatically map the F1 key press or the "?" help button button to be directed to the CHM.

To sort using ArrayList.Sort()

Quoted from http://www.codeproject.com/useritems/sortingarraylist.asp public struct MyStrcuture { public Int32 iID; public String sName; } In order to be able to sort elements contained in an ArrayList , we have to define the CompareTo method of the IComparable interface, and then use the ArrayList's .Sort() method. This -of course- means that our structure should be inherited from that interface .. and so we'll do! public struct MyStrcuture : IComparable { public Int32 iID; public String sName; public Int32 CompareTo(Object obj) { MyStrcuture tmpObj = (MyStrcuture) obj; return ( this .sName.CompareTo(tmpObj.sName)); } } This would allow the array list to be sorted by just calling MyArrayList.Sort() provided the arraylist containing the item with the above structure. Useful sorting algorithms in C#. URL

Useful C++ code snippet (ascii to unicode)

void ascii2unicode(LPCTSTR strin, wchar_t* strout) { int len = strlen(strin); for(int i=0; i<len; i++) strout[i]=(wchar_t)strin[i]; strout[i] = 0; }

ImpLib32

http://www.geocities.com/SiliconValley/5806/implib32.htm ImpLib32 is a small utility which creates an import library for Visual C++ 2.x/4.x/5.x from an existing DLL. What is Implib32: Implib32 creates 32 bit import libraries for the use with Microsoft Visual C++ 2.x/4.x/5.x. Back in the good old days of Windows 3.x, Microsoft supplied a tool called IMPLIB. This tool was able to create a import library for a given DLL. After creating this library, you linked it to your program in order to call functions contained in the DLL. Unfortunatly, there is no equivalent to IMPLIB for Win32. Microsoft suggests on the Win32 Knowledge Base that you should use DUMPBIN to create a file which lists all exports of a DLL, reformat this file to .DEF-file using a text editor and then use LIB to create a import library from the .DEF-file. Implib32 does all this work for you: It invokes DUMPBIN and LIB and creates an import library! Note: ImpLib32 can't process...

Open Source Licensing Quick Guide

(quoted from http://zooko.com/license_quick_ref.html ) QUICK REFERENCE FOR CHOOSING A FREE SOFTWARE LICENSE, version 1.4.5.0, 2004-08-31 License | hackers like to accept code under it | | combine with proprietary and redistribute | | | combine with GPL'ed code and redistribute | | | | must share source of redistributed version | | | | | must include patent license with contribution | | | | | | | | | | | | v v v v v v --- --- --- --- --- --- permissive Y Y Y N N GNU LGPL Y2 Y1 Y Y Y GNU GPL ?2 N Y Y Y Mozilla PL 1.1 Y2 Y N3 Y Y (FAQ on MPL URL ) Excel doc which explains various licensing stuff http://www.mass.gov/itd/legal/quickrefchart.xls