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

Thread: Setwindowtext not working when Application run as Admin

  1. #1
    Join Date
    Apr 2020
    Posts
    2

    Setwindowtext not working when Application run as Admin

    Hi,

    This problem has me pulling my hair out?? I have an application that doesn't display text for some users. I cannot replicate the problem as it works fine for me. I did discover that if I run the application as an administrator the problem happens?

    When running the application as an administrator the SetWindowText function does not work. When running the application as normal the SetWindowText works fine.

    If I try to debug the application in Visual Studio 2017 running the application in admin mode it works fine so I cannot see what the problem is. I have displayed a message box just before it calls SetWindowText and the messabe box displays the text correctly but the SetWindowText is blank?

    Here's an example of the test code.

    Code:
    // Declared in the Header file
    WCHAR m_UserPrompt[128];
    
    
    
    // CPP implementation file
    void CUserPromptDlg::GetDisplayPrompt(WCHAR *pUserPrompt)
    {
    	wcscpy(pUserPrompt, L"Test message");
    }
    
    
    void CUserPromptDlg::TestFunc1()
    {
    	GetDisplayPrompt(m_UserPrompt);
    	AfxMessageBox(m_UserPrompt);
    	SetDlgItemTextW(IDS_USER_PROMPT, m_UserPrompt);
    }

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

    Re: Setwindowtext not working when Application run as Admin

    What happens if you try?
    Code:
    SetDlgItemTextW(IDS_USER_PROMPT, L"Test message");
    Also, is there any ddx variables bound to the IDS_USER_PROMPT resource?

    Lastly, I assume this code is compiled as UNICODE, not MBCS. Is this correct?

  3. #3
    Join Date
    Apr 2020
    Posts
    2

    Re: Setwindowtext not working when Application run as Admin

    If I try that the application works correctly and yes it is complied as UNICODE.

    If I copy the content of m_UserPrompt into a local CString variable and use that CString variable in SetWindowText it works fine in both normal mode and run as Admin.

    As far as I can remember this problem seems to arrive when we upgraded to use the latest SDK kit. It was originally using windows SDK 8.1 but I can't say for sure?? I did try to switch back to SDK 8.1 but the problem is still there?

    I've tried everything to find out what the problem is?

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width




On-Demand Webinars (sponsored)