Solved

combobox

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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 …
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.
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…

729 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