Example #1
0
        // check this post - http://stackoverflow.com/questions/1969049/c-sharp-p-invoke-marshalling-structures-containing-function-pointers
        //
        static IntPtr MainWndProc(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam)
        {
            IntPtr      hdc;
            PAINTSTRUCT ps;
            RECT        rect;

            //switch ((WM) message)
            //{
            //    WinAPI.BeginPaint(hWnd, out ps);
            //    break;
            //}
            switch ((WM)msg)
            {
            case WM.PAINT:
                hdc = WinAPI.BeginPaint(hWnd, out ps);
                WinAPI.GetClientRect(hWnd, out rect);
                WinAPI.DrawText(hdc, "Hello, Windows 98!", -1, ref rect, Win32_DT_Constant.DT_SINGLELINE | Win32_DT_Constant.DT_CENTER | Win32_DT_Constant.DT_VCENTER);
                WinAPI.EndPaint(hWnd, ref ps);
                return(IntPtr.Zero);

                break;

            case WM.DESTROY:
                WinAPI.PostQuitMessage(0);
                return(IntPtr.Zero);

                break;
            }

            return(WinAPI.DefWindowProc(hWnd, (WM)msg, wParam, lParam));
        }