76 (изменено: serzh82saratov, 2018-01-10 15:01:22)

Re: AHK: Экранная лупа

Ну вот, а ты говоришь, одной строкой делается. Осталось только в Bitmapе нарисовать что надо.


sFile = D:\Images\10х10.bmp

#SingleInstance, Force
#NoEnv
SetBatchLines, -1
OnMessage(0x201, "WM_LBUTTONDOWN")

If !pToken := Gdip_Startup()
{
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}
OnExit, Exit

Width :=1400, Height := 1000

Gui, 1: -Caption +E0x80000 +hwndhwnd +AlwaysOnTop +ToolWindow +OwnDialogs  
Gui, 1: Show, NA

hbm := CreateDIBSection(Width, Height) 
hdc := CreateCompatibleDC() 
obm := SelectObject(hdc, hbm)

G := Gdip_GraphicsFromHDC(hdc) 
Gdip_SetSmoothingMode(G, 4) 

pBitmap := Gdip_CreateBitmapFromFile(sFile)
pBrush := Gdip_CreateTextureBrush(pBitmap, 0)

Gdip_FillRectangle(G, pBrush, 0, 0, Width, Height) 

Gdip_DeleteBrush(pBrush)

UpdateLayeredWindow(hwnd, hdc, 20, 20, Width, Height)

SelectObject(hdc, obm)

DeleteObject(hbm)

DeleteDC(hdc)

Gdip_DeleteGraphics(G)
Return 

Exit: 
	Gdip_Shutdown(pToken)
	ExitApp 
	
Escape:: ExitApp

WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) { 
		PostMessage, 0xA1, 2 
}

И при движении кажется только визуальный эффект остаётся.


Так текстом, только не пойму как задать свой фон.


#SingleInstance, Force
#NoEnv
SetBatchLines, -1
OnMessage(0x201, "WM_LBUTTONDOWN")

If !pToken := Gdip_Startup()
{
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}
OnExit, Exit

Width :=1400, Height := 1000

Gui, 1: -Caption +E0x80000 +hwndhwnd +AlwaysOnTop +ToolWindow +OwnDialogs  
Gui, 1: Show, NA

hbm := CreateDIBSection(Width, Height) 
hdc := CreateCompatibleDC() 
obm := SelectObject(hdc, hbm)

G := Gdip_GraphicsFromHDC(hdc) 
Gdip_SetSmoothingMode(G, 4) 

  ;	Пытаюсь сделать общий фон
  
pBrush2 := Gdip_BrushCreateSolid(0xaa004400)
Gdip_FillRoundedRectangle(G, pBrush2, 0, 0, Width, Height, 0)
Gdip_DeleteBrush(pBrush2)

Font = Arial

If !Gdip_FontFamilyCreate(Font)
{
   MsgBox, 48, Font error!, The font you have specified does not exist on the system
   ExitApp
}

WidthText :=100, HeightText := 22
Options = x0p y0p w%WidthText%p h%HeightText%p Centre cffffffff r4 s20 Italic 

hbm2 := CreateDIBSection(WidthText, HeightText) 
hdc2 := CreateCompatibleDC() 
obm2 := SelectObject(hdc2, hbm2) 
G2 := Gdip_GraphicsFromHDC(hdc2) 
Gdip_SetSmoothingMode(G2, 4) 

Gdip_TextToGraphics(G2, "Tutorial", Options, Font, WidthText, HeightText)
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "UPtr", hbm2, "UPtr", 0, "UPtr*", pBitmap)
SelectObject(hdc2, obm2)
DeleteObject(hbm2) 
DeleteDC(hdc2) 
Gdip_DeleteGraphics(G2)

pBrush := Gdip_CreateTextureBrush(pBitmap, 0)

Gdip_FillRectangle(G, pBrush, 0, 0, Width, Height) 

Gdip_DeleteBrush(pBrush)

UpdateLayeredWindow(hwnd, hdc, 20, 20, Width, Height)

SelectObject(hdc, obm)

DeleteObject(hbm)

