Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

combobox

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

610 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