user32: Problem using SetClassLongW to subclass built-in control (Edit)

Hongbo Ni hongbo_ni at
Wed Jul 9 07:06:22 CDT 2008

Summary: SetClassLongW(hEdit, GCL_WNDPROC,(DWORD)NewEditWndProc) in Wine differs from Windows.
Background:  when a standard built-in window class (such as Edit for example) is registered initially, 
the window system register the class with two Procedures (procA and ProcW) and assign a handle as 
WNDPROC to the class.  If a Edit window is created using CreateWindowExA, it will be an Ansi Window. 
If a Edit window is created using CreateWindowExW, it will be an Unicode Window. This fine in Wine.
Problem: I globally subclass the Edit class using SetClassLongW using following code
  HWND hEdit = CreateWindowExA(0,"Edit", "E1",WS_POPUP,0, 0, 1,1,NULL,NULL,NULL,NULL);  OldEditWndProc =(WNDPROC)SetClassLongW(hEdit, GCL_WNDPROC,(DWORD)NewEditWndProc);
After this subclass, Wine behaves different from Windows
In Windows: a new Edit windows created by CreateWindowsExA((0,"Edit",...) is a Still an Ansi Windows
                   a new Edit windows created by CreateWindowsExW((0,"Edit",...) is a Unicode Windows
But in Wine, new Edit windows created by CreateWindowsExA or CreateWindowsExW are all Unicode Windows.
I checked wine 1.1 source code , basically the call to
SetClassLongW(hEdit, GCL_WNDPROC,(DWORD)NewEditWndProc) has set the Edit class proc to Unicode Only.
So regardless how you create the Edit window, it will be Unicode window.
This is understandable but it's different form windows. causing my application to mis-behave.
More problem, the OldEditWndProc returned above is only the procW of Edit class, if we try to
undo the subclass with
       SetClassLongW(hEdit, GCL_WNDPROC,(DWORD)OldEditWndProc );
the Edit class also lost it's procA.
Discussion: How wine could do the same as windows?
SetClassLongW(hEdit, GCL_WNDPROC,(DWORD)NewEditWndProc) should
1. return the proc handle of the class, instead of procW.
2. set both ProcA and ProcW of Edit class to NewEditWndProc.
    so  NewEditWndProc need to handle both messages from Ansi and Unicode Edit control.
I don't know what is the best way to fix this. Please help.
I have posted a Test application on Bugzilla #14350, please try.
Are you paid what you're worth? Find out: SEEK Salary Centre
-------------- next part --------------
An HTML attachment was scrubbed...

More information about the wine-devel mailing list