source: trunk/MFCtooling/TestProg/TestProg.cpp @ 344

Last change on this file since 344 was 148, checked in by jhall, 13 years ago

added some new elements

File size: 7.1 KB
RevLine 
[32]1// TestProg.cpp : Defines the class behaviors for the application.
2//
3
4#include "stdafx.h"
5#include "TestProg.h"
6#include "MainFrm.h"
7
8#include "ChildFrm.h"
9#include "IpFrame.h"
10#include "TestProgDoc.h"
11#include "TestProgView.h"
12#include "afxwin.h"
[148]13#include "afxcmn.h"
[32]14
15#ifdef _DEBUG
16#define new DEBUG_NEW
17#endif
18
19
20// CTestProgApp
21
22BEGIN_MESSAGE_MAP(CTestProgApp, CWinApp)
23        ON_COMMAND(ID_APP_ABOUT, &CTestProgApp::OnAppAbout)
24        // Standard file based document commands
25        ON_COMMAND(ID_FILE_NEW, &CWinApp::OnFileNew)
26        ON_COMMAND(ID_FILE_OPEN, &CWinApp::OnFileOpen)
27        // Standard print setup command
28        ON_COMMAND(ID_FILE_PRINT_SETUP, &CWinApp::OnFilePrintSetup)
29END_MESSAGE_MAP()
30
31
32// CTestProgApp construction
33
34CTestProgApp::CTestProgApp()
35{
36        // TODO: add construction code here,
37        // Place all significant initialization in InitInstance
38}
39
40
41// The one and only CTestProgApp object
42
43CTestProgApp theApp;
44// This identifier was generated to be statistically unique for your app
45// You may change it if you prefer to choose a specific identifier
46
47// {81A5B9DA-E0DC-4E02-9097-38F90D423C7B}
48static const CLSID clsid =
49{ 0x81A5B9DA, 0xE0DC, 0x4E02, { 0x90, 0x97, 0x38, 0xF9, 0xD, 0x42, 0x3C, 0x7B } };
50
51
52// CTestProgApp initialization
53
54BOOL CTestProgApp::InitInstance()
55{
56        // InitCommonControlsEx() is required on Windows XP if an application
57        // manifest specifies use of ComCtl32.dll version 6 or later to enable
58        // visual styles.  Otherwise, any window creation will fail.
59        INITCOMMONCONTROLSEX InitCtrls;
60        InitCtrls.dwSize = sizeof(InitCtrls);
61        // Set this to include all the common control classes you want to use
62        // in your application.
63        InitCtrls.dwICC = ICC_WIN95_CLASSES;
64        InitCommonControlsEx(&InitCtrls);
65
66        CWinApp::InitInstance();
67
68        void (__cdecl *InitUsagelogPtr)(void) = NULL;
69       
70        hinstDll = LoadLibrary(L"userlog.dll");
71        if( hinstDll==NULL ) {
72                MessageBox(0, L"Loading of DLL failed", L"Failure", MB_OK);
73        }
74        InitUsagelogPtr = (void (*)(void)) GetProcAddress(hinstDll, "InitUsagelog");
75        if( InitUsagelogPtr==NULL ) {
76                MessageBox(0, L"Loading of InitFuncPtr failed", L"Failure", MB_OK);
77        }
78        if( InitUsagelogPtr!=NULL ) {
79                InitUsagelogPtr();
80        }
81
82
83        // Initialize OLE libraries
84        if (!AfxOleInit())
85        {
86                AfxMessageBox(IDP_OLE_INIT_FAILED);
87                return FALSE;
88        }
89        AfxEnableControlContainer();
90        // Standard initialization
91        // If you are not using these features and wish to reduce the size
92        // of your final executable, you should remove from the following
93        // the specific initialization routines you do not need
94        // Change the registry key under which our settings are stored
95        // TODO: You should modify this string to be something appropriate
96        // such as the name of your company or organization
97        SetRegistryKey(_T("Local AppWizard-Generated Applications"));
98        LoadStdProfileSettings(4);  // Load standard INI file options (including MRU)
99        // Register the application's document templates.  Document templates
100        //  serve as the connection between documents, frame windows and views
101        CMultiDocTemplate* pDocTemplate;
102        pDocTemplate = new CMultiDocTemplate(IDR_TestProgTYPE,
103                RUNTIME_CLASS(CTestProgDoc),
104                RUNTIME_CLASS(CChildFrame), // custom MDI child frame
105                RUNTIME_CLASS(CTestProgView));
106        if (!pDocTemplate)
107                return FALSE;
108        pDocTemplate->SetContainerInfo(IDR_TestProgTYPE_CNTR_IP);
109        pDocTemplate->SetServerInfo(
110                IDR_TestProgTYPE_SRVR_EMB, IDR_TestProgTYPE_SRVR_IP,
111                RUNTIME_CLASS(CInPlaceFrame));
112        AddDocTemplate(pDocTemplate);
113        // Connect the COleTemplateServer to the document template
114        //  The COleTemplateServer creates new documents on behalf
115        //  of requesting OLE containers by using information
116        //  specified in the document template
117        m_server.ConnectTemplate(clsid, pDocTemplate, FALSE);
118        // Register all OLE server factories as running.  This enables the
119        //  OLE libraries to create objects from other applications
120        COleTemplateServer::RegisterAll();
121                // Note: MDI applications register all server objects without regard
122                //  to the /Embedding or /Automation on the command line
123
124        // create main MDI Frame window
125        CMainFrame* pMainFrame = new CMainFrame;
126        if (!pMainFrame || !pMainFrame->LoadFrame(IDR_MAINFRAME))
127        {
128                delete pMainFrame;
129                return FALSE;
130        }
131        m_pMainWnd = pMainFrame;
132        // call DragAcceptFiles only if there's a suffix
133        //  In an MDI app, this should occur immediately after setting m_pMainWnd
134
135
136        // Parse command line for standard shell commands, DDE, file open
137        CCommandLineInfo cmdInfo;
138        ParseCommandLine(cmdInfo);
139
140        // App was launched with /Embedding or /Automation switch.
141        // Run app as automation server.
142        if (cmdInfo.m_bRunEmbedded || cmdInfo.m_bRunAutomated)
143        {
144                // Don't show the main window
145                return TRUE;
146        }
147        // App was launched with /Unregserver or /Unregister switch.  Unregister
148        // typelibrary.  Other unregistration occurs in ProcessShellCommand().
149        else if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister)
150        {
151                m_server.UpdateRegistry(OAT_INPLACE_SERVER, NULL, NULL, FALSE);
152        }
153        // App was launched standalone or with other switches (e.g. /Register
154        // or /Regserver).  Update registry entries, including typelibrary.
155        else
156        {
157                m_server.UpdateRegistry(OAT_INPLACE_SERVER);
158        }
159
160        // Dispatch commands specified on the command line.  Will return FALSE if
161        // app was launched with /RegServer, /Register, /Unregserver or /Unregister.
162        if (!ProcessShellCommand(cmdInfo))
163                return FALSE;
164        // The main window has been initialized, so show and update it
165        pMainFrame->ShowWindow(m_nCmdShow);
166        pMainFrame->UpdateWindow();
167
168        return TRUE;
169}
170
171
172int CTestProgApp::ExitInstance()
173{
174        //TODO: Zusätzliche Ressourcen behandeln, die Sie möglicherweise hinzugefügt haben
175        AfxOleTerm(FALSE);
176       
177        void (*ReleaseUsagelogPtr)(void) = NULL;
178               
179        ReleaseUsagelogPtr = (void (*)(void)) GetProcAddress(hinstDll, "ReleaseUsagelog");
180        if( ReleaseUsagelogPtr==NULL ) {
181                MessageBox(0, L"Loading of ReleaseFuncPtr failed", L"Failure", MB_OK);
182        }
183        if( ReleaseUsagelogPtr!=NULL ) {
184                ReleaseUsagelogPtr();
185        }
186
187        FreeLibrary(hinstDll);
188
189        return CWinApp::ExitInstance();
190}
191
192// CAboutDlg dialog used for App About
193
194class CAboutDlg : public CDialog
195{
196public:
197        CAboutDlg();
198
199// Dialog Data
200        enum { IDD = IDD_ABOUTBOX };
201
202protected:
203        virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
204
205// Implementation
206protected:
207        DECLARE_MESSAGE_MAP()
208public:
[148]209        CListBox listbox_test;
210        CTabCtrl tabControl_test;
211        afx_msg void OnBnClickedButton1();
[32]212};
213
214CAboutDlg::CAboutDlg() : CDialog(CAboutDlg::IDD)
215{
216       
217}
218
219void CAboutDlg::DoDataExchange(CDataExchange* pDX)
220{
221        CDialog::DoDataExchange(pDX);
222
[148]223        DDX_Control(pDX, IDC_LIST1, listbox_test);
224        for(int i=0; i<10; i++) listbox_test.AddString(L"Testeintrag");
[32]225
[148]226        DDX_Control(pDX, IDC_TAB1, tabControl_test);
227        tabControl_test.InsertItem(0, L"Tab 1");
228        tabControl_test.InsertItem(1, L"Tab 2");
229        tabControl_test.InsertItem(2, L"Tab 3");
230}
[32]231
232BEGIN_MESSAGE_MAP(CAboutDlg, CDialog)
233END_MESSAGE_MAP()
234
235// App command to run the dialog
236void CTestProgApp::OnAppAbout()
237{
238        CAboutDlg aboutDlg;
239        aboutDlg.DoModal();
240       
241}
242
243
244// CTestProgApp message handlers
Note: See TracBrowser for help on using the repository browser.