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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [host/] [tools/] [Utils/] [win32/] [CSHCommon.cpp] - Blame information for rev 790

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
// ####ECOSHOSTGPLCOPYRIGHTBEGIN####                                        
2
// -------------------------------------------                              
3
// This file is part of the eCos host tools.                                
4
// Copyright (C) 1998, 1999, 2000 Free Software Foundation, Inc.            
5
//
6
// This program is free software; you can redistribute it and/or modify     
7
// it under the terms of the GNU General Public License as published by     
8
// the Free Software Foundation; either version 2 or (at your option) any   
9
// later version.                                                           
10
//
11
// This program is distributed in the hope that it will be useful, but      
12
// WITHOUT ANY WARRANTY; without even the implied warranty of               
13
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU        
14
// General Public License for more details.                                 
15
//
16
// You should have received a copy of the GNU General Public License        
17
// along with this program; if not, write to the                            
18
// Free Software Foundation, Inc., 51 Franklin Street,                      
19
// Fifth Floor, Boston, MA  02110-1301, USA.                                
20
// -------------------------------------------                              
21
// ####ECOSHOSTGPLCOPYRIGHTEND####                                          
22
// CSHCommon.cpp : implementation file
23
//
24
 
25
#include "stdafx.h"
26
#include "CSHCommon.h"
27
#include <HTMLHelp.h>
28
#include <windowsx.h> // for GET_X_LPARAM, GET_Y_LPARAM
29
 
30
#ifdef _DEBUG
31
#define new DEBUG_NEW
32
#undef THIS_FILE
33
static char THIS_FILE[] = __FILE__;
34
#endif
35
 
36
/////////////////////////////////////////////////////////////////////////////
37
// CCSHCommon
38
 
39
CString CCSHCommon::m_strCSHFilePath;
40
 
41
CCSHCommon::CCSHCommon()
42
{
43
  m_bSupressContextMenu=false;
44
}
45
 
46
CCSHCommon::~CCSHCommon()
47
{
48
}
49
 
50
CWnd *CCSHCommon::WndFromPoint(CWnd *pDialog,CWnd* pWnd,CPoint pt)
51
{
52
  CWnd *rc=NULL;
53
  CPoint ptClient(pt);
54
  pDialog->ScreenToClient(&ptClient);
55
  if(pWnd==pDialog){
56
    // The pWnd argument is the dialog itself for disabled controls
57
    // Can't use ChildWindowFromPoint() - may return an enclosing group box
58
    for(CWnd *p=pDialog->GetWindow(GW_CHILD);p;p=p->GetWindow(GW_HWNDNEXT)){
59
      TCHAR buf[256];
60
      if(::GetClassName(p->m_hWnd,buf,sizeof buf)){
61
        if(0==_tcscmp(buf,_T("STATIC"))){
62
          continue;
63
        } else if(0==_tcscmp(buf,_T("Button")) && p->GetStyle()&BS_GROUPBOX) {
64
          continue;
65
        } else {
66
          CRect rect;
67
          p->GetWindowRect(rect);
68
          if(rect.PtInRect(pt)){
69
            rc=p;
70
            break;
71
          }
72
        }
73
      }
74
    }
75
  } else {
76
    rc=pWnd;
77
  }
78
  return rc;
79
}
80
 
81
void CCSHCommon::DisplayHelp(HWND hCtrl,UINT ids,HINSTANCE hInst)
82
{
83
  DWORD dwPos=GetMessagePos();
84
  HH_POPUP hhp;
85
  if (HIWORD(ids) == 0) {
86
    hhp.idString=ids;
87
    hhp.pszText=_T("No help is available for this item");
88
  } else {
89
    hhp.idString=0;
90
    hhp.pszText=(LPCTSTR)ids;
91
  }
92
 
93
  hhp.cbStruct=sizeof(hhp);
94
  hhp.hinst=hInst;
95
  hhp.pt.x=GET_X_LPARAM(dwPos);
96
  hhp.pt.y=GET_Y_LPARAM(dwPos);
97
  hhp.clrForeground=(COLORREF)-1; //default 
98
  hhp.clrBackground=GetSysColor(COLOR_INFOBK);
99
  hhp.rcMargins=CRect(-1,-1,-1,-1);
100
  hhp.pszFont=NULL;
101
 
102
  HtmlHelp(hCtrl,NULL,HH_DISPLAY_TEXT_POPUP,(DWORD)&hhp);
103
}
104
 
105
// FilterMessage has the same semantics as OnWndMsg
106
bool CCSHCommon::FilterMessage(UINT &message, WPARAM &wParam,LPARAM &lParam,LRESULT *&)
107
{
108
  switch(message){
109
    case WM_ACTIVATE:
110
      // This fixes a bug in HTMLHelp v1.3 whereby a click on the dialog to dismiss a helpbox causes a crash
111
      if(WA_CLICKACTIVE==wParam && !::IsWindow((HWND)lParam)) {
112
        lParam=0;
113
      }
114
      break;
115
      /*
116
    case WM_NOTIFY:
117
      // This deals with the case that a control is sending us the notification message.  We set the flag to ignore
118
      // the next WM_CONTEXTMENU message (for else we would prevent
119
      if(NM_RCLICK==((LPNMHDR)lParam)->code) {
120
        m_bSupressContextMenu=true;
121
      }
122
      break;
123
      */
124
    case WM_CONTEXTMENU:
125
      if(m_bSupressContextMenu){
126
        m_bSupressContextMenu=false;
127
          return true; // processed
128
      }
129
      break;
130
    default:
131
      break;
132
  }
133
  return false;
134
}
135
 
136
 
137
/////////////////////////////////////////////////////////////////////////////
138
// CCSHCommon message handlers
139
 
140
bool CCSHCommon::OnContextMenu(CWnd *pDialog, CPoint pt, UINT idHelp)
141
{
142
  bool rc=false;
143
  if(NULL!=m_pwndContext&& 0!=idHelp){
144
    CMenu menu;
145
    menu.CreatePopupMenu();
146
    menu.AppendMenu(MF_STRING,ID_WHATS_THIS,_T("&What's This?"));
147
    menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RIGHTBUTTON, pt.x,pt.y,pDialog);
148
    rc=true;
149
  }
150
  return rc;
151
}

powered by: WebSVN 2.1.0

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