Go to the documentation of this file.00001
00002 #include "StdAfx.h"
00003 #include "vgui_mfc_app.h"
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "vgui_mfc_view.h"
00017 #include "vgui_mfc_doc.h"
00018 #include "vgui_mfc_mainfrm.h"
00019 #include "resource.h"
00020 #if 0
00021 #ifdef _DEBUG
00022 #define new DEBUG_NEW
00023 #undef THIS_FILE
00024 static char THIS_FILE[] = __FILE__;
00025 #endif
00026 #endif
00027
00028
00029
00030 vgui_mfc_app::vgui_mfc_app()
00031 {
00032
00033
00034 }
00035
00036
00037
00038 class vgui_mfc_app_command_line_info : public CCommandLineInfo
00039 {
00040 public:
00041 void ParseParam( LPCTSTR lpszParam, BOOL bFlag, BOOL bLast )
00042 {
00043 CCommandLineInfo::ParseParam(lpszParam, bFlag, bLast);
00044 }
00045 };
00046
00047 static void f();
00048
00049
00050
00051 BOOL vgui_mfc_app::InitInstance()
00052 {
00053 AfxEnableControlContainer();
00054
00055
00056
00057
00058
00059 #if 0
00060 #ifdef _DEBUG
00061 Enable3dControls();
00062 #else
00063 Enable3dControlsStatic();
00064 #endif
00065 #endif
00066
00067
00068
00069 SetRegistryKey(_T("Local AppWizard-Generated Applications"));
00070
00071 LoadStdProfileSettings();
00072
00073
00074
00075 CSingleDocTemplate *pDocTemplate;
00076 pDocTemplate = new CSingleDocTemplate(
00077 IDR_MAINFRAME,
00078 RUNTIME_CLASS(vgui_mfc_doc),
00079 RUNTIME_CLASS(vgui_mfc_mainfrm),
00080 RUNTIME_CLASS(vgui_mfc_view));
00081 AddDocTemplate(pDocTemplate);
00082
00083
00084 vgui_mfc_app_command_line_info cmdInfo;
00085 #if 0
00086 ParseCommandLine(cmdInfo);
00087 #endif
00088
00089
00090 CDocument *pDocument = pDocTemplate->CreateNewDocument();
00091
00092
00093
00094 CFrameWnd* pFrame = (CFrameWnd *)(RUNTIME_CLASS(vgui_mfc_mainfrm)->CreateObject());
00095 CCreateContext context;
00096 context.m_pCurrentFrame = pFrame;
00097 context.m_pCurrentDoc = pDocument;
00098 context.m_pNewViewClass = RUNTIME_CLASS(vgui_mfc_view);
00099 context.m_pNewDocTemplate = pDocTemplate;
00100 pFrame->Create(NULL, _T("VGUI"), WS_OVERLAPPEDWINDOW ,
00101 pFrame->rectDefault,NULL,NULL,0,&context);
00102 m_pMainWnd = pFrame;
00103 pDocTemplate->InitialUpdateFrame(pFrame,pDocument);
00104
00105 #if 0
00106 m_pMainWnd->SetScrollRange(SB_HORZ,-1024,1024);
00107 m_pMainWnd->SetScrollRange(SB_VERT,-1024,1024);
00108 m_pMainWnd->SetScrollPos(SB_HORZ,0);
00109 m_pMainWnd->SetScrollPos(SB_VERT,0);
00110 #endif
00111 m_pMainWnd->ShowWindow(SW_SHOW);
00112 m_pMainWnd->UpdateWindow();
00113
00114 return TRUE;
00115 }
00116
00117
00118 BOOL vgui_mfc_app::Run()
00119 {
00120
00121 BOOL bIdle = TRUE;
00122 LONG lIdleCount = 0;
00123 MSG msgCur;
00124
00125
00126 for (;;)
00127 {
00128
00129 while (bIdle && !::PeekMessage(&msgCur, NULL, NULL, NULL, PM_NOREMOVE))
00130 {
00131
00132 if (!OnIdle(lIdleCount++))
00133 bIdle = FALSE;
00134 }
00135
00136
00137 do
00138 {
00139 MSG tmp_msg;
00140 if (::PeekMessage(&tmp_msg,NULL,NULL,NULL,PM_NOREMOVE))
00141 {
00142 if (true)
00143 {
00144
00145 while (tmp_msg.message == WM_MOVE)
00146 {
00147
00148 ::PeekMessage(&tmp_msg,NULL,NULL,NULL,PM_REMOVE);
00149
00150 BOOL status = ::PeekMessage(&tmp_msg,NULL,NULL,NULL,PM_NOREMOVE);
00151
00152
00153
00154 if (!status || !(tmp_msg.message == WM_MOVE))
00155 {
00156 ::TranslateMessage(&tmp_msg);
00157 ::DispatchMessage(&tmp_msg);
00158 }
00159 }
00160 }
00161 }
00162
00163
00164 {
00165 switch (tmp_msg.message)
00166 {
00167 case 0x036a:
00168 case 0x0362:
00169 case WM_PAINT:
00170 case WM_KEYUP:
00171 default: f(); break;
00172 }
00173 }
00174
00175
00176 if (!PumpMessage())
00177 return ExitInstance();
00178
00179
00180 if (IsIdleMessage(&msgCur))
00181 {
00182 bIdle = TRUE;
00183 lIdleCount = 0;
00184 }
00185 } while (::PeekMessage(&msgCur, NULL, NULL, NULL, PM_NOREMOVE));
00186 }
00187 ASSERT(FALSE);
00188 }
00189
00190
00191
00192 void f() {}
00193
00194 BOOL vgui_mfc_app::OnIdle( LONG lCount )
00195 {
00196
00197
00198
00199 if (CWinApp::OnIdle(lCount))
00200 return TRUE;
00201
00202
00203 POSITION tmpl_pos = this->GetFirstDocTemplatePosition();
00204 while ( tmpl_pos )
00205 {
00206 CDocTemplate *tmpl = this->GetNextDocTemplate(tmpl_pos);
00207 POSITION doc_pos = tmpl->GetFirstDocPosition();
00208 while ( doc_pos )
00209 {
00210 CDocument *pdoc = tmpl->GetNextDoc(doc_pos);
00211 POSITION view_pos = pdoc->GetFirstViewPosition();
00212 while ( view_pos )
00213 {
00214 vgui_mfc_adaptor *adaptor = (vgui_mfc_adaptor *)pdoc->GetNextView(view_pos);
00215 if ( adaptor->do_idle() ) {
00216 return TRUE;
00217 }
00218 }
00219 }
00220 }
00221
00222 return FALSE;
00223 }