Solved

combobox

Posted on 1997-02-25
1
716 Views
Last Modified: 2013-11-20
Hi All,

environment: VC++1.5 and Win 3.11

I have a little big problem:

I have 3 ComboBox ( from 3rd party) in my CDialog.

Iwant to know when a user press a key, which key pressed and in which combobox?

I use this code to know which combobox has a focus:

::GetDlgCtrlID(::GetFocus())

This code works fine with Cedit control and not with combobox.

In the case of combobox this code return the value : 1001 which doesn't correspond
with the reel control ID of these combobox.
what can i do?


In other side i don't know how to retrieve the text typed in these combobox.

in the case of CEdit control this code works fine:

CWnd *pEditbox;
pEditbox = GetDlgItem(ID);
GotoDlgCtrl(pEditbox);
CEdit * pEditCtrl = (CEdit *)pEditbox;
pEditCtrl->SetSel(-1);
pEditCtrl->GetWindowText(word,30);

is it possible to use similar code by replacing the CEdit by CComboBox???
This is will be possible if i know how to retreive the ID number of the
combobox as explained above.

thanks;

                                                Dja.
0
Comment
Question by:djamal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 23

Accepted Solution

by:
chensu earned 100 total points
ID: 1300211
1. I want to know when a user press a key, which key pressed and in which combobox?
// get the three combobox window pointers
CWnd *pcbox1 = GetDlgItem(ID1);
CWnd *pcbox2 = GetDlgItem(ID2);
CWnd *pcbox3 = GetDlgItem(ID3);

// get the focus window pointer
CWnd *pEdit = CWnd::GetFocus();

if (pEdit == pcbox1 || pcbox1->IsChild(pEdit))
    // combobox 1
if (pEdit == pcbox2 || pcbox2->IsChild(pEdit))
    // combobox 2
if (pEdit == pcbox3 || pcbox3->IsChild(pEdit))
    // combobox 3


2. How to retrieve the text typed in these combobox.
CWnd *pEdit = CWnd::GetFocus();
if (pEdit != NULL)
    pEdit->GetWindowText(word,30);

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
repeateFront java challenge 31 99
twoTwo  challenge 35 118
pre4 challenge 19 116
Problem to open Excel file 15 261
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question