]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - tools/src/tools/Utils/win32/CSHDialog.cpp
Initial revision
[karo-tx-redboot.git] / tools / src / tools / Utils / win32 / CSHDialog.cpp
1 //####COPYRIGHTBEGIN####
2 //                                                                          
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
5 //
6 // This program is part of the eCos host tools.
7 //
8 // This program is free software; you can redistribute it and/or modify it 
9 // under the terms of the GNU General Public License as published by the Free 
10 // Software Foundation; either version 2 of the License, or (at your option) 
11 // any later version.
12 // 
13 // This program is distributed in the hope that it will be useful, but WITHOUT 
14 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
15 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for 
16 // more details.
17 // 
18 // You should have received a copy of the GNU General Public License along with
19 // this program; if not, write to the Free Software Foundation, Inc., 
20 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
21 //
22 // ----------------------------------------------------------------------------
23 //                                                                          
24 //####COPYRIGHTEND####
25 // CSHDialog.cpp : implementation file
26 //
27
28 #include "stdafx.h"
29 #include "CSHDialog.h"
30 #include <afxpriv.h> // for WM_COMMANDHELP
31
32 #ifdef _DEBUG
33 #define new DEBUG_NEW
34 #undef THIS_FILE
35 static char THIS_FILE[] = __FILE__;
36 #endif
37
38 #include <htmlHelp.h>
39 #include <windowsx.h>
40 /////////////////////////////////////////////////////////////////////////////
41 // CCSHDialog dialog
42
43 void CCSHDialog::DoDataExchange(CDataExchange* pDX)
44 {
45         CDialog::DoDataExchange(pDX);
46         //{{AFX_DATA_MAP(CCSHDialog)
47                 // NOTE: the ClassWizard will add DDX and DDV calls here
48         //}}AFX_DATA_MAP
49 }
50
51
52 BEGIN_MESSAGE_MAP(CCSHDialog, CDialog)
53         //{{AFX_MSG_MAP(CCSHDialog)
54         ON_WM_CONTEXTMENU()
55         ON_WM_HELPINFO()
56   ON_MESSAGE(WM_COMMANDHELP,OnCommandHelp)
57   ON_COMMAND(ID_WHATS_THIS,OnWhatsThis)
58         ON_COMMAND(IDHELP, OnHelp)
59         //}}AFX_MSG_MAP
60 END_MESSAGE_MAP()
61
62 /////////////////////////////////////////////////////////////////////////////
63 // CCSHDialog message handlers
64 void CCSHDialog::OnContextMenu(CWnd* pWnd, CPoint pt) 
65 {
66   m_pwndContext=WndFromPoint(this,pWnd,pt);
67   if(NULL==m_pwndContext || !CCSHCommon::OnContextMenu(this,pt,HelpID(m_pwndContext->GetDlgCtrlID()))){
68     CDialog::OnContextMenu(pWnd,pt);
69   }
70 }
71
72 void CCSHDialog::OnWhatsThis()
73 {
74   DisplayHelp(m_pwndContext->m_hWnd,HelpID(m_pwndContext->m_hWnd),GetInstanceHandle());
75 }
76
77 BOOL CCSHDialog::OnHelpInfo(HELPINFO* pHelpInfo) 
78 {
79   DisplayHelp((HWND)pHelpInfo->hItemHandle,HelpID((HWND)pHelpInfo->hItemHandle),GetInstanceHandle());
80   return TRUE;
81 }
82
83 BOOL CCSHDialog::OnInitDialog() 
84 {
85         CDialog::OnInitDialog();
86         
87   if(0==HelpID(IDOK)){
88     // Dynamically add/remove the question mark button to the title bar of the dialog box:
89     ModifyStyleEx(WS_EX_CONTEXTHELP,0,0);
90   } else {
91     ModifyStyleEx(0,WS_EX_CONTEXTHELP,0);
92   }
93
94   CWnd *pHelpButton=GetDlgItem(IDHELP);
95   if(NULL!=pHelpButton){
96     pHelpButton->EnableWindow(!CSHFile().IsEmpty());
97   }
98         return TRUE;  // return TRUE unless you set the focus to a control
99                       // EXCEPTION: OCX Property Pages should return FALSE
100 }
101
102 CString CCSHDialog::CSHFile() const // return the context-sensitive help file 
103 {
104   return _T("");
105 }
106
107 UINT CCSHDialog::HelpID(DWORD) const
108 {
109   return 0; // dummy implementation
110 }
111
112 void CCSHDialog::OnHelp() 
113 {
114   if(!CSHFile().IsEmpty()){
115     HtmlHelp(NULL,GetCSHFilePath()+CSHFile(),HH_DISPLAY_TOPIC,0);
116   }
117 }
118
119 HINSTANCE CCSHDialog::GetInstanceHandle()
120 {
121   return AfxGetInstanceHandle();
122 }
123
124 BOOL CCSHDialog::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
125 {
126   if(CCSHCommon::FilterMessage(message, wParam,lParam,pResult)){
127     return true; // handled
128   }
129   return CDialog::OnWndMsg(message, wParam, lParam, pResult);
130 }
131