Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding images to TComboBox / TTabControl

Status
Not open for further replies.

801119

Programmer
Apr 10, 2000
311
SE
Hey all..!!

I know it's possible, and I find example codes in 'BCB help'!! But it doesn't work!! the code follows:
It adds everything but the graphic..!? Why?
Is it beacuse of my version? (BCB 3 Standard)

{
static char * Drive_Letter[]={"a:\\","b:\\","c:\\","d:\\","e:\\","f:\\",
"g:\\","h:\\","i:\\","j:\\","k:\\","l:\\","m:\\","n:\\","o:\\","p:\\",
"q:\\","r:\\","s:\\","t:\\","u:\\","v:\\","w:\\","x:\\","y:\\","z:\\"};

int AddedIndex;
for(int x =0; x <= 25; x++ )
{
switch(GetDriveType(Drive_Letter[x]))
{
case DRIVE_REMOVABLE:
AddedIndex=DriveTabSet->Tabs->AddObject(String(Drive_Letter[x]),
Floppy->Picture->Graphic);
break;
case DRIVE_FIXED:
AddedIndex=DriveTabSet->Tabs->AddObject(String(Drive_Letter[x]),
Fixed->Picture->Graphic);
break;
case DRIVE_REMOTE:
AddedIndex=DriveTabSet->Tabs->AddObject(String(Drive_Letter[x]),
Network->Picture->Graphic);
break;
case DRIVE_CDROM:
AddedIndex=DriveTabSet->Tabs->AddObject(Drive_Letter[x],
Floppy->Picture->Graphic);
break;
case DRIVE_RAMDISK:
AddedIndex=DriveTabSet->Tabs->AddObject(Drive_Letter[x],
Floppy->Picture->Graphic);
break;
}
}
} Martin G Broman
mgb_svea@thevortex.com

DWS - Alpha Whitin Dead Wolf Society
 
Greetings!

If you want use TTabControl instead. It have the property you need, the Images is pointer to image list that may contains all needed pictures for any drive type.
 
Yes, I would really appreciate it!
The problem is that I've tried this code on a TTabContrl, also! But didn't work!

If you got any idee how to make it work, I'll listen!! Martin G Broman
mgb_svea@thevortex.com

DWS - Alpha Whitin Dead Wolf Society
 
Greetings!

This sample of my code!

static char * Drive_Letter[]={&quot;a:\\&quot;,&quot;b:\\&quot;,&quot;c:\\&quot;,&quot;d:\\&quot;,&quot;e:\\&quot;,&quot;f:\\&quot;,
&quot;g:\\&quot;,&quot;h:\\&quot;,&quot;i:\\&quot;,&quot;j:\\&quot;,&quot;k:\\&quot;,&quot;l:\\&quot;,&quot;m:\\&quot;,&quot;n:\\&quot;,&quot;o:\\&quot;,&quot;p:\\&quot;,
&quot;q:\\&quot;,&quot;r:\\&quot;,&quot;s:\\&quot;,&quot;t:\\&quot;,&quot;u:\\&quot;,&quot;v:\\&quot;,&quot;w:\\&quot;,&quot;x:\\&quot;,&quot;y:\\&quot;,&quot;z:\\&quot;};

UINT dr;

for(int i = 0; i < 26; i++)
{
dr = GetDriveType(Drive_Letter);
if(!dr || dr == 1)
continue;
DriveTabControl->Tabs->Add(Drive_Letter);
switch(dr)
{
case DRIVE_REMOVABLE:
DriveTabControl->Images->Add(FlopBmp,NULL);
break;
case DRIVE_FIXED:
DriveTabControl->Images->Add(HardBmp,NULL);
break;
case DRIVE_REMOTE:
DriveTabControl->Images->Add(NetBmp,NULL);
break;
case DRIVE_CDROM:
DriveTabControl->Images->Add(CDBmp,NULL);
break;
case DRIVE_RAMDISK:
DriveTabControl->Images->Add(RamBmp,NULL);
break;
}
}


Where FlopBmp is TBitmap with preloaded picture of floppy drive, HardBmp is one with picture of hard drive, and so on.

If you need only existing drives, you should use GetLogicalDriveStrings function, which return pointer to string (type of char *) of existing drive letters.
 
I tried your code, but was unable to make it work!

I got this error message:
'Images' is not a member of 'Comctrl::TTabControl'

Got any idea what it means? Martin G Broman
mgb_svea@thevortex.com

DWS - Alpha Whitin Dead Wolf Society
 
Greetinx!

I'am using the BCB5 and it has that property!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top