Maybe a weird question

This is a discussion on Maybe a weird question within the C++ Programming forums, part of the General Programming Boards category; > Thanks but I already got it to work. Care to share?...

  1. #16
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    > Thanks but I already got it to work.
    Care to share?
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  2. #17
    Registered User
    Join Date
    Aug 2006
    Sorry I thought nobody wanted to see my crummy code.

    I narrowed it down to only three columns to search for. Other were nonsense anyway.

    Look and be amazed!
    (translated for easier undestanding)

    void CVaja6ListControlDlg::OnBtnFind() 
    	// clean the list of previously selected items
    	int i=0;
    		m_cMyList.SetItemState(i, 0, LVIS_SELECTED); 
    	CString readName;
    	CString readSurname;
    	CString readAge;
    	int numberChecks=3; // let's say all three check boxes were selected
    	// then we substract 1 if it was not checked 
    	// if not checked we set some nonsense so there won't be a hit
    		{ m_name="ihopeyoudidntinputthis"; numberChecks--; }  
    		{ m_surname="ihopeyoudidntinputthis"; numberChecks--; }
    		{ m_age=9545; numberChecks--; }
    	// if no checboxes were checked we exit otherwise everything will be a hit
    	if(numberChecks==0) { return; } 
    	int hits; // number of hits, if this equals numberChecks we have a complete hit
    	m_cMyList.SetFocus(); // focus on listctrl so we can select
    		readName = m_cMyList.GetItemText(i,0);	// read from CListCtrl
    		readSurname = m_cMyList.GetItemText(i,1);
    		readAge = m_cMyList.GetItemText(i,2);
    		// compare what we read from CListCtrl with what was put into the edit boxes to search for
    			{ hits++; }
    			{ hits++; }
    		CString strStarost;
    		strStarost.Format("%i", m_age);	
    			{ hits++; }
    		if(numberChecks==hits) // if we have a complete hit
    			m_cMyList.SetItemState(i, LVIS_SELECTED, 0xFF);
    	// here I should scrool the list down to the last record found, but how??
    Last edited by MarkookraM; 08-25-2006 at 12:18 PM.

Page 2 of 2 FirstFirst 12
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A weird question.
    By IanKoro in forum C Programming
    Replies: 19
    Last Post: 06-08-2009, 12:00 PM
  2. another do while question
    By kbpsu in forum C++ Programming
    Replies: 3
    Last Post: 03-23-2009, 12:14 PM
  3. Question...
    By TechWins in forum A Brief History of
    Replies: 16
    Last Post: 07-28-2003, 09:47 PM
  4. opengl DC question
    By SAMSAM in forum Game Programming
    Replies: 6
    Last Post: 02-26-2003, 08:22 PM
  5. Weird Question maybe
    By Unregistered in forum C++ Programming
    Replies: 3
    Last Post: 12-27-2001, 06:30 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21