-
April 14th, 2020, 09:56 AM
#1
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);
}
-
April 14th, 2020, 02:07 PM
#2
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?
-
April 14th, 2020, 02:16 PM
#3
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|