Click here to Skip to main content
15,885,757 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralCreate shortcut with initial window size Pin
baerten9-Dec-07 22:54
baerten9-Dec-07 22:54 
GeneralRe: Create shortcut with initial window size Pin
KarstenK10-Dec-07 0:22
mveKarstenK10-Dec-07 0:22 
GeneralRe: Create shortcut with initial window size Pin
baerten10-Dec-07 4:08
baerten10-Dec-07 4:08 
GeneralAbout VC++ Pin
john56329-Dec-07 22:36
john56329-Dec-07 22:36 
GeneralRe: About VC++ Pin
Cedric Moonen9-Dec-07 22:43
Cedric Moonen9-Dec-07 22:43 
GeneralRe: About VC++ Pin
Chandrasekharan P9-Dec-07 22:44
Chandrasekharan P9-Dec-07 22:44 
GeneralRegarding combo box Pin
Chandrasekharan P9-Dec-07 22:28
Chandrasekharan P9-Dec-07 22:28 
GeneralRe: Regarding combo box [modified] Pin
CPallini9-Dec-07 23:04
mveCPallini9-Dec-07 23:04 
With MFC, the simplest a way is binding the combo to an int a CString variable (use the Add Variable Wizard of VS) and then convert the latter to an int (for instance with _tstoi). You may also use the GetItemData/SetItemData pair to store (and retrieve) directly int values inside combo box items.
If you don't like MFC, the you should retrieve the item text and then convert it to int, i.e.
const INT SIZE=0x100;
TCHAR buffer[SIZE];
INT SelectedInt;
LRESULT sel = SendMessage(hCombo,CB_GETCURSEL,(WPARAM)0, (LPARAM)0);
if ( sel != CB_ERR)
{
  INT n = SendMessage(hCombo,CB_GETLBTEXT,(WPARAM)0, (LPARAM) (LPTSTR) buffer);
  if ( n != CB_ERR)
  {
    SelectedInt = _tstoi(buffer); // here's your integer
  }
}

Please note, I used a 'quick way' of allocating a relatively large buffer (since your combo contains short strings); you can use CB_GETLBTEXTLEN message to know requested buffer size in advance.

BTW, you have also the option to associate the int values to the Item Data of the combo box and retrieve it, whenever needed, via CB_SETITEMDATA message (it is left as an exercise for the reader... Big Grin | :-D ).


Smile | :)

If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.


modified on Monday, December 10, 2007 6:40:52 AM

GeneralRe: Regarding combo box Pin
Chandrasekharan P10-Dec-07 0:00
Chandrasekharan P10-Dec-07 0:00 
GeneralRe: Regarding combo box Pin
CPallini10-Dec-07 0:33
mveCPallini10-Dec-07 0:33 
GeneralRe: Regarding combo box Pin
Chandrasekharan P10-Dec-07 17:21
Chandrasekharan P10-Dec-07 17:21 
GeneralRe: Regarding combo box Pin
CPallini10-Dec-07 22:01
mveCPallini10-Dec-07 22:01 
GeneralRe: Regarding combo box Pin
Chandrasekharan P10-Dec-07 23:59
Chandrasekharan P10-Dec-07 23:59 
Generalproblem with network programming Pin
Kogee San9-Dec-07 22:11
Kogee San9-Dec-07 22:11 
GeneralRe: problem with network programming Pin
Cedric Moonen9-Dec-07 22:24
Cedric Moonen9-Dec-07 22:24 
GeneralRe: problem with network programming Pin
CPallini9-Dec-07 22:43
mveCPallini9-Dec-07 22:43 
GeneralRe: problem with network programming Pin
Kogee San11-Dec-07 19:36
Kogee San11-Dec-07 19:36 
GeneralRead the first byte of a buffer Pin
CodingLover9-Dec-07 20:58
CodingLover9-Dec-07 20:58 
GeneralRe: Read the first byte of a buffer Pin
Cedric Moonen9-Dec-07 21:03
Cedric Moonen9-Dec-07 21:03 
GeneralRe: Read the first byte of a buffer [modified] Pin
toxcct9-Dec-07 21:24
toxcct9-Dec-07 21:24 
GeneralRe: Read the first byte of a buffer Pin
CodingLover9-Dec-07 23:46
CodingLover9-Dec-07 23:46 
GeneralRe: Read the first byte of a buffer Pin
toxcct9-Dec-07 23:51
toxcct9-Dec-07 23:51 
GeneralRe: Read the first byte of a buffer Pin
CodingLover9-Dec-07 23:54
CodingLover9-Dec-07 23:54 
GeneralRe: Read the first byte of a buffer Pin
CodingLover9-Dec-07 21:50
CodingLover9-Dec-07 21:50 
GeneralModulable programming Pin
Lord Kixdemp9-Dec-07 20:57
Lord Kixdemp9-Dec-07 20:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.