Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 20th, 2012  |  syntax: C++  |  size: 1.53 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #pragma once
  2. #include "stdafx.h"
  3. #include <commctrl.h>
  4. #include <types.h>
  5. #include "gstring.h"
  6. #include "winapi.h"
  7.  
  8. class CWnd
  9. {
  10. public:
  11.         CWnd();
  12.  
  13.         operator HWND() const {return hWnd;}
  14.         virtual inline HWND GetWnd() {return hWnd;}
  15.         virtual int PreTranslateMessage(MSG* pMsg) { return 0; }
  16.         inline void GetClientRect(RECT *rect) { ::GetClientRect(*this,rect); }
  17.         inline void GetClientRect(HWND hWnd, RECT* rect) { ::GetClientRect(hWnd,rect); }
  18.         //inline void GetFocus() { hWnd=::GetFocus (); }
  19.         inline HWND GetParent() { return hParent; }
  20.         inline DWORD GetStyle() { return GetWindowLongPtr(hWnd, GWL_STYLE); }
  21.         inline HWND GetTopWindow() { return ::GetTopWindow(*this); }
  22.         inline void SetFocus() { ::SetFocus(*this); }
  23.         inline BOOL SetWindowText(LPCTSTR lpString) { return ::SetWindowText(hWnd,lpString); }
  24.         inline int MessageBox(LPCTSTR lpText, LPCTSTR lpCaption=NULL, UINT uType=MB_OK) { return ::MessageBox(hWnd,lpText,lpCaption,uType); }
  25.  
  26.         void Invalidate(BOOL bErase=TRUE);
  27.         GString GetWindowText();
  28.         GString GetWindowText(UINT uID);
  29.         void SetDlgItem(HWND hWnd, UINT uID);
  30.         void SetWindowPos(HWND hWndInsertAfter, int x, int y, int w, int h);
  31.         void ShowWindow(int nCmdShow);
  32.  
  33. protected:
  34.         HWND hWnd, hParent;
  35.         UINT uID;
  36. };
  37.  
  38. class CEditCtrl : public CWnd
  39. {
  40. public:
  41.         inline void SetText(LPCTSTR text) { SetWindowText(text); }
  42.  
  43.         u32 GetValue();
  44.         void SetValue(u32 value, bool has_sign=false);
  45. };
  46.  
  47. class CSpinControl : public CWnd
  48. {
  49. public:
  50.         void SetRange(short low, short high);
  51.         void SetRange32(int low, int high);
  52. };