Solved

Using custom controls in dialogs.....

Posted on 2000-04-11
6
411 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

Industry Leaders: 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!

Question has a verified solution.

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

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

630 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