천객만래 [千客萬來] (It has an interminable succession of visitors)





VC++ Source Code
// Subclassing.cpp : Defines the entry point for the application.
// #include "stdafx.h"#include <tchar.h> 
#define STRSAFE_NO_DEPRECATE 
WNDPROC g_pOldProc;
char szAppName[]="Subclassing Demo"; 
LRESULT CALLBACK SubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{   
 if(uMsg == WM_CLOSE)    
 {        
  DestroyWindow(hWnd);        
  PostQuitMessage(0);        
  return 0;    
 }    
 return CallWindowProc(g_pOldProc, hWnd, uMsg, wParam, lParam);

int APIENTRY _tWinMain(HINSTANCE hInstance,                     
 HINSTANCE hPrevInstance,                     
 LPSTR     lpCmdLine,                     
 int       nCmdShow)
{    
 HWND hEdit = 0;        
 /*Create a top-level edit control*/    
 hEdit = CreateWindowEx(                0, 
   _T("EDIT"), _T(szAppName),                
   WS_OVERLAPPEDWINDOW,                 
   CW_USEDEFAULT,                 
   CW_USEDEFAULT,                 
   200,                 
   100,                 
   0,                 
   0,                 
   hInstance,                 
   0);        
 g_pOldProc = (WNDPROC)SetWindowLong(hEdit, GWL_WNDPROC, PtrToLong(SubclassProc));     
 ShowWindow(hEdit, SW_SHOWNORMAL);     
 
 MSG msg;    
 
 while(GetMessage(&msg, 0, 0, 0))    
 {        
  TranslateMessage(&msg);        
  DispatchMessage(&msg);    
 }    
 
 return 0;
}

반응형
Posted by 사용자 SB패밀리

댓글을 달아 주세요