|
Richard MacCutchan wrote: Is there supposed to be a question here?
I see a question mark there.
Pardon the silly humour, it's a rainy Sunday, here...
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
CPallini wrote: Pardon the silly humour, it's a rainy Sunday, here.
I didn't think you would notice the rain after yesterday's brilliance by your team.
I must get a clever new signature for 2011.
|
|
|
|
|
Well, beating France is always a great satisfaction for all. Anyway, I know, you're more used to.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
If using a memory pool, it should be faster, doesn't it?
|
|
|
|
|
Possibly, but it depends on the implementation and how the objects/memory are managed.
I must get a clever new signature for 2011.
|
|
|
|
|
Sorry for being late to reply, but since there doesn't seem to be a useful answer yet I thought I'd add some explanations.
Looking at your code, the results you got from test0() and test(1) look ok, but those from test2() and test(3) are probably useless: std::vector has it's own method of maintaining a buffer for cases of repeated resizing, which is very similar to the one used in boost::pool. Thus it will not allocate memory once per loop, in fact there will probably only be a few dozen allocations forwarded to the boost::pool allocator. If you want to ensure one allocation per loop count, then I suggest you use std::list instead.
I am not quite sure why object_pool is so slow, but I suspect the reason is the method free(). This method, to my knowledge, is disabled for pools of standard objects, because it is very inefficient (it is O(n) where n is the number of objects in the pool). The standard memory allocator (i. e. new/delete)), although quite slow, is still only O(1)! Therefore, the only sensible way to use boost::object_pool at this time is to not call the destroy() method at all! Don't worry, the moment the pool gets destroyed, all the objects will still be destructed properly, but that will be much more efficient than destroying each object individually.
I've tried to use boost::pool 2 years ago for our application, but, in similar tests, found that it wasn't usable for our purposes. I eventually created my own implementation that dynamically frees (and destructs) objects at O(1), and considerably faster than new/delete (tested for up to 10 million allocations). If that's what you're looking for, I could make this into an article. It might take some time though.
|
|
|
|
|
|
I create a applicaion named PipeLine .
I add a dialog named Connect and insert a EditBox resourse with a ID called IDC_CONNECT .A variable named m_conn is relevant to the ID ,that is IDC_CONNECT, maybe it's an unnecessary move.
What I want to do is to call m_conn in the CPipeLineApp.
Please do me a favor.Very grateful.
|
|
|
|
|
Jokcy wrote: What I want to do is to call m_conn...
This makes no sense. You don't call an edit box. You can, for example, access it by setting/getting the text.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
Maybe I don't make myself understood.Please let me make it clear.The variable m_conn is attached to the IDIDC_CONNECT .
I want to access the it in CPipeLineAPP
|
|
|
|
|
Jokcy wrote: I want to access the it in CPipeLineAPP
That usually indicates a bad design. The dialog object should implement public getter/setter methods instead.
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Some people are making such thorough preparation for rainy days that they aren't enjoying today's sunshine." - William Feather
|
|
|
|
|
En ,I have realized it.So Changes have been made.Thank you .
|
|
|
|
|
As David said you must use getter/setter methods in the dialog class to access the variable.
So to get the value of m_conn , add a method called GetConn in the Connect class.
Now using the object that you created with the Connect class, call its GetConn method.
|
|
|
|
|
I've tried it.Do not get value of dialog variable.
Maybe I don't make myself understood.Please let me make it clear.The variable m_conn is attached to the ID IDC_CONNECT .
I want to make m_conn as a extern variable and access it in CPipeLineAPP
modified on Sunday, March 13, 2011 3:27 AM
|
|
|
|
|
How is m_conn "attached" to IDC_CONNECT.
|
|
|
|
|
For ID value is theIDC_CONNECT CEditBox resources added associated variables m_conn
|
|
|
|
|
I am guessing here as your question is not very clear, but I think you probably need to use the GetDlgItemText() [^] function to get the text from the edit box and store it in your variable. You can do this in your DlgProc() when you handle the OK response.
I must get a clever new signature for 2011.
|
|
|
|
|
Thank you for noticing my question.I've got it.
By the way ,do you know how to paste or insert a picture here .
Because ,as you know ,a picture can speak a lot of things
|
|
|
|
|
Jokcy wrote: By the way ,do you know how to paste or insert a picture here .
I don't think you can do that directly in these forums. Most people post their pictures to a free sharing web site and post the link in their question.
I must get a clever new signature for 2011.
|
|
|
|
|
Anyway ,thank you all the same.I will make my words more easily to be understood.Because I am so poor in English.
do my best to pursue knowledge
|
|
|
|
|
You do not need to apologise for your English; most of us have no other language.
However, do try and respond as clearly as you can when people ask for more information on your questions. Most of the time they are trying to help to solve your problem, and understanding your question is the first step.
I must get a clever new signature for 2011.
|
|
|
|
|
OK.I will.Once again thank you for your advice.
|
|
|
|
|
I was browsing through the web and trying to find the method of double buffering to load an bmp image. I get all the example, except I can't seems to find anyway to actually draw the bmp file into the memhdc. to be precise I will get an example code here.
hdc_mem = CreateCompatibleDC(hDC);
bmp_mem = CreateCompatibleBitmap(hDC, 80, 25);
hdc_mem = LoadBitmap(hInst, MAKEINTRESOURCE(ID_for_BMP));
SelectObject(hdc_mem, bmp_mem);
BitBlt(hDC, 100, 50, 180, 75, hdc_mem, 0, 0, SRCCOPY);
DeleteDC (hDC);
DeleteDC (hdc_mem);
DeleteObject (bmp_button);
In the part where I should write stuff into hdc_mem, and I did LoadBitmapbut nothing is drawn on the screen. If i take the LoadBitmap line away, it will draw me a black box.
what should I do? any links for any example?
|
|
|
|
|
You code does not suggest you are attempting to double buffer but since that is the topic you stated you are trying to understand, I would suggest this article first. (Your question will be answered indirectly in there)
Flicker Free Drawing In MFC[^]
|
|
|
|
|
ahh its MFC.. please gimme some winapi/C example tyvm
|
|
|
|