home *** CD-ROM | disk | FTP | other *** search
/ BUG 4 / BUGCD1997_05.BIN / aplic / clip4win / clip4win.exe / C4W30E.HUF / SOURCE / OD.PRG < prev    next >
Text File  |  1993-09-22  |  1KB  |  76 lines

  1.  
  2. #define    WIN_WANT_ALL
  3. #include "windows.ch"
  4.  
  5. #define    APPNAME    "OWNERB"
  6. #define    IDC_BTN1    1
  7.  
  8. static    hWnd
  9. static    aDbg
  10.  
  11.  
  12. function main()
  13. static    nProc
  14. local    hBtn, nEvent
  15.  
  16. hWnd = WinSetup(APPNAME, "Clip-4-Win Owner Draw Button Demo")
  17.  
  18. nProc = SubClassWindow(hWnd,                        ;
  19.                {|hWnd, nMsg, nwParam, nlParam|            ;
  20.                 BtnWndProc(nProc, hWnd, nMsg, nwParam, nlParam)}, ;
  21.                WM_DRAWITEM)
  22.  
  23. hBtn = CreateWindow("button",                    ;
  24.             "Button",                    ;
  25.             WS_CHILD + WS_VISIBLE + BS_OWNERDRAW,    ;
  26.             40, 20,                    ;
  27.             40, 20,                    ;
  28.             hWnd,                    ;
  29.             IDC_BTN1)
  30.  
  31. @ 10,10 say "...."
  32.  
  33. do while .t.
  34.     do while (nEvent := ChkEvent()) == EVENT_NONE
  35.     enddo
  36.     do case
  37.     case nEvent == EVENT_QUIT
  38.         exit
  39.     endcase
  40. enddo
  41.  
  42. if IsWindow(hWnd)
  43.     DestroyWindow(hWnd)
  44. endif
  45.  
  46. UnregisterClass(APPNAME)
  47.  
  48. return 0
  49.  
  50.  
  51. #define    ODT_BUTTON    4
  52.  
  53.  
  54. static function BtnWndProc(nProc, hWnd, nMsg, nwParam, nlParam)
  55. static    cDIB
  56. // nMsg == WM_DRAWITEM, so nlParam is LPDRAWITEMSTRUCT
  57. local    aDIS := bin2a(c4w_peek(nlParam, 26), "uint[7],int[4],dword")
  58. local    hDC
  59.  
  60. aDbg = aDIS
  61.  
  62. if cDIB == nil
  63.     cDIB = ReadDIB("play.bmp")
  64. endif
  65.  
  66. if aDIS[1] == ODT_BUTTON
  67.     hDC = GetDC(hWnd)
  68.     ShowDIB(hDC, cDIB)
  69.     ReleaseDC(hWnd, hDC)
  70.     return 1
  71. endif
  72.  
  73. return CallWindowProc(nProc, hWnd, nMsg, nwParam, nlParam)
  74.  
  75.  
  76.