UIHandle.h
上传用户:hbzxgg2
上传日期:2009-03-28
资源大小:291k
文件大小:2k
源码类别:

Windows Mobile

开发平台:

Visual C++

  1. #pragma once
  2. #include "global.h"
  3. DLL_INTERNAL void DrawCurveByDataBuffer ( CDC *pDC, CRect &rcClient, COLORREF clr, BYTE *data, int size, int nCellSize=1, int nStepX=0 );
  4. DLL_INTERNAL void DeleteInstance ( CWnd **ppWnd );
  5. DLL_INTERNAL CSize GetWorkAreaSize ();
  6. DLL_INTERNAL void HandleSpanClick(
  7. CWnd *pOwnerWnd,
  8. UINT nEditCtrlID,
  9. NMHDR* pNMHDR,
  10. LRESULT* pResult,
  11. int nMaxValue,
  12. int nMinValue,
  13. int nInterval=1);
  14. DLL_INTERNAL BOOL LoadBitmapFromFile(CBitmap &bmp, LPCTSTR lpszBmpPath);
  15. DLL_INTERNAL void DrawBitmap ( CBitmap &bmp, CDC *pDC, CRect &rc, BOOL bStretch );
  16. DLL_INTERNAL void SetWaitCursor ();
  17. DLL_INTERNAL void ResotreCursor ();
  18. // 创建对话框实例模板函数
  19. template<class T>
  20. T* TGetInstance (
  21. T **pptDlg, // 保存对话框指针的指针
  22. UINT nIDTemplate, // 对话框资源 ID
  23. CWnd *pParentWnd=NULL, // 父窗口句柄
  24. BOOL bRecreateWhenExist=FALSE, // 对话框存在时是否重新创建,删除已经存在的
  25. BOOL bNotCreateWindow=FALSE, // 不创建窗口,仅仅 New 一个对象
  26. BYTE nShowImmediately=1 // 是否立即显示对话框。0 - 不显示;1 - 显示并激活获取焦点;2 - 仅仅显示,不获取焦点
  27. )
  28. {
  29. if ( !pptDlg ) return NULL;
  30. if ( *pptDlg )
  31. {
  32. if ( bRecreateWhenExist )
  33. {
  34. ::DeleteInstance ( (CWnd**)pptDlg );
  35. }
  36. else if ( ::IsWindow ( (*pptDlg)->m_hWnd ) )
  37. {
  38. ActiveWindowAndHoldFocus ( (*pptDlg)->m_hWnd );
  39. return (*pptDlg);
  40. }
  41. }
  42. if ( !(*pptDlg) )
  43. {
  44. *pptDlg = new T ( pParentWnd );
  45. }
  46. if ( !(*pptDlg) ) return NULL;
  47. if ( bNotCreateWindow ) return (*pptDlg);
  48. if ( !::IsWindow ( (*pptDlg)->GetSafeHwnd() ) )
  49. {
  50. if ( !(*pptDlg)->Create ( nIDTemplate, pParentWnd ) )
  51. {
  52. ::DeleteInstance ( (CWnd**)pptDlg );
  53. return NULL;
  54. }
  55. }
  56. if ( nShowImmediately != 0 )
  57. {
  58. (*pptDlg)->ShowWindow ( SW_SHOW );
  59. // (*pptDlg)->SetForegroundWindow ();
  60. if ( nShowImmediately == 1 )
  61. ActiveWindowAndHoldFocus ( (*pptDlg)->m_hWnd );
  62. }
  63. ASSERT ( (*pptDlg) && ::IsWindow ( (*pptDlg)->GetSafeHwnd() ) );
  64. return (*pptDlg);
  65. }