Click here to Skip to main content
15,909,039 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In an own small software tool, we change the orientation according to user input. It works well, with one exception. After a reboot always the landscape orientation is restored.

Here are the essential lines of code, that we use:

mode.dmDisplayOrientation = portrait ? DMDO_270 : DMDO_DEFAULT;
ChangeDisplaySettingsEx(device.DeviceName, &mode, NULL, CDS_UPDATEREGISTRY | CDS_RESET | CDS_GLOBAL, NULL);


How can I figure out, the reason for the described problem?

What I have tried:

I read MSDN documentation. Changed the main monitor (2 monitors are conected to the PC). ....
Posted
Updated 15-Jul-19 5:24am
Comments
Richard MacCutchan 15-Jul-19 11:36am    
You are not checking the return value so it is impossible to guess whether it was successful at changing the registry.

USE.THE.DEBUGGER.

If you can't use the tools you have on hand, you will NOT succeed as a programmer.
 
Share this answer
 
NEVER perform a calculation and the assignment in a single line.

Break the calculation out into it own variable, then use the value in that variable to make the assignment. This makes it far easier to debug the code instead of guessing at the result of the calculation.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900