error in use edit control and EndDialog() !!!

Discussion in 'MFC' started by hadikazemi, Sep 30, 2009.

  1. hadikazemi

    hadikazemi Banned

    Joined:
    Sep 30, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    hi
    i use one edit Control in my Dialog.
    when i use below code for read content of it :

    Code:
    GetWindowTextA(hEdit,editStr,10);
    
    if content of Edit control is more than one Character my program give error in :

    Code:
    EndDialog( hDlg, FALSE );
    
    error:

    First-chance exception at 0x7e424f4a in CreateDevice.exe: 0xC0000005: Access violation reading location 0x00003355.
    Unhandled exception at 0x7e424f4a in CreateDevice.exe: 0xC0000005: Access violation reading location 0x00003355.


    if i enter one Character in Edit control error dont accure.

    why ?
     
  2. shabbir

    shabbir Administrator Staff Member

    Joined:
    Jul 12, 2004
    Messages:
    15,375
    Likes Received:
    388
    Trophy Points:
    83
    Looks like you have not allocated editStr correctly and so when the content of the box is being copied it gives an error.
     
  3. hadikazemi

    hadikazemi Banned

    Joined:
    Sep 30, 2009
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    editStr is LPSTR and i debug it. my program get string correctly and store it on editStr but only cant do EndDialog() if string be more than one Character!
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice