Solved

combobox

Posted on 1997-02-25
1
699 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
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now