CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 14 of 14
  1. #1
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    9

    [RESOLVED] Please suggest for this dialog based application...

    For every english alphabet you have to map it value e.g.,

    A - 1
    B - 2
    C - 3
    .
    .
    .
    Z - 26

    You have to create one dialogbox in which 2 edit box will be there. In one edit box we can input text and the other edit box will be read only in which the summation of the alphabets entered in the first edit box will be displayed as soon as we enter an alphabet and the value should be decremented as soon as we delete any alphabet.

    Please suggest me how to proceed.

    Thanks..

  2. #2
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Please suggest for this dialog based application...

    1. Create a dialod with two edit controls (as stated)
    2. Handle the EN_CHANGE notification message in the first control
    3. In the EN_CHANGE message handler read the text from the first edit control
    4. In a loop get every char of the read text, find out according number from the map and calculate the sum
    5. Set this number to the second edit box
    Victor Nijegorodov

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

    Re: Please suggest for this dialog based application...

    Victor's already done it for you, but the key to any problem is to break it down into smaller problems.

    Can you create a dialog app?
    Can you create edit controls?
    Can you make one read only?
    Do you know what to do when the edit changes?
    Can you convert the alpha characters to a numeric value?
    Can you do basic math?

    Figure out what you can do, do it, then ask when you get stuck.

  4. #4
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    9

    Re: Please suggest for this dialog based application...

    Quote Originally Posted by VictorN View Post
    1. Create a dialod with two edit controls (as stated)
    2. Handle the EN_CHANGE notification message in the first control
    3. In the EN_CHANGE message handler read the text from the first edit control
    4. In a loop get every char of the read text, find out according number from the map and calculate the sum
    5. Set this number to the second edit box
    Thanks alot.

    Please let me know how to set the cursor at the edit box when the dilog is created..

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

    Re: Please suggest for this dialog based application...

    Please let me know how to set the cursor at the edit box when the dilog is created..
    CWnd::SetFocus

  6. #6
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Please suggest for this dialog based application...

    Another way is using CDialog::GotoDlgCtrl
    Victor Nijegorodov

  7. #7
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    9

    Re: Please suggest for this dialog based application...

    Is there a property that I can use to set the Textbox to show capital alphabet even if I type using lower case ?

  8. #8
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: Please suggest for this dialog based application...

    If by text Textbox you mean static control, no.
    If by Textbox you mean edit control, yes. You can set ES_UPPERCASE style
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  9. #9
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    9

    Re: Please suggest for this dialog based application...

    Quote Originally Posted by Skizmo View Post
    Hi all,

    I added this code inside OnInitDialog() to set the focus on the Edit Box when the dialog is created. Still its not getting the focus. Please suggest..

    Code:

    CEdit *EditInput;
    EditInput = reinterpret_cast<CEdit *>(GetDlgItem(IDC_INPUT)); // IDC_INPUT is the ID of the Edit Box
    EditInput->SetFocus();

    Thanks

  10. #10
    VictorN's Avatar
    VictorN is offline Super Moderator Power Poster
    Join Date
    Jan 2003
    Location
    Hanover Germany
    Posts
    20,430

    Re: Please suggest for this dialog based application...

    See the post#6
    Victor Nijegorodov

  11. #11
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    9

    Re: Please suggest for this dialog based application...

    Quote Originally Posted by VictorN View Post
    See the post#6
    Same thing happening with
    CDialog::GotoDlgCtrl

  12. #12
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    9

    Re: Please suggest for this dialog based application...

    Quote Originally Posted by jawedalamkhan View Post
    Same thing happening with
    CDialog::GotoDlgCtrl
    Oh..

    I m sorry !

    The problem was due to the return value of the dialog was set to TRUE.

  13. #13
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917

    Re: [RESOLVED] Please suggest for this dialog based application...

    This all is too complicated for just setting focus on control when dialog starts.
    Simply, in dialog editor set tab order for edit control to 1.
    This will set focus to this control on start. DO not change any return values, keep it default.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  14. #14
    Join Date
    Dec 2006
    Location
    Bangalore, India
    Posts
    9

    Re: [RESOLVED] Please suggest for this dialog based application...

    Ok..

    Thanks.

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured