From CComboBox to CSpinButtonCtrl (Help Help)

This is a discussion on From CComboBox to CSpinButtonCtrl (Help Help) within the Windows Programming forums, part of the Platform Specific Boards category; I have "translated" this line, where I use the ComboBox: Code: CComboBox* box1 = ((CComboBox*)GetDlgItem(IDC_COMBO1)); to this, because I have ...

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    45

    From CComboBox to CSpinButtonCtrl (Help Help)

    I have "translated" this line, where I use the ComboBox:
    Code:
    CComboBox* box1 = ((CComboBox*)GetDlgItem(IDC_COMBO1));
    to this, because I have to use the CSpinButtonCtrl:
    Code:
    CSpinButtonCtrl *spin1 = (CSpinButtonCtrl*)GetDlgItem(IDC_SPIN1);
    By now everything is good, but I have a problem in that line:
    Code:
    CText* key = new CText(&usedAlphabet);
    key->addSymbol((CSymbol*)box1->GetItemDataPtr(box1->GetCurSel()));
    I have to translate this line
    Code:
    key->addSymbol((CSymbol*)box1->GetItemDataPtr(box1->GetCurSel()));
    using the CSpinButtonCtrl, but I'm not able.
    I thought something like this:
    Code:
    key->addSymbol((CSymbol*)spin1->(and here?????)
    I don't know how can I change the last line using the CSpinButtonCtrl, cause I need to use it!

    Someone could help me?

  2. #2
    Registered User
    Join Date
    Jul 2005
    Posts
    45
    No hints??

  3. #3
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Bumping posts is against the board rules....

    Start by understanding what the old code DOES....

    GetItemDataPtr() gets the additional info for an item (lparam). I use it to hold indexes (from a list, array or DB recordset). This is so the items in the combo can be sorted and you can still find the index to the original list.



    What is the spinbuttons buddy control?

    Thats where you need to get the data from.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    45
    I have a combobox with 26 letters (from A-Z) and I have to an edit control + the spin button so I can "navigate" among the letters.

    I have two edit controls, one on the left and one on the right, I write for example "A" in the edit control on the left, push a button that has to codify my letter reading what letter there is in the "box1" and the codified letter will appear in the edit control on the right!

    I have to do the same thing with the Spin but I don't know how!

  5. #5
    train spotter
    Join Date
    Aug 2001
    Location
    near a computer
    Posts
    3,859
    Don't understand what you want....

    Each item in the combo contains two pieces of data.

    The item text and the item lparam. Find where you add the items to the combo and what this second piece of data is (lparam).


    break this down
    key->addSymbol((CSymbol*)box1->GetItemDataPtr(box1->GetCurSel()));


    iSelection = box1->GetCurSel();
    lParam = box1->GetItemDataPtr(iSelection);
    key->addSymbol(lParam);

    You should be changing the letter each time the spincontrols is clicked.
    Once the user has finalised their selection you will need to
    find the relevant letter,
    convert to this letters second piece of data (lparam).
    Then add this to your 'key'.
    "Man alone suffers so excruciatingly in the world that he was compelled to invent laughter."
    Friedrich Nietzsche

    "I spent a lot of my money on booze, birds and fast cars......the rest I squandered."
    George Best

    "If you are going through hell....keep going."
    Winston Churchill

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. CComboBox scrolling
    By smash84 in forum Windows Programming
    Replies: 2
    Last Post: 08-15-2006, 11:09 AM
  2. CComboBox issue
    By axr0284 in forum Windows Programming
    Replies: 0
    Last Post: 03-11-2006, 01:33 PM
  3. Visual C++ Problem, CComboBox
    By UnclePunker in forum C++ Programming
    Replies: 5
    Last Post: 09-17-2003, 10:11 AM
  4. CComboBox
    By DominicTrix in forum Windows Programming
    Replies: 4
    Last Post: 09-06-2003, 10:28 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21