1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Drop-down (Combo Box)

Discussion in 'MFC' started by stp, Feb 8, 2008.

  1. stp

    stp New Member

    Joined:
    Feb 8, 2008
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    I want to do this.Two drop-down lists

    First contains hard-disk drives on my computer

    [​IMG]


    And the second drop-down i want to contains files in the drive that i choose in the first drop-down

    Here are the files

    [​IMG]


    I am using Visual Studio C++ 6.
    Can you tell me or give me links how to scan hard disks on my computer and add them to the first drop-down then to see the files in this drive in the second drop-down
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Use GetLogicalDrives, which returns a DWORD that's a bitmask telling which drive letters are assigned. Bit 0 is drive A, bit 1 is drive B, and so on.
     
  3. stp

    stp New Member

    Joined:
    Feb 8, 2008
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    10x.But i have a question.
    This code scan for drivers.But how to add the strings to the combo box.How to show them?

    Code:
    int main()
    
    {
    		char buf[1000];
    	DWORD buf_size, cnt;
    
    	buf_size = GetLogicalDriveStrings(1000, buf);
    
    	cout << "buf_size= " << buf_size << endl;
    
    
    
    	cout << &buf[4] << endl;
    
    
    	int i;
    	for(i=0;i<buf_size;i=i+strlen(&buf[i])+1)
    	{cout << &buf[i] << " ";}
    
    
    
    	return 0;
    }
    
     
  4. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,283
    Likes Received:
    364
    Trophy Points:
    83
    Depending on the number of bit set you need to add the character 'A' , 'B' as a string into the combo box.
     

Share This Page