Solved

Using custom controls in dialogs.....

Posted on 2000-04-11
6
370 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
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
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 video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

743 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

10 Experts available now in Live!

Get 1:1 Help Now