Tell me please, why this happens:
I need to apply for my parent window during the triggering of a specific condition in WINDPROC
– WS_VSCROLL
style, well, at some point the window appears the vertical scroll bar.
Actually, I call a function:
setlaasterror (1); // MSDN recommends installing code before calling SetWindOwongPTR
LONG_PTR My_Long_PTR = SetWindowLongPTR (HWND, GWL_EXSTYLE, WS_VSCROLL);
COUT & LT; & LT; GetLasterRor () & lt; & lt; ENDL; // Error code 87 - Invalid parameter
As can be seen with such a call – an error occurs 87 – an incorrect parameter.
It is necessary to change gwl_exstyle
on gwl_style
, in this case, the error code installed setlasterror ()
does not change, that is, setwindowlongptr
– completes successfully. All is well and cool.
But I’m interested in another, namely, why in the first case, the function ended with an error 87, but still applied the specified WS_VSCROLL
style, that is, the window appeared a vertical scroll bar.
Answer 1, Authority 100%
setwindowlong [ptr]
Not just a setter in some memory area, even rather “simply not a setter”, although constants look like displacement. It processes incoming values, especially GWL_EXSTYLE
/ GWL_STYLE
The window comes wm_stylecnging
/ WM_STyleChanged
. In the first of them, the installed styles can fix the window, and the returned old value.
Answer 2, Authority 50%
Perhaps, certain components must be present in the extended style. In order not to destroy the style at all, but only add the desired, do this:
setwindowlongptr (hwnd, gwl_exstyle, ws_vscroll | getwindowlongptr (hwnd, gwl_exstyle));
Answer 3
at least, you need to carefully do exactly what is written in MSDN, namely:
by Calling Setlasterr WITH 0
Clean the old error status value 0 (you specify 1)
Function Failure Will Be Indicated by A Return Value of Zero and A
GetLastterror Result That Is Nonzero.
Error occurs when the function returned 0 and getlasterror returned not 0, at the comparison of the return function from 0 no