|
This how I would do the allocation into CMap.
CMap<int, int, void*, void*> myMap;
m_pClassXYZ = new ClassXYZ;
m_pClassXYZ->Create(NULL, NULL, WS_CHILD, CRect(0, 0, 0, 0), this, nClsID, NULL);
p_vPtr = (void*)m_pClassXYZ;
myMap.SetAt(n, p_vPtr);
The deallocation would be done as follows -
int nKey;
void* pValue;
POSITION pos = myMap.GetStartPosition();
while (pos)
{
myMap.GetNextAssoc(&pos, &nKey, &pValue);
myMap.RemoveKey(nKey);
m_pClassXYZ = (ClassXYZ*)pValue;
delete m_pClassXYZ;
}
|
|
|
|
|
Superman, you came to the rescue. Your reply cleared out all of those pesky client blocks. Thanks. I do have some normal blocks left, but I will start another thread to address them.
Barry
BTW - I too love work; I can lie down next to it all day long. 
|
|
|
|
|
|
You say you are using DLLs. Is the memory allocated in one module and deleted in another? You have to keep the allocation and deletion of objects in the same module.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
My mistake. I was refering to the header files MS supplies that allow the memory leak detail in the output pane. The project does not have any DLL's as of this stage in the writing. Again, sorry for misleading you.
Thanks,
Barry
|
|
|
|
|
void CaDlg::OnBnClickedBrefreshdevices()
{
m_ctlStatus.SetString(_T("Not Functional"));
UpdateData(FALSE);
unsigned int field0 = 0, field1 = 0, field2 = 0, field3 = 0;
CString ips = _T("");
char a[4] = "";
int t=0,c=0;
for(field0 = 192; field0 <= 192; field0++)
{
for(field1 = 168; field1 <= 168; field1++)
{
for(field2 = 0; field2 <= 255; field2++)
{
for(field3 = 0; field3 <= 255; field3++)
{
_itoa_s(field0, a, 4, 10);
ips += a;
ips += '.';
_itoa_s(field1, a, 4, 10);
ips += a;
ips += '.';
_itoa_s(field2, a, 4, 10);
ips += a;
ips += '.';
_itoa_s(field3, a, 4, 10);
ips += a;
t = LCDevices.InsertItem(c, ips);
c++;
LCDevices.SetItemText(c, 1, _T("Testing"));
ips = _T("");
}
}
}
}
}
In this code I am getting a bug when the value of t reaches 9. When InsertItem(c, ips); increases the
value to 10 (ten) it becomes 2 (i.e. 10 is treated as binary nos. 1 0).
Why is it so?
the integer c is not treated as binary no.
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
Manmohan29 wrote: _itoa_s(field0, a, 4, 10);
ips += a;
You could change this to:
ips = a; and eliminate the "reset" at the bottom of the loop.
Manmohan29 wrote: LCDevices.SetItemText(c, 1, _T("Testing"));
This should probably be:
LCDevices.SetItemText(t, 1, _T("Testing"));
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I did what you told but
values after inserting a breakpoint after
c++;
ips "192.168.0.9"
t 9
c 10
ips "192.168.0.10"
t 2
c 11
the problem is still there.
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
I'm not sure what you are asking or showing. When you call InsertItem() , it will return the index of the item that was added. This index is used in subsequent calls to SetItemText() . If you have anything other than that, your code will not work correctly.
Feel free to show the updated code.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
void CaDlg::OnBnClickedBrefreshdevices()
{
m_ctlStatus.SetString(_T("Not Functional"));
UpdateData(FALSE);
unsigned int field0 = 0, field1 = 0, field2 = 0, field3 = 0;
CString ips = _T("");
char a[4] = "";
int t=0,c=0;
for(field0 = 192; field0 <= 192; field0++)
{
for(field1 = 168; field1 <= 168; field1++)
{
for(field2 = 0; field2 <= 255; field2++)
{
for(field3 = 0; field3 <= 255; field3++)
{
_itoa_s(field0, a, 4, 10);
ips = a;
ips += '.';
_itoa_s(field1, a, 4, 10);
ips += a;
ips += '.';
_itoa_s(field2, a, 4, 10);
ips += a;
ips += '.';
_itoa_s(field3, a, 4, 10);
ips += a;
t = LCDevices.InsertItem(c, ips);
c++;
LCDevices.SetItemText(t, 1, _T("Testing"));
}
}
}
}
}
I am using index in subsequent calls to SetItemText().
but still when t = 10 then it becomes t = 2 (binary 10).
one more thing the counting is like this:-
ips "192.168.0.0" t = 0
.
.
.
ips "192.168.0.9" t = 9
ips "192.168.0.10" t = 2
.
.
.
ips "192.168.0.20" t = 13
.
.
.
ips "192.168.0.99" t = 99
ips "192.168.0.100" t = 3
ips "192.168.0.101" t = 4
ips "192.168.0.102" t = 5
Future Lies in Present.
Manmohan Bishnoi
|
|
|
|
|
While not related to your problem (at least I don't think so), you could shorten it down a bit to:
int c = 0;
for (unsigned int field2 = 0; field2 <= 255; field2++)
{
for (unsigned int field3 = 0; field3 <= 255; field3++)
{
CString ips;
ips.Format(_T("192.168.%u.%u"), field2, field3);
int nIndex = LCDevices.InsertItem(c, ips);
LCDevices.SetItemText(nIndex, 1, _T("Testing"));
c++;
}
}
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi. Well... I have a trouble with scrollbars. In my (developer) computer it all looks great! BUT in any other computer it looks incorrectly. The first time, when i create the window scrollbars are painted on the border of the dialog instead of the inside of the window. And when i resize it, it repaints the window correctly with the scrollbars inside.
This i wrote in OnCreate
this->EnableScrollBar(SB_VERT);
this->EnableScrollBar(SB_HORZ);
And this is at OnInit
this->SetScrollRange(SB_HORZ,0,2*STARTPIXELX+MAPSQUARE*FIELDSIZE);
this->SetScrollRange(SB_VERT,0,2*STARTPIXELY+MAPSQUARE*FIELDSIZE);
SCROLLINFO info;
info.cbSize = sizeof(info);
info.fMask = SIF_ALL | SIF_DISABLENOSCROLL;
info.nMin = 0;
info.nMax = 2*STARTPIXELY+MAPSQUARE*FIELDSIZE;
CRect rr;
this->GetClientRect(&rr);
info.nPage = rr.bottom-rr.top;
info.nPos = 0;
info.nTrackPos = 0;
SetScrollInfo(SB_VERT,&info);
info.nPage = rr.right-rr.left;
info.nMax = 2*STARTPIXELX+MAPSQUARE*FIELDSIZE;
SetScrollInfo(SB_HORZ,&info);
this->ShowScrollBar(SB_VERT);
this->ShowScrollBar(SB_HORZ);
My dialog has application window, Overlapped, resizing border styles. Pls help!
|
|
|
|
|
Well.. A found a solution.. I don't like it, but it works.
void MainDial::OnTimer(UINT_PTR nIDEvent)
{
if (theApp.First)
{
CRect rr;
this->GetWindowRect(&rr);
rr.right-=1;
rr.bottom-=1;
MainDial::MoveWindow(rr);
theApp.First=false;
}
}
modified on Friday, October 23, 2009 6:53 PM
|
|
|
|
|
You could put this in OnSize and check.
|
|
|
|
|
The problem is that after OnSize it shows all correct, that's why i use MoveWindow in my timer. But my problem is how to make that right after OnInit it draws correctly? I resolved it only with timer... And by the way.. WHY it's all working on MY computer and on any other not?!?! (I have VS2008 SP1 and Windows XP SP3)
|
|
|
|
|
You can try another method.
Create a custom message and map it to a handler using ON_MESSAGE[^].
In the OnInitDialog function to a PostMessage[^] for your custom message.
In the message handler you could put the code that is in the timer.
|
|
|
|
|
Solution found.
LRESULT MainDial::OnMyMsg(WPARAM, LPARAM)
{
CRect rr;
this->GetWindowRect(&rr);
rr.bottom-=1;
rr.right-=1;
MainDial::MoveWindow(rr);
return NULL;
}
with ON_MESSAGE use.
Big thnx.
modified on Friday, October 23, 2009 8:30 PM
|
|
|
|
|
|
I'm looking for a MEE that can handle number expressed with factions.
Example: A user may use 3.5 * 4 7/8 or 3 1/2 * 4.875
I see a lot of MEE but do not want to go through each one.
Any help, pointers would be helpful
Thanks
Tony Teveris
Gerber Scientific Products
Senior Software Engineer
Phone: 860 648 8151
Fax: 860 648 8214
83 Gerber Road West
South Windsor, CT 06074
|
|
|
|
|
Are you looking for a seriously advanced one (see this thread), or just one to handle 4-5 basic operators? The latter cab be done via a basic RPN calculator.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
How terrible is it to find out what application has a particular file open?
Clues?
-peter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Via code?
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Absolutely!
I'd love to display status information in my app about why I am having trouble backing up a file.
"File in use by Microsoft Word"
I could of course "guess using the file associations", but it would be cooler to know the actual application using the file.
-peter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<a href="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</a>
|
|
|
|
|
Peter Weyzen wrote: Absolutely!
Several utilities made by SysInternals do this, but they work in conjunction with a file-system driver. Many years ago, there used to be a "How does it work?" blurb on their Web site. I think it was removed even before Microsoft bought them.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Hi,
Saw a lot of posts related to this but still not totally clear -
It appears that even if you override OnOK for all property pages only the first page(1) OnOK override is called. The others are never called even if the user hits OK when page 2-n is active.
Does this means it is difficult to perform additional OnOK processing of the data on pages 2-n when the user dismisses the sheet?
Thanks
modified on Friday, October 23, 2009 2:34 PM
|
|
|
|