Solved

Unable to Create a Modal DialogBox in SDK

Posted on 2001-06-21
3
320 Views
Last Modified: 2013-12-03
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;
}
0
Comment
Question by:megaastar
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 1

Accepted Solution

by:
kvrnkiran earned 50 total points
ID: 6217094
Hi

Your program is working correctly. Please check, whether you have added any common controls, like Rich Edit, Progress Bar etc. for which, you have to use the InitCommonControls() function before calling the DialogBox function. Please do check this. This might be the problem.

KVRN Kiran Kumar.
0
 
LVL 1

Expert Comment

by:rgoerdes
ID: 6231293
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.
0
 

Author Comment

by:megaastar
ID: 6232285
1st of all....... sry for the delay....


Mr Kiran is rite!

Thankx!
0

Featured Post

Revamp Your Training Process

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
With most software applications trying to cater to multiple user needs nowadays, the focus is to make them as configurable as possible. For e.g., when creating Silverlight applications which will connect to WCF services, the service end point usuall…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…

615 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question