DeleteDC(hdc)

Gdip_DeleteGraphics(G)
Return

Exit: 
	Gdip_Shutdown(pToken)
	ExitApp 
	
Escape:: ExitApp

WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) { 
		PostMessage, 0xA1, 2 
}
Post's attachments

10х10.bmp 374 b, 4 downloads since 2018-01-10 

You don't have the permssions to download the attachments of this post.
По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

77

Re: AHK: Экранная лупа

serzh82saratov пишет:
pBrush := Gdip_CreateTextureBrush(pBitmap, 0)

Да, верная идея. В GDI есть аналог — PatternBrush.

Gui, -DPIScale
Gui, Color, White
Gui, Margin, 20, 20
Gui, Add, Pic, w640 h640 hwndhPic1
Gui, Add, Pic, x+7 yp wp hp hwndhPic2

options := { hStatic:     hPic1
           , cellsNumber: 80
           , rowsNumber:  80
           , darkColor:   0xFF0D00    ; будет фоном
           , lightColor:  0xC618 }
           
board1 := new ChessBoard(options)

options := { hStatic:     hPic2
           , cellsNumber: 80
           , rowsNumber:  80
           , darkColor:   0x028E9B    ; будет фоном
           , lightColor:  0xFF7800 }

board2 := new ChessBoard(options)

Gui, Show
Return

GuiClose:
   ExitApp

class ChessBoard
{
   __New(options)  {
      this.options := options
      hPic := options.hStatic
      this.hParent := DllCall("GetAncestor", Ptr, hPic, UInt, GA_ROOT := 2, Ptr)
      
      WinGetPos,,, W, H, ahk_id %hPic%
      this.BoardWidth := W, this.BoardHeight := H
      this.CellWidth := W/options.cellsNumber
      this.CellHeight := H/options.rowsNumber
      
      this.hDC := DllCall("GetDC", Ptr, hPic, Ptr)
      this.oMDC := new this.CompatibleDC(this.hDC, W, H)
      this.hMDC := this.oMDC.hCDC
      
      OnMessage( 0xF, this.redraw := ObjBindMethod(this, "WM_PAINT") )
      this.DrawBoard()
   }
   
   __Delete()  {
      this.oMDC := ""
      DllCall("DeleteDC", Ptr, this.hDC)
      OnMessage(0xF, this.redraw, 0)
   }
   
   DrawBoard()  {
      oCDC := new this.CompatibleDC(this.hDC, this.CellWidth*2, this.CellHeight*2)
      hCDC := oCDC.hCDC
      Loop 2  {
         row := A_Index
         Loop 2  {
            cell := A_Index
            X := this.CellWidth*(cell - 1)
            Y := this.CellHeight*(row - 1)
            brush := new this.Brush(hCDC, this.options[ mod(row + cell, 2) ? "darkColor" : "lightColor" ])
            this.FillRect(hCDC, brush.hBrush, X, Y, X + this.CellWidth, Y + this.CellHeight)
         }
      }
      brush := new this.Brush(this.hMDC, oCDC.hCBM)
      this.FillRect(this.hMDC, brush.hBrush, 0, 0, this.BoardWidth, this.BoardHeight)
      this.BitBlt(this.hDC, this.hMDC)
   }
   
   FillRect(hDC, hBrush, left, top, right, bottom)  {
      VarSetCapacity(RECT, 16, 0)
      NumPut(left,   RECT, 0)
      NumPut(top,    RECT, 4)
      NumPut(right,  RECT, 8)
      NumPut(bottom, RECT, 12, "UInt")
      DllCall("FillRect", Ptr, hDC, Ptr, &RECT, Ptr, hBrush)
   }
   
   BitBlt(ddc, sdc)  {
      DllCall("BitBlt", Ptr, ddc, Int, 0, Int, 0, Int, this.BoardWidth, Int, this.BoardHeight
                      , Ptr, sdc, Int, 0, Int, 0, UInt, SRCCOPY := 0xCC0020)
   }
   
