-3

誰かが私のウィンドウ作成の何が問題になっているのか教えてもらえますか?この関数はmain関数内から呼び出されており、すべてコンパイルされて正常に実行されます。ただし、レンダリングされるウィンドウはウィンドウではなく、大きな白い正方形にすぎません。これが私のウィンドウ作成機能です:

/**
 *  handles everything for initialising a window
 *
 *  @param  hInst               unique handle of window instance
 *  @param  hPrevInst           legacy parameter for copying memory from other instance into this one
 *  @param  cmdLine             commands application is started with
 *  @param  cmdShow             specifies how program should be displayed (maximised, minimized, or hidden)
 */
int Window::Init (HINSTANCE hInst, HINSTANCE hPrevInst, PSTR cmdLine, int cmdShow)
{
    //  name of application
    static TCHAR    appName[]       = TEXT ("App");

    //  contains window class information
    WNDCLASSEX      wndC;

    //  window handle
    HWND            hWnd;

    //  define the windows class information
    wndC.cbSize                 = sizeof (WNDCLASSEX);          //  specifies the size of the structure (in bytes)
    wndC.style                  = CS_HREDRAW | CS_VREDRAW;      //  employs window class style to redraw if any resizing occurs
    wndC.lpfnWndProc            = WndProc;                      //  pointer to the window procedure function
    wndC.cbClsExtra             = 0;                            //  number of extra bytres to allocate for window class
    wndC.cbWndExtra             = 0;                            //  number of extra bytes to allocate per window instance
    wndC.hInstance              = hInst;                        //  handle to instnace conatining window procedure for this class
    wndC.hIcon                  = NULL;                         //  handle to large 32x32 (shown when alt + tab)
    wndC.hCursor                = LoadCursor (NULL, IDC_ARROW); //  handle to class cursor resource
    wndC.hbrBackground          = (HBRUSH) (COLOR_WINDOW + 1);  //  handle to class background brush (for painting background)
    wndC.lpszMenuName           = NULL;                         //  pointer to string with name of class menu (no default menu)
    wndC.lpszClassName          = appName;                      //  specifies windows class name
    wndC.hIconSm                = NULL;                         //  handle to small 16x16 icon (top left corner of window)

    //  registers window class with system, will terminate is parameter is invalid
    if (!RegisterClassEx (&wndC))   return 0;

    //  rect used for defining window
    RECT            wndRc;

    //  calculate size of window based on entire client window size
    wndRc.left                  = 0;
    wndRc.top                   = 0;
    wndRc.right                 = 800;
    wndRc.bottom                = 600;

    long            tStyle      = 0;

    //  style chosen based on whether this window is fullscreen
    if (mFullScreen)
        tStyle                  = WS_POPUP;
    else
    {
        tStyle                  = WS_OVERLAPPEDWINDOW;
        //  calculates required size of window rectangle, based on desired client-rectangle size
        AdjustWindowRect (&wndRc, tStyle, FALSE); 
    }

    //  now class is registered, we create a window with it
    hWnd                        = CreateWindowEx (0, appName, appName, WS_POPUP, CW_USEDEFAULT, CW_USEDEFAULT, 
                                    wndRc.right - wndRc.left, wndRc.bottom - wndRc.top, NULL, NULL, hInst, NULL);
    //  check we have a valid handle
    if (hWnd == NULL)               return 0;

    //  show window and update it (cmdShow allows user to specify whether they want window to start maximised, minimised, etc.)
    ShowWindow (hWnd, cmdShow);
    UpdateWindow (hWnd);

    //  if we fail to create the direct x device send an error message and terminate
    if (DirectDraw::GetInstance()->CreateDevice (hWnd, 800, 600, mFullScreen) != 1)
    {
        MessageBox (hWnd, "Failed to create surfaces", "Error", MB_OK);
        return 0;
    }

    //  adds rectangle to the specified window's update region (portion of window to be redrawn)
    InvalidateRect (hWnd, NULL, TRUE);

    return 1;
}
4

1 に答える 1

0

私の投稿へのコメントで Arx と Tenfour の厚意により、問題は単純にウィンドウ クラスのスタイルを 'WS_POPUP' に設定していたことで、これは明らかに全画面ウィンドウの外では適切ではありませんでした。

于 2012-07-20T22:36:17.890 に答える