Solved

Using custom controls in dialogs.....

Posted on 2000-04-11
6
390 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Show shut-down message as Windows 8 shuts down. 9 92
conditional code and condition difference 9 83
twoTwo  challenge 35 104
abstract class with all non abstract mentods 6 76
Here is how to use MFC's automatic Radio Button handling in your dialog boxes and forms.  Beginner programmers usually start with a OnClick handler for each radio button and that's just not the right way to go.  MFC has a very cool system for handli…
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.

832 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