Advertisement
Guest User

Untitled

a guest
May 25th, 2015
283
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.95 KB | None | 0 0
  1.  
  2. JustTheBasics() {
  3. global
  4.  
  5. ; Start gdi+
  6. If !pToken := Gdip_Startup()
  7. {
  8. MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
  9. ExitApp
  10. }
  11. OnExit, Exit
  12. return
  13.  
  14.  
  15. Exit:
  16. ; gdi+ may now be shutdown on exiting the program
  17. Gdip_Shutdown(pToken)
  18. ExitApp
  19. Return
  20.  
  21. }
  22.  
  23. SetUpGDIP(iWidth=-1, iHeight=-1) {
  24. global
  25. Width := iWidth
  26. Height := iHeight
  27. If (iWidth < 0) {
  28. Width := A_ScreenWidth
  29. }
  30. if (iHeight < 0) {
  31. height := A_ScreenHeight
  32. }
  33.  
  34.  
  35. JustTheBasics()
  36.  
  37. ; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption
  38. Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
  39.  
  40. ; Show the window
  41. Gui, 1: Show, NA
  42.  
  43. ; Get a handle to this window we have created in order to update it later
  44. hwnd1 := WinExist()
  45. return
  46. }
  47.  
  48. StartDrawGDIP() {
  49. global
  50.  
  51. ; Create a gdi bitmap with width and height of what we are going to draw into it. This is the entire drawing area for everything
  52. hbm := CreateDIBSection(Width, Height)
  53.  
  54. ; Get a device context compatible with the screen
  55. hdc := CreateCompatibleDC()
  56.  
  57. ; Select the bitmap into the device context
  58. obm := SelectObject(hdc, hbm)
  59.  
  60. ; Get a pointer to the graphics of the bitmap, for use with drawing functions
  61. G := Gdip_GraphicsFromHDC(hdc)
  62. }
  63.  
  64. EndDrawGDIP() {
  65. global
  66.  
  67. ; Update the specified window we have created (hwnd1) with a handle to our bitmap (hdc), specifying the x,y,w,h we want it positioned on our screen
  68. ; So this will position our gui at (0,0) with the Width and Height specified earlier
  69. UpdateLayeredWindow(hwnd1, hdc, 0, 0, Width, Height)
  70.  
  71.  
  72. ; Select the object back into the hdc
  73. SelectObject(hdc, obm)
  74.  
  75. ; Now the bitmap may be deleted
  76. DeleteObject(hbm)
  77.  
  78. ; Also the device context related to the bitmap may be deleted
  79. DeleteDC(hdc)
  80.  
  81. ; The graphics may now be deleted
  82. Gdip_DeleteGraphics(G)
  83. }
  84.  
  85. ClearDrawGDIP() {
  86. global
  87. Gdip_GraphicsClear(G)
  88. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement