home *** CD-ROM | disk | FTP | other *** search
/ Windows 95 Secrets (4th Edition) / Windows95Secrets4thEdition.iso / tools / installr / freeman / awndobj.h_ / awndobj
Encoding:
Text File  |  1995-06-14  |  6.5 KB  |  308 lines

  1. #define __AWNDOBJ_H
  2.  
  3. #ifndef __STDARG_H
  4. #include "stdarg.h"
  5. #endif
  6.  
  7. class abswndobj
  8. {
  9.    public:
  10.  
  11.    virtual HWND getwnd() = 0;
  12.  
  13.    int destroy()
  14.    {
  15.       return DestroyWindow(getwnd());
  16.    }
  17.    int gettxtlen()
  18.    {
  19.       return GetWindowTextLength(getwnd());
  20.    }
  21.    int begtimer(int id, int timeout)
  22.    {
  23.       return SetTimer(getwnd(), id, timeout, 0);
  24.    } 
  25.    int endtimer(int id)
  26.    {
  27.       return KillTimer(getwnd(), id);
  28.    }
  29.    int totop()
  30.    {
  31.       return BringWindowToTop(getwnd());
  32.    }
  33.    int chknull()
  34.    {
  35.       return getwnd() == 0;
  36.    }
  37.    int chkpopup()
  38.    {
  39.       return (getstyle() & WS_POPUP) != 0L;
  40.    }
  41.    int chkvisible()
  42.    {
  43.       return IsWindowVisible(getwnd());
  44.    }
  45.    int getclass(char s[], int sz = 40)
  46.    {
  47.       return GetClassName(getwnd(), s, sz);
  48.    }
  49.    int getclaimedw()
  50.    {
  51.       return LOWORD(getclaimedwh());
  52.    }
  53.    int getclaimedh()
  54.    {
  55.       return HIWORD(getclaimedwh());
  56.    }
  57.    int chkbtn()
  58.    {
  59.       return chkclass("BUTTON");
  60.    }
  61.    int chkedit()
  62.    {
  63.       return chkclass("EDIT");
  64.    }
  65.    int chkcomb()
  66.    {
  67.       return chkclass("COMBOBOX");
  68.    }
  69.    void gettxt(char s[], int sz = 255)
  70.    {
  71.       GetWindowText(getwnd(), s, sz);
  72.    }
  73.    void clrtxt()
  74.    {
  75.       settxt("");
  76.    }
  77.    void settxt(char s[])
  78.    {
  79.       SetWindowText(getwnd(), s);
  80.    }
  81.    void setint(int i)
  82.    {
  83.       settxtfmt("%d", i);
  84.    }
  85.    void setlng(LONG l)
  86.    {
  87.       settxtfmt("%ld", l);
  88.    }
  89.    void setdbl(double d)
  90.    {
  91.       settxtfmt("%lg", d);
  92.    }
  93.    void setuint(UINT i)
  94.    {
  95.       settxtfmt("%u", i);
  96.    }
  97.    void show(int cmd)
  98.    {    
  99.       ShowWindow(getwnd(), cmd);
  100.    }
  101.    void setactive()
  102.    {
  103.       SetActiveWindow(getwnd());
  104.    }
  105.    void update()
  106.    {
  107.       UpdateWindow(getwnd());
  108.    }
  109.    void begpaint(PAINTSTRUCT *ps)
  110.    {
  111.       BeginPaint(getwnd(), (PAINTSTRUCT FAR*)ps);
  112.    }
  113.    void endpaint(PAINTSTRUCT *ps)
  114.    {
  115.       EndPaint(getwnd(), ps);
  116.    }
  117.    void setfont(HFONT f, int isredraw)
  118.    {
  119.       SendMessage(getwnd(), WM_SETFONT, (WPARAM)f, (LPARAM)MAKELONG(isredraw, 0));
  120.    }
  121.    void scr2clt(POINT *p)
  122.    {
  123.       ScreenToClient(getwnd(), p);
  124.    }
  125.    void clt2scr(POINT *p)
  126.    {
  127.       ClientToScreen(getwnd(), p);
  128.    }
  129.    void getclientrect(RECT *clt)
  130.    {
  131.       GetClientRect(getwnd(), clt);
  132.    }
  133.    void getrect(RECT *r)
  134.    {
  135.       GetWindowRect(getwnd(), r);
  136.    }
  137.    void redraw(int iserase = 1)
  138.    {
  139.       invalidate(iserase);
  140.  
  141.       update();
  142.    }
  143.    void invalidate(int iserase = 1)
  144.    {
  145.       InvalidateRect(getwnd(), NULL, iserase);
  146.    }
  147.    void invalidate(RECT &r, int iserase = 1)
  148.    {
  149.       InvalidateRect(getwnd(), &r, iserase);
  150.    }
  151.    void validate()
  152.    {
  153.       ValidateRect(getwnd(), 0);
  154.    }
  155.    void validate(RECT &r)
  156.    {
  157.       ValidateRect(getwnd(), &r);
  158.    }
  159.    void enable(int isenable = 1)
  160.    {
  161.       EnableWindow(getwnd(), isenable);
  162.    }
  163.    void move(int l, int t, int w, int h, int isrepaint = 0)
  164.    {
  165.       MoveWindow(getwnd(), l, t, w, h, isrepaint);
  166.    }
  167.    void setredraw(int isredraw = 0)
  168.    {
  169.       sendmsg(WM_SETREDRAW, isredraw, 0L);
  170.    }
  171.    void setpos(HWND insertafter, int x, int y, int w, int h, UINT flags)
  172.    {
  173.       SetWindowPos(getwnd(), insertafter, x, y, w, h, flags);
  174.    }
  175.    void endcapture()
  176.    {
  177.       ReleaseCapture();
  178.    }
  179.    void notifydad(int code)
  180.    {
  181.       senddadmsg(WM_COMMAND, getid(), MAKELPARAM(getwnd(), code));
  182.    }
  183.    void setscrollpos(int bar, int pos, int isredraw = 1)
  184.    {
  185.       SetScrollPos(getwnd(), bar, pos, isredraw);
  186.    }
  187.    void setscrollrange(int bar, int min, int max, int isredraw = 1)
  188.    {
  189.       SetScrollRange(getwnd(), bar, min, max, isredraw);
  190.    }
  191.    void scroll(int dx, int dy, RECT *scrollr = 0, RECT *clipr = 0)
  192.    {
  193.       ScrollWindow(getwnd(), dx, dy, scrollr, clipr);
  194.    }
  195.    void showownedpopups(int isshow)
  196.    {
  197.       ShowOwnedPopups(getwnd(), isshow);
  198.    }
  199.    operator HWND ()
  200.    {
  201.       return getwnd();
  202.    }
  203.    HWND setfocus()
  204.    {
  205.       return SetFocus(getwnd());
  206.    }
  207.    HWND begcapture()
  208.    {
  209.       return SetCapture(getwnd());
  210.    }
  211.    HWND getdad()
  212.    {
  213.       return GetParent(getwnd());
  214.    }
  215.    HWND setdad(HWND dad)
  216.    {
  217.       return SetParent(getwnd(), dad);
  218.    }
  219.    HWND getkid(int id)
  220.    {
  221.       return GetDlgItem(getwnd(), id);
  222.    }
  223.    HWND getotherwnd(UINT rel)
  224.    {
  225.       return GetWindow(getwnd(), rel);
  226.    }
  227.    WORD getword(int off)
  228.    {
  229.       return GetWindowWord(getwnd(), off);
  230.    }
  231.    WORD getid()
  232.    {
  233.       return getword(GWW_ID);
  234.    }
  235.    LONG getlong(int off)
  236.    {
  237.       return GetWindowLong(getwnd(), off);
  238.    }
  239.    LONG setlong(int off, LONG l)
  240.    {
  241.       return SetWindowLong(getwnd(), off, l);
  242.    }
  243.    LONG getstyle()
  244.    {
  245.       return getlong(GWL_STYLE);
  246.    }
  247.    LONG setstyle(LONG style)
  248.    {
  249.       return setlong(GWL_STYLE, style);
  250.    }
  251.    HICON seticon(HICON icon)
  252.    {
  253.       return (HICON)sendmsg(STM_SETICON, (WPARAM)icon, 0L);
  254.    }
  255.    LRESULT sendmsg(UINT msg, WPARAM wp, LPARAM lp)
  256.    {
  257.       return SendMessage(getwnd(), msg, wp, lp);
  258.    }
  259.    LRESULT postmsg(UINT msg, WPARAM wp, LPARAM lp)
  260.    {
  261.       return PostMessage(getwnd(), msg, wp, lp);
  262.    }
  263.    LRESULT senddadmsg(UINT msg, WPARAM wp, LPARAM lp)
  264.    {
  265.       return SendMessage(getdad(), msg, wp, lp);
  266.    }
  267.    LRESULT postdadmsg(UINT msg, WPARAM wp, LPARAM lp)
  268.    {
  269.       return PostMessage(getdad(), msg, wp, lp);
  270.    }
  271.    LRESULT defwndproc(UINT msg, WPARAM wp, LPARAM lp)
  272.    {
  273.       return DefWindowProc(getwnd(), msg, wp, lp);
  274.    }
  275.    LRESULT defdlgproc(UINT msg, WPARAM wp, LPARAM lp)
  276.    {
  277.       return DefDlgProc(getwnd(), msg, wp, lp);
  278.    }
  279.    HINSTANCE getinst()
  280.    {
  281.       return (HINSTANCE)getword(GWW_HINSTANCE);
  282.    }
  283.  
  284.    int getint(int *i);
  285.    int getlng(LONG *l);
  286.    int getuint(UINT *i);
  287.    int scanf(char fmt[], ...);
  288.    int chkclass(char cls[]);
  289.    void settxtfmt(char fmt[], ...);
  290.    void settxtvar(va_list args, char fmt[]);
  291.    void setzorder(HWND insafter, UINT flags);
  292.    void movecenter(HWND bkwnd = 0);
  293.    void movecenter(int x, int y);
  294.    void resizekeepc(int w, int h, int isredraw);
  295.    void getrectindad(RECT *dr);
  296.    void errormsg(char msg[], ...);
  297.    void errorvar(va_list args, char msg[]);
  298.    void outofmem();
  299.    void badctrldata(int id, char msg[], ...);
  300.    void transferkids(int toframe, int n, int frframe, int isshow, int tolast = 0, int frthis = 1);
  301.    HWND getsibwnd(int i);
  302.    DWORD getclaimedwh();
  303.  
  304.    static int peekdiscardmsg(int ismore = 0);
  305.  
  306.    static int peekdispatchmsg(int ismore = 0);
  307. };
  308.