Hottest Forum Q&A on CodeGuru - February 22nd - 2004
Introduction:
Lots of hot topics are covered in the Discussion Forums on CodeGuru. If you missed the forums this week, you missed some interesting ways to solve a problem. Some of the hot topics this week include:
- How do I set the focus of multiple items in a list control when a dialog is open?
- Why does my DOS application run satisfactorily in Win98 but improperly in Win2000?
- Why does rand() always return the same number?
- How can I resolve MFC Class conflicts?
|
wow9999 is working in an application in which he needs to set the focus of several list control items.
I created a dialog and added a List control which is an icon list control. I can select several items if I press Ctrl or Shift. Now, I want several items to be seleted and set focus when a user opens this dialog. This means if items 1, 2, and 3 are seleted, and the user closes the dialog, they should be selected automatically and the focus should be set when the dialog is opened the next time. I just want to know how to set several items' focus when a user opens the dialog.
You should be able to use CListCtrl::SetItemState to set mutiple items as selected (you would have to call it once for each item you want to select). As for the focus, only one item can have the focus, but you can use CListCtrl::SetItemState to do that as well. You also should make sure that your list control doesn't have the LVS_SINGLESEL style set and make sure your listctrl is set to "Always Show Selection," and it should work. Here is an example code:
m_List.SetFocus(); CString sLabel; // add 10 items to list for(int i = 0;i < 9; i++) { sLabel.Format("Item%d", i); m_List.InsertItem(i, sLabel); } // select 1st 5 items for(int i = 0;i < 5; i++) m_List.SetItemState(i, LVIS_SELECTED, LVIS_SELECTED ); // set focus to first item m_List.SetItemState(0, LVIS_FOCUSED , LVIS_FOCUSED );
|
acselli has a DOS application that works properly in Win98SE, but in Win2K it also works, but not properly. Let's see what acselli says.
I have a DOS application that communicates through the RS232 with an Intel ICE (in circut emulator). With W98SE no problem but with W2000, the application runs but doesn't communicate with the ICE. How I can solve this problem? Is it possible to write some code to run first my DOS application?
Well, you always have to consider that if you are dealing with hardware-related problems, don't expect a program that works on one OS to work on another without any changes. Those changes can be anything from changing an argument to a function to rewriting the whole application from scratch. That is why, without the source code, you may be out of luck.
Windows 98 is essentially DOS 7.0 with a GUI interface. Windows 2000 is not DOS (the command line in Win2000 is not DOS—it is the 32-bit command line), and many things that you can do in DOS will not work in Windows 2000.

Thread:
Comments
There are no comments yet. Be the first to comment!