|
Are you building your maps top-down (first A s, then B s, finally C s) or bottom-up? The latter order is likely to be way faster, since B s and C s store copies of the enclosed types. So, instead of writing
A a;
B b;
b["Hello"]=a; you should write
B b;
A& a=b["Hello"];
Other ways to improve your code:Define B as a map<CString,A*> (and similarly wih C ) to prevent excessive copying. If this imposes a problem with keeping track of the objects (to do the final cleanup), consider some ref-counted smart pointer instead.
Give my block allocator a try (though I wouldn't expect but a modest improvement thru its use.)Good luck.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
In your case (no inserts or deletes), you could achieve similar search performance and faster building with sorted vector s and binary_search algorithm.
|
|
|
|
|
If you use .NET then you may consider using hash_map
Best regards,
Alexandru Savescu
|
|
|
|
|
Hello,
I tested the folowing things:
1. With a CView based MDI project, I added a second document with a CFormView. Butr when I run it and choose the new document I get a debug/assert in viewform.cpp.
Next I tried so that both docs have views based on CFormView. Same problem. View1 shows fine, view2 asserts. ANy ideas?
Thanks,
ns
|
|
|
|
|
Hi! I've just created a button by code, and i would like to have in the same class where it has been created, its control member variable, what i have is :
botao->Create("Cancel", WS_CHILD|WS_VISIBLE, CRect(10, y+120, 60, y+170), this, 1232123);
I use this ast argumento to give it a name and then i edited Resource.h and write : #define IDNB_TESTE 1232123, 'assigning' that id number to a name, which i would use in DDX:
DDX_Control(pDX, IDNB_TESTE, m_teste);
then i tried to use the m_teste variable, but i kept receiving errors, what ave i done wrong? How can i do this?
Thank you for your time
|
|
|
|
|
I found it, i had just to had BS_PUSHBUTTON and process the ON_BT_CLICKED message with the id i had chose to the function.
Thank you the same
|
|
|
|
|
Hi,
I use Visual C++ 6.0 and have problem working with MS Access Database 2000:
a) After I created a database table with MS Access 1997, then later if I use Class Wizard (in Visual C++ 6.0) to add a new class with DAO option (CdaoRecordSet or CDaoRecordView) ... there is no problem, every thing working fine!
b) But if I created a database table with MS Access 2000, then when I add a new class with DAO option (CdaoRecordSet or CDaoRecordView) ... it did not allow and said "unrecognized format"
- I did add this code: AfxGetModuleState()->m_dwVersion = 0x0601; to let Visual C++ recognize new driver, I also download "DaoPatch.dll" and put it into \Program Files\MS Visual Studio\VC98\Setup\1033 & \Program Files\MS Visual Studio\Common\Wizzard98 ... still had the same problem!
- Even I tried to update with Microsoft Visual Studio 6.0 Service Pack 5 that claimed improvement some problem with DAO 3.6 files (Dao header & cpp files... the result is the same!
*) I know it should work, but I do not know how to do it? Can any one help me?
I am really appreciate it! Thanks.
Thanh Chau
|
|
|
|
|
You need the latest version of MDAC. You can probably get it off the MS web site.
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
I found this function:
LRESULT CMainFrame::OnTestMessageLParam(WPARAM wParam, LPARAM lParam)
used by some sample code. But when I went to "add windows messsage handler" in the mainframe class context menu I didnt see any thing like wm_message or something. SO where is this function coming from and what does it respond to? Shouldnt it have been in the context menu?
|
|
|
|
|
If you are using MFC you most surely have the source code also. Search the MFC src directory for OnTestMessageLParam .
|
|
|
|
|
Hi There,
Does anybody know the best way of rendering a 2d circle outline onto 3d device of a known number of pixels readius? I've tried rendering it by making vertex buffer with some points arranged in a circle drawn in close proximity to the camera, but it seems to be a bit of a convoluted way of going about it... Does anybody know a better way of overlaying 2d shapes into the buffer?
Thanks for you help...
With time we live, with money we spend!
Joel Holdsworth
|
|
|
|
|
Draw a plain circle on a bitmap and the use it as a texture.
Since this is also how it's done in OpenGL you might have a look at e.g. "NeHe Productions" or opengl.org (note, you might get biased against proprietary API's using free information like this :->).
|
|
|
|
|
My app will have only two MDI docs and two views (one for each). No new views or windows can be created. I want to show (or spawn) doc2 and view2 in response to a buttonclick on view1. Then after the user has finished entering data in view2, I want to click a button, get rid of view2 (destroy or hide), and show view1 (updated) again. How do I go about doing this?
I am working on how to get view1 the info returned by view2 in a separate thread.Thanks so much,
ns
|
|
|
|
|
I added classes for the second doc and view and added the template. Wouldnt compile. I compared it with a successful example with uses CViews , not CFormViews. My CFOrmView view code differed from the CView code,: the constructor wasnt argumentless and was public, and there was no dyncraete staement. SO I moved the declaration of my cosntructor to protected and added the dyncreate statement, but still wont compile. What am I doing wrong or not doing?
Thank you!
|
|
|
|
|
ns wrote:
but still wont compile
what are the error messages???
-c
Garbage collection, making life better - for weenies!
|
|
|
|
|
Thanks so much for the interest. I used class wizard to make my view and doc files (the second doc)
The example with CView that works has:
from .h
protected:
CMDIBillView(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CMDIBillView)
and from .cpp
IMPLEMENT_DYNCREATE(CMDIBillView, CView)
CMDIBillView::CMDIBillView()
{
}
I just noticed that:
The implement line was missing in my view code (CFOrmView based)
so I added
IMPLEMENT_DYNCREATE(CMDIKVView, CFormView)
plus the other changes noted below. Now only 1 error:
C:\Trainer\mditalk\MDIKVView.cpp(16) : error C2512: 'CMDIKVView' : no appropriate default constructor available
My second view class has the following relevant code (I moved the constructor to protected and added dyncreate - it didnt show up by default as is does in a CView based example I made)
From the .h file:
protected:
CMDIKVView(CWnd* pParent /*=NULL*/); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CMDIKVView)
From the cpp file:
CMDIKVView::CMDIKVView(CWnd* pParent /*=NULL*/)
: CDialog(CMDIKVView::IDD, pParent)
{
//{{AFX_DATA_INIT(CMDIKVView)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
}
The example with CView that works has:
from .h
protected:
CMDIBillView(); // protected constructor used by dynamic creation
DECLARE_DYNCREATE(CMDIBillView)
and from .cpp
IMPLEMENT_DYNCREATE(CMDIBillView, CView)
CMDIBillView::CMDIBillView()
{
}
I just noticed that:
The implement line was missing in my view code (CFOrmView based)
so I added
IMPLEMENT_DYNCREATE(CMDIKVView, CFormView)
plus the other changes noted below. Now only 1 error:
C:\Trainer\mditalk\MDIKVView.cpp(16) : error C2512: 'CMDIKVView' : no appropriate default constructor available
|
|
|
|
|
Well,
It turns out that my second document I accidentally derived from CDIalog, whereas I wanted CFormView. So things are okay regarding my troubles with that. Which brings me to the question: Does one not make a view derived from CDialog in MDI?
|
|
|
|
|
ns wrote:
Does one not make a view derived from CDialog in MDI?
no. one does not use CFormView instead.
-c
Garbage collection, making life better - for weenies!
|
|
|
|
|
Hello,
This is in regards to MDI architecture.
I have a CString that gets set to (lpszPathName) on the OpenDocument function inside the Doc class.
I want to access this string in the View class, and I don't know how to access it.
I tried this.
(in Doc Class)
m_String = lpszPathName;
AfxMessageBox(m_String);
This MessageBox display the Pathname as I wanted.
(in View class)
CMyView NewView;
AfxMessageBox( NewView.m_String );
This MessageBox displays a blank box. Obviously, the string isn't passing as I thought it would.
Does anyone know how I could do this?
Thanks a whole lot.
|
|
|
|
|
You have to get a pointer to the view's associated document first.
CMyDoc* pDoc = (CMyDoc*)GetDocument();
if (pDoc)
{
AfxMessageBox((LPCTSTR)pDoc->m_String);
}
------- signature starts
"...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
Please review the Legal Disclaimer in my bio.
------- signature ends
|
|
|
|
|
Perhaps i wasnt clear: I want to send info from view2 of doc2 to doc1 which will update view1 (how is mysterious yet).
I'm going to try the postmessage and see if I can populate a variable in view1 with info from view2.
However I'm still unable to even create a cFORMView project with 2 documents!!!! I posted about this just now.
I appreciate your responses.
|
|
|
|
|
HEY!!!!!!!!
That was awesome! That reply came so quick! And it hella worked.
Thank you, Outlaw Programmer. You da man!
-<>-
|
|
|
|
|
If this is confusing, please just read my summary. Thats what my ultimate goal is:
I am trying to communicate information received in a View (which is associated with doc1) to Doc2 so it can update View2.
First question is that if I put a button on my view and in the click event try to set the doc2 public variable directly (like Doc2::var = abc), it says that its illegal to access a data member from a static variable.
So I put a setvariable() function in doc1, and tried to create an object of type doc1 in view2 to set the variable (which I dont think is going to do what I want because of the way the document is created from the template). Anyways turns out that doc1() constructor is protected in order to use the dyn_create stuff.
I suppose making the classes friends might allow me access, but the view (view1) I eventually want to use to display info from view2, is created from a template so it wont be communicated to by the simple doc1 object that I am trying to make.
Summary:
I call a dll in view2, and want to give the info received in view2, to be seen in view1. THis I realize has to be done via doc1, but I am not able to figure out how to transmit this info to doc1.
Additional question: In response to a button click on view2, if I can successfully change the value of a variable in doc1, how do I updateallviews()? I dont want to click a ,menu item in doc1 to update all views. rather I want it done automatically as soon as the variable value changes.
|
|
|
|