Holger Posted June 11, 2004 Posted June 11, 2004 (edited) I needed a function to change the screenresolution and frequency so I started to write code to implement to Autoit3, cause I didn't want to use an external tool like "setres.exe". For instance one part of it is to set the display frequency through: devMode.dmDisplayFrequency = (ulong)vParams[3].szValue(); the MSDN help shows that this parameter has to be an unsigned long value, so I do it with conversation "(ulong)". The result ist that it doesn't work. If I use f.i.: devMode.dmDisplayFrequency = 75; then the screenfrequency will change. Hmmm....I don't know...I've looked into my c++book but can't find anything about it... Has anyone of you an idea? maybe with "strtoul"? Thanks for your help and regards Edited June 11, 2004 by Holger Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
Holger Posted June 11, 2004 Author Posted June 11, 2004 @Larry: thanks so much So simple that I didn't see that Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
Valik Posted June 11, 2004 Posted June 11, 2004 One good example of why C++ casts (Although slightly cumbersome) are much better. Attempting to compile your code with the C-style cast, I get a pointer truncation Warning. Attempting to compile by using a C++ cast, I get an Error. devMode.dmDisplayFrequency = static_cast<ulong>(vParams[3].szValue()); error C2440: 'static_cast' : cannot convert from 'const char *' to 'unsigned long' This conversion requires a reinterpret_cast, a C-style cast or function-style castJust a little food for thought, I use C-style casts in too many places also, hard habit to break.
Nutster Posted June 12, 2004 Posted June 12, 2004 szValue() returns a string (char *) and nValue() returns a number (double). If you want numeric values, use nValue(). David NuttallNuttall Computer Consulting An Aquarius born during the Age of Aquarius AutoIt allows me to re-invent the wheel so much faster. I'm off to write a wizard, a wonderful wizard of odd...
Holger Posted June 12, 2004 Author Posted June 12, 2004 @all: thanks for your answer's, it works now Old project:GUI/Tray menu with icons and colors Other old stuff:IconFileScanner, TriState/ThreeState GUI TreeView, GUI ContextMenu created out of a TreeView
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now