-
combox box problem
ok my problem is:
I have a combobox and 3 shapes (circle, square and ellipse)
Each of the shapes is listed in my combobox
When I select 'square' i need my square to appear and the other 2 to disappear
and likewise when I select circle, circle needs to appear and when I select ellipse i need ellipse to appear.
Now I've managed to do this with buttons, no problem!
(heres my button code for ellipse:
void __fastcall TForm1::EllipseButtonClick(TObject *Sender)
{
if (Ellipse->Visible == false);
{
Square->Visible = false;
Circle->Visible = false;
Ellipse->Visible = true;
}
}
)
But I just cannot work out the code for the combobox! I've tried my compilers help system but it really was no help at all!
I'm provided with this:
void __fastcall TForm1::ComboBox1Change(TObject *Sender)
for my combobox
and I believe I need to use this:
ComboBox1 = new TComboBox(this);
please help I am completely stumped!
also how do I change the colour of shapes? changing the colour of forms, no problem, but shapes?! HELP!
-
First explain exactly what you're trying to do with the combobox, if you want your combobox to display graphic images of a square, ellipse or circle then you should use csOwnerDraw style for your combobox and write the corresponding event handler.
To change the color of a shape use the TCanvas' Brush property like
Canvas->Brush->Color = clYellow;
Canvas->Ellipse(0,0,100,100); //the ellipse will be filled with yellow
-
selecting a shape from the combobox dropdown menu should have the same effect as the buttons, the shape selected will appear if its not already visible.
I tried using the code with Canvas suggested but my compiler says square is not a member of TCanvas if i put it in OnStartDrag event (there is no onclick event)
if i put it in onmousedown, nothing happens
(the shapes want to change colour when the mouse button is clicked on them)
I am really regretting taking this course theres no way I'm gonna pass my final exam if I can't even get these simple things
Last edited by iiisecondcreep; 07-21-2006 at 07:58 AM.
-
If the code for button works there's no reason why it shouldn't work for the combobox.
void __fastcall TForm1::TComboBoxOnChange(TObject* sender)
{
if (ComboBox1->ItemIndex != -1) {//make sure the user selected an item
switch (ComboBox1->ItemIndex) {
case 0:
//draw circle
break;
case 1:
//draw ellipse
break;
case 2:
//draw square
break;
}
}
-
Thanks that worked!
Now just to get those **** colours changing!
Similar Threads
-
Replies: 3
Last Post: 02-06-2006, 05:04 AM
-
By Spumbu1977 in forum VB Classic
Replies: 1
Last Post: 01-12-2006, 11:09 AM
-
Replies: 0
Last Post: 10-30-2002, 05:40 AM
-
By Dhiraj Nilange in forum Java
Replies: 1
Last Post: 12-10-2000, 03:59 PM
-
By Tony cyriac in forum Java
Replies: 1
Last Post: 05-29-2000, 11:26 AM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Development Centers
-- Android Development Center
-- Cloud Development Project Center
-- HTML5 Development Center
-- Windows Mobile Development Center
|