?
Solved

combobox

Posted on 1997-02-25
1
Medium Priority
?
718 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 200 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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…

752 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