Which GDI function is best for, or commonly used for setting a single pixel?
This is a discussion on setting a single pixel within the Windows Programming forums, part of the Platform Specific Boards category; Which GDI function is best for, or commonly used for setting a single pixel?...
Which GDI function is best for, or commonly used for setting a single pixel?
SetPixel works well.
Thanks. I see it is a bitmap function.
I have been unable to search at msdn for some reason.
That could be it. I never registered, as I have been able to access everything.
I can see the lessons, look at all the functions, download stuff, etc.
Also I just tried using bing directly from bing.com (searched "msdn setpixel")
and found the msdn page for the function immediately.
Just doesn't work from within the msdn site. Or is there another search at
the msdn site?
It looks like the SDK is for Vista and later, though? I am using XP.
Don't let that stop you. Each function is indexed by operating system version, library, header and dll support... Just don't be using anything newer than XP...
Matter of fact, I work on Win7 (not by choice!) and still write for win2000 whenever possible. Backwards compatibility does matter.
That's it... all you do is check which OS versions a given API call is supported on and it's all good.
If you are forced to do something where you have to specify "Minimum Operating System" requirements it's easy enough to test for them...
The following tests for XP-SP2....
Code:// handle versioning VOID CheckWindowsVersion(void) { OSVERSIONINFOEX os = {0}; // version information DWORDLONG cm = 0; // conditioning value // precondition struct os.dwOSVersionInfoSize = sizeof(os); os.dwMajorVersion = 5; os.dwMinorVersion = 1; os.wServicePackMajor = 2; // condition the results VER_SET_CONDITION(cm,VER_MAJORVERSION,VER_GREATER_EQUAL); VER_SET_CONDITION(cm,VER_MINORVERSION,VER_GREATER_EQUAL); VER_SET_CONDITION(cm,VER_SERVICEPACKMAJOR,VER_GREATER_EQUAL); // exit on older versions if (!VerifyVersionInfo(&os,VER_MAJORVERSION | VER_MINORVERSION | VER_SERVICEPACKMAJOR,cm)) ReportError(20020,TRUE); }
Last edited by CommonTater; 03-24-2011 at 10:41 AM.