   WM_PAINT(wp, lp, msg, hwnd)  {
      if (this.hParent = hwnd)   {
         timer := ObjBindMethod(this, "BitBlt", this.hDC, this.hMDC)
         SetTimer, % timer, -10
      }
   }
   
   class Brush
   {
      __New(hDC, pattern)  {
         if DllCall("GetObject", Ptr, pattern, Int, 0, Ptr, 0)
            this.hBrush := DllCall("CreatePatternBrush", Ptr, pattern, Ptr)
         else
            this.hBrush := DllCall("CreateSolidBrush", UInt, DllCall("Ws2_32\ntohl", UInt, pattern << 8, UInt), Ptr)
         this.oBR := DllCall("SelectObject", Ptr, hDC, Ptr, this.hBrush, Ptr)
      }
      
      __Delete()  {
         DllCall("SelectObject", Ptr, hDC, Ptr, this.oBR, Ptr)
         DllCall("DeleteObject", Ptr, this.hBrush)
      }
   }
   
   class CompatibleDC
   {
      __New(hDC, w, h)  {
         this.hCDC := DllCall("CreateCompatibleDC", Ptr, hDC, Ptr)
         this.hCBM := DllCall("CreateCompatibleBitmap", Ptr, hDC, Int, w, Int, h, Ptr)
         this.oBM := DllCall("SelectObject", Ptr, this.hCDC, Ptr, this.hCBM, Ptr)
      }
      
      __Delete()  {
         DllCall("SelectObject", Ptr, this.hCDC, Ptr, this.oBM, Ptr)
         DllCall("DeleteDC", Ptr, this.hCDC)
         DllCall("DeleteObject", Ptr, this.hCBM)
      }
   }
}
Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

78

Re: AHK: Экранная лупа

Интересно как с текстом, хочется типа водяных знаков, наклонный полупрозрачный текст (желательно с тенью) на непрозрачном фоне.

По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

79

Re: AHK: Экранная лупа

serzh82saratov пишет:

Так текстом, только не пойму как задать свой фон.

Для текста фон задаётся через SetBkColor.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

80

Re: AHK: Экранная лупа

Не получается.

Gdip_TextToGraphics(G2, "Tutorial", Options, Font, WidthText, HeightText)
DllCall("SetBkColor", Ptr, hdc2, UInt, 0xffffff)
По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

81

Re: AHK: Экранная лупа

В G2 просто залей фон прямоугольником перед добавлением текста.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

82

Re: AHK: Экранная лупа

Так? А черный фон как убрать, как сделать прозрачным на что текстура накладывается?


#SingleInstance, Force
#NoEnv
SetBatchLines, -1
OnMessage(0x201, "WM_LBUTTONDOWN")

If !pToken := Gdip_Startup()
{
	MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
	ExitApp
}
OnExit, Exit

Width := 1600, Height := 1000

Gui, 1: -Caption +E0x80000 +hwndhwnd +AlwaysOnTop +ToolWindow +OwnDialogs  
Gui, 1: Show, NA

hbm := CreateDIBSection(Width, Height) 
hdc := CreateCompatibleDC() 
obm := SelectObject(hdc, hbm)

G := Gdip_GraphicsFromHDC(hdc) 
Gdip_SetSmoothingMode(G, 4) 

  ;	Пытаюсь сделать общий фон
  
; pBrush2 := Gdip_BrushCreateSolid(0xaa004400)
; Gdip_FillRoundedRectangle(G, pBrush2, 0, 0, Width, Height, 0)
; Gdip_DeleteBrush(pBrush2)

Font = Arial

If !Gdip_FontFamilyCreate(Font)
{
   MsgBox, 48, Font error!, The font you have specified does not exist on the system
   ExitApp
}

WidthText := 100, HeightText := 25
Options = x0p y0p w%WidthText%p h%HeightText%p Centre cffffffff r4 s20 Italic 

hbm2 := CreateDIBSection(WidthText, HeightText) 
hdc2 := CreateCompatibleDC() 
obm2 := SelectObject(hdc2, hbm2) 
G2 := Gdip_GraphicsFromHDC(hdc2) 

