Advertisement

[Win32 API]Subclassing controls

Started by August 06, 2001 11:05 AM
3 comments, last by Clash Rocker 23 years, 6 months ago
Does anyone have or know of some tutorials on subclassing. I''m have a hell of alot of trouble trying to subclass my edit control. I wish I had some code to present, but alas I do not. So some a few pointer would be much appreciated. TIA
gimme yer email
i''ll send ya some code to subclass an edit control in win32api
if you want

Arkon
[QSoft Systems]
Advertisement
1. Create your custom WndProc for message handling etc.

2. Use SetWindowLong GWL_WNDPROC flag to get access to the controls original window procedure and replace it with your own. Make sure

3. Make sure your custom WndProc makes a call to the original one, or your edit box wont do very much.

  // untested code.....void SubClassControl(HWND ctrl, WNDPROC custom){  WNDPROC original = SetWindowLong(ctrl,GWL_WNDPROC,(LONG)custom);  // need to store a copy of the original somewhere so we can   // get at it later... use the user defined space for the control...  SetWindowLong(ctrl,GWL_USERDATA,(LONG)original);}// also need to call this function at the end of your custom WndProcBOOL OriginalWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam){  // retrieve the original window proc from the user defined  // data field and run it...  WNDPROC original = (WNDPROC)GetWindowLong(hWnd,GWL_USERDATA);  return CallWindowProc(original, hWnd, msg,wParam,lParam); }    



HTH
i forgot i wrote a note about it
check it out:
http://qsoft.ragestorm.com/tutors/windows/subclasswnd.txt

all luck

Arkon
[QSoft Systems]
Ohhhhh
Thanks for info fellas.
Should get moving forward for the time being

This topic is closed to new replies.

Advertisement