|
|
Hi,
I don't have more knowlegde about VC++, but try following if it can satisfy your requirement.
CComboBox *combo = new CComboBox();
combo->m_hWnd = GetDlgItem(IDC_TEST)->m_hWnd;
combo->AddString("AS");
combo->AddString("ZX");
m_combo = "ZX";
UpdateData(FALSE);
Try it.
Best Regards,
Aniket
-- modified at 9:07 Friday 19th May, 2006
|
|
|
|
|
|
My app reports memory leaks. The problem is, I can't track them down because the allocation numbers (the ones in curly brackets) change every time I run the app, even though I do so in exactly the same way each time. I have tried using Visual Leak detector, but it doesn't find any leaks. Any suggestions would be most appreciated!
Here's what pops up in the Debug Window. I am using Visual C++ 6.0, under Windows XP Home edition.
Detected memory leaks!
Dumping objects ->
strcore.cpp(118) : {1398} normal block at 0x00EF4300, 16 bytes long.
Data: < F:\ > 01 00 00 00 03 00 00 00 03 00 00 00 46 3A 5C 00
strcore.cpp(118) : {1397} normal block at 0x00EF4448, 16 bytes long.
Data: < C:\ > 01 00 00 00 03 00 00 00 03 00 00 00 43 3A 5C 00
thrdcore.cpp(166) : {1388} client block at 0x00EF47D8, subtype 0, 112 bytes long.
a CWinThread object at $00EF47D8, 112 bytes long
thrdcore.cpp(166) : {1367} client block at 0x00EF44A0, subtype 0, 112 bytes long.
a CWinThread object at $00EF44A0, 112 bytes long
Object dump complete.
Thanks for any help!
|
|
|
|
|
This is purely a guess, but you are 'new'ing two CWinThread based objects and they are not being 'delete'd. I'd also suspect that these CWinThread based objects are where the CString leaks are coming from. But without any kind of code listed, it's all guesswork.
Chris Meech
I am Canadian. [heard in a local bar]
The America I believe in has always understood that natural harmony is only one meal away from monkey burgers. [Stan Shannon]
GOOD DAY FOR: Bean counters, as the Australian Taxation Office said that prostitutes and strippers could claim tax deductions for adult toys and sexy lingerie. [Associated Press]
|
|
|
|
|
Thanks, Chris.
I found the problem, deleting monitoring threads in OnDestroy() which wasn't being called.
|
|
|
|
|
Hi !!!
If you want to detect your Memory Leaks, I wouldn't use the Visual Leaks Detector. It makes some things they are not good in the Runtime. If you want to use VLD, use it only for debugging, belive me. If you don't want to use VLD, I don't know any other Leak Detectors for the Visual Studio 6.0. In Visual Studio .NET 2005 you can do it by using the _CrtMapAlloc in your watches and than you can trigger a breakpoint.
By!!!
-:KNOX:-
|
|
|
|
|
I have three document types in my software. However, when I run the app, it prompts me to decide what type of document to start with; furthermore when I try to use the same resource ID for more than one of my document templates...it also seems to do the same thing. Any ideas? The offending code is listed below.
Thanks in advance.
<br />
pDocTemplate = new CMultiDocTemplate(IDR_PhotonOneTYPE,<br />
RUNTIME_CLASS(CPhotonOneDoc),<br />
RUNTIME_CLASS(CChildFrame),
RUNTIME_CLASS(CPhotonOneView));<br />
if (!pDocTemplate)<br />
return FALSE;<br />
AddDocTemplate(pDocTemplate);<br />
pLWDocTemplate = new CMultiDocTemplate(IDR_MAINFRAME,<br />
RUNTIME_CLASS(CLyghtWayveDoc),<br />
RUNTIME_CLASS(CLyghtWayveFrm),<br />
RUNTIME_CLASS(CLyghtWayveView));<br />
if(!pLWDocTemplate)<br />
return FALSE;<br />
AddDocTemplate(pLWDocTemplate);<br />
pNuDocTemplate = new CMultiDocTemplate(IDR_PhotonOneTYPE,<br />
RUNTIME_CLASS(CNuonDoc),<br />
RUNTIME_CLASS(CNuonFrm),<br />
RUNTIME_CLASS(CNuonFormView));<br />
if(!pNuDocTemplate)<br />
return FALSE;<br />
AddDocTemplate(pNuDocTemplate);<br />
<br />
<br />
CMainFrame* pMainFrame = new CMainFrame;<br />
if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))<br />
return FALSE;<br />
m_pMainWnd = pMainFrame;<br />
m_pMainWnd->DragAcceptFiles();<br />
EnableShellOpen();<br />
RegisterShellFileTypes(TRUE);<br />
CCommandLineInfo cmdInfo;<br />
ParseCommandLine(cmdInfo);<br />
if (!ProcessShellCommand(cmdInfo))<br />
return FALSE;<br />
pMainFrame->ShowWindow(m_nCmdShow);<br />
pMainFrame->UpdateWindow();<br />
-- modified at 13:46 Thursday 18th May, 2006
|
|
|
|
|
BlitzPackage wrote: when I run the app, it prompts me to decide what type of document to start with
I'm assuming this is undesireable. If so, see here.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
David,
Thank you so much; because of you I found that answer. I really appreciate it.
What I did was implement the method you provided the link for in an overrided version of the CWinApp::OnFileNew() method.
Thanks again,
BP
|
|
|
|
|
hello again
Can anybody explain me :
1) What we need stdafx.h and stdafx.cpp files for ?
2) Why are they useful ?
thank you.
|
|
|
|
|
|
Hi !!!
The stdafx file is Precompiled Header file. You can call it Monkey, too. It is only some name from the ActiveX libs.
By !!!
-:KNOX:-
|
|
|
|
|
I'm trying to add a task to the context menu of the Results Pane but can not seem to do this atall!!
I have added a task to the node in the scope pane but when using the same code to add to the results pane it compiles but doesn't do anything. The results pane displays entries that are read into a vector from reading files from a particular directory.
Code I have used is same as below - help!!!
//This is taken from an platform sdk sample and works on the node but not the results
//add item adds the item to the context menu and the menu command deals with the
//resulting command.
HRESULT CRocket::OnAddMenuItems(IContextMenuCallback *pContextMenuCallback, long *pInsertionsAllowed)
{
HRESULT hr = S_OK;
CONTEXTMENUITEM menuItemsTask[] =
{
{
L"Start vehicle", L"Start the space vehicle",
IDM_START_SPACE, CCM_INSERTIONPOINTID_PRIMARY_TASK, 0, CCM_SPECIAL_DEFAULT_ITEM
},
{
L"Pause vehicle", L"Pause the space vehicle",
IDM_PAUSE_SPACE, CCM_INSERTIONPOINTID_PRIMARY_TASK, 0, 0
},
{
L"Stop vehicle", L"Stop the space vehicle",
IDM_STOP_SPACE, CCM_INSERTIONPOINTID_PRIMARY_TASK, 0, 0
},
{ NULL, NULL, 0, 0, 0 }
};
// Loop through and add each of the menu items
if (*pInsertionsAllowed & CCM_INSERTIONALLOWED_TASK)
{
for (LPCONTEXTMENUITEM m = menuItemsTask; m->strName; m++)
{
hr = pContextMenuCallback->AddItem(m);
if (FAILED(hr))
break;
}
}
return hr;
}
HRESULT CRocket::OnMenuCommand(IConsole *pConsole, long lCommandID)
{
const size_t cchBuffer = 128;
_TCHAR szVehicle[cchBuffer];
// StringCchPrintf and StringCchCopy always null-terminate the destination string.
// However the string may be a truncation of the ideal result (indicated by return value other than S_OK).
switch (lCommandID) {
case IDM_START_SPACE:
iStatus = RUNNING;
break;
case IDM_PAUSE_SPACE:
iStatus = PAUSED;
break;
case IDM_STOP_SPACE:
iStatus = STOPPED;
break;
}
StringCchPrintf(szVehicle, cchBuffer, _T("%s has been %s"), szName,
(long)iStatus == RUNNING ? _T("started") :
(long)iStatus == PAUSED ? _T("paused") :
(long)iStatus == STOPPED ? _T("stopped") : _T("!!!unknown command!!!"));
MAKE_WIDEPTR_FROMTSTR(ptrname, szVehicle);
int ret = 0;
pConsole->MessageBox(ptrname,
L"Vehicle command", MB_OK | MB_ICONINFORMATION, &ret);
return S_OK;
}
Steve
|
|
|
|
|
Hi everybody,
I have a small problem with a CRecordset. I open a dialog-box, where I set some values. When I close the dialog-box with OnOK(), I put all the values in an access-mdb using ODBC.
Right after closing my dialog-box, I need the values in the calling function. So I open my recordset again and read all the values. But the last value is missing.
When I debug my application, all values appear. When I add a button, to get the values from my database, all values appear. When the values are to be read immediately after closing my dialog-box, the last value is missing.
So I think, it is some kind of timing problem. That I read from the database, before all records are written. I tried to reopen the database in my dialogbox right after closing it and I close it again. Now all my records are there (at least mostly). But this is not really elegant.
So, is there any possibility, to wait, until the data is really written in the database after closing it, before reopening it again?
Or am I completely wrong and the problem is something else?
Juergen
|
|
|
|
|
Hi everybody,
I have a big problem when using a CRecordset, that contains a CTime-object.
I use an Access-mdb via ODBC and have a table containing a date/time-row.
I can open this table using CRecordset.
I then do an Edit(), set my values and perform an Update(). Everythings works as expected.
But when I do an AddNew(), set my values and perform an Update(), a access-violation occurs. Debugging shows, that the CTime-object is called with a GetYear(). And here the GPF happens. Since this is somewhere deep inside the MFC, I can not tell, what's going wrong.
Something strange:
I have another table, containing CTime-objects and AddNew() works fine here. I have not found any special differences in my algorithms.
So, can anybody tell me the right questions to help me here?
Juergen
|
|
|
|
|
In the record set's constructor, how are you initializing the CTime member?
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
The Class Wizard generated the constructor and as far as I can see, the CTime is not initialized.
However, before I Update() I call SetFieldNull() to initialize it.
Something special. meanwhile I don't get GPF when at least one record is in my tabel. when the table is empty, I get an GPF, but the record is written correctly. So when starting my application again, everything works.
I add the codesnippet:
Favorit.m_strFilter="User='"+myUser+"' AND Dokument='"+Number+"'";
Favorit.Open();
if(!Favorit.IsBOF())
{
Favorit.MoveFirst();
Favorit.Edit();
}
else
{
Favorit.AddNew();
Favorit.m_User=myUser;
Favorit.m_Dokument=Number;
Favorit.SetFieldNull(&(Favorit.m_Gelesen));
}
Favorit.m_Favorit=bChecked;
Favorit.Update();
Favorit.Close();
The function crashes, when Favorit.Update() is called after Favorit.AddNew().
Here is the declaration of the members in my Recordset:
CString m_Dokument;
CString m_User;
long m_Favorit;
CTime m_Gelesen;
And here is the constructor:
DBFavoriten::DBFavoriten(CDatabase* pdb)
: CRecordset(pdb)
{
m_Dokument = _T("");
m_User = _T("");
m_Favorit = 0;
m_nFields = 4;
m_nDefaultType = dynaset;
}
I don't know, what to do next. This is my first attempt at recordsets and it looks terrible.
Juergen
|
|
|
|
|
Initialize m_Gelesen to CTime(NULL) in DBFavoriten 's constructor.
"The largest fire starts but with the smallest spark." - David Crow
|
|
|
|
|
Great !
This did the job.
Why does the class wizard not initialize CTime, when everything else is initialized?
Juergen
|
|
|
|
|
hi Friends,
i got different problem.i made dll. after i create new project name called main (i.e new project). i tried linking implictly / explictly. every thing working Fine.
In main() i created Objects Impliectly passing the arguments.(i.e not new because implemented operater overloading.
code like this :
// after include dll
// include header files
int main()
{
char *p;
cls clsobt("./"rrr.ini);
cls1 cls1ob1 = clsobj["section"];
p=cls1ob1["varible"];
cout<
|
|
|
|
|
bujji_bec wrote: delete []p;
delete []p ,should always be associated with new [].
I think,that is only reason why u r getting an Error.
Can u be more specific about the Error ??
Appu..
"If you judge people, you have no time to love them."
|
|
|
|
|
bujji_bec wrote: delete []p; // this statement giving problem
Probably because it is wrong. The previous code gives no evidence that address is a heap address. Even if it is heap based, it was allocated by whatever clsobj is and therefore should be cleaned up by that same class rather than user code.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|
led mike wrote: it was allocated by whatever clsobj is and therefore should be cleaned up by that same class rather than user code.
That doesn't make sense outside the dll context. You can allocate memory inside a class a release it outside (in the mean function for example). I agree this is ugly and to be avoided by all means but that won't produce any error.
In the context of a dll, it's different because your exe and the dll are two separate processes, so the heap managers are different. Everything that has been created by the dll has to be released by your dll and everything that has been created by your exe has to be released by your exe. If you mix that, you will get troubles
Cédric Moonen
Software developer
Charting control
|
|
|
|
|
Cedric Moonen wrote: You can allocate memory inside a class a release it outside (in the mean function for example). I agree this is ugly and to be avoided by all means but that won't produce any error.
Yes I agree. I did not mean to imply that it would break, my post was not clear in that regard.
Cedric Moonen wrote: In the context of a dll, it's different because your exe and the dll are two separate processes, so the heap managers are different. Everything that has been created by the dll has to be released by your dll and everything that has been created by your exe has to be released by your exe. If you mix that, you will get troubles
I have no idea what you mean with that statement. You can't "mix" memory addresses across processes because you don't have access to them. Therefore you can't get that "trouble".
His post gives no indication of any remote processes. Even if there is a second process whatever address char *p; is assigned p=cls1ob1["varible"]; is in the current process anyway so I have no clue what you are talking about.
"What classes are you using ? You shouldn't call stuff if you have no idea what it does" Christian Graus in the C# forum
led mike
|
|
|
|
|