Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 869955
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T10:23:27+00:00 2026-05-15T10:23:27+00:00

Well I have 2 issues but my main concern right now is my catch

  • 0

Well I have 2 issues but my main concern right now is my catch exception. Here is the code…

int GXRenderManager::Ignite(HINSTANCE * hinst, int * nCmd, GXDEVICE DeviceType, int width, int height)
{
 try
 {
  GXRenderManager::hinstance = hinst;
  GXRenderManager::nCmdShow = nCmd;

  GXRenderManager::height = height;
  GXRenderManager::width = width;

  InitWindows();

  switch(DeviceType)
  {
  case DIRECTX:
   GXRenderManager::renderDevice = new GXDX;
   break;
  case OPENGL:
   GXRenderManager::renderDevice = new GXGL;
   break;
  default:
   throw GXException(L"Error Finding Video Device"); 
  }

  Device()->StartUp(GXRenderManager::mainWindow ,width, height); //Error happens here
 }
 catch(GXVideoException &e)
 {
  MessageBox(0,e.pReason,L"GXVideoException",1);//Catch happens but no message box
  return 0;
 }
 catch(GXWindowsException &e)
 {
  MessageBox(0,e.pReason,L"Windows Error",1);
  return 0;
 }
 catch(GXException &e)
 {
  MessageBox(0,e.pReason,L"Error",1);
  return 0;
 }

 return 1;
}

Here is where the error happens

void GXDX::StartUp(HWND* mainWindow,int w, int h)
{
 width = w;
 height = h;
 this->mainWindow = mainWindow;

 ID3D10Texture2D *backBufferSurface;

 DXGI_SWAP_CHAIN_DESC swapChainDesc;
 swapChainDesc.BufferCount = 2;
 swapChainDesc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
 swapChainDesc.BufferDesc.RefreshRate.Numerator = 60;
 swapChainDesc.BufferDesc.RefreshRate.Denominator = 1;
 swapChainDesc.BufferDesc.Width = width;
 swapChainDesc.BufferDesc.Height = height;
 swapChainDesc.SampleDesc.Count = 1;
 swapChainDesc.SampleDesc.Quality = 0;
 swapChainDesc.OutputWindow = *mainWindow;
 swapChainDesc.Windowed = TRUE;

 D3D10_DRIVER_TYPE driverType = D3D10_DRIVER_TYPE_HARDWARE;

 HRESULT hr = D3D10CreateDeviceAndSwapChain(NULL,driverType,NULL,0,
  D3D10_SDK_VERSION, &swapChainDesc,&swapChain,&dxDevice);

 if(FAILED(hr))
  throw GXVideoException(L"Problems retrieving directX device");
}

When I do a walk through. the D3D10CreateDeviceAndSwapChain returns a failure, therefore triggering the GXVideoException error.

It then catches and returns back to GXRenderManager class as shown below.

catch(GXVideoException &e)
 {
  MessageBox(0,e.pReason,L"GXVideoException",1);
  return 0;
 }

At this point in time, If I put my cursor over the &e, I clearly see my message “Problems retrieving directX device”. But the message box does not show

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
    LPSTR lpCmdLine, int nCmdShow)
{
 if(GXRenderManager::Ignite(&hInstance, &nCmdShow,DIRECTX) != 1)
  return 0;
      //NEVER REACHES THE RUN METHOD BELOW YET THE MAIN WINDOW REMAINS OPEN
 GXRenderManager::Run();

 return 0;
}

Another thing I find strange is that my created window remains showing but never reaches the main loop. It is like the application is idle due to the message box, but the message box is not showing…

I also would like to add that the static member renderDevice is a interface datatype. GXDX is of course a implemented class of the interface.

GXDX class includes the GXException Header so it is able to throw those exceptions so the main GXRenderManager can catch them.

[EDIT]

Another thing I would like to add is if I remove the Show window method

ShowWindow(*GXRenderManager::mainWindow, *GXRenderManager::nCmdShow);

It works. So as long as my main application window is not open. My message box appears like its suppose to.

[EDIT]

Prior to dauphic response which fixed part of the problem, I went on and edited my code. My catch now looks like this

catch(GXVideoException &e)
    {
        MessageBox(*GXRenderManager::mainWindow,e.pReason,L"GXVideoException",1);
        return 0;
    }

But now my application opens and then immediately closes without displaying the box. mainWindow is a pointer to my base window. So I had to dereference the pointer.

[EDIT]

The windows pointer is bad

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T10:23:28+00:00Added an answer on May 15, 2026 at 10:23 am

    If a dialog is present, MessageBox should always be passed a handle to it, rather than 0. Only pass MessageBox 0 if no dialog is available.

    Side note, I don’t understand the exact reason for this, so it would be great if someone else could give insight.

    It’s also possible that your message box is being attached to your dialog, and because your dialog isn’t active, the message box isn’t showing. Pressing alt when it hangs may cause it to show.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

well i have most probably an extremly stupid problem but could not figure it
My code works fine in a way. I have two issues with it though.
I've used them in java and didn't seem to have too many issues, but
I have an issue regarding an recursive count which works well in SQL server,
Please i have an issue with my form background image display. It works well
I have a serious issue with Liferay 6.1 themes , I know well about
Well hi, guess what, I have an IE positioning issue! This is in 8,
well I have a simple text file where I have my textual data filled,
well i have this messages table with sample values like these: msg_id recipient_id read
Well I have a videos website and a few of its tables are: tags

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.