Solved

Really Easy : How do you reference a control ?

Posted on 1998-12-12
1
165 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
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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
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.

840 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