HICON hIcon;
hIcon = ExtractIcon( AfxGetApp()->m_hInstance, "C:\\WINDOWS\\system32\\calc.exe", 0 );
SetIcon( hIcon, FALSE );
//Do at destroy of dialog
//To avoid Resourse Leak
//DestroyIcon(hIcon);
HICON hIcon;
hIcon = ExtractIcon( AfxGetApp()->m_hInstance, "C:\\WINDOWS\\system32\\calc.exe", 0 );
SetIcon( hIcon, FALSE );
//Do at destroy of dialog
//To avoid Resourse Leak
//DestroyIcon(hIcon);
#pragma comment (lib, "advapi32.lib")
#pragma comment (lib, "user32.lib")
#include <vector>
#include <algorithm>
using namespace std;
// Add this header files
/*
Template function to Remove Duplicates
From a vector */
template <class T>
void RemoveDuplicates(vector<T> &vecContents)
{
vector<T> ::iterator vItr;
sort(vecContents.begin(),vecContents.end());
vItr=unique(vecContents.begin(),vecContents.end());
if(vItr!=vecContents.end())
vecContents.erase(vItr,vecContents.end());
}
//Usage Example 1
vector<CString> vNames;
vNames.push_back("John");
vNames.push_back("Victor");
vNames.push_back("Nancy");
vNames.push_back("William");
vNames.push_back("Nancy");
RemoveDuplicates(vNames);
//Usage Example 2
vector<int> vNos;
vNos.push_back(1);
vNos.push_back(1);
vNos.push_back(4);
RemoveDuplicates(vNos);
/*
string and CSting Find, mid, left funtion
Example and comparison.
*/
#include <string> //string
using namespace std; //string
string strSample,strLeft,strRight,str;
size_t pos=0;
strSample="This is my sample";
pos=strSample.find("my");
if(pos!=string::npos)
{
strLeft=strSample.substr(0,pos);
//This is
strRight=strSample.substr(pos);
//my sample
str=strSample.substr(pos+strlen("my"));
// sample
}
CString csSample,csLeft,csRight,csStr;
int nPos=-1;
csSample="This is my sample";
if( (nPos=csSample.Find("my"))>-1)
{
csLeft=csSample.Left(nPos);
//This is
csRight=csSample.Mid(nPos);
//my sample
csStr=csSample.Mid(nPos+_tcslen("my"));
// sample
}
//DWORD to CString
DWORD dwNumber = 1234;
CString csNumber;
csNumber.Format("%lu", dwNumber);
//CString to DWORD
DWORD dwNO;
CString csDwNumber="1234";
dwNO= atol((char*)(LPCTSTR)csDwNumber);
/*Error 122 error LNK2019: unresolved external symbol "wchar_t * __stdcall _com_util::ConvertStringToBSTR(char const *)" (?ConvertStringToBSTR@_com_util@@YGPA_WPBD@Z
) referenced in function
"public: __thiscall _variant_t::_variant_t(char const *)"
(??0_variant_t@@QAE@PBD@Z)
Error 121 error LNK2019: unresolved external symbol "char * __stdcall _com_util::ConvertBSTRToString(wchar_t *)" (?ConvertBSTRToString@_com_util@@YGPADPA_W@Z)
referenced in function "public: char const * __thiscall _bstr_t::Data_t::GetString(void)const " (?GetString@Data_t@_bstr_t@@QBEPBDXZ)
*/
/*
Some Times when we are using COM lt will give above Linker Errors
To fix this add the following header file and library
*/
#include <comutil.h>
# pragma comment(lib, "comsuppwd.lib")
// Set a window position as a topmost window.
::SetWindowPos( GetSafeHwnd(),
HWND_TOPMOST,
0, 0, 0, 0,
SWP_NOMOVE | SWP_NOREDRAW | SWP_NOSIZE );