?
Solved

Really Easy : How do you reference a control ?

Posted on 1998-12-12
1
Medium Priority
?
168 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

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

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
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 video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
Suggested Courses

741 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