DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: combox box problem

  1. #1
    Join Date
    Jun 2006
    Posts
    11

    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!

  2. #2
    Join Date
    Apr 2006
    Location
    Zagreb, Croatia
    Posts
    152
    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

  3. #3
    Join Date
    Jun 2006
    Posts
    11
    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.

  4. #4
    Join Date
    Apr 2006
    Location
    Zagreb, Croatia
    Posts
    152
    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;
    }
    }

  5. #5
    Join Date
    Jun 2006
    Posts
    11
    Thanks that worked!
    Now just to get those **** colours changing!

Similar Threads

  1. Problem with a message box
    By Castello in forum C++
    Replies: 3
    Last Post: 02-06-2006, 05:04 AM
  2. Datalist Box problem
    By Spumbu1977 in forum VB Classic
    Replies: 1
    Last Post: 01-12-2006, 11:09 AM
  3. Reliability Problem
    By elise in forum Java
    Replies: 0
    Last Post: 10-30-2002, 05:40 AM
  4. Replies: 1
    Last Post: 12-10-2000, 03:59 PM
  5. 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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center