Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
C

carter2000

@carter2000
About
Posts
37
Topics
2
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • Help with Standard Input
    C carter2000

    use _getch(), the header file is conio.h

    C / C++ / MFC c++ help question

  • I want to copy strings,but occur this....."Access to memory errors....",why?
    C carter2000

    :) Maybe I made something wrong, but it just works fine in my computer. My compiler is VS2008.

    C / C++ / MFC c++ data-structures performance question

  • I want to copy strings,but occur this....."Access to memory errors....",why?
    C carter2000

    Loveprogramer wrote:

    char *from = "c plus plus"; char *to = "oooooooooooooooo";

    Here "from" and "to" are constant strings exactly, so the codes below would be mistake. "*to++ = *from++". If you declare "from" and "to" as array of string, your program would work fine. Just like: char from[] = "c plus cplus"; char to[] = "oooooooooooooooooooooo";

    C / C++ / MFC c++ data-structures performance question

  • when should i use a list and when to use vector?
    C carter2000

    If you need random access operation frequently in your code, use vector. If you need insert and delete operation frequently, use list. And map should be use when you want to identify a value by a key(mobbish).

    C / C++ / MFC graphics docker question

  • An unexpected output
    C carter2000

    Yes, not #pragma pack(1). I put it in my program, and the output was "22". :)

    C / C++ / MFC

  • An unexpected output
    C carter2000

    Thanks. I add "#pragma pack(4)", and it works as I wish.

    C / C++ / MFC

  • An unexpected output
    C carter2000

    Thanks for your answer.

    C / C++ / MFC

  • An unexpected output
    C carter2000

    #include <iostream> using namespace std; class CTestA { public: virtual void FuncA() {} private: int m_iValue1; char m_cValue1; int m_iValue2; char m_cValue2; double m_dValue1; }; class CTestB : public CTestA { public: virtual void FuncB() {} private: }; void main() { cout << sizeof(CTestB) << endl; system("pause"); } Why the output is '32', while my expected is '28'.

    C / C++ / MFC

  • search a list control
    C carter2000

    If your compiler is VS200X, you can right click the control, and click the "Add Variable" in the pop menus. Then it will pop out a window, and you can set the property in it. If your compiler is VC++6.0, select the control, and in the "View->Class Wizzard->Add Member", I hope I don't misremember.

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    Yes, it can. you can set the property of the control to gain what you want. I forget the details, but I am sure it can. My computer do not have a compiler, so I can't take a test.

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    :)

    LVFINDINFO temp;
    CString ff;
    temp.flags = LVFI\_STRING | LVFI\_PARTIAL;    
    CStdioFile fileh;
    fileh.Open(L"C:\\\\srvc.txt", CFile::modeRead);	
    int i;
    do	
    {		
        if(fileh.ReadString(ff)== NULL) 		
        {			
            break;		
        }	
        temp.psz = ff.GetBuffer();	
        i = m\_objListCtrl.FindItem(&temp);
        if(lstrcmp(m\_objListCtrl.GetItemText(i, 0), temp.psz) == 0)	
        {		
            m\_objListCtrl.SetCheck(i, TRUE);	
        }		
    }
    while(ff.GetBuffer() != NULL);		
    fileh.Close();
    

    This can work in my computer, but I don't guarantee it could work in your computer. And by the way, I am in school now, but tomorrow I'll back home(There is no computer in my house :) ). It means I could not use computer for a long time. And I can't solve problem together with you, I'm sorry for that..

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    Before you changed the "temp.flags = LVFI_PARTIAL|LVFI_STRING;" to "tem.flags=LVFI_STRING;", it's a wrong case exactly. But now it isn't. :)

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    You are right. :)

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    I think your code still has some problems. Consider the situation below: There are two items in CListCtrl. 111.111.111.111 111.111.111.11 And you enter 111.111.111.11 to insert the new item, see what happen. If I am right, it will insert successfully!!That may not be what you want.

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    BYTE m_M1, m_M2, m_M3, m_M4;
    TCHAR ss[50] = {0};
    UpdateData();
    ipAdd.GetAddress(m_M1, m_M2, m_M3, m_M4);
    _stprintf_s(ss, _T("%d.%d.%d.%d"), m_M1, m_M2, m_M3, m_M4);
    int compare;
    for (int i = 0; i < ipList.GetItemCount(), ++i)
    {
    compare = lstrcmp(ss, ipList.GetItemText(i));
    if(radBut1->GetState())
    {
    if(m_M1 && m_M2 && m_M3 && m_M4 && compare != 0)
    {
    ipList.InsertItem(s++, (LPCTSTR)ss);
    ipAdd.ClearAddress();
    }
    }
    else if(radBut2->GetState())
    {
    if(compare == 0)
    ipList.DeleteItem(i);
    else
    MessageBox((LPCTSTR)L"Error: Address not found", (LPCTSTR)L"Delete Address", MB_ICONWARNING | MB_OK);
    ipAdd.ClearAddress();
    }
    }

    This is the final version. :)

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    rahuljin wrote:

    if(i != -1) ipList.DeleteItem(i);

    Relpace the codes with: if (i != -1 && lstrcmp(ipList.GetItemText(i), temp.psz) == 0) { ipList.DeleteItem(i); }

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    rahuljin wrote:

    ipList.DeleteItem(i);

    What's "s" means? The last index of CListCtrl? So if it's, then here

    rahuljin wrote:

    ipList.DeleteItem(i);

    after deleting a item, you must also descend "s". I don't know if this is the reason.

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    you solve the problem by yourself, congratulation :) . maybe you can try replace the follow codes by "srvc.Write(ff, 2 * lstrlen(ff));", it works too in my computer.

    rahuljin wrote:

    while(i) { srvc.Write(&ff[j++], 1); --i; }

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    You can try this, open the "srvc.txt", and select all text, and copy them, and open anthor TextEditor(Edit Plus), and paste. If still there is no new line, then I have no ideas. It's seems that Microsoft define a new line as '\r\n', while in Unix it's '\n'.

    C / C++ / MFC c++ help question

  • search a list control
    C carter2000

    You can try veiwing the text in Edit Plus or other text edit software.

    C / C++ / MFC c++ help question
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups