Link to home
Start Free TrialLog in
Avatar of megaastar
megaastar

asked on

Unable to Create a Modal DialogBox in SDK

When I try to create a modal dialog box using DialogBox() macro, I get an error 1402 (Class not found). I created the DialogBox in resource editor and included the resource.h

My source:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <stdio.h>
#include "resource.h"

HWND hDlg;
BOOL CALLBACK fnStatDlg(HWND, UINT, WPARAM, LPARAM);

int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{

     HWND hWndOwner = GetDesktopWindow();
     int iVal=DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, (DLGPROC)fnStatDlg);
     int iErr=GetLastError();
     return 0;
}

BOOL CALLBACK fnStatDlg(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
     switch(uMsg)
     {
     case WM_INITDIALOG:
          return true;
     
     case WM_CLOSE:
          EndDialog(hDlg,0);
          return 0;
     }
     return false;
}
ASKER CERTIFIED SOLUTION
Avatar of kvrnkiran
kvrnkiran

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rgoerdes
rgoerdes

Your code seems to be ok.
the line hWndOwner ... seems to be redundant. you never use hWndOwner.
let me see your resource-file, please. maybe something wrong in it.
Avatar of megaastar

ASKER

1st of all....... sry for the delay....


Mr Kiran is rite!

Thankx!