pBrush := Gdip_BrushCreateSolid(0x55198F00)
Gdip_FillRectangle(G2, pBrush, 0, 0, WidthText, HeightText)
Gdip_DeleteBrush(pBrush)
Gdip_SetSmoothingMode(G2, 4) 

Gdip_TextToGraphics(G2, "Tutorial", Options, Font, WidthText, HeightText)
 
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "UPtr", hbm2, "UPtr", 0, "UPtr*", pBitmap)
SelectObject(hdc2, obm2)
DeleteObject(hbm2) 
DeleteDC(hdc2) 
Gdip_DeleteGraphics(G2)

pBrush := Gdip_CreateTextureBrush(pBitmap, 0)

Gdip_FillRectangle(G, pBrush, 0, 0, Width, Height)

Gdip_DeleteBrush(pBrush)

UpdateLayeredWindow(hwnd, hdc, 20, 20, Width, Height)

SelectObject(hdc, obm)

DeleteObject(hbm)

DeleteDC(hdc)

Gdip_DeleteGraphics(G)
Return

Exit: 
	Gdip_Shutdown(pToken)
	ExitApp 
	
Escape:: ExitApp

WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) { 
		PostMessage, 0xA1, 2 
}
По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

83 (изменено: serzh82saratov, 2018-01-10 21:07:32)

Re: AHK: Экранная лупа

Получается нужен не фон текста, то есть как раз текст без фона надо, а нужен фон окна прозрачный или полупрозрачный с заданным цветом. Сейчас он просто чёрный.
Также как если в 76 1 пример использовать иконку с прозрачностью.

По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

84

Re: AHK: Экранная лупа

Похоже, эта кисть прозрачный фон не поддерживает.


#SingleInstance, Force
#NoEnv
SetBatchLines, -1
OnMessage(0x201, "WM_LBUTTONDOWN")

If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}
OnExit, Exit

Width := 1600, Height := 1000

Gui, 1: -Caption +E0x80000 +hwndhwnd +AlwaysOnTop +ToolWindow +OwnDialogs  
Gui, 1: Show, NA

hbm := CreateDIBSection(Width, Height) 
hdc := CreateCompatibleDC() 
obm := SelectObject(hdc, hbm)

G := Gdip_GraphicsFromHDC(hdc) 
Gdip_SetSmoothingMode(G, 4) 

  ;   Пытаюсь сделать общий фон
  
; pBrush2 := Gdip_BrushCreateSolid(0xaa004400)
; Gdip_FillRoundedRectangle(G, pBrush2, 0, 0, Width, Height, 0)
; Gdip_DeleteBrush(pBrush2)

Font = Arial

If !Gdip_FontFamilyCreate(Font)
{
   MsgBox, 48, Font error!, The font you have specified does not exist on the system
   ExitApp
}

WidthText := 100, HeightText := 25
Options = x0p y0p w%WidthText%p h%HeightText%p Centre cffffffff r4 s20 Italic 

hbm2 := CreateDIBSection(WidthText, HeightText) 
hdc2 := CreateCompatibleDC() 
obm2 := SelectObject(hdc2, hbm2) 
G2 := Gdip_GraphicsFromHDC(hdc2) 

pBrush := Gdip_BrushCreateSolid(0xFF198F00)
Gdip_FillRectangle(G2, pBrush, 0, 0, WidthText, HeightText)
Gdip_DeleteBrush(pBrush)
Gdip_SetSmoothingMode(G2, 4) 

Gdip_TextToGraphics(G2, "Tutorial", Options, Font, WidthText, HeightText)
 
DllCall("gdiplus\GdipCreateBitmapFromHBITMAP", "UPtr", hbm2, "UPtr", 0, "UPtr*", pBitmap)
SelectObject(hdc2, obm2)
DeleteObject(hbm2) 
DeleteDC(hdc2) 
Gdip_DeleteGraphics(G2)

pBrush := Gdip_CreateTextureBrush(pBitmap, 0)

