CListBox vertikale Srcollbar anzeigen



  • hi

    ich hab ne CListBox erstellt
    einfach indem ich folgedes geschrieben hab:

    CListBox * textBox; 
    textBox = new CListBox();
    textBox->Create( WS_BORDER | WS_CHILD | WS_VISIBLE | ES_WANTRETURN, CRect(50,250,1230,700), this, 1 ) ;
    textBox->ShowWindow(1);
    

    das funktioniert auch und ich kann da auch ganz normal zeilen rein schreiben...
    nun möchte ich aber das die vertikale Scrollbar angezeigt wird wenn zuviel zeilen drin stehn ... wie bekomm ich das hin ???

    mfg LT


  • Mod



  • WS_VSCROLL hab ich beim create mit rein genommen und die wird mir jetzt auch angezeigt ... aber benutzen kann ich die scrollbar nicht ... also weder die hoch runter buttons noch die leiste direkt verschieben ...


  • Mod

    Hats Du genügend Einträge drin?

    Siehe Link den ich Dir gegeben habe:

    LBS_DISABLENOSCROLL (Windows Version 3.1 or Later)
    The LBS_DISABLENOSCROLL style causes the list box to disable any scroll bar that is not needed because the current contents fit the list box. Normally, when a list box scroll bar is not needed, it is hidden. The LBS_DISABLENOSCROLL style must be used in conjunction with the WS_VSCROLL or WS_HSCROLL style.

    WS_VSCROLL and WS_HSCROLL
    When either or both of these styles are specified for a list box, scroll bars are created for the list box.

    A vertical scroll bar is displayed when there are more items in a list box without the LBS_MULTICOLUMN style than can be displayed at one time. Without a scroll style (WS_VSCROLL or WS_HSCROLL), the list box will not display a vertical scroll bar, although the list box still scrolls when the user uses the mouse or keyboard. List boxes with the LBS_MULTICOLUMN style cannot scroll vertically, so no vertical scroll bar is displayed.



  • void SetAnzeigeText(CString text){
    	locker.Lock();
    	CString lastzeile;
    	if(textBox->GetCount()>0){
    		for(int i=textBox->GetCount(); i>0; i--){
    			CString ins;
    			textBox->GetText(i-1,ins);
    			textBox->DeleteString( i ) ;
    			textBox->InsertString( i, ins ) ;
    		}
    	}
    
    	textBox->DeleteString( 0 ) ;
    	textBox->InsertString( 0 ,text );
    	textBox->ShowWindow(1);
    	locker.Unlock();
    }
            //erzeugen  
            CListBox * textBox; 
    	textBox = new CListBox();
    	textBox->Create( WS_BORDER | WS_CHILD | WS_VISIBLE | WS_VSCROLL , CRect(50,250,1230,700), this, 1 ) ;
    	textBox->ShowWindow(1);
            //Füllen
    	for(int ii=0; ii<50; ii++){
    		CString ausg;
    		ausg.Format("%i",ii);
    		SetAnzeigeText(ausg);
    	}
    


  • hmmm also wenn ich das richtig versteh müsste man noch LBS_DISABLENOSCROLL mit beim erstellen dazu schrieben ... nur das bringt auch nix ...


Anmelden zum Antworten