1 //####COPYRIGHTBEGIN####
3 // ----------------------------------------------------------------------------
4 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
6 // This program is part of the eCos host tools.
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)
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
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.
22 // ----------------------------------------------------------------------------
24 //####COPYRIGHTEND####
25 // CSHCommon.cpp : implementation file
29 #include "CSHCommon.h"
31 #include <windowsx.h> // for GET_X_LPARAM, GET_Y_LPARAM
36 static char THIS_FILE[] = __FILE__;
39 /////////////////////////////////////////////////////////////////////////////
42 CString CCSHCommon::m_strCSHFilePath;
44 CCSHCommon::CCSHCommon()
46 m_bSupressContextMenu=false;
49 CCSHCommon::~CCSHCommon()
53 CWnd *CCSHCommon::WndFromPoint(CWnd *pDialog,CWnd* pWnd,CPoint pt)
57 pDialog->ScreenToClient(&ptClient);
59 // The pWnd argument is the dialog itself for disabled controls
60 // Can't use ChildWindowFromPoint() - may return an enclosing group box
61 for(CWnd *p=pDialog->GetWindow(GW_CHILD);p;p=p->GetWindow(GW_HWNDNEXT)){
63 if(::GetClassName(p->m_hWnd,buf,sizeof buf)){
64 if(0==_tcscmp(buf,_T("STATIC"))){
66 } else if(0==_tcscmp(buf,_T("Button")) && p->GetStyle()&BS_GROUPBOX) {
70 p->GetWindowRect(rect);
71 if(rect.PtInRect(pt)){
84 void CCSHCommon::DisplayHelp(HWND hCtrl,UINT ids,HINSTANCE hInst)
86 DWORD dwPos=GetMessagePos();
88 if (HIWORD(ids) == 0) {
90 hhp.pszText=_T("No help is available for this item");
93 hhp.pszText=(LPCTSTR)ids;
96 hhp.cbStruct=sizeof(hhp);
98 hhp.pt.x=GET_X_LPARAM(dwPos);
99 hhp.pt.y=GET_Y_LPARAM(dwPos);
100 hhp.clrForeground=(COLORREF)-1; //default
101 hhp.clrBackground=GetSysColor(COLOR_INFOBK);
102 hhp.rcMargins=CRect(-1,-1,-1,-1);
105 HtmlHelp(hCtrl,NULL,HH_DISPLAY_TEXT_POPUP,(DWORD)&hhp);
108 // FilterMessage has the same semantics as OnWndMsg
109 bool CCSHCommon::FilterMessage(UINT &message, WPARAM &wParam,LPARAM &lParam,LRESULT *&)
113 // This fixes a bug in HTMLHelp v1.3 whereby a click on the dialog to dismiss a helpbox causes a crash
114 if(WA_CLICKACTIVE==wParam && !::IsWindow((HWND)lParam)) {
120 // This deals with the case that a control is sending us the notification message. We set the flag to ignore
121 // the next WM_CONTEXTMENU message (for else we would prevent
122 if(NM_RCLICK==((LPNMHDR)lParam)->code) {
123 m_bSupressContextMenu=true;
128 if(m_bSupressContextMenu){
129 m_bSupressContextMenu=false;
130 return true; // processed
140 /////////////////////////////////////////////////////////////////////////////
141 // CCSHCommon message handlers
143 bool CCSHCommon::OnContextMenu(CWnd *pDialog, CPoint pt, UINT idHelp)
146 if(NULL!=m_pwndContext&& 0!=idHelp){
148 menu.CreatePopupMenu();
149 menu.AppendMenu(MF_STRING,ID_WHATS_THIS,_T("&What's This?"));
150 menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, pt.x,pt.y,pDialog);