transformXGR

2009. 9. 3. 17:09 from 셈말짓기/헤아림


graphedt.exe를 이용하여 XML Format인 XGR로 저장하면 자동으로 C++ Code변환해주는 XSL입니다.
안에 Batch File을 사용하시면 자동으로 C++ File이 생성됩니다.

예:
c:\transformXGR.bat a.xgr


원본 XSL출처는 아래 URL입니다.
http://groups.google.com/group/microsoft.public.win32.programmer.directx.video/browse_thread/thread/29ccdbf293ef8eb8/937a6e037a20de30
안에 내용을 조금 수정했습니다.

Posted by 셈말짓기 :


HINSTANCE CreateInstanceFromDll(LPCTSTR lpDllName, REFCLSID rclsid, REFIID riid, LPVOID * ppv)
{
 (*ppv) = NULL;

 HINSTANCE hDll = LoadLibrary( lpDllName );
 if ( NULL == hDll )
 {
  return NULL;
 }

 typedef HRESULT (__stdcall *GETCLASS_PROC)(REFCLSID,REFIID,LPVOID*);

 GETCLASS_PROC procGetClassObject = (GETCLASS_PROC)GetProcAddress( hDll, "DllGetClassObject" );

 if( procGetClassObject )
 {
  IClassFactory* pFactory = NULL;

  HRESULT hr = procGetClassObject(rclsid, IID_IClassFactory, (void**)&pFactory);
  if( pFactory )
  {
   hr = pFactory->CreateInstance( NULL, riid, ppv);

   pFactory->Release();
   pFactory = NULL;

   if( NULL == *ppv )
   {
    FreeLibrary( hDll );
    return NULL;
   }
  }
  else
  {
   FreeLibrary( hDll );
   return NULL;
  }
 }
 else
 {
  FreeLibrary( hDll );
  return NULL;
 }

 return hDll;
}

Posted by 셈말짓기 :

// wf1.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using System.Drawing;
using System.Drawing.Imaging;

public partial class wf1 : System.Web.UI.Page
{
    private const int    IMAGE_WIDTH  = 320;
    private const int    IMAGE_HEIGHT = 240;
    private const string IMAGE_FORMAT = "image/gif";

    private Bitmap     _bitmap;
    private Graphics   _graphics;
    private Font       _font      = new Font ("굴림", 8);
    private SolidBrush _fontBrush = new SolidBrush(Color.Black);
    private SolidBrush _fillBrush = new SolidBrush(Color.Yellow);
    private string     _label     = "테스트";

    protected void Page_Load(object sender, EventArgs e)
    {
        _bitmap = new Bitmap(IMAGE_WIDTH, IMAGE_HEIGHT, PixelFormat.Format32bppArgb);

        _graphics = Graphics.FromImage(_bitmap);

        _graphics.FillRectangle(_fillBrush, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT);
        _graphics.DrawString   (_label, _font, _fontBrush, 10, 10);

        Response.ContentType = IMAGE_FORMAT;
        _bitmap.Save(Response.OutputStream, ImageFormat.Gif);
    }
}

Posted by 셈말짓기 :

class CMainFrame :

        public CFrameWindowImpl<CMainFrame>,

        public CUpdateUI<CMainFrame>,

        public CMessageFilter, public CIdleHandler

