|
Hi,
Create a new class derived from CWnd (your custom control). Declare your member variables (LEDs, Bitmaps, Edit controls,...). Use Create member function of member variables to create, size and justify them.
You can also use some handy utility for managing layout of child controls.
It's better that you create a dll as host of your custom control and use it in your application whenever you want.
A. Riazi
|
|
|
|
|
I have to apply a message handler for my Button (on_click) or something.
so I need a new ID which is applied to the new created Button. How can I do this
without doing it statically in the resource file?
greetings, Ingmar
|
|
|
|
|
Hello All,
I have written a driver which retreives the RTC value. I have used WRITE_UCHAR_PORT and READ_UCHAR_PORT macros. They operate on port 0x70 and 0x71 respectively to get the RTC value. They are run in a loop of 12. I get the value properly if run once. But when the values are retreived continously , over a time it gives all the values as ff. i.e. the date and time value which are retreved are all 'F's. The driver does not give any error. I.e. the driver is correctly binded and everything seems to be properly executiong apart from the fact that the values reteived for date and time is all 'F's. Can it be the case that RTC is busy updating some registers (at the time of giving error values - all F's ) so invalid values are retreived by the driver.
The driver is able to retrieve correct values for once or twice but only during a long run it gives problem. Could there be some problem in the hardware or am I missing something.
I am running the driver in Windows XP home OS and on Intel chipsets.
Can you please suggest as to what could be the problem.
Any help would be highly appreciated.
Thanks and regards,
Sandeep
|
|
|
|
|
Sandeep Shetty wrote:
Can it be the case that RTC is busy updating some registers
Anything is possible when dealing with PC hardware.
But I'd more worry about the possible implications of you emitting e.g.
out 0x70, 2 /* minute */
then your driver is interrupted by Windows itself wanting to access the RTC (which I presume it assumes it has exclusive access of), emitting e.g.
out 0x70, 0
out 0x71, 0 /* set seconds to zero */
and voila, your driver fails. For all I know, the RTC might even have deadlocked at this point.
Coming to think of it, is even 0x70-0x73 shared? (you have successfully claimed the address range, by e.g. IoAssignResources?)
|
|
|
|
|
Hello!!
Thank you for your answer.
But I am not using statements like "out 0x70, 2". I am using the macro WRITE_UCHAR_PORT and READ_UCHAR_PORT and pass 0x70 and 0x71 as parameters.
I do not think we have to claim addresses and the macro does require on its own.
I cam across a small article at site http://www.pcprofile.com/timepiece.HTM#overview
There is some problem in chip set INtel 810. Can you please on this?
Hope I am on the right track.
Please give your suggestions.
regards,Sandeep
|
|
|
|
|
Sandeep Shetty wrote:
But I am not using statements like "out 0x70, 2".
I understand that. I just used that as syntax to keep down on the writing.
I do not think we have to claim addresses
Is think really a good word to use when dealing with stuff like this?
But it also seems you have to check whether an update is in progress before trying to read anything. Have a look at this for example.
I still don't think you are allowed to do this without either disabling interrupts (which I'm quite certain you may not on NT) or claiming the resources you access - even more so since the built-in "System CMOS/real time clock" device already have claimed this I/O range.
|
|
|
|
|
Friends, at some point of my program execution, i want the memory consumption of my program (same value that we read from task manager). Any API solution that also work for Win 98 do tell me please ?
|
|
|
|
|
Shah Shehpori wrote:
i want the memory consumption of my program (same value that we read from task manager). Any API solution that also work for Win 98 do tell me please ?
Since when did Win98 get a Task Manager?
Whatever. Try GetProcessWorkingSetSize .
|
|
|
|
|
REQUIREMENT:: Application shud be sized to full monitor irrespective of the monitor size and current system resolution.
My APPLICATION:: Application is having four formviews in tabcontrol with many controls(AcitveX Lables and Buttons) on each forma view. My application is developed for best view in 15 inch and 800*600 resolution.
MY PROBLEM: i have written code to catch when resolution ic changed.and accorind to the new resolution m changing the each contols's client rect and moving the corresponding control to new client react. but reafreshing si becoming problem and some controls are painting over other controls.
adi narayana
|
|
|
|
|
I have a dialog based application with a group of 4 radiobuttons. I want one of 4 radiobutton to be active when form loads ?
So can i do it ??;P
|
|
|
|
|
i can't undesratnd what you want...but I guess you need to place the code for radiobuttons so as to make them active...when form loads..in OnInitDialog function...if it is a dialog based application..just put the code in InitInstance() that should do the work you want..
cheers
Himanshu
|
|
|
|
|
I'll just expand what Himanshu said :
First get a control to the button you want to active. Two ways to do it :
1.Add a control with the class wizard, let's name it m_FirstButton.
In the CMyDlg::OnInitDialog()
BOOL CMyDlg::OnInitDialog()
{
...stuff...
m_FirstButton.SetCheck(TRUE);
...stuff...
}
_or_
2.Get a control to it through the Index (IDC_...), like following :
BOOL CMyDlg::OnInitDialog()
{
...stuff...
CButton *firstbutton=(CButton*)GetDlgItem(IDC_FIRSTRADIOBUTTON);
firstbutton->SetCheck(TRUE);
...stuff...
}
And as Himanshu said, you can do some calculation also in the InitInstance (like processing the command line) if this is needed to chose which of your radiobutton should be active at startup.
~RaGE();
|
|
|
|
|
GetDlgItem is giving errors
CButton *firstbutton=(CButton*)GetDlgItem(IDC_FIRSTRADIOBUTTON);firstbutton->SetCheck(TRUE);
GetDlgItem' : function does not take 1 parameters
Error executing cl.exe.
|
|
|
|
|
Use a control-variable. You can make those with the Wizard, exactly like the Member variable, but you have to set the type to 'Control'.
Now, you have all options that the respective MFC-class offers.
Especially handy as your dialog grows.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
Just set your radio button member variable in dialog constructor. e.g.:
if your member variable is m_Options:
CDummyDlg::CDummyDlg()
{
m_Options = 0;
}
A. Riazi
|
|
|
|
|
Good Riazi that really worked !!!
|
|
|
|
|
Sorry, i had not thought that you could have used the value associated to your button (i prefer using controls). Riazi got me on this one.
~RaGE();
|
|
|
|
|
Hi all,
I want to delete the history, cache entries and cookies craeted by internet thru programming..Is there any good tutorial or can anyone guide me so as how to do it...Any thoughts and ideas are most welcome..
Thanks in advance..
Himanshu
|
|
|
|
|
Just call some shell function to retrieve folders of Temprory Internet Files and also History then delete all of files on it!
For more information on how to retrieve shell folders path, view my article: System Information[^].
A. Riazi
|
|
|
|
|
|
thanks buddy..this was what I was looking for....thans a lot..
cheers
Himanshu
|
|
|
|
|
i am using CALG_MD5 to encrypt/decrypt a string. it encryts the text but in decrypting it shows error "NTE_BAD_DATA" on lastblock other blocks are decrypted well. How can i resolve this erro.
Note:
final parameter is set to true for last block.
|
|
|
|
|
Zaid Ansari wrote:
am using CALG_MD5 to encrypt/decrypt a string
Are you sure you are using MD5 for encyrption/decryption? MD5 is an hash-algorithm so its result can't be "decrypted". Search the net for information about hashing vs. encrypting/decrypting. You could use algorithms like AES or DES for your needs.
--
karl
|
|
|
|
|
thanks karl,
i know that MD5 is a one way hash but i dont have any experiance in VC can u please tell me if i am making any mistake in this code.
to //code
if(!CryptAcquireContext(&hCryptProv, NULL, NULL, PROV_RSA_FULL,0))
{
}
// Create a hash object.
if(!CryptCreateHash(hCryptProv, CALG_MD5, 0, 0, &hHash))
{
strcat(strErrorMessage, "Error executing CryptCreateHash");
return NULL;
}
if(!CryptHashData(hHash, (BYTE *)password, strlen(password), 0))
{
strcat(strErrorMessage, "Error executing CryptHashData");
return NULL;
}
// Derive a session key from the hash object.
if(!CryptDeriveKey(hCryptProv, CONST_ENCRYPT_ALGORITHM, hHash, 0, &hKey))
{
strcat(strErrorMessage, "Error executing CryptDeriveKey");
return NULL;
}
// Destroy the hash object.
CryptDestroyHash(hHash);
hHash = 0;
// Determine number of bytes to encrypt at a time.
// This must be a multiple of CONST_ENCRYPT_BLOCK_SIZE.
// CONST_ENCRYPT_BLOCK_SIZE is set by a #define statement.
dwBlockLen = 10 - 10 % CONST_ENCRYPT_BLOCK_SIZE;
// get data block as close to 1000 bytes as possible making sure it's a multiple of ENCRYPT_BLOCK_SIZE
// Determine the block size. If a block cipher is used,
// it must have room for an extra block.
if(CONST_ENCRYPT_BLOCK_SIZE > 1)
dwBufferLen = dwBlockLen + CONST_ENCRYPT_BLOCK_SIZE;
else
dwBufferLen = dwBlockLen;
// Allocate memory.
pbBuffer = (BYTE *)malloc(dwBufferLen);
BYTE *pAllBlocks = NULL;
BYTE *pPreviousBlocks = NULL;
bool fMoreDataExists = true;
DWORD dwIndex = 0;
DWORD dwLength;
DWORD dwLengthOfEncryptedData;
DWORD dwAllBlocksLength, dwPreviousBlocksLength;
// Make way through data one block at a time. Find out how big
// each encrypted string will be, allocate memory for it, and save
// in array.
do
{
// get next block of clear text data
GetBYTEDataBlockFromString(dwIndex, pClearTextString, dwBlockLen, pbBuffer, dwLength);
// check if more data exists after current block
if (dwIndex >= strlen(pClearTextString))
fMoreDataExists = false;
// encrypt current data block
dwLengthOfEncryptedData = dwLength;
if(!CryptEncrypt(hKey, 0, !fMoreDataExists, 0, pbBuffer, &dwLengthOfEncryptedData, dwBufferLen))
{
fout<<"Error Occured in CryptEncrypt";
}
if (pAllBlocks)
delete [] pAllBlocks;
if (pPreviousBlocks)
dwAllBlocksLength = dwPreviousBlocksLength + dwLengthOfEncryptedData;
else
dwAllBlocksLength = dwLengthOfEncryptedData;
pAllBlocks = new BYTE[dwAllBlocksLength];
if (!pAllBlocks)
{
if(pbBuffer)
free(pbBuffer);
if (pPreviousBlocks)
delete [] pPreviousBlocks;
strcat(strErrorMessage, "Unable to allocate memory for pAllBlocks");
FreeAllCryptHandles(hKey, hHash, hCryptProv);
return NULL;
}
// copy all encrypted data to pAllBlocks
if (pPreviousBlocks)
{
CopyBYTEData(dwPreviousBlocksLength, pPreviousBlocks, pAllBlocks, dwAllBlocksLength, 0);
CopyBYTEData(dwLengthOfEncryptedData, pbBuffer, pAllBlocks, dwAllBlocksLength, dwPreviousBlocksLength);
delete [] pPreviousBlocks;
}
else
CopyBYTEData(dwLengthOfEncryptedData, pbBuffer, pAllBlocks, dwAllBlocksLength, 0);
if (fMoreDataExists)
{ // save previous data blocks for next iteration of this do loop
dwPreviousBlocksLength = dwAllBlocksLength;
pPreviousBlocks = new BYTE[dwPreviousBlocksLength];
if (!pPreviousBlocks)
{
if(pbBuffer)
free(pbBuffer);
if (pAllBlocks)
delete [] pAllBlocks;
strcat(strErrorMessage, "Unable to allocate memory for pPreviousBlocks");
FreeAllCryptHandles(hKey, hHash, hCryptProv);
return NULL;
}
else
CopyBYTEData(dwAllBlocksLength, pAllBlocks, pPreviousBlocks, dwPreviousBlocksLength, 0);
}
}
while(fMoreDataExists);
|
|
|
|
|
can any one send me code for encryption/decryption string using DES.
|
|
|
|