Which subclass process is better?

Which subclass process is better?

I have found two ways for subclassing the control window classes (buttons, edit boxes, list boxes, combo boxes, static controls, and scroll bar).

Which is better and why?

Using,
1
2
3
LONG g_iResult; // For subclassing.

WNDPROC OldWndProc; // For subclassing. 



The two ways of subclassing. Which is better?

g_iResult = (LONG)(LONG_PTR)SetWindowLong(GetDlgItem(hwnd, IDB_SUBCLASSED_TEXT), GWL_WNDPROC, (LONG)(LONG_PTR)SubclassedEditBoxProceedure);

or

OldWndProc = (WNDPROC) SetWindowLong(hSUBCLASSED, GWL_WNDPROC, (LONG)SubclassedEditBoxProceedure);



And, why?


Thanks.


Last edited on
SetWindowLong(...) returns LONG. You just interpret it differently. What makes the most sense is of course up to you. Do you even need the result and what are you doing with it?

It seems that in case 1 you search for a window handle that you already have in case 2. So case 2 would be more efficient.
Coder777,

Thank you.

I was studying how to make two text boxes (one normal) and one subclassed, have different background colors. The normal Edit control would be blue and the subclassed Edit control would be red. I wanted to make certain that I am subclassing correctly first. You have helped me past this part.

Last edited on
Topic archived. No new replies allowed.