| zuoyan's profileKNOWLEDGE B@$EBlogGuestbookNetwork | Help |
|
|
9/16/2008 读《沉思录》
1.培养良好的脾性,不要轻易动怒。
2.谦虚,保持男子气概。
3.慷慨大方,懂得容忍别人,不屑报复的念头,消费理性。
4.在学习上,要懂得自如支配时间。
5.不要加入相互对立的任何一方,也不要为其中任何一方喝彩。你要过的始终只是你自己; 能够忍受艰辛和疲劳; 要突破必然性的制约; 不要搅和别人的事情,不要轻易相信通风报信的人。
6.不要做徒然无益的追求;通过写对话录来提高自己。
7.正直立身,追求完美。不要沾染诡辩家的虚荣心,不要因为虚荣去写些文字,不要慷慨激昂的谈论道德,不要故作热情洋溢,不要存心表现心胸开阔或者严于律己。不被修辞和诗词技巧迷惑。
8.享受自由,不依赖于偶然机遇,保持心灵平静。在承担一个道德义务时,既不自卑,又不让朋友感到不悦。
9.学会富有意义地展示善意。
10.不要挑别人遣词造句或者发音的毛病。善意的修正别人表达的真实意义。
11.不要掩饰自己的真实情感,如果不会造成伤害的话。
12.若非必须,绝不要对他人说话或者写信,不要懒散闲适。不要找借口逃避。
13.不要轻慢,回复的自然禀性。充满至诚的爱意。
14.爱亲人,正义和真实;坦诚地表达对他人合理的嫌恶,明白的提出自己的希望与要求。绝不让朋友猜测自己的意图所在。
15.把握自己,不过多地受外在事物影响;身罹疾病活遭遇不幸时不会垂头丧气;立身行事谦恭、乐于助人、举止尊严;凡有要务,不因循拖延,不怨天尤人,在事情初显端倪时便及时处理。 9/3/2008 [HOW TO:] Get Current CDocument or CView from AnywhereHow to Get Current CDocument or CView from AnywhereFrom Microsoft Knowledge Base (Article ID: Q108587)One of the cases where you might need a pointer to the currently active view or document is in a modal or modeless dialog box. Generally, a dialog box should be created by the view class, because the view is what deals with the application's user interface. Because the view class is creating the dialog box, it can pass a pointer to itself, or the active document [obtained with the GetActiveDocument() function] to the dialog box. This could be done through the dialog box's constructor or some other member function. For modal dialog boxes, the view could also put data from the dialog box into the document when DoModal() returns. These methods are generally preferable to relying on generic functions to return pointers to the currently active view or document. To allow you to get a pointer to the currently active document from anywhere in the program, add a static member function to your CDocument derived class as follows: Edit the document's header file as follows to add a static member function, GetDoc(): // Document header file
class CMyDoc : public CDocument
{
...
public:
static CMyDoc * GetDoc();
...
};
For a single document interface (SDI) application, add the following code to your SDI document's implementation file for CMyDoc::GetDoc():
// SDI document implementation file
CMyDoc * CMyDoc::GetDoc()
{
CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
return (CMyDoc *) pFrame->GetActiveDocument();
}
For a multiple document interface (MDI) application, the CMyDoc::GetDoc() code should be the following:
CMyDoc * CMyDoc::GetDoc()
{
CMDIChildWnd * pChild =
((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();
if ( !pChild )
return NULL;
CDocument * pDoc = pChild->GetActiveDocument();
if ( !pDoc )
return NULL;
// Fail if doc is of wrong kind
if ( ! pDoc->IsKindOf( RUNTIME_CLASS(CMyDoc) ) )
return NULL;
return (CMyDoc *) pDoc;
}
To allow you to get a pointer to the currently active view from anywhere in the program, add a static member function to your CView derived class as follows:
Edit the view's header file as follows to add a static member function, GetView(): // View header file
class CMyView
{
...
public:
static CMyView * GetView();
...
};
For an SDI application, add the following code to your SDI view's implementation file for CMyView::GetView():
// View implementation file
CMyView * CMyView::GetView()
{
CFrameWnd * pFrame = (CFrameWnd *)(AfxGetApp()->m_pMainWnd);
CView * pView = pFrame->GetActiveView();
if ( !pView )
return NULL;
// Fail if view is of wrong kind
// (this could occur with splitter windows, or additional
// views on a single document
if ( ! pView->IsKindOf( RUNTIME_CLASS(CMyView) ) )
return NULL;
return (CMyView *) pView;
}
For an MDI application, the CMyView::GetView() code should be the following:
// MDI view implementation file
CMyView * CMyView::GetView()
{
CMDIChildWnd * pChild =
((CMDIFrameWnd*)(AfxGetApp()->m_pMainWnd))->MDIGetActive();
if ( !pChild )
return NULL;
CView * pView = pChild->GetActiveView();
if ( !pView )
return NULL;
// Fail if view is of wrong kind
if ( ! pView->IsKindOf( RUNTIME_CLASS(CMyView) ) )
return NULL;
return (CMyView *) pView;
}
Now, from anywhere in your program, where the document or view header files have been included, you can call:
CMyDoc::GetDoc();-or- CMyView::GetView();to get a pointer to the currently active document or view, respectively. These functions return NULL if there is no active document or view. Note that a pointer to the application's CDocument or CView derived class is returned, not just a generic CDocument or CView pointer. This allows you to access members specific to your new class. The MDI versions of these functions, and the SDI version of the GetView() function, will use run-time type checking to verify that the document or view is of the correct class. |
|
|