How to View and Populate a RECT (with scrolling) within the Client Area of a Win32 API program from an MFC DLL

  • Thread starter Thread starter Richard.G
  • Start date Start date
R

Richard.G

Guest
Hi all,

I am developing in Native C++ in a Win32 API environment using Visual Studio 2008. However, I have now added a new MFC DLL Project to the Solution. The intention is to access MFC classes within an MFC DLL to display data in a scrollable RECT within the Client Area of the Win32 API EXE, and ultimately to print the data.



I am now stuck and do not know how to proceed further. From within the MFC DLL, the data is accessed from a database and depending on which report / document the user selects such data is then populated into Objects within Vectors. The document details and associated data are then to be viewed on screen. Once the user is satisfied with the correctness of the data there is a button to print. The reports / documents will never be saved (serialized) to or retrieved from the disk, as the hard copy will be the final representation of the data as input during the Add, Edit and Delete Win32 API DLL programs.



The screen representation and printed reports need to be in a specific format with Headings, Line Feeds, Underlines etc which are to be incorporated programmatically and could be any number of pages long.



I have done extensive research within the System Help Files and various search results, including Ivor Horton’s Beginning Visual C++ 2008, and cannot find anything appropriate as they involve an MFC created exe, but most of all, nothing makes sense to me.



My system is represented as follows:


System Structure.

WIN32 API EXE - Calls

WIN32 API DLL - Deals with Add / Edit / Delete data & Controls Access to View & Print - Calls

MFC DLL - View / Print - Then returns to WIN32 API DLL.





I have the following questions:

  1. Is my strategy achievable within this structure?
  2. The InitInstance() function is called on start-up, even before WinMain() is executed.

2.1 Should this happen on start-up? I envisaged this to be executed only when a specific report / document is selected.

2.2 . The InitInstance() function is:

BOOL CMFC_DLLAPP::InitInstance()

{

CWinApp::InitInstance();

if(!AfxOleInit())

{

{

AfxMessageBox(IDP_OLE_INIT_FAILED);

return FALSE;

return }

afxenablecontrolcontainer():;

CSingleDocTemplate* pDocTemplate;

pDocTemplate = new CSingleDocTemplate(

IDR_MAINFRAME,

RUNTIME_CLASS(CMyDoc),

RUNTIME_CLASS(CMainFrame),

RUNTIME_CLASS(CMyView));


if(!pDocTemplate) return FALSE;

AddDocTemplate(pDocTemplate);

CCommandLineInfo cmdInfo;

ParseCommandLine(cmdInfo);

cmdInfo.m_nShellCommand = CCommandLineInfo::FileNothing;

if(!ProcessShellCommand(cmdInfo)) return FALSE;




return TRUE;

}




2.3 . These commands were merely copied from various examples, and not actually sure what is needed.



3 Assuming, this is possible.

3.1. How do I incorporate the required data with headings, line feeds etc into CMyDoc.

3.2. How do I adapt CMainFrame to accommodate this strategy.

3.3. How do I adapt CMyView to accommodate this strategy.



I hope that there is a solution to achieving this. Your comments, advice and any links to usable examples would be much appreciated.



Regards,

Richard

Continue reading...
 
Back
Top