Print Page | Close Window

XTPReport as Custom Control

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Report Control
Forum Description: Topics Related to Codejock Report Control
URL: http://forum.codejock.com/forum_posts.asp?TID=4572
Printed Date: 14 May 2024 at 7:19pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: XTPReport as Custom Control
Posted By: cpede
Subject: XTPReport as Custom Control
Date Posted: 11 July 2006 at 2:25pm
Hi,
 
I try to use the XTPReport as a custom control in a dialog. I have seen this in one of your examples, and it works fine when my main application is showing a dialog.
 
Now I'm trying to do the same from deep within a dialog in a separate DLL. This time the XTPReport class fails to create with an error in DoModal as a result.
 
Do I need to register or initialize anything within this DLL to get the custom control to work?
 
-cpede



Replies:
Posted By: cpede
Date Posted: 11 July 2006 at 2:38pm
Well this did the trick in the constructor from within my DLL:
 
m_ctrlReport.RegisterWindowClass(<ResourceInstance handle of My DLL>);
 
Smile
 
-cpede


Posted By: jpnascim
Date Posted: 17 November 2006 at 5:11am
Hello,

I am new to MFC and Xtreme Toolkit so excuse me if my doubts seem very basic. I am having the same problem with my Report Control.

I have a dialog in my DLL where I place a custom control to receive a Report Control.  The problem is when I make a call to 'doModal' method of the dialog, it returns with -1 and the dialog won't show up.

In the class of my dialog I have the following member variable:

CXTPReportControl m_MissionList;

and in the constructor of the dialog class I've tried adding:

BOOL result = m_MissionList.RegisterWindowClass();

It returns 1 but the dialog still won't show up. I couldn't find a RegisterWindoClass method that would accept a parameter like the previous post. Am I doing something wrong or missing anything ?

Help is much appreciated.

Thank you,

Joćo Pedro




Posted By: sserge
Date Posted: 17 November 2006 at 7:46am
For old versions of toolkit RegisterWindowClass() has no parameter.
 
This is not a big problem, just create other one with parameter RegisterWindowClass(HINSTANCE hInstance).
copy code from existing RegisterWindowClass()
and change it a little, like:
    wndcls.hInstance = hInstance ? hInstance : AfxGetInstanceHandle();
 
See also:
https://forum.codejock.com/forum_posts.asp?TID=5211&KW=RegisterWindowClass

--
WBR,
Serge


Posted By: jpnascim
Date Posted: 20 November 2006 at 4:45am
Ok, I've tried doing what you recommended but it still won't show up and do Modal keeps returning -1.

This is the resulting code for the RegisterWindowClass method after the changes you've suggested. After changing it, I've used the deploy Wizard to re-generate all Codejock LIB's and DLL's.

BOOL CXTPReportControl::RegisterWindowClass(HINSTANCE hInstance)
{
    WNDCLASS wndcls;
    HINSTANCE hInst = AfxGetInstanceHandle();
   
    if (!(::GetClassInfo(hInst, XTPREPORTCTRL_CLASSNAME, &wndcls)))
    {
        // otherwise we need to register a new class
        wndcls.style            = CS_DBLCLKS | CS_HREDRAW | CS_VREDRAW;
        wndcls.lpfnWndProc      = ::DefWindowProc;
        wndcls.cbClsExtra       = wndcls.cbWndExtra = 0;
        //wndcls.hInstance        = hInst;
        wndcls.hInstance = hInstance ? hInstance : AfxGetInstanceHandle();
        wndcls.hIcon            = NULL;
        wndcls.hCursor          = AfxGetApp()->LoadStandardCursor(IDC_ARROW);
        wndcls.hbrBackground    = (HBRUSH) (COLOR_3DFACE + 1);
        wndcls.lpszMenuName     = NULL;
        wndcls.lpszClassName    = XTPREPORTCTRL_CLASSNAME;

        if (!AfxRegisterClass(&wndcls))
        {
            AfxThrowResourceException();
            return FALSE;
        }
    }

    return TRUE;
}

And this is its call in my dialog's constructor:

    HINSTANCE hRCthisDLL = AfxFindResourceHandle(MAKEINTRESOURCE(IDD), RT_DIALOG);
    m_MissionList.RegisterWindowClass(hRCthisDLL);

Is there are any other thing that I should do ?

Thank you very much,

Joćo Pedro


Posted By: Oleg
Date Posted: 20 November 2006 at 6:42am

Hi,

 
replace
HINSTANCE hInst = AfxGetInstanceHandle();
 
to
HINSTANCE hInst =  hInstance ? hInstance : AfxGetInstanceHandle();


-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: jpnascim
Date Posted: 20 November 2006 at 12:01pm
Ok, it worked !

Thank you very much.

Joćo Pedro





Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net