DownLoad
This is designed to allow some one to draw on a desktop with the GDIP functions. Hope you enjoy it.
Any ideas, comments, concerns or Ect appreciated.
CODE: ("Included in Download")
Code:
#SingleInstance, Force
#NoEnv
#Include, Gdip.ahk
SetBatchLines, -1
Smoother = 5 ; Set between 1-10 For smooth values
; Options
CoordMode, Mouse
CoordMode, Pixel
Pen_Colour = FFFFFF
MySlider = 20
; End of Options
SplashImage, pens\spidergames.bmp, y50, Now Loading (Not Realy I just want you to look at me),, GDIP Desktop Drawer
Loop, 100
{
Progress, %a_index%
Sleep, 50
if a_index = 100
break
}
SplashImage off
Progress, Off
Gui, Add, Picture, gPannelClick, ColourPannel.bmp
Gui, Add, Text, w100 vColour,
Gui, Add, ListView, BackGroundFFFFFF ReadOnly w30 h30 x50 y180 vMyListView,
Gui, Add , Picture, x10 y180 vState0 gSubRoutine1, pens\PenPressedMulti.Bmp
Gui, Add , Picture, x10 y180 vState1 gSubRoutine1, pens\PenunPressedMulti.Bmp
Gui, Add , Picture, x10 y235 w20 h20 vpic, pic.Bmp
Gui, Add, Slider, x80 y200 vMySlider gSlider Range1-50 Left AltSubmit Vertical, 20
Gui, Add, Button, gGDELETE, Clear
Gui, Show,, Pallet
GoSub, Pen
Return,
Slider:
GuiControl,,pic, *w%mySlider% *h%mySlider% pic.Bmp
Return,
PannelClick:
while GetKeyState("LButton")
{
MouseGetPos, x, y
PixelGetColor, SelectedColour,%x%, %y%, RGB
GuiControl, +Background%SelectedColour%, MyListView
GuiControl,, Colour,%SelectedColour%
Pen_Colour := SubStr(SelectedColour, 3)
}
Return,
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////***PEN***/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
;///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Pen:
; Start gdi+
If !pToken := Gdip_Startup() ; If DLL Did not loaded properly
{
MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
ExitApp
}
OnExit, Exit
CoordMode, Mouse
GADD:
Gui, 3: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui, 3: Show, NA
hwnd1 := WinExist()
hbm := CreateDIBSection(A_ScreenWidth, A_ScreenHeight)
hdc := CreateCompatibleDC()
obm := SelectObject(hdc, hbm)
G := Gdip_GraphicsFromHDC(hdc)
Gdip_SetSmoothingMode(G, 4)
Return,
SubRoutine1:
Sleep,1000
GuiControl, Hide, State1
if drawing = 0
GoSub, GAdd ; Creates PEN as tool
drawing = 1 ; tells computer we are now drawing
pPen := Gdip_CreatePen(0xc0(Pen_Colour), myslider) ; Creates pen tool with the chosen colour and size;
Hotkey, $*LButton, LleftClick, On
Hotkey, $*LButton Up, LleftClickup, On
Gui, 5:Add, Text,, Click Pen here to`n remove tool
Gui, 5:Show, x0 y0 w100 h100, Winhold
Return,
ButtonClear:
GoSub, GDELETE
Return,
LleftClick:
Left_Click := True
while Left_Click =1
{
MouseGetpos, NewX, NewY
if lx !=
Gdip_DrawLine(G, pPen, lx, ly, NewX, NewY)
UpdateLayeredWindow(hwnd1, hdc, 0, 0, A_ScreenWidth, A_ScreenHeight) ; refresh screen to show drawings
sleep % Smoother
lx = %NewX%
ly = %NewY%
}
lx := ""
ly := ""
if NewX between 0 and 100 ; if mouse is in the selected box Destroy the drawing surface
{
if NewY between 0 and 100
{
Gui, 5:Destroy
Hotkey, $*LButton, LleftClick, off
Hotkey, $*LButton Up, LleftClickUp, off
GuiControl, Show, State1
Return,
}
}
LleftClickup:
Left_Click := False
Return,
GDelete:
; DELETE GRAHPICS SUB
Gui, Submit, NoHide
SelectObject(hdc, obm)
; Now the bitmap may be deleted
DeleteObject(hbm)
; Also the device context related to the bitmap may be deleted
DeleteDC(hdc)
; The graphics may now be deleted
Gdip_DeleteGraphics(G)
Gui, 3:Destroy
UpdateLayeredWindow(hwnd1, hdc, 0, 0, A_ScreenWidth, A_ScreenHeight)
drawing = 0
Return,
;#######################################################################
Exit:
; gdi+ may now be shutdown on exiting the program
Gdip_Shutdown(pToken)
ExitApp
Return