Solved

Unable to Create a Modal DialogBox in SDK

Posted on 2001-06-21
3
314 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
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
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…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now