|
whatever@whatever.com wrote: I guess such a feature is not supported in VC6
This[^] should given an idea. Drag and drop between listboxes is not intrinsically supported but you can provide this support through coding.
|
|
|
|
|
See this article by Paul DiLascia, from his "C++ Q&A" column in the October 2004 issue of MSDN: "Create Client Windows, Drag and Drop Between Listboxes" at http://msdn.microsoft.com/msdnmag/issues/04/10/CQA/[^]
It explains the coding needed to obtain drag and drop between different list boxes in the same application.
Mike
|
|
|
|
|
Thanks! U made my dae. Also thanks to all others who had given their comments.
|
|
|
|
|
Hi
All
I want to design resource in japanese, marathi font how can i set font of resource to japanese by using coding. Is there any API for setting font of resources. I don't want to set font from control panel because it is meaningless because by doing this user have to set font manually which affects fonts of all application in Win XP.
Atool
|
|
|
|
|
M. Atul wrote: marathi font how can i set font of resource to japanese by using coding.
You need to provide the same resource for multiple languages. You can choose a language for a resource in the resource editor.
|
|
|
|
|
To manualy cheange the font, I find the simplest way is to open the .rc file in a text editor and chage the "system 10" for each window to whatever font you want to use.
In my experience, I write many English/Chinese apps, the best way is to distribte the font with your app. When your program starts, create the font and enumerate all the child windows setting the new font for each.
|
|
|
|
|
I would go to Microsoft’s web-sight and look up internationalization, there is a book that was presented in the VC 6.0 version of the MSDN; which has since been updated. In general the idea is to have a DLL supply all the strings required in you application, instead of building it in as an application resource, and then just loading the appropriate DLL, based on then national language, at runtime.
Another method I have used in the passed (non-unicode) was to copy the multi-byte string from another document and just paste it between “” in the resource file. Also remember that files, such as text files, can be included in the resource file as an external source.
INTP
"Program testing can be used to show the presence of bugs, but never to show their absence."Edsger Dijkstra
|
|
|
|
|
Hi,
I have done "report generation" in vc++(MFC).After generate the report,which
can take the print on printer(HP officejet printer) ok....till now nothing else
but when i use different type of printers like compaq,canon,Epson,etc there is
araise some problems like print preview region problem and page size problem.
For example,
1.When i take print(A4 size) on HP officejet printer ,no problem
2.when i take print(A4 size) on other printers like Epson..., only partial of data will be shown.
How can i solve the print preview region problem.Currently i am using visual studio 2005.
Thanks in advance...
|
|
|
|
|
I saw so many articles in codeproject all are working under _MBCS , but wHEN define UNICODE,_UNICODE the encrypt and decypt is not working.
plz Help me out
|
|
|
|
|
kiranin wrote: the encrypt and decypt
What is encrypt and decrypt that you are talking about? Are you taking care of string handling accordingly when in UNICODE build?
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
am storing usernames and passwords in a file. I want encrypt password and store it in file. When after retrive the password i want to decrypt and compare. This is not working when UNICODE defined application.
|
|
|
|
|
Can you show a relevant code snippet?
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
BOOL EncryptString(LPTSTR szPassword,LPTSTR szEncryptPwd,LPTSTR szKey)
{
BOOL bResult = TRUE;
HKEY hRegKey = NULL;
HCRYPTPROV hProv = NULL;
HCRYPTKEY hKey = NULL;
HCRYPTKEY hXchgKey = NULL;
HCRYPTHASH hHash = NULL;
DWORD dwLength;
if (CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0))
{
if (CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash))
{
dwLength = sizeof(TCHAR)*_tcslen(szKey);
if (CryptHashData(hHash, (BYTE *)szKey, dwLength, 0))
{
if (CryptDeriveKey(hProv, MY_ENCRYPT, hHash, CRYPT_EXPORTABLE, &hKey))
{
dwLength = sizeof(TCHAR)*_tcslen(szPassword);
BYTE *pbBuffer = (BYTE *)malloc(dwLength);
if (pbBuffer != NULL)
{
memcpy(pbBuffer, szPassword, dwLength);
if (CryptEncrypt(hKey, 0, TRUE, 0, pbBuffer, &dwLength, dwLength))
{
memcpy(szEncryptPwd, pbBuffer, dwLength);
}
else
{
bResult = FALSE;
}
free(pbBuffer);
}
else
{
bResult = FALSE;
}
CryptDestroyKey(hKey);
}
else
{
bResult = FALSE;
}
}
else
{
bResult = FALSE;
}
CryptDestroyHash(hHash);
}
else
{
bResult = FALSE;
}
CryptReleaseContext(hProv, 0);
}
return bResult;
}
BOOL DecryptString(LPTSTR szEncryptPwd,LPTSTR szPassword,LPTSTR szKey)
{
BOOL bResult = TRUE;
HCRYPTPROV hProv = NULL;
HCRYPTKEY hKey = NULL;
HCRYPTKEY hXchgKey = NULL;
HCRYPTHASH hHash = NULL;
TCHAR szPasswordTemp[32] = _T("");
DWORD dwLength;
if (CryptAcquireContext(&hProv, NULL, NULL, PROV_RSA_FULL, 0))
{
if (CryptCreateHash(hProv, CALG_MD5, 0, 0, &hHash))
{
dwLength = sizeof(TCHAR)*_tcslen(szKey);
if (CryptHashData(hHash, (BYTE *)szKey, dwLength, 0))
{
if (CryptDeriveKey(
hProv, MY_ENCRYPT, hHash, CRYPT_EXPORTABLE, &hKey))
{
dwLength = sizeof(TCHAR)*_tcslen(szEncryptPwd);
_tcscpy(szPasswordTemp,szEncryptPwd);
if (!CryptDecrypt(
hKey, 0, TRUE, 0, (BYTE *)szPasswordTemp, &dwLength))
bResult = FALSE;
CryptDestroyKey(hKey);
_tcscpy(szPassword,szPasswordTemp);
}
else
{
bResult = FALSE;
}
}
else
{
bResult = FALSE;
}
CryptDestroyHash(hHash);
}
else
{
bResult = FALSE;
}
CryptReleaseContext(hProv, 0);
}
return bResult;
}
These are the functions am using to encrypt and decrypt. These are working fine when i define _MBCS, but if UNICODE deifned the functions are not working
|
|
|
|
|
I asked you for relevant[^] code!
And from what I could make from this code, it should work with unicode since TCHAR , _tcslen , etc are being used. Are you just adding _UNICODE or are you replacing _MBCS with _UNICODE ?
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
i replaced _MBCS with _UNICODE ,UNICODE.
These two functions are failing to encrypt and decrypt even though THCAR ,_tcslen , etc used, thats why i posted a question here...
|
|
|
|
|
No no, I didn't mean that. There are plenty of external dependencies. For instance, the following: CryptAcquireContext , CryptCreateHash , CryptHashData , etc.
So I do not have a clue of what is going on. Did you try debugging to analyse what is going on in the program?
PS: Replacing _MBCS with _UNICODE is sufficient. _UNICODE implicitly defines UNICODE and so you do not need to define UNICODE separately.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
yeah i debugged
memcpy(pbBuffer, szPassword, dwLength);
if (CryptEncrypt(hKey, 0, TRUE, 0, pbBuffer, &dwLength, dwLength))
{
memcpy(szEncryptPwd, pbBuffer, dwLength);
may be CryptEncrypt function or CryptDeriveKey these two functions
and/or memcpy() function and length these are the main concerns
|
|
|
|
|
Use wmemcpy while working with Unicode strings. memcpy is for working with non-unicode strings. Sorry that I missed it earlier.
Nobody can give you wiser advice than yourself. - Cicero
ப்ரம்மா
|
|
|
|
|
You'll need to go through the code and make SURE that all your "dwLength" (and similar) variables
are both initialized and used properly.
The Cryptxxx() APIs only deal in bytes - Unicode doesn't change that. Make sure you are using
counts calculated in TCHARs or in bytes where applicable.
wmemcpy doesn't apply here either
Mark
|
|
|
|
|
How is this going to work:
dwLength = sizeof(TCHAR)*_tcslen(szEncryptPwd);
If szEncryptPwd is encrypted there's not necessarily an ASCIIZ at the end so _tcslen()
won't work. You need a way to store the encrypted length somewhere or use a pre-defined length.
*EDIT* The encrypt side looks ok but the decrypt isn't going to work as coded.
Also, not all encryption algorithms produce the same number of encrypted bytes as unencrypted
source bytes, but you've assumed that in your encryption function. Be careful
You can check the size required with an extra call to CryptEncrypt() with the pbData param set to
NULL.
Mark
|
|
|
|
|
There's more
BOOL EncryptString(LPTSTR szPassword,LPTSTR szEncryptPwd,LPTSTR szKey)
In addition to my last reply...
szEncryptPwd should be a BYTE *, not a TCHAR *. The bytes are encrypted so can no longer be used
as a character string. You could maybe append a WORD value to the beginning of the bufer
to store the encrypted length for use in the decrypt function (just one scheme).
Mark
|
|
|
|
|
I want to safely remove the usb drive programatically.How can i do this.
Thanks.
|
|
|
|
|
|
Okay... this question feels out of place in this forum, but it doesn't fit in OS/SysAdmin as that is more of the usage side - not the programming side. Given my driver is in C++, I figure this is as good a place as any.
That out of the way, I found a bug (handle leak) in cmd.exe:
I'm writing a device driver that I want to be able to write stuff to via the command prompt redirection. For example, typing
echo Hello there > \\.\MyDevice
Should send the string "Hello there" to the MyDevice device.
Unfortunately it does not work. Cmd opens the handle to my device, but never writes to it or closes it! So until I exit cmd, my driver cannot be unloaded.
Some debugging indicates that cmd opens my device with CreateFile, which succeeds, then calls GetFileType, and since it is not a file or network file, it cancels the redirection operation, forgetting to close the original handle.
So now for the real question:
Does anybody happen to know how GetFileType is implemented in kernel mode (ie. if there's a field of the FILE_OBJECT I can set to get GetFileType to work properly? Or is there any way to register something like lpt1 which is a device that cmd can write to?
Thanks,
Mike
|
|
|
|
|
Hi i am writing a dll to proses msg files (sender,subject, etc). I managed to get right down to the IMessage Properties but i can't figure out how to return the value from my DLL.. This is my First c++ project (I know right in to the deep end MAPI and all, but it is better than MsgBox("hello world") )
Note the return value neads to be VB safe
CODE (See bit commented STUCK HERE)
/--------------------------------------------------------------------------------
#include <malloc.h>
#include "stdafx.h"
#include <mapi.h>
#include <mapix.h>
#include <mapiutil.h>
#include <ole2.h>
#include <imessage.h>
#define TEST_EXPORTS
#include "SSFILEDLL.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
switch (ul_reason_for_call)
{
case DLL_PROCESS_ATTACH:
case DLL_THREAD_ATTACH:
case DLL_THREAD_DETACH:
case DLL_PROCESS_DETACH:
break;
}
return TRUE;
}
SSFILEDLL_API BSTR __stdcall Test()
{
HRESULT hr;
BSTR Message;
hr = MAPIInitialize(NULL);
if (FAILED(hr))
return "False";
hr = OleInitialize(NULL);
if (FAILED(hr))
return "False";
//get storage from msg file
LPSTORAGE pStorage= NULL;
hr = StgOpenStorage(L"C:\\Test\\2005-1~4.MSG",
NULL,
STGM_READWRITE | STGM_TRANSACTED | STGM_SHARE_EXCLUSIVE,
NULL,
0,
&pStorage);
if (FAILED(hr))
return "False";
//Alloc memory
LPMALLOC pMalloc = MAPIGetDefaultMalloc();
//open a IMessage session
LPMSGSESS pMsgSession = NULL;
hr = OpenIMsgSession (pMalloc, 0 , &pMsgSession);
if (FAILED(hr))
return "False";
//open an IMessage on the IStorage object
LPMESSAGE pSourceMsg = NULL;
hr = OpenIMsgOnIStg(pMsgSession,
MAPIAllocateBuffer,
MAPIAllocateMore,
MAPIFreeBuffer,
pMalloc,
NULL,
pStorage,
NULL,
0,0,&pSourceMsg);
if (FAILED(hr))
return "False";
//ok can we get to the properties
SizedSPropTagArray(1, _attrs_) =
{
1,
{
PR_SUBJECT
}
};
LPSPropAttrArray lpAttributes = NULL;
hr = GetAttribIMsgOnIStg(
pSourceMsg,
(LPSPropTagArray)&_attrs_,
&lpAttributes
);
if (FAILED(hr))
{
return "False";
}
else
{
//STUCK HERE
//lpAttributes[0].cValues; should be the subject
//so how do i convert this to a BSTR (the way I have retrned data in the Past)
return Message;
MAPIFreeBuffer(lpAttributes);
}
//------------------------------------
if (pSourceMsg)
pSourceMsg->Release();
if (pMsgSession)
CloseIMsgSession(pMsgSession);
if (pStorage)
pStorage->Release();
MAPIUninitialize();
}
/--------------------------------------------------------------------------------
Many thnaks
|
|
|
|
|