OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [tools/] [src/] [tools/] [Utils/] [win32/] [CSHCommon.cpp] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 26 unneback
//####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
// CSHCommon.cpp : implementation file
26
//
27
 
28
#include "stdafx.h"
29
#include "CSHCommon.h"
30
#include <HTMLHelp.h>
31
#include <windowsx.h> // for GET_X_LPARAM, GET_Y_LPARAM
32
 
33
#ifdef _DEBUG
34
#define new DEBUG_NEW
35
#undef THIS_FILE
36
static char THIS_FILE[] = __FILE__;
37
#endif
38
 
39
/////////////////////////////////////////////////////////////////////////////
40
// CCSHCommon
41
 
42
CString CCSHCommon::m_strCSHFilePath;
43
 
44
CCSHCommon::CCSHCommon()
45
{
46
  m_bSupressContextMenu=false;
47
}
48
 
49
CCSHCommon::~CCSHCommon()
50
{
51
}
52
 
53
CWnd *CCSHCommon::WndFromPoint(CWnd *pDialog,CWnd* pWnd,CPoint pt)
54
{
55
  CWnd *rc=NULL;
56
  CPoint ptClient(pt);
57
  pDialog->ScreenToClient(&ptClient);
58
  if(pWnd==pDialog){
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)){
62
      TCHAR buf[256];
63
      if(::GetClassName(p->m_hWnd,buf,sizeof buf)){
64
        if(0==_tcscmp(buf,_T("STATIC"))){
65
          continue;
66
        } else if(0==_tcscmp(buf,_T("Button")) && p->GetStyle()&BS_GROUPBOX) {
67
          continue;
68
        } else {
69
          CRect rect;
70
          p->GetWindowRect(rect);
71
          if(rect.PtInRect(pt)){
72
            rc=p;
73
            break;
74
          }
75
        }
76
      }
77
    }
78
  } else {
79
    rc=pWnd;
80
  }
81
  return rc;
82
}
83
 
84
void CCSHCommon::DisplayHelp(HWND hCtrl,UINT ids,HINSTANCE hInst)
85
{
86
  DWORD dwPos=GetMessagePos();
87
  HH_POPUP hhp;
88
  if (HIWORD(ids) == 0) {
89
    hhp.idString=ids;
90
    hhp.pszText=_T("No help is available for this item");
91
  } else {
92
    hhp.idString=0;
93
    hhp.pszText=(LPCTSTR)ids;
94
  }
95
 
96
  hhp.cbStruct=sizeof(hhp);
97
  hhp.hinst=hInst;
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);
103
  hhp.pszFont=NULL;
104
 
105
  HtmlHelp(hCtrl,NULL,HH_DISPLAY_TEXT_POPUP,(DWORD)&hhp);
106
}
107
 
108
// FilterMessage has the same semantics as OnWndMsg
109
bool CCSHCommon::FilterMessage(UINT &message, WPARAM &wParam,LPARAM &lParam,LRESULT *&)
110
{
111
  switch(message){
112
    case WM_ACTIVATE:
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)) {
115
        lParam=0;
116
      }
117
      break;
118
      /*
119
    case WM_NOTIFY:
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;
124
      }
125
      break;
126
      */
127
    case WM_CONTEXTMENU:
128
      if(m_bSupressContextMenu){
129
        m_bSupressContextMenu=false;
130
          return true; // processed
131
      }
132
      break;
133
    default:
134
      break;
135
  }
136
  return false;
137
}
138
 
139
 
140
/////////////////////////////////////////////////////////////////////////////
141
// CCSHCommon message handlers
142
 
143
bool CCSHCommon::OnContextMenu(CWnd *pDialog, CPoint pt, UINT idHelp)
144
{
145
  bool rc=false;
146
  if(NULL!=m_pwndContext&& 0!=idHelp){
147
    CMenu menu;
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);
151
    rc=true;
152
  }
153
  return rc;
154
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.