{

public:

 

DECLARE_FRAME_WND_CLASS(NULL, IDR_MAINFRAME)

 

BEGIN_MSG_MAP(CMainFrame)

 

        MESSAGE_HANDLER    ( WM_CREATE        , OnCreate       )

        MESSAGE_HANDLER    ( WM_DESTROY       , OnDestroy      )

        MESSAGE_HANDLER    ( WM_DROPFILES     , OnDropFile     )

        COMMAND_ID_HANDLER ( ID_SELECTFOLDER  , OnSelectFolder )

        COMMAND_ID_HANDLER ( ID_FILE_OPEN     , OnFileOpen     )

        COMMAND_ID_HANDLER ( ID_FILE_SAVE     , OnFileSave     )

        ...

END_MSG_MAP()

 

LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

{

        ...

        DragAcceptFiles (TRUE);

 

        return 0;

}

 

LRESULT OnDestroy(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& bHandled)

{

        DragAcceptFiles (FALSE);

        ...

}

 

LRESULT OnDropFile (UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/)

{

        HDROP  hDrop = (HDROP) wParam;    

 

        TCHAR filePath [MAX_PATH];

        int   fileCount;

        int   index;

 

        fileCount = DragQueryFile (hDrop, -1, NULL, NULL);

        if (fileCount > 0)

        {

               for (index=0; index<fileCount; index++)

               {

                       if (DragQueryFile (hDrop, index, filePath, sizeof(filePath)))

                       {

                              ATLTRACE (_T("OnDropFile(): %s \r\n"), filePath);

                       }

               }

        }

 

        DragFinish(hDrop);

 

        return 0;

}

 

LRESULT OnSelectFolder (WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)

{

        BROWSEINFO   bi = { 0 };

        LPITEMIDLIST pidl;

        TCHAR        path[MAX_PATH] = { 0 };

 

        ZeroMemory (&bi,sizeof(BROWSEINFO));

 

        bi.ulFlags        = 0;

        bi.lpszTitle      = NULL;

        bi.pszDisplayName = path;

        pidl              = SHBrowseForFolder ( &bi );

 

        if ( pidl != 0 )

        {

               if (SHGetPathFromIDList (pidl, path))

               {

                       ATLTRACE (_T("OnSelectFolder(): %s \r\n"), path);

               }

 

               // free memory used

               IMalloc * imalloc = 0;

               if ( SUCCEEDED( SHGetMalloc ( &imalloc )) )

               {

                       imalloc->Free ( pidl );

                       imalloc->Release ( );

               }

        }

 

        return 0;

}

 

LRESULT OnFileSave(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/)

{

        CFileDialog FileOpenDilaog

        (

               FALSE,

               _T("bin"),

               _T("default.bin"),         

               OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,

               _T("Binary Files (*.bin)\0*.bin\0All Files (*.*)\0*.*\0"),

               m_hWnd

        );

 

 

        if (FileOpenDilaog.DoModal() == IDOK)

        {

               ATLTRACE (_T("OnFileSave(): %s \r\n"), FileOpenDilaog.m_szFileName);

        }

 

        return 0;

}

 

LRESULT OnFileOpen(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)

{

        CFileDialog FileOpenDilaog

        (

                TRUE,

               _T("bin"),

               NULL,

               OFN_HIDEREADONLY,

               _T("Binary Files (*.bin)\0*.bin\0All Files (*.*)\0*.*\0"),

               m_hWnd

        );

 

        if (FileOpenDilaog.DoModal() == IDOK)

        {

               ATLTRACE (_T("OnFileOpen(): %s \r\n"), FileOpenDilaog.m_szFileName);

        }

 

        return 0;

}

 

};

 

Posted by 셈말짓기 :

 

LRESULT OnCreate(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)

{

        // . . .

 

        // delete memuitems

        CMenuHandle menu     = m_CmdBar.GetMenu();

        CMenuHandle menuFile = menu.GetSubMenu (0);

       

        menuFile.RemoveMenu (ID_FILE_NEW,           MF_BYCOMMAND);

        menuFile.RemoveMenu (ID_FILE_OPEN,          MF_BYCOMMAND);

        menuFile.RemoveMenu (ID_FILE_SAVE,          MF_BYCOMMAND);

        menuFile.RemoveMenu (ID_FILE_SAVE_AS,       MF_BYCOMMAND);

        menuFile.RemoveMenu (0,                     MF_SEPARATOR);

        menuFile.RemoveMenu (ID_FILE_PRINT,         MF_BYCOMMAND);

        menuFile.RemoveMenu (ID_FILE_PRINT_PREVIEW, MF_BYCOMMAND);

        menuFile.RemoveMenu (ID_FILE_PRINT_SETUP,   MF_BYCOMMAND);

        menuFile.RemoveMenu (0,                     MF_SEPARATOR);

 

        CMenuHandle menuWindow = menu.GetSubMenu (3);

        menuWindow.RemoveMenu (ID_WINDOW_CLOSE,      MF_BYCOMMAND);

        menuWindow.RemoveMenu (ID_WINDOW_CLOSE_ALL,  MF_BYCOMMAND);

        menuWindow.RemoveMenu (0,                    MF_SEPARATOR);

       

        menu.DeleteMenu (1,MF_BYPOSITION); // EDIT menu

        m_CmdBar.AttachMenu (menu);

       

        // delete buttons of toolbar

        CToolBarCtrl toolbar;

       

        toolbar.Attach (hWndToolBar);

 

        toolbar.DeleteButton (0); // NEW

        toolbar.DeleteButton (0); // OPEN

        toolbar.DeleteButton (0); // SAVE

        toolbar.DeleteButton (0); // -

        toolbar.DeleteButton (0); // CUT

        toolbar.DeleteButton (0); // COPY

        toolbar.DeleteButton (0); // PASTE

        toolbar.DeleteButton (0); // -

        toolbar.DeleteButton (0); // PRINT

       

        toolbar.Detach ();

       

        return 0;

}

 

Posted by 셈말짓기 :