Ok, I really feel dumb now hehe. I was out of code for a while so I totally overlooked that fact about the operator referring to the pointer. Thanks for the help. I just used strlen
and it works fine. Thanks for all the help! :-D
David Z
Posts
-
How do I get the size of a character array of unspecified size? -
How do I get the size of a character array of unspecified size?This is a newbie question but I somehow cannot get this part of my code to work. I have the user input into a character array of unspecified size like this:
char *cArray1 = new char[]; cin >> cArray1;
and then when I try to calculate how many elements is in the array, the sizeof() function always returns 4 for some reason. I'm calculating the number of elements by the following.size_t iArraySize = sizeof(cArray1)/sizeof(*cArray1);
(I also tried int as the datatype instead of size_t but no luck) I always get 4 as the return cause sizeof(cArray1) always gives me 4 and 4/1=4. I think sizeof() cannot be used with dynamically allocated arrays, so is there anyways to do this? :confused: Please give me some advice how so solve this question... Thanks! :) -
Need help with sychronizing list control datas in different windowsWell, finally got it to work just copying every item through a loop. So I guess that'll have to do for now. Thanks for everyone's help. Now I just need to figure out how to render the listview based on the data given to it.. (Don't know if that's possible..) But that's for another thread... :)
-
Need help with sychronizing list control datas in different windowsGreat Response Derek! You are right that the assertion error is at runtime, I got confused.. :) This definitely put me in the right direction. However, after I copied the list through item data, nothing is showing in the newly generated list... I just added this code to test if the data are being copied in an overridden OnInitDialog function-> LVITEM tempdata; CopiedList->GetItem(&tempdata); m_SortedList.InsertItem(&tempdata); No luck... Please help me solve this final obstacle. Thanks.
-
Need help with sychronizing list control datas in different windowsOk, I have been trying to get this to work for a while now. X| The response I got from my previous thread helped me in theory but didn't help my code.. :confused: so I'm posting a more detailed question if anyone can help me. I have a dialog based MFC app with a child listcontrol in report view. I then created another class for another window that will display another listcontrol but with the exact same column and data in it. My problem is that I can't copy the data over with what i've tried.. I have the user add item to the first list using SetItemData(). Like the following-> listitems.mask = LVIF_TEXT; listitems.iItem = 0; listitems.iSubItem = 0; listitems.pszText = (LPTSTR)(LPCTSTR)(strTitle); m_MyList.InsertItem(&listitems); listitems.mask = LVIF_TEXT; listitems.iSubItem = 1; listitems.pszText = (LPTSTR)(LPCTSTR)(m_strFirstName); m_MyList.SetItem(&listitems); ...... There are five columns and then when the user clicks a menu item it will open up another window showing the listcontrol that is supposed to show the same data. Here is the code for that-> void CMFCDlg::OnListSortbyday() { DWORD_PTR tempdata = m_MyList.GetItemData(0); GenList SortWindow; SortWindow.m_SortList.SetItemData(0,tempdata); SortWindow.DoModal(); } m_MyList is a public member CListCtrl of the main window, and m_SortList is a public member CListCtrl of the newly opened window. This is my most recent try at getting this to work... I get an assertion error when compiling though....:mad: My previous methods were declaring m_SortList as a CListCtrl pointer and point it to m_MyList, or setting the DDX_Control of the listview to CMFCDlg::m_MyList, but neither methods worked. I'm sure there is a way to get this to work.. Maybe making an instance of my main window.. but I don't know how to do that... So can someone guide me in the right direction? I don't want to just loop through and copy every single row, but I may have to.. Please help me out with some explicit instructions and sample code. Thanks!!:-D Sorry for the long post..
-
MFC list view control question....That's a really cool solution! I seemed to have missed that member function looking through MSDN :). That should solve my problem, thanks for everyone's help!
-
MFC list view control question....so how exactly should I declare this item data type?? I looked around MSDN and it seems like my LV_ITEM datatype is not quite the same as what you are talking about ravi. How should I declare that kind of datatype and some example of how to use it would be awesome! Thanks for all the comments! :)
-
MFC list view control question....Well, I am using the LV_ITEM datatype for the list. So I guess I should make it into a member variable and access it through scoping?? But wouldn't I still have to get the number of items and loop through inserting each one? I'm not quite understanding your suggestion ravi :) Can you please be a little more specific, like including a declaration example and how I should initialize my child diag class and/or duplicate list view class. Thanks for the replies!!
-
MFC list view control question....This is probably going to make some of you laugh but here goes :) I have a dialog base MFC app with a list control in report view. How can i copy the data in the list view class to another list view class in a child window? I have the child window pop up mapped to a button event. Would i have to create a loop to copy the data? or is there a faster way. Please help, Thanks!
-
C++.NET and MFC7 Compatibility Issue?Thanks for the reply! Just one last thing, will the .net Framework be enough? or i'd have to distribute the individual .dlls?
-
C++.NET and MFC7 Compatibility Issue?Will MFC programs written with VC++.net work for older platforms like Windows 98? Or I would have to distribute the MFC7 libraries? I'm having trouble getting things to run. Please help a newbie :)