Solved

Disabling button using OnUpdate handler

Posted on 1998-01-06
3
477 Views
Last Modified: 2013-11-20
Is it possible to disable (via EnableWindow( FALSE ) or some other documented mechanism) a CButton control in a VC 1.52 CRecordView by using an ON_UPDATE_COMMAND_UI handler ?  I know I could probably do it via a custom DDX routine (examine the value for the field, then disable the control) but for various reasons I don't really want to write another custom DDX routine for this application (although if I have to, I will).  Thanks.
0
Comment
Question by:xn12z9i
[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
3 Comments
 
LVL 1

Expert Comment

by:richhxb
ID: 1313497
Just use UpdateData to get the value for the field,
then enable or disable the control according to the
value using EnableWindow.


0
 

Author Comment

by:xn12z9i
ID: 1313498
From what function/handler should I call UpdateData() ? I've already tried doing this from my ON_UPDATE_COMMAND_UI handler. Also, as this is a Recordview, I would prefer to let the framework call UpdateData() so that my recordset does not get clobbered.

I guess what I want to know is, will the following work, and if not, what is the best way to implement what I want from a single handler function ?

ON_UPDATE_COMMAND_UI(IDC_MY_BUTTON, OnUpdateMyButton1)

void CMyRecordView::OnUpdateMyButton1(CCmdUI *pCmdUI)
{
    CButton *pb = (CButton *) GetDlgItem( IDC_MY_BUTTON );

    if( pb->GetCheck() )
        pCmdUI->Enable( FALSE );
    else
        pCmdUI->Enable( TRUE );
}
0
 
LVL 1

Accepted Solution

by:
WBerthin earned 100 total points
ID: 1313499
THE FOLLOWING WILL WORK TO "GRAY" THE CONTROL
      
CWnd* pButton = GetDlgItem(IDC_MY_BUTTON );
pButton->EnableWindow(FALSE);

And of course substitute TRUE for FALSE to put the
button back on.

If you have the ON_UPDATE_COMMAND_UI handler set up
right you should be OK with this.

0

Featured Post

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
method notes when mouse over in eclipse 5 94
sum67 challenge 35 127
My project did see openJDK that I installed. What could be the problem 7 169
JQuery serialize and unserialize 8 260
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

739 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