title: Win32 GUI : failing to create win32 GUI dialog
body: <p>i'm trying to create a simple dll which has a .rc file with simple dialogbox and listbox within it. i have created the resource by the help of visual studio and by use of drag and drop the controls. i have exposed a function which is intern calls <strong>DialogBox()</strong> API.</p>
  
  <p>I'm dynamically loading the dll from sample windows application and calling the exposed function. dialog box creation failing with error code 126 </p>
  
  <p>could any one help me why it is behaving like this !?</p>
  
  <p>Here is the code:</p>
  
  <pre><code>INT_PTR CALLBACK WndProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
  {
      switch(uMsg)
      {
  
      case WM_INITDIALOG:
          {
                 InitCommonControls();
                 PopulateList(hwndDlg);
                 return TRUE;
          }
      case WM_COMMAND:
          {
            switch(wParam)
            {
            case IDOK:
                SaveSelectedItem(hwndDlg);
                 EndDialog(hwndDlg,0);    
                 return TRUE;
           case IDCANCEL:
                 EndDialog(hwndDlg, 0);
                 return TRUE;
  
            }
  
          }   
      default:
          DefWindowProc(hwndDlg, uMsg, wParam, lParam);
  
      }
  }
  HINSTANCE gInstance;
  
  int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                 LPSTR lpCmdLine, int nCmdShow) 
  {
  DialogBox(gInstance, MAKEINTRESOURCE(IDD_DIALOG), hwnd, WndProc);
  
  return TRUE;
  }
  </code></pre>