Category : C++ Source Code
Archive   : AFXVBX.ZIP
Filename : AFXVBX.CPP

 
Output of file : AFXVBX.CPP contained in archive : AFXVBX.ZIP
/*------------------------------------------------------------------------------*
| |
| File Name: AFXVBX.CPP |
| |
| Description: This file contains all the functions for the AFXDLL used by |
| its calling application APP.EXE |
| |
| History: Date Author Comment |
| 05/23/93 Pran Punniamoorthy Created with the help |
| of John Seghers |
| |
*------------------------------------------------------------------------------*/
#include
#include
#include // standard MFC Extension DLL routines
#include "afxdllres.h" // The DLL resource definitions
#include "afxvbx.h" // The DLL class definitions

HINSTANCE hInstDLL; // Global copy of the DLL instance handle

/////////////////////////////////////////////////////////////////////////////
// Initialization of MFC Extension DLL

static AFX_EXTENSION_MODULE NEAR extensionDLL = { NULL, NULL };

extern "C" int CALLBACK LibMain(HINSTANCE hInstance, WORD, WORD, LPSTR)
{
// Extension DLL one-time initialization - do not allocate memory here,
// use the TRACE or ASSERT macros or call MessageBox

AfxInitExtensionModule(extensionDLL, hInstance);
hInstDLL = hInstance;
return 1;
}

/////////////////////////////////////////////////////////////////////////////
// Exported DLL initialization is run in context of running application

extern "C" extern void _export WINAPI InitAfxVbx()
{
new CDynLinkLibrary(extensionDLL);

CWinApp* pApp = AfxGetApp();
ASSERT(pApp != NULL);

pApp->m_pMainWnd = new CMainWindow(); // Create MainWindow object
pApp->m_pMainWnd->ShowWindow(SW_SHOWNORMAL);
pApp->m_pMainWnd->UpdateWindow();

WNDCLASS wndClass;

if(::GetClassInfo(hInstDLL,"VBControl",&wndClass)==0) // Get the wndclass struct. of class VBControl
{
VERIFY(::GetClassInfo(AfxGetInstanceHandle(),"VBControl",&wndClass));
wndClass.hInstance = hInstDLL; // Change the instance handle so it is that of the DLL and not the App.
VERIFY(::RegisterClass(&wndClass)); // Register the class
}

}


/*------------------------------------------------------------------------------*
| Constructor For class CMainWindow |
| |
| Description: In the constructor, the main window for the application is |
| created. |
| |
| Parameters : none |
| |
| Returns : void |
| |
*------------------------------------------------------------------------------*/

CMainWindow::CMainWindow()
{
Create( NULL, "VBX Control resource of AFXDLL",
WS_OVERLAPPEDWINDOW, rectDefault, NULL, MAKEINTRESOURCE(IDR_MENU1) );
}

/*------------------------------------------------------------------------------*
| CMainWindow::OnVBXDialog() |
| |
| Description: This function displays a dialog box that contains a vbx control|
| which is a resource of the DLL. |
| |
| Parameters : none |
| |
| Returns : void |
| |
*------------------------------------------------------------------------------*/

void CMainWindow::OnVBXDialog()
{
CVBXDialog vbxDialog(IDD_DIALOG1);
vbxDialog.DoModal();
}



////////////////////////////// The Message Map for class CMainWindow /////////////////////////

BEGIN_MESSAGE_MAP( CMainWindow, CFrameWnd )
ON_COMMAND( ID_DIALOG_DIALOGPRESS, OnVBXDialog )
END_MESSAGE_MAP()


/*------------------------------------------------------------------------------*
| CVBXDialog::OnInitDialog() |
| |
| Description: This function does the necessary function calls to get a vbx |
| control that is part of a dialog that is a resource of a AFXDLL|
| to be displayed correctly. Add your own initialization code |
| below the comment line "Add your initialization code below". |
| |
| Parameters : none |
| |
| Returns : BOOL |
| |
*------------------------------------------------------------------------------*/

BOOL CVBXDialog::OnInitDialog()
{
HINSTANCE hOldInstance = _AfxGetAppData()->appCurrentInstanceHandle;
_AfxGetAppData()->appCurrentInstanceHandle = hInstDLL;
CDialog::OnInitDialog();
_AfxGetAppData()->appCurrentInstanceHandle = hOldInstance;

// Add your initialization code below

return TRUE;
}




  3 Responses to “Category : C++ Source Code
Archive   : AFXVBX.ZIP
Filename : AFXVBX.CPP

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/