dcsimg
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: Can't access dialog elements in MFC

  1. #1
    Join Date
    Sep 2014
    Location
    Las Vegas, NV
    Posts
    85

    Can't access dialog elements in MFC

    Hello
    I'm trying to access static text element from a thread from a second modal dialog.
    Code:
    CRDPDlg* MainDialog = (CRDPDlg *)AfxGetApp()->m_pMainWnd;
    MainDialog->statictext1.SetWindowTextW(L"OK");
    It shows unhandled exception error but can't understand why
    Any help is appreciated

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,227

    Re: Can't access dialog elements in MFC

    UI components should only be accessed from the thread you created them in.

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

    Re: Can't access dialog elements in MFC

    Has Windows created the controls yet? Just creating the CDialog object doesn't actually create the controls. You're probably trying to set text on a window that doesn't exist yet.

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




On-Demand Webinars (sponsored)