Solved

Unable to Create a Modal DialogBox in SDK

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
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…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

943 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

4 Experts available now in Live!

Get 1:1 Help Now