|
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?
|
|
|
|
|
According to MSDN FindText[^] can search starting from a given character position. Use the chrg and chrgText members of the FINDTEXT[^] structure to set and get the ranges, and lpstrText to set the text to search for.
Edit: this is for rich edit
|
|
|
|
|
Hello,
i use C++ with Windows Forms for development.
As you knows in form we can use many controls and i want 2 re size each control as per the system resolution. so if anybody knows then please help me.........
|
|
|
|
|
ddgalande wrote: i want 2 re size each control as per the system resolution.
I am not sure what problem you are having with this but you can get the screen resolution from the GetSystemMetrics()[^] function. How you use that information to resize your controls is up to you, but I presume you just want to apply some scaling to them.
I must get a clever new signature for 2011.
|
|
|
|
|
hi,
i did not got your answer.
My question is that suppose my screen resolution is 1024x768 and i have designed my GUI as per the current resolution.
by using following code i can get my systems current resolution
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)
{
MessageBox::Show("Screen Resolution is : " +monitor_width +" x " + monitor_height, "Dnyan", MessageBoxButtons::OK, MessageBoxIcon::Information);
double xRatio = monitor_height / 800.00;
double yRatio = monitor_width / 600.00;
}
public: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e)
{
monitor_height=Screen::PrimaryScreen->Bounds.Height;
monitor_width=Screen::PrimaryScreen->Bounds.Width;
}
Now suppose my project is in network and one persons system resolution is 800x600 second person screen resolution is 1024x768 and others is different
in this case i want to adjust control default location as well as its size as per screen resolution
then please tel me how its possible in C++ with Windows platform (in .net IDE)
Please help me
|
|
|
|
|
You will need to adjust the size of your form, and all the controls, before you display it. I would guess that you need to find some calculation that will optimise it for different size screens. It would probably be best to design it for the lowest resolution and adjust upwards for the higher ones.
I must get a clever new signature for 2011.
|
|
|
|
|
I am sure there are some articles covering that subject here on CP. Just look in the Dialog and Windows article section.
|
|
|
|
|
Hi all,
I am using SortItems function to sort my list. I am using it this way
m_list.SortItems(2,TRUE);
In Visual studio 2008 its compiling ok but in VS-2010 its giving a error
error C2664: 'CListCtrl::SortItems' : cannot convert parameter 1 from 'int' to 'PFNLVCOMPARE'
to remove this error i write my line in this form
m_list.SortItems((PFNLVCOMPARE)2,TRUE);
the error is removed but it is not sorting the list either...
How can i make it work ?
Thanks in advance
|
|
|
|