Gdip_FillRectangle(G, pBrush, 0, 0, Width, Height)

Gdip_DeleteBrush(pBrush)

UpdateLayeredWindow(hwnd, hdc, 20, 20, Width, Height)

SelectObject(hdc, obm)

DeleteObject(hbm)

DeleteDC(hdc)

Gdip_DeleteGraphics(G)
Return

Exit: 
   Gdip_Shutdown(pToken)
   ExitApp 
   
Escape:: ExitApp

WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) { 
      PostMessage, 0xA1, 2 
}
Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

85

Re: AHK: Экранная лупа

Так у иконок же прозрачность выодит.

По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

86

Re: AHK: Экранная лупа

Да, точно. Наверно, нужны ещё какие-то пляски с бубном, чтобы получить bitmap из graphics с прозрачностью.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

87

Re: AHK: Экранная лупа

Пример из библиотеки не поможет? Текст непрозрачен.


; gdi+ ahk tutorial 8 written by tic (Tariq Porter)
; Requires Gdip.ahk either in your Lib folder as standard library or using #Include
;
; Tutorial to write text onto a gui

#SingleInstance, Force
#NoEnv
SetBatchLines, -1

; Uncomment if Gdip.ahk is not in your standard library
;#Include, Gdip.ahk

; Start gdi+
If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}
OnExit, Exit

; Set the width and height we want as our drawing area, to draw everything in. This will be the dimensions of our bitmap
Width := 300, Height := 200

; Create a layered window (+E0x80000 : must be used for UpdateLayeredWindow to work!) that is always on top (+AlwaysOnTop), has no taskbar entry or caption
Gui, 1: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs

; Show the window
Gui, 1: Show, NA

; Get a handle to this window we have created in order to update it later
hwnd1 := WinExist()

; 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
hbm := CreateDIBSection(Width, Height)

; Get a device context compatible with the screen
hdc := CreateCompatibleDC()

; Select the bitmap into the device context
obm := SelectObject(hdc, hbm)

; Get a pointer to the graphics of the bitmap, for use with drawing functions
G := Gdip_GraphicsFromHDC(hdc)

; Set the smoothing mode to antialias = 4 to make shapes appear smother (only used for vector drawing and filling)
Gdip_SetSmoothingMode(G, 4)

; Create a partially transparent, black brush (ARGB = Transparency, red, green, blue) to draw a rounded rectangle with
pBrush := Gdip_BrushCreateSolid(0x11004400)

; Fill the graphics of the bitmap with a rounded rectangle using the brush created
; Filling the entire graphics - from coordinates (0, 0) the entire width and height
; The last parameter (20) is the radius of the circles used for the rounded corners
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 20)

; Delete the brush as it is no longer needed and wastes memory
Gdip_DeleteBrush(pBrush)

; We can specify the font to use. Here we use Arial as most systems should have this installed
Font = Arial
; Next we can check that the user actually has the font that we wish them to use
; If they do not then we can do something about it. I choose to give a wraning and exit!
If !Gdip_FontFamilyCreate(Font)
{
   MsgBox, 48, Font error!, The font you have specified does not exist on the system
   ExitApp
}

; There are a lot of things to cover with the function Gdip_TextToGraphics

; The 1st parameter is the graphics we wish to use (our canvas)

