|
Can't you simply write a test function that in turn calls the other two functions?
|
|
|
|
|
That will work.
But, the error report generated will not be of much help.
Say,if I have a function called testCaller() which in turn calls the two functions, doTest1 and doTest2 respectively.
If there happens an assertion failure in doTest1,the control returns without executing assert statements written in doTest2.
Also the report will say the test name only as testCaller and not the relevant function (doTest1 in this case).
|
|
|
|
|
I understand, but is that not an imaginary problem? The test should succeed. If you get an error, you would probably just go back and debug the test case anyway?
|
|
|
|
|
Hi everyone,
I am trying to do simple line plotting, i have used a CStaticCtrl on which i am trying to plot a line on a button click event,this works fine for the first time,when the button is pressed for the second time,the value is not updated,i mean the previous line is not erased and the new line is drawn
My Code
void CMainWindow::OnPumpOffClicked()
{
CRect rect;
CDC *dc=m_pic1.GetDC();
CPen pen,*oldpen;
m_pic1.GetClientRect(&rect);// m_pic1 is variable for the static control
//dc->Rectangle(&rect);
pen.CreatePen(PS_SOLID,10,RGB(255,0,0));
oldpen=dc->SelectObject(&pen);
dc->SetMapMode(MM_ISOTROPIC);
dc->SetViewportOrg(0, 148);
dc->MoveTo(x1,y1);
dc->LineTo(x2,y2);
}
Any help is appreciated
|
|
|
|
|
You really shouldn't put your drawing code in the mouse event. What you have to do instead is store the new lines coordinate when the button is clicked and refresh your control. This will call the OnPaint method in which you erase the background and draw all the lines that you stored.
If you want to use an existing charting control, you can also look at my sig: there's a link to such a control that I developed.
|
|
|
|
|
Hey,
Thanks for the reply,sir i would be very kind of u if u please explain it more detail, i mean if u can just edit my code and show me in short,i know i am asking for too much from u,but the ctrls u have developed are like a bouncer for me,thanks again
|
|
|
|
|
It's a bit too much code to write here but if you want an example, simply look at my chart control (the CChartCtrl class and more specifically the OnPaint method). What you are doing is drawing your stuff on your main window. You should in fact create a custom control and put the drawing code in your custom control (search for articles about custom controls, there are a couple for beginners on this website).
|
|
|
|
|
Hi,
I have a dialog box application. It contains one list control (CListCtrl). It filled with some data. After double clicking on any row of it new modeless dialog gets opened.
My problem is after opening new modeless dialog box, the main dialog box's row on which i have double clicked should remain selected means display it partially that it is selected. So the user can see on which row he has double clicked previously though a modeless dialog box is opened.
If have any idea please reply.
Thanks in advance.
Regards
Rajendra
|
|
|
|
|
Add the style LVS_SHOWSELALWAYS to the CListCtrl.
|
|
|
|
|
Use List Control Properties Dialog.Select "Show Selection Always" so you can see your the item as selected item in List Control
I am a HUMAN. I have that keyword in my name........
_AnsHUMAN_
|
|
|
|
|
I want to fix the number of threads to spawn for a particular task and I do'nt know if that should depend on the number of logical processors or on the number of physical processors available to the system.
The number of physical processors can be read using the ::GetSystemInfo API while the ::GetLogicalProcessorInformation API returns the number of logical processors.
Any insight please ?
thx in advance.
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
[ADDED]
What follows is based on the assumption a lot of homogeneous work, mainly calculations, is to be performed and can be organized in a (small) number of threads without needing lots of synchronization. It would not apply to inhomogeneous operations, say some threads performing calculations, others disk I/O, others network I/O, etc.
[/ADDED]
In general I would base my considerations on the number of threads that can be active at the same time; this would ignore the physical aspects involved such as separate packaging, multi-core, hyper-threading... So the number of (logical) processors returned by GetSystemInfo() is what I would use.
The one exception would be applications where performance is dominated by cache efficiency; if so, what really matters is the number of separate level-2 caches available, which could be better approximated by the number of physical processors.
Hint: what would be keeping you from trying both? As your threading code would be dynamic anyway, why not perform an experiment? or even make it automatic: run with N threads for a while, then try 2*N and see if that is an improvement, then decide.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
modified on Tuesday, February 8, 2011 5:10 PM
|
|
|
|
|
Hi and thx for your reply.
The work is inhomegeneous, so the result of the experiment will surely show an increase of performance using 2*N threads.
That is the current number of threads I am using : #threads := c * #Physical Processors
where c is a constant that compensates for the non-zero probability that a thread could be in a blocking state within the task.
Exceeding this limit, will show a decrease of performance due to context switching.
My specific concern is with virtualized environment where most of our application execute nowadays.
The guest system is often allowed to "see" less processors than the host : I expect this to be true then :
#Physical Processors > #Logical Processors
Thus the c * #Physical Processors limit will exceed the actual number of threads that the system can actually execute in //.
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
here are some more thoughts:
- I'm not really familiar with virtual operations, however I expect the virtualisation widens the gap between your app's best performance and the number of physical processors even more, so I would not use the number of physical processors at all. I would rather use the number of logical processors, divided by some constant to compensate for how much of your system you want to dedicate to that app (maybe equal to the number of virtual systems).
- if your operations are not homogeneous and sometimes blocking (and assuming they have random blocking phases) but you can organize them in identical jobs, then you can add threads to execute said jobs until (a) performance no longer improves and/or (b) total CPU load reaches 100% or whatever number you want to allot to your virtual machine.
Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum
Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.
|
|
|
|
|
I see, the ideal is to use the logical processors then.
In your first reply I thought you meant the physical processors here, because you were talking about the ::GetSystemInfo API.
Luc Pattyn wrote: So the number of (logical) processors returned by GetSystemInfo() is what I would use.
Thanks !
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
Hi!
I need to make synchronization in my c++ function, and I don't know how to do that. Which library I can use?
( I heard about windows.h, but I don't see any methods for synchronization here... )
Thanks in advance!
Andry.
|
|
|
|
|
create a critical section object CRITCAL_SECTION cs; initialize it then call ::EnterCriticalSection(&cs) and ::LeaveCriticalSection(&cs) to surround the code you want to protect.
Push Framework - now released !
http://www.pushframework.com
|
|
|
|
|
Andry_st wrote: I need to make synchronization
Why ? is your application multithreaded ?
If no, don't bother.
If yes, have a look at mutex, semaphore, ...
read here : Thread Synchronization for Beginners[^]
Watched code never compiles.
|
|
|
|
|
Yes, it is multithreaded.
Good link, thx.
Just one question: what I must to #include to enable this code?
How I can see, this is a windows.h functions, right?
|
|
|
|
|
I've got an SDI application that displays JPG files in a list control. When one of those files is right-clicked, I am displaying the context menu that is associated with JPG files (this menu is the same one that Explorer uses). The problem is that every menu option is gray, thus TrackPopupMenu() returns 0 . Any ideas why?
I suspect some sort of handler is required and the framework is not finding one.
Thanks.
[edit]
Setting a new window procedure via SetWindowLong() and calling IContextMenu2::HandleMenuMsg() from within that seemed to do the trick.
[/edit]
- DC
"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
"Man who follows car will be exhausted." - Confucius
modified on Tuesday, February 8, 2011 11:32 AM
|
|
|
|
|
DavidCrow wrote: this menu is the same one that Explorer uses
What do you mean by that ? you load the explorer menu or just make it look like the exporer menu?
I think you need to have handlers for you menu item; or you can use the option TPM_RETURNCMD to have TrackPopupMenu return the item selected item; then you will need to handle the state of the items manually.
Watched code never compiles.
|
|
|
|
|
Maximilien wrote: What do you mean by that ? you load the explorer menu or just make it look like the exporer menu?
Meaning it is one in the same. I go through all of the COM and Shell stuff to create and display the context menu, like:
LPSHELLFOLDER folderParent;
DesktopFolder->BindToObject(pidlParent, 0, IID_IShellFolder, (LPVOID *) &folderParent);
LPITEMIDLIST pidlFile;
folderParent->ParseDisplayName(AfxGetMainWnd()->GetSafeHwnd(), 0, (LPWSTR) ((LPCTSTR) strFile), &ulEaten, &pidlFile, 0);
LPCONTEXTMENU CM;
folderParent->GetUIObjectOf(AfxGetMainWnd()->GetSafeHwnd(), 1, (LPCITEMIDLIST *) &pidlFile, IID_IContextMenu, 0, (LPVOID *) &CM);
HMENU hMenu = CreatePopupMenu();
DWORD dwFlags = CMF_CANRENAME;
CM->QueryContextMenu(hMenu, 0, 1, 0x7fff, dwFlags);
int Cmd = TrackPopupMenu(...);
Maximilien wrote: ...or you can use the option TPM_RETURNCMD to have TrackPopupMenu return the item selected item...
All of the menu items are gray, so TrackPopupMenu() is only going to return 0 .
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
thanks. I did not know that (getting the explorer menu).
(you could do a tip/tricks entry for that!, but for now, I'm just bookmarking it).
Max.
Watched code never compiles.
|
|
|
|
|
Maximilien wrote: (you could do a tip/tricks entry for that!, but for now, I'm just bookmarking it).
I'm actually working on an actual application that uses this stuff. Once done, I'll see if it's post-worthy.
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Is there any inbuild function available to implement Incremental Search in CRicheditview?
|
|
|
|