Solved

Unable to Create a Modal DialogBox in SDK

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Does Microsoft Office 2016 support COM/ActiveX? 3 102
Problem to file 3 74
Need more details 5 148
Visual Studio: built-in keystroke automation 2 64
This article describes how to programmatically preset the "Pages per Sheet" option that's available with most printer drivers.   This setting lets you do "n-Up" printing, where two, four, or more pages are printed on each sheet of paper. If your …
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…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

808 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