Dialog box focus
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Dialog box focus

  1. #1
    Join Date
    Jun 2010
    Posts
    23

    Dialog box focus

    Hello,
    I am writing a program using VC++ with MFC,
    I added some dialog boxes and I want that once one of the dialog is opened by DoModal()
    all the buttons on the parent dialog will be disabled,
    How can I do it?


    thanks

  2. #2
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,228

    Re: Dialog box focus

    What's the point in that? DoModal will prevent the user from accessing all other windows anyway.

  3. #3
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Re: Dialog box focus

    What's the point in that? DoModal will prevent the user from accessing all other windows anyway.
    Sometimes it looks nice

    With GetWindow you can enumerate all the children of the dialog, and with IsKindOf you can check if the childwindow is a CButton and en/disable it. With these 2 you can make a loop that loops all the elements on a dialog and set the buttonstate.

  4. #4
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,605

    Re: Dialog box focus

    Quote Originally Posted by Skizmo View Post
    S... and with IsKindOf you can check if the childwindow is a CButton and en/disable it. With these 2 you can make a loop that loops all the elements on a dialog and set the buttonstate.
    I'd suggest checking windows class (using GetClassName) rather than MFC class because there may be unsubclassed buttons.
    Victor Nijegorodov

  5. #5
    GCDEF is offline Elite Member Power Poster
    Join Date
    Nov 2003
    Location
    Florida
    Posts
    12,228

    Re: Dialog box focus

    Again though, what's the point in disabling buttons you can't click on anyway?

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Wallisellen (ZH), Switzerland
    Posts
    17,605

    Re: Dialog box focus

    Quote Originally Posted by GCDEF View Post
    Again though, what's the point in disabling buttons you can't click on anyway?
    I don't know! Perhaps, OP would like to see all these buttons as disabled!?
    Victor Nijegorodov

  7. #7
    Join Date
    Jul 2005
    Location
    Netherlands
    Posts
    2,016

    Re: Dialog box focus

    I agree with GCDEF. It's more user-friendly to let an application behave as most other applications do. Otherwise, it's just confusing. Users may think there is something wrong with the application just because a button is disabled when they didn't expect it.
    Cheers, D Drmmr

    Please put [code][/code] tags around your code to preserve indentation and make it more readable.

    As long as man ascribes to himself what is merely a posibility, he will not work for the attainment of it. - P. D. Ouspensky

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center