![]()  | 
 
XTPReport as Custom Control | 
 
    Post Reply  
   | 
  
| Author | |
   
   cpede  
   
   Senior Member  
   Joined: 13 August 2004 Location: Denmark Status: Offline Points: 683  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Topic: XTPReport as Custom ControlPosted: 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 
    | 
 |
![]()  | 
 |
   
   cpede  
   
   Senior Member  
   Joined: 13 August 2004 Location: Denmark Status: Offline Points: 683  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     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>); 
-cpede 
    | 
 |
![]()  | 
 |
   
   jpnascim  
   
   Groupie  
   Joined: 17 November 2006 Location: Brazil Status: Offline Points: 12  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     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  | 
 |
![]()  | 
 |
   
   sserge  
   
   Moderator Group  
   Joined: 01 December 2004 Status: Offline Points: 1297  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     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  | 
 |
![]()  | 
 |
   
   jpnascim  
   
   Groupie  
   Joined: 17 November 2006 Location: Brazil Status: Offline Points: 12  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     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  | 
 |
![]()  | 
 |
   
   Oleg  
   
   Senior Member  
   Joined: 21 May 2003 Location: United States Status: Offline Points: 11234  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 20 November 2006 at 6:42am | 
 
| 
   
    Hi, replace 
HINSTANCE hInst = AfxGetInstanceHandle(); 
to 
HINSTANCE hInst =  hInstance ? hInstance : AfxGetInstanceHandle(); 
    | 
 |
| 
   
     
     Oleg, Support Team 
   
  CODEJOCK SOFTWARE SOLUTIONS  | 
 |
![]()  | 
 |
   
   jpnascim  
   
   Groupie  
   Joined: 17 November 2006 Location: Brazil Status: Offline Points: 12  | 
  
   
      Post Options
    
        Thanks(0)
      Quote   Reply
   
     Posted: 20 November 2006 at 12:01pm | 
 
| 
   
    
   Ok, it worked ! 
   
  Thank you very much. Joćo Pedro  | 
 |
![]()  | 
 |
    Post Reply  
   | 
  |
|       
  
  Tweet   	
    | 
 
| Forum Jump | Forum Permissions  ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum  |