[ create a new paste ] login | about

Link: http://codepad.org/HqAS3H8p    [ raw code | fork ]

C++, pasted on Nov 4:
#include <windows.h>
#include <boost/shared_ptr.hpp>
#include <boost/type_traits/remove_pointer.hpp>

static LRESULT CALLBACK Procedure(HWND wnd , UINT msg , WPARAM wp , LPARAM lp) {
  switch(msg) {
    case WM_CLOSE :
      return 0 ;

    case WM_DESTROY :
      MessageBox(wnd , TEXT("Destroy") , 0 , MB_OK) ;
      return 0 ;

    default :
      return DefWindowProc(wnd , msg , wp , lp) ;
  }
}

int APIENTRY WinMain(HINSTANCE inst , HINSTANCE , LPSTR , int ) {
  TCHAR appName[] = TEXT("Hello") ;
  WNDCLASS wc ;
  wc.cbClsExtra = 0 ;
  wc.cbWndExtra = 0 ;
  wc.hbrBackground = (HBRUSH)(GetStockObject(0)) ;
  wc.hCursor = LoadCursor(0 , IDC_ARROW) ;
  wc.hIcon = LoadIcon(0 , IDI_APPLICATION) ;
  wc.hInstance = inst ;
  wc.lpfnWndProc = Procedure ;
  wc.lpszClassName = appName ;
  wc.lpszMenuName = 0 ;
  wc.style = 0 ;

  if(RegisterClass(&(wc))) {
    DWORD style = WS_OVERLAPPEDWINDOW | WS_VISIBLE ; 

    {
    boost::shared_ptr<boost::remove_pointer<HWND>::type>
      wnd(CreateWindow(appName , appName , style , 0 , 0 , 400 , 300 , 0 , 0 , inst , 0), DestroyWindow) ;
    }

    if(!UnregisterClass(appName , inst))
      MessageBox(0 , TEXT("UNREG NG") , 0 , 0) ;
    else
      MessageBox(0 , TEXT("UNREG OK") , 0 , 0) ;
  }

  MessageBox(0 , TEXT("owari") , 0 , 0) ;

  return 0 ;
}


Create a new paste based on this one


Comments: