Solved

Really Easy : How do you reference a control ?

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

705 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

17 Experts available now in Live!

Get 1:1 Help Now