|
Note if you want to improve performance consider this.
If you are removing entries within the vector frequently then this is a "slow" process. It calls copy constructors for all entries above the deleted item as it shuffles them down.
Consider using list instead in these cases.
i.e.
#include <list><br />
<br />
typedef std::list<int> TIntList;<br />
<br />
TIntList m_MyIntList;
Ant.
I'm hard, yet soft. I'm coloured, yet clear. I'm fuity and sweet. I'm jelly, what am I? - David Williams (Little Britain)
|
|
|
|
|
How can I call a function, given its name as a string?
|
|
|
|
|
In a map push the pointer to your function and its name as a string
and when you need to call the function just query for its pointer and pass the correct parameters.
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I have created my project ... with VC++ + DirectShow. + MS Access..
I need to build installer for my application that can i give to my users .. to intall the application on their PC..
How can i do it ,, any Software ,, etc..
i thikn there r some scrpts with which we do ir ..
But i not have experince on these .. how can i easily build my installer
thanx
|
|
|
|
|
Try out Microsoft Visual Studio Installer
It is easy to use
and really cool.
|
|
|
|
|
Hello,
Can anyone please tell me, why "c" doesn't support nested functions
|
|
|
|
|
Do you mean the bizarre Pascal construct where you can have a function inside a function?
That is:
void func1() {
void func2(){
}
}
If that is the case, the answer is simply "because it doesn't". And a good thing it is too, support nightmare and everything It is completely unnecessary, tools converting Pascal code to C do this by creating a struct of the local variables in func1, making func2 a separate function and having the struct as an inparam to func2, if you need to convert code.
|
|
|
|
|
As has already been mentioned, there is no need. What is it that you are doing that you think requires such a construct?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
i am doing project on vc++ MFC DIALOG, where in i will be repeatedly calling the same dialog box morethan 100 times, but the problem is, that the dialog box is getting crashed(terminating or ending) after some 50 times..
what can be the problem?
|
|
|
|
|
jklhjk wrote:
what can be the problem?
Probably that you have a bug in your program. As you don't describe anything about what the dialog does, it's difficult to be more specific
Have you tried running it in debug mode, you ought to get some more info on the reason this way?
|
|
|
|
|
There is no bug in program,the same program i can run it in (c language) cmd prompt..
i have check it out by creating new dialog box ("hello")having only "OK" Buttton in it.
void CHelloDlg::OnOK()
{
// TODO: Add extra validation here
CDialog::EndDialog(IDOK);
CHelloDlg cmd(this);
cmd.DoModal();
}
after running it . keep pressing the "ok" button continously, the dialog box crashes or ends after 50 times..
|
|
|
|
|
Are you trying to do some silly version of the obnoxious JavaScript-script popping up a messagebox forever ?
Anyway, your problem might not so much be the number of times you display a dialog, but rather the amount of dialogs displayed (and parented) at the same time. But the idea of popping up a new dialog - of the same kind - in response to a press on the OK-button - is in the best case silly, in the worst downright malicious.
As it is so easy to break out of the loop, by pressing Ctrl+Alt+Del, I'll suggest what you should do anyway:
1. Remove the code in the OnOK -handler, except for the call to the base class implementation.
2. Change the code originally creating the dialog to:
while( true ) {
CHelloDlg cmd;
cmd.DoModal();
}
3. Get a new hobby.
|
|
|
|
|
Hai everyone,
I am doing a project using Listcontrol box.
In that i need some help,can any one tell me how to set font size for a particular item in a list controlbox.
for example,if i am adding a new item to the listcontrol box, it should appear bold. and other items shold be in normal font size.
Please help..
Thanks a lot. .in reading my question.
kailasam
|
|
|
|
|
|
Hi there,
I have a class called CChecklist that derives from CFormview and a checkmark image that I made invisible until the user finishes entry of another view called CFruits. How can I access IDC_CHECKMARK from CFruits class? I tried creating a object of class CChecklist to access its member function in order to change the visibility property of the control, but it gave me a run-time error. Please see below. How can I accomplish this?
void CCheckList::makeVisible()
{
GetDlgItem(IDC_CHECKMARK)->ShowWindow(TRUE);
}
void CFruits::OnOK()
{
CChecklist cl;
cl.makeVisible(); //run-time error
PostMessage(WM_COMMAND,ID_FILE_CLOSE);
}
|
|
|
|
|
makeVisible will try to find a child-control of CCheckList with the id IDC_CHECKMARK . Furthermore, you are creating an instance of CChecklist out of the blue - this instance has nothing to do with your other view/control.
You should not try to access controls between views, this makes it impossible to move one view to another application, and is considered Real Bad Programming. If you have two views, I assume that you have a single document holding both of them? In that case, the proper way to go about this is via the CDocument update-mechanism. You do this by calling CDocument::OnUpdateAllViews when you want to change stuff across view-boundaries, in (pseudo)code:
void CFirstView::SomeFunction()
{
CSomeDoc* pDoc = GetDocument();
pDoc->UpdateAllViews( this, HINT_SOME_VALUE_YOU_DEFINE );
}
and in the recipient view, you add an update handler, so:
void CSecondView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
if( lHint == HINT_SOME_VALUE_YOU_DEFINE )
{
}
}
You should also get a basic textbook on C++, you'll have to learn the difference between a class and an instance of a class, for example. Lots of grief lies ahead if you don't know this
|
|
|
|
|
I did just as you suggested but I might have missed something. Here are my code samples just in case you can pinpoint the problem.
//Main application class
BOOL CMPSApp::InitInstance()
{
/* additional code present */
CMultiDocTemplate* pFirstView = new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMyDoc), RUNTIME_CLASS(CMDIChildWnd),
RUNTIME_CLASS(CFirstView));
AddDocTemplate(pMHCEditDocTemplate);
CMultiDocTemplate* pFirstView = new CMultiDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMyDoc), RUNTIME_CLASS(CMDIChildWnd),
RUNTIME_CLASS(CSecondView));
AddDocTemplate(pMHCEditDocTemplate);
}
void CFirstView::OnOK()
{
if (g_selected == TRUE)
{
CDocument* pDoc = GetDocument();
pDoc->UpdateAllViews(NULL);
}
PostMessage(WM_COMMAND, ID_FILE_CLOSE);
}
void CSecondView::OnUpdate(CView* pSender, LPARAM lHint, CObject* pHint)
{
If (g_list->items.selected == 0)
{
GetDlgItem(IDC_APPLE)->ShowWindow(TRUE);
}
}
When UpdateAllViews() is called, there is only one view in the list and that is CFirstView, the calling view. Why does it not recognize the other views? Am I missing something? Thanks!
|
|
|
|
|
You are not only trying to send data between two views, they reside in different documents as well.
First, you have to get the doc templates from, the app, loop them and get the documents from each doc template. Well, it's easier to explain in code
POSITION templatePosition = AfxGetApp()->GetFirstDocTemplatePosition();
while( templatePosition != NULL )
{
CDocTemplate* documentTemplate = AfxGetApp()->GetNextDocTemplate( templatePosition );
if( documentTemplate )
{
POSITION documentPosition = documentTemplate->GetFirstDocPosition();
while( documentPosition != NULL )
{
CDocument* document = documentTemplate->GetNextDoc( documentPosition );
if( document )
document->UpdateAllViews( NULL );
}
}
}
Now, OnUpdate will be called for all views.
|
|
|
|
|
It works beautifully! Thanks Johan!
|
|
|
|
|
My pleasure
|
|
|
|
|
The CChecklist object you create in the CFruits::OnOK() isn't the same you have subclassed somewhere else in your code. That object isn't subclassed at all and I suppose that this is why you get that runtime error.
You could try to do something like this (ain't that pretty though and I'm not sure does this work):
void CFruits::OnOK()
{
HWND hCheckMark =
::GetDlgItem( ::GetDlgItem(handle_to_checklists_parent, IDC_CHECKLIST), IDC_CHECKMARK );
::ShowWindow( hCheckMark, SW_SHOW );
PostMessage(WM_COMMAND,ID_FILE_CLOSE);
}
Cohen
|
|
|
|
|
Hi
I made a project of Dialog box using MFC.My Project name is Dialog1.All Operations I have done.Finally I Select the ClassView tab from the project workspace pane.CDialog1Dlg
class is not appeared in calss veiw tab.
I would like to know that "how to get CDialog1Dlg class " in class view tab.
rajesh
|
|
|
|
|
Go to the Dlg class header file.Make some change there..
( Just give a blank line after class declaration )
Check the class view.
|
|
|
|
|
Hian buddy close your project and now sercah for your projectname.ncb file and delete the file
now reopen yiour dsw file you Class CDialog1Dlg visible in class view
I Think It will Work
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hello,
I want to send a packet of data to a web server on port 80. How exactly would I go about doing this.
|
|
|
|