Combox problem

Discussion in 'MFC' started by answerme, Jan 2, 2010.

  1. answerme

    answerme New Member

    Joined:
    Dec 17, 2007
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    0
    Dear Friends
    I have combo box in which i have two strings i.e. nothing but properties->data ->insert string
    First is BABINA & 2nd JAIPUR
    I have two maps which are in tga format ( map1.tga & map2.tga). What i want is when i selected BABINA & press OK map1.tga should display & when I select JAIPUR & press OK map2.tga should display .
    Right now only map1.tga is getting displayed.

    Code:
    [B] CenView.cpp[/B]
    int CenView::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    	if (CView::OnCreate(lpCreateStruct) == -1)
    		return -1;
    
    	HWND hWnd = GetSafeHwnd();
    	HDC hDC = ::GetDC(hWnd);
    
    	if (SetWindowPixelFormat(hDC)==FALSE)
    		return 0;
    
    	if (CreateViewGLContext(hDC)==FALSE)
    		return 0;
    
    	[B]m_objTexture.LoadTGA("map2.tga") ;  
    
    	m_objTexture.LoadTGA("map1.tga") ;[/B]
    	objQuad = gluNewQuadric();
    	gluQuadricNormals(objQuad,GLU_FLAT);
    	gluQuadricDrawStyle(objQuad,GL_LINE); 
    	gluQuadricOrientation(objQuad,GLU_OUTSIDE);
    	gluQuadricTexture(objQuad,GL_TRUE);
    
    	return 0;
    }

    Code:
    [B]CLocationSelection.cpp[/B]
    BOOL CLocationSelection::OnInitDialog()
    {
    	CDialog::OnInitDialog();
    
    	((CComboBox*)GetDlgItem(CMB_LOC_SEL))->SetCurSel(0) ;
    	[B]mycombo.FindString(0,"BABINA");
             mycombo.FindString(0,"JAIPUR");[/B]
    	return TRUE;  
    }
    
    I dont know how to link my Data i.e babina with map1.tga & jaipur with map2.tga. Does anyone have solution
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Put the condition when loading the map here

    Code:
    	m_objTexture.LoadTGA("map2.tga") ;  
    
    	m_objTexture.LoadTGA("map1.tga") ;
    
    The condition should be which is selected in combo box
     
  3. answerme

    answerme New Member

    Joined:
    Dec 17, 2007
    Messages:
    114
    Likes Received:
    0
    Trophy Points:
    0
    ya i gave the condition but still its not working

    Code:
    if(mycombo.FindString(0,"babina")==0)
    		m_objTexture.LoadTGA("map1.tga") ;
    	if(mycombo.FindString(1,"jaipur")==0)
    		m_objTexture.LoadTGA("map2.tga") ;
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    It should be selected index of the combox and not FindString.

    Also remember to test for right Case. Lower Case String with Lower case and vice versa
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice