Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Report Control
  New Posts New Posts RSS Feed - XTPReport as Custom Control
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

XTPReport as Custom Control

 Post Reply Post Reply
Author
Message
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post Topic: XTPReport as Custom Control
    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
Back to Top
cpede View Drop Down
Senior Member
Senior Member


Joined: 13 August 2004
Location: Denmark
Status: Offline
Points: 668
Post Options Post Options   Thanks (0) Thanks(0)   Quote cpede Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
jpnascim View Drop Down
Groupie
Groupie
Avatar

Joined: 17 November 2006
Location: Brazil
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpnascim Quote  Post ReplyReply Direct Link To This Post 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


Back to Top
sserge View Drop Down
Moderator Group
Moderator Group


Joined: 01 December 2004
Status: Offline
Points: 1297
Post Options Post Options   Thanks (0) Thanks(0)   Quote sserge Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
jpnascim View Drop Down
Groupie
Groupie
Avatar

Joined: 17 November 2006
Location: Brazil
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpnascim Quote  Post ReplyReply Direct Link To This Post 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
Back to Top
Oleg View Drop Down
Admin Group
Admin Group


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 20 November 2006 at 6:42am

Hi,

 
replace
HINSTANCE hInst = AfxGetInstanceHandle();
 
to
HINSTANCE hInst =  hInstance ? hInstance : AfxGetInstanceHandle();
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
jpnascim View Drop Down
Groupie
Groupie
Avatar

Joined: 17 November 2006
Location: Brazil
Status: Offline
Points: 12
Post Options Post Options   Thanks (0) Thanks(0)   Quote jpnascim Quote  Post ReplyReply Direct Link To This Post Posted: 20 November 2006 at 12:01pm
Ok, it worked !

Thank you very much.

Joćo Pedro


Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.156 seconds.