Solved

Using custom controls in dialogs.....

Posted on 2000-04-11
6
402 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
Technology Partners: 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

Title # Comments Views Activity
maxBlock challenge 30 146
method notes when mouse over in eclipse 5 90
if loop in java 3 163
moto 4g phone enable finger print 4 47
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: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

749 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