1

I am programming a game with DirectX 8, and I am trying to use the GUI options that are provided by the Win32 window that I am using. However, when I try to render a button or, in this case, a textbox to the screen, I am unsuccessful. I remember previously being able to get one to render for like 0.5 seconds, but then it would disappear.

What could be the reason for this? What could I have done wrong with the setup of the window?

 WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, 
                      GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
                      "Engine", NULL };
    wc.hIcon = (HICON)LoadImage(NULL, "EEXIcon.ico", IMAGE_ICON,
        0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
    wc.hIconSm = (HICON)LoadImage(NULL, "EEXIcon.ico", IMAGE_ICON,
        0, 0, LR_DEFAULTSIZE | LR_LOADFROMFILE);
    RegisterClassEx( &wc );
    
    // Create the application's window



    hWnd = CreateWindow( "Engine", "Engine", WS_CAPTION, 100, 100, 800, 600, NULL, NULL, wc.hInstance, NULL );

Here is the DirectX setup

D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = d3ddm.Format;
d3dpp.EnableAutoDepthStencil = TRUE;
d3dpp.AutoDepthStencilFormat = D3DFMT_D16;

//d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
if (fullscreen)
{
    d3dpp.Windowed = FALSE;
    d3dpp.BackBufferWidth = 800;
    d3dpp.BackBufferHeight = 600;
    d3dpp.BackBufferFormat = D3DFMT_X8R8G8B8;//D3DFMT_R5G6B5;
    d3dpp.BackBufferCount = 3;
    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
    d3dpp.EnableAutoDepthStencil = TRUE;
    d3dpp.AutoDepthStencilFormat = D3DFMT_D24S8;
    d3dpp.FullScreen_PresentationInterval = D3DPRESENT_INTERVAL_IMMEDIATE;
}

And finally, here is the GUI instance I was trying to create:

//hWndEditBox defined earlier in the file as a HWND
hWndEditBox = CreateWindow("EDIT","Edit Boxes",WS_VISIBLE | WS_CHILD,10,10,100,50,hWnd,(HMENU)IDC_EDITBOX_TEXT,(HINSTANCE)GetWindowLong(hWnd, GWL_HINSTANCE),NULL);

Any ideas would be appreciated!

14
  • I'm not sure that this is the best forum to get an answer to this question. You might be better asking on Stackoverflow. But you'll probably need to explain why you are using DirectX 8 which is quite old.
    – JeremyP
    May 9 at 7:59
  • "Quite old", yeah. Not exactly retrocomputing.
    – OmarL
    May 9 at 9:01
  • 1
    DirectX 8.1 is the highest version released for Windows 98. Does it not count?
    – wizzwizz4
    May 9 at 12:14
  • 3
    I'd say DX8 is retro - we all know the term is subjective at best, but when it comes to things like graphics APIs, they move fast, and DX8 is pretty far removed from current GPU and API architectures. Still, I do feel like you're more likely to get a better answer on SO.
    – Matt Lacey
    May 9 at 14:59
  • This is the win32 api, so do you also need to call ShowWindow() at the end? May 9 at 17:28

0

Browse other questions tagged or ask your own question.