Hi all.
It seems I have following strange problem:

1. I am creating edit control (Class 'EDIT') with style: WS_VISIBLE or WS_CHILD or WS_BORDER = 05080000h
2. The created edit box is OK. It have border and it works fine.
3. Then I make: "invoke GetWindowLong, hedit, GWL_STYLE" and it returns only 05000000h i.e. WS_VISIBLE or WS_CHILD (without WS_BORDER) :confused:

Any, suggestions, why this happens???

John Found
Posted on 2003-06-28 18:25:07 by JohnFound
This is a normal return from Windows as reported in the Knowledge base. The WS_BORDER style of an edit control is always reported as cleared by GetWindowLong:

PSS ID Number: 83366 (Q83366)

    [*]Combo boxes always report the following styles as clear:

    [*]All edit controls report the WS_BORDER style clear.

    [*]Multiline edit controls report the WS_HSCROLL style clear if the control contains centered or right-justified text.
Posted on 2003-06-28 18:37:13 by donkey
Donkey, thank you very much.

But, how I can determine, what is the true style of the control??? How to determine is the edit box have border or not???
Posted on 2003-06-28 18:46:28 by JohnFound
There is no way to determine if an edit control has the WS_BORDER style set. Since you are making the control yourself just remember to always OR the value returned from GetWindowLong with WS_BORDER in order to get the correct value. If you are recycling the routine then you must add code to trap the edit and treat it differently than other controls.

Worse than that there's more in the same article :
Windows can set and clear the following styles over the lifetime of a window: WS_CLIPSIBLINGS, WS_DISABLED, WS_HSCROLL, WS_MAXIMIZE, WS_MINIMIZE, WS_SYSMENU (for MDI child windows), WS_THICKFRAME, WS_VISIBLE, and WS_VSCROLL. Windows will not dynamically set or clear any of the other styles. An application can modify the style state at the GWL_STYLE offset at any time by calling SetWindowLong(hWnd, GWL_STYLE, dwNewLong), but Windows will not be aware that the style has changed. Windows maintains some internal flags on the window style and may use these rather than checking the GWL_STYLE offset of the window data structure.

So the actual style of the window is not necessarily the value that windows uses to determine the value sent to GetWindowLong. In other words - don't bet your app on this function.
Posted on 2003-06-28 18:57:43 by donkey
That's really dumb.
Posted on 2003-06-28 19:44:30 by iblis