|
Using the cipher is working great, I've implemented a quick test using Rijndael. Now I'm trying to get a large sample w/o repeats. I'm up to 250K so far. I'll just need to keep playing with the keys and I'll get there.
The drawback with a hash is security - once someone figured out the algorithm then all PINs would be subject. While the same is true with a cipher, the cipher give a larger "randomness".
Thanks again for the help, you have given me just what I needed.
David
|
|
|
|
|
Anyone have a recommendation for an OLE DB or ADO class to access MS SQL Server? Was using Carlos Antollini v2.07, but now I need one without MFC.
|
|
|
|
|
Hi friends!!!
I've created a simple program, the main function of my program starts another thread and itself remain busy doing other things. Now at some point, my main program wants to "terminate" the thread "immediately" no matter whatever thread was doing. The problem is that my thread function uses lots of new/delete and regularly calls other functions that allocates/deallocates memory from the heap. I feal that if main program interrupt this thread in between using TerminateThread(), there may be memory leakages.
But i want my main program to exit this thread "immediately" and "gracefully"..what do you suggest ???
|
|
|
|
|
CreateEvent, SetEvent, WaitForSingleObject
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Ted Ferenc wrote:
CreateEvent, SetEvent, WaitForSingleObject
No, this is not my problem. My thread is running and its parent thread want to terminate it "immediately". For this purpose, the parent thread can use TerminateThread() API. But the child thread might have allocated memory from the heap that it had not deallocated and parent thread terminating this child in such a manner, can cause memory leaks
|
|
|
|
|
For a graceful shutdown you do NOT want to use TerminateThread. TerminateThread should only be used as a last resort. You should Create an "kill" event in the thread and set it in the main application and test it every once and a while in the thread.
John
|
|
|
|
|
As John says create a kill event, you won't just get memory leaks, but you could get an exception as well!
Just raise a kill event and use WaitForSingleObject on the thread handle with, say a 5 second timeout, only a very last resort use TerminateThread()
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Theres a CP project :
http://www.codeproject.com/docking/ToolbarWithCombo.asp
which has either a regular combobox being created in the toolbar or a CSmartComboBox (derived from CComboBox).
However
BOOL CreateComboBox(class CComboBox& comboBox, UINT nIndex, UINT nID, int nWidth, int nDropHeight);
has class CComboBox in it. Can I pass in a SmartComboBox variable instead? Or do I have to modify the function to:
BOOL CreateComboBox(class CSmartComboBox& comboBox, UINT nIndex, UINT nID, int nWidth, int nDropHeight);
?
The second question is : why the word class in class CComboBox& comboBox ??? Cant it just be:
CreateComboBox(CComboBox& comboBox,...) withgout the word class?
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
...has class CComboBox in it. Can I pass in a SmartComboBox variable instead?
Yes, so long as SmartComboBox is derived from CComboBox.
ns wrote:
Cant it just be:
CreateComboBox(CComboBox& comboBox,...) withgout the word class?
Yes.
cheers,
-B
|
|
|
|
|
MAny thanks! That helps!
Appreciate your help,
ns
|
|
|
|
|
Got a quick question the following code works in the OnInitDialog function of CPropertySheet, however the same code does nothing in the OnInitDialog function of the CPropertyPage?
// CPropertySheet OnInitDialog code
CRect rect;
CPropertyPage *pPage = GetActivePage();
pPage->GetWindowRect(&rect);
ScreenToClient(&rect);
rect.right += 50;
rect.bottom += 50;
pPage->MoveWindow(&rect);
// CPropertyPage OnInitDialog code
CRect rect;
GetWindowRect(&rect);
ScreenToClient(&rect);
rect.right += 50;
rect.bottom += 50;
MoveWindow(&rect);
Now i know it shouldn't matter to me cause i got it working in the sheet, but it's driving me crazy knowing that this should work in each individual page as well!! Help me understand this craziness
|
|
|
|
|
WHy do they have tbbs_separator in the following in the CP article:
SetButtonInfo (0, ID_EDIT_R, <code>TBBS_SEPARATOR </code>, <code>cxChar * 8</code>);
GetItemRect (0, &rect);
http://www.codeproject.com/docking/spnsld.asp
FRom MSDN:
void SetButtonInfo(
int nIndex,
UINT nID,
UINT nStyle,
int <code>iImage </code>);
THe fourth parameter is puzzling me too.....they are two different things...cxChar * 8
looks like a width, not an image index....
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
cxChar * 8
is the width of the separator
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
TBBS_SEPARATOR indicates the use of an separator. Then it's size is widened to have place for inserting other elements. This is the common method for placing custom items like combo boxes etc. on a toolbar.
|
|
|
|
|
Ah! Thank you for clearing that!!!! I was really puzzled on this one!!
Appreciate your help,
ns
|
|
|
|
|
The release exe runs fine. The debug one crashes on:
CBKDoc * pDoc = (CBKDoc *)GetDocument();
pDoc->dynaMenuMap.clear();
where:
typedef std::set <CString> SubMenuSet;
typedef std::map <CString, SubMenuSet> DynaMenuMap;
;
THe very first time I entere the function, DynaMenuMap dynaMenuMap is empty, so perhaps clearing an empty map is a no-no? The release exe doesnt care....
How do I sidestep this?
Appreciate your help,
ns
|
|
|
|
|
int size = pDoc->dynaMenuMap.size();
if (pDoc->dynaMenuMap.size())
{
pDoc->dynaMenuMap.clear();
}
THe map starts out empty, and I clear only if its not empty....but now my debug version is saying size = some large neg number. All I have in the code mentioning the map untilk this point is DynaMenuMap dynaMenuMap in the .h file...
Appreciate your help,
ns
|
|
|
|
|
Are you certain it's crashing on the clear() call?
(It may be the case that pDoc is NULL, though I don't see why that would work in release but not in debug)
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
pDoc is not null . The size of the empty map is weird: some larege neg number. If I get rid of the clear(), it still crashes , but on the line in red!!!!!! If I put the clear(0 in it crashes on the clear()!!!!!!!!!!!
int size = pDoc->dynaMenuMap.size();
if (pDoc->dynaMenuMap.size())
{
pDoc->dynaMenuMap.clear();
}
<code>SubMenuSet & subMenuCat = pDoc->dynaMenuMap["Cat</code>"];
//crashes here if I comment out the clear()
size = -125......
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
The size of the empty map is weird: some larege neg number
No;P Its just unsigned int .
You can use dynaMenuMap::size_type as type for your size results, but in the current implementation, this is just typedef ed to unsigned int .
Personally, I use size_t , AFAIK defined by Microsoft to be unsigned int .
Less typing as 'unsigned int ', and conveyes a meaning.
<edit> Something must be rotten with your doc-pointer.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
I guess its the pointer...but what can I do?
In a view class where I generate the map:
unsigned int size = pDoc->dynaMenuMap.size();
with unsigned, I still get a non zero number --- large positive!!! Theres been no map created so far!!! So it should be zero!
But in the doc class whose member the map is:
BOOL CBKDoc::OnNewDocument()
{
if (!CDocument::OnNewDocument())
return FALSE;
CString abc;
abc.Format(" size of map in doc is %d", dynaMenuMap.size());
AfxMessageBox(abc);
return TRUE;
} retiurns size of zero!!! As it should...
Appreciate your help,
ns
|
|
|
|
|
Hi ns, most likely pDoc is not a valid pointer: check if other members of this object hold consistent values.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
What he said...
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Pardon me? I don't get what you mean.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Whoops, I guess that is a colloquialism.
I basically said I agree with you on all counts.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|