|
It works for me even with checkboxes enabled. There are multiple LVN_ITEMCHANGED notifications when you change the selection for each selected/deselected item. Can you post the handler for LVN_ITEMCHANGED?
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Your response is very reassuring. Heres my code:
void CDlgLists::OnItemchangedList2(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;
if (pNMListView->uOldState == 0 && pNMListView->uNewState == 0)
return;
BOOL bPrevState = (BOOL)(((pNMListView->uOldState &
LVIS_STATEIMAGEMASK)>>12)-1);
if (bPrevState < 0)
bPrevState = 0;
BOOL bChecked=(BOOL)(((pNMListView->uNewState & LVIS_STATEIMAGEMASK)>>12)-1);
if (bChecked < 0)
bChecked = 0;
BOOL bNameClicked = (bChecked < 0);
if (bPrevState == bChecked)
return;
DWORD dwPos = ::GetMessagePos();
CPoint point((int) LOWORD(dwPos), (int) HIWORD(dwPos));
m_list2.ScreenToClient(&point);
int nIndex;
if ((nIndex = m_list2.HitTest(point)) == -1) return;
OptStateMap &optStateMap = keyOptMap[activeKey];
if (optStateMap.empty())
GetOpts(activeKey,optStateMap);
CString temp;
temp.Format("index is %d ",nIndex);
AfxMessageBox (temp);
CString opt = m_list2.GetItemText(nIndex,0);
keyOptMap[activeKey][opt] = !keyOptMap[activeKey][opt];
*pResult = 0;
}
Do you think its the HitTest thats causing trouble and not letting it respond? My msgbox is beyond the hittest line (for testing).
So you can make the function run just by clicking the name? (or selecting a range of names, regardless of checkbox state)?
I thank you for your interest.
Appreciate your help,
ns
|
|
|
|
|
1) try to replace the LVIS_STATEIMAGEMASK magic with calls to CListCtrl::GetCheck and CListCtrl::SetCheck
2) use TRACE instead of AfxMessageBox. There's a non-zero probability that displaying msgboxes in the handler interferes with notifications.
3) You should use NMLISTVIEW::uChanged if you want to check which item properties were changed.
4) I'm not sure if you should change the item state in LVN_ITEMCHANGED handler - this may lead to infinite recursion.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Would you post your code that works so I can pattern mine after yours? That would help a lot.
Appreciate your help,
ns
|
|
|
|
|
I don't have any real code - just dummy handle which displays the NMLISTVIEW::iItem using TRACE. I think you should start with that and ensure you're getting LVN_ITEMCHANGED for each item.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
If I dont setcheck in the itemchanged event, then where shall I setcheck? I see that itemchanged fires even while populating the listbox initially....so setcheck may cause probs like you said...
Appreciate your help,
ns
|
|
|
|
|
I think you should test NMLISTVIEW::uChanged and call SetCheck only if item's check state didn't change.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
I found the structure NM_LISTVIEW defined in commctrl.h, but it doesnt tell me what uchanged tests for? I n your post you said test for properties changed with uchange> But how does it tell me which properties changed?
Appreciate your help,
ns
|
|
|
|
|
Check the NMLISTVIEW docs in MSDN. The flag you'll probably need is LVIF_STATE. Note that both selection and check state are stored as different bits in item state.
I don't have the VC at hand right now; can't post the code. Just insert TRACEs liberally and you should see what's going on.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
I have a directory named, "S Y S T E M T O O L S". (Actually, there are two spaces between "system" and "tools".)
From the command prompt window (in Win2K), when I try to change directory to point to that name, I get a message that the system could not find the path specified.
Take my word for it, I've tried all sort of permutations including enclosing the name in double quotes, inserting backslash, drive letters, etc., and nothing works.
Win2K doesn't have a problem accepting the directory name as shown above, and I have many folders included in that directory that I'm always using. No problem!!
The problem is with command prompt whenever I try to run an application from a subdirectory listed in that directory.
Does anybody have an idea how I may get command prompt to cooperate?
Thanks!!
William
|
|
|
|
|
It works for me when I'm using double quotes... but I'm running XP Pro.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Just tested on my 2K box. Went fine for me. cd "S Y S T E M T O O L S"
sometimes it helps to look at the IL generated code
a MS guy on develop.com "answering" .NET issues
|
|
|
|
|
Here's what I'm talking about. This was copied straight from the command prompt window. (Remember, there are two spaces between "system" and "tools".)
==========================================
Microsoft Windows 2000 [Version 5.00.2195]
(C) Copyright 1985-2000 Microsoft Corp.
C:\>d:
D:\>cd "codeproject samples\s y s t e m t o o l s"
The system cannot find the path specified.
D:\>cd codeproject samples
D:\CodeProject Samples>
==============================================
How can I get the directory to point to "S Y S T E M T O O L S"?
Thanks!
William
|
|
|
|
|
How can I convert a string (CString) to a Float / Int ???
--
Nice greets, Daniel.
|
|
|
|
|
try atof or atol or atoi .
However, better implemetation come from strtol and strtod
Best regards,
Alexandru Savescu
|
|
|
|
|
Hi all,
I have developed a simple database application which accesses data stored in an Access database using CRecordset. The problem is that I cannot directly see the changes that I make to the database. For example, if I insert a new record, close the recordset, open the recordset and read all records, I cannot immediately see the newly added record. In all cases, if I wait for 2-3 seconds and then read the database, I can see the newly added record. I guess that for some reason my data are not immediately stored in the database. What can I do? I have also tried with transactions (commit) but the problem remains.
I thank you in advance,
Christos P.
|
|
|
|
|
I vaguely remember seeing a KB article on MSDN about this - it has to do with how Jet (which is the database engine, Access is MS's front end to the Jet database engine) caches its disk access. I suggest you look in MSDN.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Why don't you use CDaoRecordset? Using CRecordset/ODBC with Access is like, well, sucking the cake through straw
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
If you're going away from ODBC you should - at least in my mind - go to OLEDB (or ADO if you're a pussy). DAO is legacy (but so is MFC, or at least that's what everybody asks every time there's a new VC version).
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Steen Krogsgaard wrote:
If you're going away from ODBC you should - at least in my mind - go to OLEDB
It depends on the size/complexity of the application (and prospects of moving from Jet to MSSQL, for example). I've got the impression that OP's app is quite simple and he's just entering the area. In this case, going OLEDB way with ATL templates would be an overkill IMHO.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Of course, you're right, OLEDB/ATL is not easy and may be overkill. And my comment about ADO was just kidding - I think ADO is good for simple DB apps with low requirements to performance and amount of data. I just don't think that DAO is easier than ADO (it's even the same three letters, just shuffled around ), and I don't think ODBC is easier than any of them.
But if the app has any seriousness in it it should use OLEDB/ATL (or a native interface)
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Steen Krogsgaard wrote:
I just don't think that DAO is easier than ADO
I disagree - it's waay easier to use CDaoXXX classes which are integral part of MFC than to #import ADO stuff. For simple app accessing .mdb files it's more than enough.
Steen Krogsgaard wrote:
should use OLEDB/ATL (or a native interface)
You mean Jet native interface? This would kill any chances of easy migration to real SQL database. Long time ago when I was actually working with OLEDB we had a quite compilcated program which could easily run on Jet or MSSQL without recompiling.
Tomasz Sowinski -- http://www.shooltz.com
*** Si fractum non sit, noli id reficere. ***
|
|
|
|
|
Tomasz Sowinski wrote:
You mean Jet native interface?
No, I actually ment native interfaces to databases that are more enterprise-minded (like SQL Server, DB2, Oracle, MySQL etc). I'm not even sure there is a native Jet interface? I guess DAO is the closest you get to a native Jet interface. And native interfaces should only be used if performance is more important than portability. That's what I like about OLEDB - you get a reasonable performance and a high degree of protability.
Cheers
Steen.
"To claim that computer games influence children is ridiculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
This may depend on the version of the OS and/or the version of the ODBC driver... but check to see if you can set the buffer size. I think I ran into something like when moving one of my application to ME and I may have been moving to a newer ODBC driver at the same time (sorry I don't have details on version number just now). Anyway I think there was something that set the buffer to 1024 and I changed it to 256 (or something like that).
|
|
|
|
|
I have a custom control derived from CListBox and instead of using DrawItem I am using OnPaint() instead because the gui is to complex for OwnerDraw (Or so i've determined while attempting to do so).
Anyways the question I have is this:
I have created the listbox with the extended BIT checked and have had problems while painting the control for multiple selection (Although this would be really nice feature).
Using GetSel() and GetCaretIndex()
Doesn't seem to work and causes problems when drawing multiple selections (like drawing items which aren't really selected).
I'm thinking of using the CListBox::GetSelItems() instead, but would prefer to use the above for simplicity. Has anyone ever tried this before and had better luck with using the multiple selection functions...?
Thanks!
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|