|
Hi,
why do we need to use CreateCompatibleDC to create a DC even though we can create a Dc using CreateDC?
Regards,
KDevloper
|
|
|
|
|
Performance!!!
BitBlt between compatible DC as many TIMES faster than otherwise.
|
|
|
|
|
They are two different functions that create different kinds of DCs.
You don't "need" to use CreateCompatibleDC. You use it when you need
a memory DC compatible with an existing DC.
It's not the same as CreateDC.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
how i can use the code available in code project to my project..means suppose i need a different style buttons(whose .h and .cpp i download from net)and i want to use that perticular style button in my project then waht is the setting for that
thanks a lot
|
|
|
|
|
|
if u can't then don't ....
|
|
|
|
|
Now excuse me sir!
Have a think about it before you ask such foolish and useless questions.
What bloody button code? Which bloody article?
What was the response you got when you asked how to use the code on the page you downloaded it from? Is there not an example application that may be obtained from the article page?
Like you said - if you can't ask a reasonable & sensible question, then just don't!
|
|
|
|
|
I am using COXTreeCtrl from the Ultimate Toolbox in my code. I have a parent tree and under it, 4000 child items with unique IDs. When I click on the "ID" column for this tree, it is calling a CALLBCK procedure to sort these 4000 items.
But the real problem is THE TIME IT IS TAKING to sort 4000 items -- More than 5 Min.
Is there any way I could sort the column, which will take less time to sort??
|
|
|
|
|
Does it draw the tree during the sort process? I mean, do you see as items get swapped? Becuase you can speed up things a lot if you disable the repainting of the control while the process is running. You can try using SetRedraw(FALSE) just before you begin the sort and SetRedraw(TRUE) and RedrawWindow(NULL), after it. I hope that can help some.
|
|
|
|
|
No, the items are not getting swapped. I think it will draw the tree items only after completing the sorting process. And drawing of 4000 items is taking approximately 10 Sec of time.
I also tried SetRedraw() function while sorting but could not see any improvement.
While debugging, I observed that for sorting 4000 items, it is entering into callback procedure >100000 times.
Is there any way to sort the list using other than callback method??
|
|
|
|
|
Hi all,
I've got an error once I include <local> herder file
<br />
#include <locale><br />
The error message is,
<br />
c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\include\xlocmon(249): error C2061: syntax error : identifier '_DebugHeapTag'<br />
Can someone tell me what's going on.
I appreciate your help all the time...
CodingLover
|
|
|
|
|
I believe this means that you are linking with both the Release and Debug C Run-Time Libraries[^]. Check your project settings for each project in the solution and choose one or the other but not both.
Best Wishes,
-David Delaune
|
|
|
|
|
Hi All
how can i open a application through shortcut key?My application is running in hidden mode.Plz help me
|
|
|
|
|
You mean you are able to intercept the shortcut key and now you want to execute your application. then you can use ShellExecute(/*parameters*/) or CreateProcess(/*parameters*/) depending upon your needs
Some things seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
|
i have View in that view a line is there(say link)
how to set the color of a lik to grey color
|
|
|
|
|
Not sure I understand your question, but if the red, green, and blue components are a color are the same, you get a shade of grey.
RGB (80, 80, 80) is dark grey, and RGB (200, 200, 200) is light grey.
|
|
|
|
|
|
What's your question exactly ? You simply want the tabs or how to put the images in the tabs ? If you want to show some tabs, you have to use a CTabCtrl for that purpose.
For the images, I'm not sure but you could try to add an image list to your tabcontrol (see here[^]) and supply the image index when adding a new item (see here[^]). You'll have to supply TCIF_IMAGE for the nMask. I don't know if that works because I never tried it but you could check it and see what it does.
|
|
|
|
|
Hello member..
Do you mean a TabbedToolBar in which tabs you' going to put buttons ??
Something like :
http://www.bcgsoft.com/featuretour/tour26.htm[^]
If that is the case, then check if you cabn find this in the MFC Feature Pack since BCGControlBar has been integrated into MFC.
|
|
|
|
|
Thank you,hINTModuleState! Is there any free source code for the tab view(/dialog) like 3ds max?
|
|
|
|
|
|
Hi all,
I have this c# decrypting code:
public static string Decrypt(string cipherString, bool useHashing)
{
byte[] keyArray;
byte[] toEncryptArray = Convert.FromBase64String(cipherString);
System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
if (useHashing)
{
MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
hashmd5.Clear();
}
else
keyArray = UTF8Encoding.UTF8.GetBytes(key);
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Key = keyArray;
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = tdes.CreateDecryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
tdes.Clear();
return UTF8Encoding.UTF8.GetString(resultArray);
}
public static string Encrypt(string toEncrypt, bool useHashing)
{
byte[] keyArray;
byte[] toEncryptArray = UTF8Encoding.UTF8.GetBytes(toEncrypt);
System.Configuration.AppSettingsReader settingsReader = new AppSettingsReader();
string key = (string)settingsReader.GetValue("SecurityKey", typeof(String));
if (useHashing)
{
MD5CryptoServiceProvider hashmd5 = new MD5CryptoServiceProvider();
keyArray = hashmd5.ComputeHash(UTF8Encoding.UTF8.GetBytes(key));
hashmd5.Clear();
}
else
keyArray = UTF8Encoding.UTF8.GetBytes(key);
TripleDESCryptoServiceProvider tdes = new TripleDESCryptoServiceProvider();
tdes.Key = keyArray;
tdes.Mode = CipherMode.ECB;
tdes.Padding = PaddingMode.PKCS7;
ICryptoTransform cTransform = tdes.CreateEncryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
tdes.Clear();
return Convert.ToBase64String(resultArray, 0, resultArray.Length);
}
No Randor advised me to do some thing inorder to translate it to c++ according to his advise by using Microsoft Cryptographic Service Providers I came up with this thanks to sources and samples, my question is why does cryptDecrypt give me zero as a result. The "Zed5OmjUWs8=" string is the encrypted value of "test" I am getting a result far from that any advice?
Thanks,
Jayjay
void ThreeDESdecrypt(unsigned char *cyphertext,unsigned long ctlen,unsigned char *passwd,unsigned long pwlen,unsigned char *plaintext,unsigned long *ptlen)
{
HCRYPTPROV hProv = NULL;
HCRYPTHASH hHash = NULL;
HCRYPTKEY hKey = NULL;
DWORD dMode;
BYTE * value2 = {0};
DWORD lul_len, lul_buflen, lul_skip, lul_pflags;
bool lb_rtn;
BLOB lblob_data;
TCHAR* convertedStr;
BYTE * key1 = NULL;
std::string value = "Zed5OmjUWs8=";
lul_len = strlen(value.c_str());
lul_buflen = (lul_len * 2);
BOOL result = CryptStringToBinary(value.c_str(), lul_len, CRYPT_STRING_BASE64, NULL, &lul_buflen, &lul_skip, NULL);
key1 = new BYTE [ lul_buflen ];
memset ( key1, 0 , lul_buflen );
result = CryptStringToBinary(value.c_str(), lul_len, CRYPT_STRING_BASE64, key1, &lul_buflen, &lul_skip, NULL);
hProv = InitializeCrypt();
result = CryptCreateHash(hProv,CALG_MD5,0,0,&hHash);
result = CryptHashData(hHash, passwd, pwlen, 0);
result = CryptDeriveKey(hProv,CALG_3DES,hHash,0,&hKey);
dMode = CRYPT_MODE_ECB;
DWORD dwLastError = GetLastError();
result = CryptSetKeyParam(hKey, PKCS5_PADDING, reinterpret_cast<const BYTE *>(&dMode), 0);
memcpy(plaintext,key1,*ptlen);
result = CryptDecrypt(hKey,hHash,1,0,plaintext,&lul_buflen);
*ptlen=ctlen;
CryptBinaryToString(plaintext, lul_len, CRYPT_STRING_BASE64, NULL, &lul_buflen);
convertedStr = new TCHAR [lul_buflen];
memset( convertedStr, 0 , lul_buflen );
CryptBinaryToString(plaintext, lul_len, CRYPT_STRING_BASE64, convertedStr, &lul_buflen);
result = CryptDestroyKey(hKey);
result = CryptDestroyHash(hHash);
result = CryptReleaseContext(hProv,0);
}
|
|
|
|
|
Hello again JayJay,
I have written a sample for you. It doesn't get any better than this.
#include "stdafx.h"
#include <windows.h>
#include <Wincrypt.h>
#include <assert.h>
#pragma comment(lib, "crypt32.lib")
LPTSTR Base64Decode(LPCTSTR lpData, DWORD dwSize)
{
DWORD dwResult = 0;
if(CryptStringToBinary(lpData, dwSize, CRYPT_STRING_BASE64, NULL, &dwResult,NULL,NULL))
{
LPTSTR lpszBase64Decoded = new TCHAR[dwResult+(sizeof(TCHAR) * 2)];
memset(lpszBase64Decoded,0,dwResult);
if(CryptStringToBinary(lpData, dwSize, CRYPT_STRING_BASE64,(BYTE *)lpszBase64Decoded, &dwResult,NULL,NULL))
{
*(LPWORD)(lpszBase64Decoded + (dwResult / sizeof(TCHAR))) = 0;
return lpszBase64Decoded;
}
}
return NULL;
}
LPTSTR Base64Encode(LPCBYTE lpData, DWORD dwSize, BOOL bStripCRLF)
{
DWORD dwResult = 0;
if(CryptBinaryToString(lpData, dwSize, CRYPT_STRING_BASE64, NULL, &dwResult))
{
LPTSTR lpszBase64 = new TCHAR[dwResult];
if(CryptBinaryToString(lpData, dwSize, CRYPT_STRING_BASE64, lpszBase64, &dwResult))
{
TCHAR pByteLF = *(LPWORD)(lpszBase64 + dwResult -1);
TCHAR pByteCR = *(LPWORD)(lpszBase64 + dwResult -2);
if(pByteCR == 0x0D && pByteLF == 0x0A)
{
*(LPWORD)(lpszBase64 + dwResult -2) = 0;
}
return lpszBase64;
}
}
return NULL;
}
DWORD TripleDESencrypt(TCHAR *plaintext,DWORD ptlen,TCHAR *passwd,DWORD pwlen,TCHAR *cyphertext,DWORD *ctlen)
{
HCRYPTPROV hProv;
HCRYPTHASH hHash;
HCRYPTKEY hKey;
DWORD dwSizeNeeded =0;
DWORD sz =0;
CryptAcquireContext(&hProv,NULL,MS_STRONG_PROV,PROV_RSA_FULL,0);
CryptCreateHash(hProv,CALG_MD5,0,0,&hHash);
CryptHashData(hHash,(BYTE*)passwd,pwlen,0);
CryptDeriveKey(hProv,CALG_3DES,hHash,0,&hKey);
if(NULL != cyphertext && 0 != ptlen)
{
memcpy(cyphertext,plaintext,ptlen);
sz=*ctlen;
*ctlen=ptlen;
}
if(FALSE == CryptEncrypt(hKey,NULL,1,0,(BYTE *)cyphertext,ctlen,sz))
{
DWORD dwError = GetLastError();
if(ERROR_MORE_DATA == dwError)
{
dwSizeNeeded = *ctlen * sizeof(TCHAR);
}
}
CryptDestroyKey(hKey);
CryptDestroyHash(hHash);
CryptReleaseContext(hProv,0);
return dwSizeNeeded;
}
DWORD TripleDESdecrypt(TCHAR *cyphertext,DWORD ctlen,TCHAR *passwd,DWORD pwlen,TCHAR *plaintext,DWORD *ptlen)
{
HCRYPTPROV hProv;
HCRYPTHASH hHash;
HCRYPTKEY hKey;
DWORD dwSizeNeeded =0;
CryptAcquireContext(&hProv,NULL,MS_STRONG_PROV,PROV_RSA_FULL,0);
CryptCreateHash(hProv,CALG_MD5,0,0,&hHash);
CryptHashData(hHash,(BYTE *)passwd,pwlen,0);
CryptDeriveKey(hProv,CALG_3DES,hHash,0,&hKey);
if(*ptlen >= ctlen)
{
memcpy(plaintext,cyphertext,*ptlen);
CryptDecrypt(hKey,NULL,1,0,(BYTE *)plaintext,&ctlen);
*ptlen=ctlen;
}
else
{
dwSizeNeeded = ctlen * sizeof(TCHAR);
}
CryptDestroyKey(hKey);
CryptDestroyHash(hHash);
CryptReleaseContext(hProv,0);
return dwSizeNeeded;
}
int main()
{
HCRYPTPROV hCryptProv;
HCRYPTHASH hHash = 0;
HCRYPTKEY hKey = 0;
TCHAR szKey[] = _T("key");
TCHAR szUnencrypted[MAX_PATH * sizeof(TCHAR)] = _T("test");
TCHAR * pszEncrypted = NULL;
TCHAR * pszBase64 = NULL;
TCHAR * pszBase64Decoded = NULL;
TCHAR * psz3DESDecoded = NULL;
pszBase64 = Base64Encode((LPCBYTE)&szUnencrypted,_tcslen(szUnencrypted) * sizeof(TCHAR),FALSE);
DWORD dwEncryptedSize = _tcslen(pszBase64);
DWORD dwSizeNeeded = TripleDESencrypt(pszBase64,MAX_PATH * sizeof(TCHAR),szKey,_tcslen(szKey),pszBase64,&dwEncryptedSize);
pszEncrypted = new TCHAR[dwSizeNeeded];
TripleDESencrypt(pszBase64,MAX_PATH * sizeof(TCHAR),szKey,_tcslen(szKey),pszEncrypted,&dwEncryptedSize);
DWORD dwUnEncryptedSize = NULL;
dwSizeNeeded = TripleDESdecrypt(pszEncrypted,dwSizeNeeded,szKey,_tcslen(szKey),szUnencrypted,&dwUnEncryptedSize);
psz3DESDecoded = new TCHAR[dwSizeNeeded];
TripleDESdecrypt(pszEncrypted,dwSizeNeeded,szKey,_tcslen(szKey),psz3DESDecoded,&dwSizeNeeded);
pszBase64Decoded = Base64Decode(psz3DESDecoded,_tcslen(psz3DESDecoded) * sizeof(TCHAR));
MessageBox(NULL,0 == _tcscmp(pszBase64Decoded,szUnencrypted) ? _T("Strings Match"):_T("Strings do NOT Match"),_T(""),MB_OK);
delete [] pszBase64;
delete [] pszBase64Decoded;
delete [] pszEncrypted;
return 0;
}
I have tested it in both Unicode and ANSI and both seem to function as desired. You may want to clean my code up a bit.
Hope it helps,
-David Delaune
|
|
|
|
|
Hi David,
You have been a great help so far, by the way i have tested your code it works however I still need to do some tweaking as I can't convert "Zed5OmjUWs8=" to "test" and also what is this for:
ICryptoTransform cTransform = tdes.CreateDecryptor();
byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length);
Thanks,
Jayjay
|
|
|
|
|