; The 2nd parameter is the text we wish to write. It can include new lines `n

; The 3rd parameter, the options are where all the action takes place...
; You can write literal x and y coordinates such as x20 y50 which would place the text at that position in pixels
; or you can include the last 2 parameters (Width and Height of the Graphics we will use) and then you can use x10p
; which will place the text at 10% of the width and y30p which is 30% of the height
; The same percentage marker may be used for width and height also, so w80p makes the bounding box of the rectangle the text
; will be written to 80% of the width of the graphics. If either is missed (as I have missed height) then the height of the bounding
; box will be made to be the height of the graphics, so 100%

; Any of the following words may be used also: Regular,Bold,Italic,BoldItalic,Underline,Strikeout to perform their associated action

; To justify the text any of the following may be used: Near,Left,Centre,Center,Far,Right with different spelling of words for convenience

; The rendering hint (the quality of the antialiasing of the text) can be specified with r, whose values may be:
; SystemDefault = 0
; SingleBitPerPixelGridFit = 1
; SingleBitPerPixel = 2
; AntiAliasGridFit = 3
; AntiAlias = 4

; The size can simply be specified with s

; The colour and opacity can be specified for the text also by specifying the ARGB as demonstrated with other functions such as the brush
; So cffff0000 would make a fully opaque red brush, so it is: cARGB (the literal letter c, follwed by the ARGB)

; The 4th parameter is the name of the font you wish to use

; As mentioned previously, you don not need to specify the last 2 parameters, the width and height, unless
; you are planning on using the p option with the x,y,w,h to use the percentage
Options = x10p y30p w80p Centre cff000000 r4 s20 Underline Italic
Gdip_TextToGraphics(G, "Tutorial 8`n`nThank you for trying this example", Options, Font, Width, Height)


; 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
; With some simple maths we can place the gui in the centre of our primary monitor horizontally and vertically at the specified heigth and width
UpdateLayeredWindow(hwnd1, hdc, (A_ScreenWidth-Width)//2, (A_ScreenHeight-Height)//2, Width, Height)

; By placing this OnMessage here. The function WM_LBUTTONDOWN will be called every time the user left clicks on the gui
OnMessage(0x201, "WM_LBUTTONDOWN")


; Select the object back into the hdc
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)
Return

;#######################################################################

; This function is called every time the user clicks on the gui
; The PostMessage will act on the last found window (this being the gui that launched the subroutine, hence the last parameter not being needed)
WM_LBUTTONDOWN()
{
   PostMessage, 0xA1, 2
}

;#######################################################################

Exit:
; gdi+ may now be shutdown on exiting the program
Gdip_Shutdown(pToken)
ExitApp
Return
По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

88

Re: AHK: Экранная лупа


#SingleInstance, Force
#NoEnv
SetBatchLines, -1
OnMessage(0x201, "WM_LBUTTONDOWN")

If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}
OnExit, Exit

Width := 1600, Height := 1000

Gui, 1: -Caption +E0x80000 +hwndhwnd +AlwaysOnTop +ToolWindow +OwnDialogs  
Gui, 1: Show, NA

hbm := CreateDIBSection(Width, Height) 
hdc := CreateCompatibleDC() 
obm := SelectObject(hdc, hbm)

G := Gdip_GraphicsFromHDC(hdc) 
Gdip_SetSmoothingMode(G, 4) 

  ;   Пытаюсь сделать общий фон
  
pBrush2 := Gdip_BrushCreateSolid(0xaa004400)
Gdip_FillRoundedRectangle(G, pBrush2, 0, 0, Width, Height, 0)
Gdip_DeleteBrush(pBrush2)

Font = Arial

If !Gdip_FontFamilyCreate(Font)
{
   MsgBox, 48, Font error!, The font you have specified does not exist on the system
   ExitApp
}

WidthText := 100, HeightText := 25
Options = x0p y0p w%WidthText%p h%HeightText%p Centre cffffffff r4 s20 Italic 

pBitmap := Gdip_CreateBitmap(WidthText, HeightText) 
G2 := Gdip_GraphicsFromImage(pBitmap)
Gdip_SetSmoothingMode(G2, 4) 

Gdip_TextToGraphics(G2, "Tutorial", Options, Font, WidthText, HeightText)
 
Gdip_DeleteGraphics(G2)

pBrush := Gdip_CreateTextureBrush(pBitmap, 0)

Gdip_FillRectangle(G, pBrush, 0, 0, Width, Height)

Gdip_DeleteBrush(pBrush)

UpdateLayeredWindow(hwnd, hdc, 20, 20, Width, Height)

SelectObject(hdc, obm)

DeleteObject(hbm)

DeleteDC(hdc)

Gdip_DeleteGraphics(G)
Return

Exit: 
   Gdip_Shutdown(pToken)
   ExitApp 
   
Escape:: ExitApp

WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) { 
      PostMessage, 0xA1, 2 
}
Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

89

Re: AHK: Экранная лупа

Надо взять на заметку: Gdip_CreateBitmap() создаёт прозрачную bitmap.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

90

Re: AHK: Экранная лупа

О, супер. А как наклонить отдельно каждый текст градусов на 30, не пойму как этот метод вызвать. И про тень от текста не знаешь?

По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

91

Re: AHK: Экранная лупа

Не-а, не интересовался пока.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

92 (изменено: serzh82saratov, 2018-01-11 00:19:38)

Re: AHK: Экранная лупа

Вариант наклона всей текстуры тоже интересен.
Вышла ерунда. Координаты в Gdip_TranslateWorldTransform и размеры в Gdip_FillRectangle, путём подбора.
И правильно ли у меня задана прозрачность фону, или можно проще?


#SingleInstance, Force
#NoEnv
SetBatchLines, -1
OnMessage(0x201, "WM_LBUTTONDOWN")

If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}
OnExit, Exit

Width := 1600, Height := 1000
transmain := 88
transtext := ff

Gui, 1: -Caption +E0x80000 +hwndhwnd +AlwaysOnTop +ToolWindow +OwnDialogs  
Gui, 1: Show, NA

hbm := CreateDIBSection(Width, Height) 
hdc := CreateCompatibleDC() 
obm := SelectObject(hdc, hbm)

G := Gdip_GraphicsFromHDC(hdc) 
Gdip_SetSmoothingMode(G, 4) 
Gdip_SetInterpolationMode(G, 7)

  ;   задаю прозрачность фону
  
pBrush := Gdip_BrushCreateSolid("0x" transmain "36D107")
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 0)
Gdip_DeleteBrush(pBrush)

  ;   ^ прозрачность фону
  
Font = Arial

If !Gdip_FontFamilyCreate(Font)
{
   MsgBox, 48, Font error!, The font you have specified does not exist on the system
   ExitApp
}

WidthText := 100, HeightText := 25
Options = x0p y0p w%WidthText%p h%HeightText%p Centre c%transtext%000000 r4 s20 Italic 


Angle := -22
Gdip_RotateWorldTransform(G, Angle) 
Gdip_TranslateWorldTransform(G, -700, 0)
 

pBitmap := Gdip_CreateBitmap(WidthText, HeightText) 
G2 := Gdip_GraphicsFromImage(pBitmap)
Gdip_SetSmoothingMode(G2, 4) 

Gdip_TextToGraphics(G2, "Tutorial", Options, Font, WidthText, HeightText)
 
Gdip_DeleteGraphics(G2)

pBrush := Gdip_CreateTextureBrush(pBitmap, 0)

Gdip_FillRectangle(G, pBrush, 0, 0, Width*2, Height*2)

Gdip_DeleteBrush(pBrush)

UpdateLayeredWindow(hwnd, hdc, 20, 20, Width, Height)

SelectObject(hdc, obm)

DeleteObject(hbm)

DeleteDC(hdc)

Gdip_DeleteGraphics(G)
Return

Exit: 
   Gdip_Shutdown(pToken)
   ExitApp 
   
Escape:: ExitApp

WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) { 
      PostMessage, 0xA1, 2 
}
По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

93

Re: AHK: Экранная лупа

Вроде правильно.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

94

Re: AHK: Экранная лупа

Можешь объяснить как использовать пример, там жирным выделено.
Что за SystemBrushes?

// Draw the shadow text
   g->DrawString(textToDisplay,
                 font,
                 SystemBrushes::ControlLight,
                 x + 5, y + 5);

   // Draw the foreground text
   g->DrawString(textToDisplay, font, SystemBrushes::ControlText,
                 x, y);
}

На анк ничего не нашёл.

По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

95 (изменено: teadrinker, 2018-01-12 03:28:51)

Re: AHK: Экранная лупа

SystemBrushes — это кисти с предустановленными цветами, которые используются системой по умолчанию для отрисовки определённых элементов интерфейса. Описание класса здесь, аналог в winapi GDI — GetSysColorBrush(), на GDI+ не нашёл.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

96

Re: AHK: Экранная лупа

А на GDI я так понял пример сложно будет сделать, так как надо писать аналог Gdip_TextToGraphics.

По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).

97

Re: AHK: Экранная лупа

Здесь у меня текст добавляется без использования GDI+.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

98

Re: AHK: Экранная лупа

На GDI+ вроде так можно:
http://microsoft.public.win32.programme … colorbrush

99

Re: AHK: Экранная лупа

Только зачем? Цвет кисти можно взять любой.

Разработка AHK-скриптов:
e-mail dfiveg@mail.ru
Skype dmitry_fiveg

100

Re: AHK: Экранная лупа

Ты имеешь ввиду что в примере идёт простое наложение текстов, и с тенями (SHADOW) это никак не связано?


 
#SingleInstance, Force
#NoEnv
SetBatchLines, -1
OnMessage(0x201, "WM_LBUTTONDOWN")

If !pToken := Gdip_Startup()
{
   MsgBox, 48, gdiplus error!, Gdiplus failed to start. Please ensure you have gdiplus on your system
   ExitApp
}
OnExit, Exit

Width := 1600, Height := 1000
transmain := ff
transtext := 22

Gui, 1: -Caption +E0x80000 +hwndhwnd +AlwaysOnTop +ToolWindow +OwnDialogs  
Gui, 1: Show, NA

hbm := CreateDIBSection(Width, Height) 
hdc := CreateCompatibleDC() 
obm := SelectObject(hdc, hbm)

G := Gdip_GraphicsFromHDC(hdc) 
Gdip_SetSmoothingMode(G, 4) 
Gdip_SetInterpolationMode(G, 7)

  ;   задаю прозрачность фону
  
pBrush := Gdip_BrushCreateSolid("0xffffffff")
Gdip_FillRoundedRectangle(G, pBrush, 0, 0, Width, Height, 0)
Gdip_DeleteBrush(pBrush)

  ;   ^ прозрачность фону
  
Font = Arial

If !Gdip_FontFamilyCreate(Font)
{
   MsgBox, 48, Font error!, The font you have specified does not exist on the system
   ExitApp
}

WidthText := 250, HeightText := 85


Angle := -22
Gdip_RotateWorldTransform(G, Angle) 
Gdip_TranslateWorldTransform(G, -700, 0)
 

pBitmap := Gdip_CreateBitmap(WidthText, HeightText) 
G2 := Gdip_GraphicsFromImage(pBitmap)
Gdip_SetSmoothingMode(G2, 4)  


Text = Tutorial
Options = x2p y8p w%WidthText%p h%HeightText%p  c22888888 r4 s40 Italic 
Gdip_TextToGraphics(G2, Text, Options, Font, WidthText, HeightText)

Options = x0p y0p w%WidthText%p h%HeightText%p  c44000000 r4 s40 Italic 
Gdip_TextToGraphics(G2, Text, Options, Font, WidthText, HeightText)
 
Gdip_DeleteGraphics(G2)

pBrush := Gdip_CreateTextureBrush(pBitmap, 0)

Gdip_FillRectangle(G, pBrush, 0, 0, Width*2, Height*2)

Gdip_DeleteBrush(pBrush)

UpdateLayeredWindow(hwnd, hdc, 20, 20, Width, Height)

SelectObject(hdc, obm)

DeleteObject(hbm)

DeleteDC(hdc)

Gdip_DeleteGraphics(G)
Return

Exit: 
   Gdip_Shutdown(pToken)
   ExitApp 
   
Escape:: ExitApp

WM_LBUTTONDOWN(wParam, lParam, msg, hwnd) { 
      PostMessage, 0xA1, 2 
} 
По вопросам возмездной помощи пишите письма
E-Mail: serzh82saratov@mail.ru
OS: Win7x64, AutoHotkey_L v1.1.27.03 (Unicode 32-bit).