Solved

Using custom controls in dialogs.....

Posted on 2000-04-11
6
410 Views
Last Modified: 2013-11-20
Dear all
I have a dialog in a MFC DLL VC++ 5.0 application. I've added a custom control(using the Controls toolbar) over the dialog box and given a class name in the 'Class' section of the properties of the custom control.

I invoke the dialog from a menu function, in normal way as:

CxyDlg dlg;
dlg.DoModal();

But at runtime when the menu option is clicked the dialog is not displayed.

Can anyone please give me some solution for this?

Thanx
Rashmin
0
Comment
Question by:Rashmin
[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
6 Comments
 
LVL 4

Expert Comment

by:captainkirk
ID: 2704110
It could be that there is a problem with creating the child control... is the custom control an OCX?? Is it properly registered???
0
 

Expert Comment

by:kakamna
ID: 2704629
What is the name of the custom control u r using
0
 
LVL 2

Expert Comment

by:DKostov
ID: 2705664
Call

void AfxEnableControlContainer( )

in your application object's InitInstance function to enable support for containment of OLE controls.

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Rashmin
ID: 2706481
Well the control is not an OCX. It is a object of a class which is converted to a WNDCLASS object and registered using AfxRegisterClass function so that it can be used as a custom control.
It seems that the problem might lie with this function and the class is not getting properly registered.
So how to check it?
I've done AfxEnableControlContainer(.

Rashmin
0
 
LVL 4

Accepted Solution

by:
piano_boxer earned 50 total points
ID: 2706886
Maby MFC loads the dialog wrong resource (from the EXE or another DLL).

Try forcing MFC to load resources from your DLL using the function AfxSetResourceHandle();

Ex:

HINSTANCE g_hInstDll;

extern "C" int APIENTRY
DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
{
    // [...]
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        g_hInstDll = hInstance;
        // [...]
    }
    // [...]
}


void ShowDialogInDll()
{
    HINSTANCE hPrev = AfxGetResourceHandle();
    AfxSetResourceHandle(g_hInstDll);

    CxyDlg dlg;
    dlg.DoModal();

    AfxSetResourceHandle(hPrev);
}
0
 

Author Comment

by:Rashmin
ID: 2707026
Thanx piano_boxer.
I am accepting your answer
Rashmin
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…

728 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