Home
Tutorials
Code Snippets
Code Samples
Downloads
Links

The Blog
Our Projects
About
Contact

::Add RageStorm to Favorites!::

The Blog | Our Projects | Guest Book | About | Contact

 
Code Snippet - Subclassing Windows
Author:Arkon
Category:Win32API
File Size:833 Bytes
Uploaded at:30-Nov-02 07:11:24 pm
Description:
  Shows how to subclass a window, so you can override its Window Procedure with your own.
  
Subclassing is a technique to concuest the window procedure
and process the messages by your own window procedure.
When subclassing note that you can ONLY subclass windows from same thread.

The new window procedure STILL has to stand in the WindowProc callback function demands!

WNDPROC lpfnOldWndProc;

LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
 .
 switch(uMsg)
 {
  case ...:
  return(0);
 }
 .
 .
 // Call the original window procedure with the unprocessed messages
 return(CallWindowProc((WNDPROC)lpfnOldWndProc, hWnd, uMsg, wParam, lParam));
}

// Initialize
lpfnOldWndProc = (WNDPROC)SetWindowLong(hEdit, GWL_WNDPROC, (DWORD)EditProc);
SetWindowLong(hEdit, GWL_WNDPROC, (DWORD)EditProc);

// Destroy:
SetWindowLong(hEdit, GWL_WNDPROC, (DWORD)lpfnOldWndProc);
NOTE:
Comments that will hurt anyone in any way will be deleted.
Don't ask for features, advertise or curse.
If you want to leave a message to the author use the contacts,
if you have any question in relation to your comments please use the forum.
Comments which violate any of these requests will be deleted without further
notice. Use the comment system decently.

Post your comment:
Name:
email:
Comment:
::Top 5 Tutorials::
Embedded Python[117037]
2D Rotated Rectangles Collision Detection[88976]
Keyboard Hook[77314]
UDP[65820]
HTTP Proxy[41209]

::Top 5 Samples::
2D ColDet Rotated Rectangles[11561]
PS2 Mouse Driver[6958]
Wave Format Player[5792]
Reading FAT12[5620]
CodeGuru[5359]


All rights reserved to RageStorm © 2009