Solved

Really Easy : How do you reference a control ?

Posted on 1998-12-12
1
166 Views
Last Modified: 2010-04-02
I have a resource file that contains a dialog box which in turn contains 3 Text boxes (Edit Controls) and a button. When the button is clicked I want to disable the text boxes.

There is only one dialog for the entire application (done with CreateDialogParam). When the user clicks on the button I receive the windows message and the handle to the button : I need to use the EnableWindow API but how do I pass it the hWnd of the Text boxe  ?


here is some sammple code (in BASIC) :

CASE %WM_COMMAND
   SELECT CASE LOWRD(wParam)
          CASE 104
          '== [ Start/Abort Button Clicked ] ==
          IF HIWRD(wParam) = %BN_CLICKED THEN
                     Dim cbtnText as ASCIIZ * 256
                     Dim iRCLen as Integer
                iRCLen = GetWindowText (lParam,cbtnText,255)
                if left$(cbtnText,iRCLen) = "&Start Router" then  
                    SetWindowText lParam,"&Abort"
                    '<< Diable Text Boxes >>
                else
                    SetWindowText lParam,"&Start"
                  EnableWindow 101,0
             end if

              END SELECT
0
Comment
Question by:dm_14
[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 8

Accepted Solution

by:
Answers2000 earned 0 total points
ID: 1180005
Use the GetDlgItem API to get the HWND of the text box

The format is

HWND hWndText = GetDlgItem( hWndDialog, IDC_TEXT ) ;

You have the hWndDialog (hWnd of the dialog, this comes in the message you're responding to).  IDC_TEXT is the control id of the text box.


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

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

749 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