Post by Renz » 10 Mar 2018, 09:23
nnnik wrote:Oh ich habs vergessen zu sagen aber was ich meinte ist in der linken, oberen Ecke der GUI.
Bei der RECT Struktur reicht es eignetlich, wenn du dir anschaust was in MSDN darüber steht.
Wenn du das nicht machst läufst du Gefahr, dass deine Ränder sich z.B. um ein Pixel verschieben und du nicht weißt wieso.
Vielen Dank, das werde ich berücksichtigen, lese mich da gleich rein
Ich habe eine Frage zur Anordnung der Gui´s,
Wie kann ich es am besten lösen, das die Gui´s eine feste Reihenfolge haben?
Hier ein Test Skript was mein Problem darstellt...
Code: Select all
#Persistent
#SingleInstance force
#include gdip_New.ahk
#NoEnv
global GUICOUNT:=1
global _GUISTRUCT:= Object()
global DEFAULTBUTTONHANDLE := "BTN_Handle"
BTN_POS := {X:25,Y:25,W:55,H:35,Size: 16}
o := new Main.GDICLASS(GDIP_Startup(),DEFAULTBUTTONHANDLE)
Box1 := o.CreateBox(15,15,250,250,0xDD000000,[True,5,0xFFD4FFFF])
Str1 := o.DrawStringEx("HIER KLICKEN","Arial",25,"FFFFFFFFF",30,70,200,30,"Centre vCentre")
BTN1 := o.CreateButton(BTN_POS.X,BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Solo",0xFF000000,[True,"Solo","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
BTN2 := o.CreateButton((BTN_POS.X:=BTN_POS.X + (BTN_POS.W+3)),BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Duo",0xFF000000,[True,"Duo","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
BTN3 := o.CreateButton((BTN_POS.X:=BTN_POS.X + (BTN_POS.W+3)),BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Trio",0xFF000000,[True,"Trio","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
BTN4 := o.CreateButton((BTN_POS.X:=BTN_POS.X + (BTN_POS.W+3)),BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Squad",0xFF000000,[True,"Squad","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
return
class Main
{
static _ERROR := False
,GDITOKEN
class GDICLASS
{
static HWND,HDC,HBM,OBM,GRAPH,PEN,BRUSH,_tmpSTRUCTID
__New(pToken) {
Main._ERROR := False
Main.GDITOKEN := pToken
if(!Main.GDITOKEN){
return this.SetLastError("Error in __New(" Main.GDITOKEN ") -> GDIP StartUp Failed")
}
}
CreateBoxOutline(BoxX,BoxY,BoxW,BoxH,pSize:=5,pColor:=0xFF000000)
{
if(!Main.GDITOKEN)
Main.GDITOKEN := Gdip_Startup()
g_ID := this.HandleGUIID("INC")
Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %g_ID%: Show, % "w" BoxW " h" BoxH " y" BoxY " x" BoxX ""
this.HWND := WinExist()
this.HDC := CreateCompatibleDC()
this.HBM := CreateDIBSection(BoxW,BoxH, this.HDC ,32)
this.OBM := SelectObject(this.HDC, this.HBM)
this.GRAPH := Gdip_GraphicsFromHDC(this.HDC)
this.PEN := Gdip_CreatePen(pColor,pSize)
Gdip_DrawRectangle(this.GRAPH,this.PEN,0,0,BoxW,BoxH)
if(UpdateLayeredWindow(this.HWND,this.HDC) != 0)
return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,-1, this.PEN,BoxX,BoxY,BoxW,BoxH,"TYP_BORDERONLY")
return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
}
CreateBox(BoxX,BoxY,BoxW,BoxH,pColor:=0xAA000000,pBorder:="")
{
if(!Main.GDITOKEN)
Main.GDITOKEN := Gdip_Startup()
g_ID := this.HandleGUIID("INC")
Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %g_ID%: Show, % "x" BoxX " y" BoxY " w" BoxW " h" BoxH
this.HWND := WinExist()
this.HDC := CreateCompatibleDC()
this.HBM := CreateDIBSection(BoxW,BoxH, this.HDC ,32)
this.OBM := SelectObject(this.HDC, this.HBM)
this.GRAPH := Gdip_GraphicsFromHDC(this.HDC)
this.BRUSH := Gdip_BrushCreateSolid(pColor)
pBorder[1] == True ? this.PEN:=Gdip_CreatePen((pBorder[3] <> "" ? pBorder[3] : 0xFF000000), (pBorder[2] <= 1 || pBorder[2] < 0 ? 2 : pBorder[2])) : ""
Gdip_FillRectangle(this.GRAPH, this.BRUSH,0,0,BoxW,BoxH)
IsObject(pBorder) && pBorder[1] == True ? Gdip_DrawRectangle(this.GRAPH,this.PEN,0,0,BoxW,BoxH) : ""
if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
bID:=this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,this.BRUSH, this.PEN,BoxX,BoxY,BoxW,BoxH,"TYP_FILLEDBOX")
return bID
}
return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
}
CreateEditBox(BoxX,BoxY,BoxW,BoxH,pText,pColor:=0xAA000000,pBorderColor:=0xFFFFFFFF)
{
if(!Main.GDITOKEN)
Main.GDITOKEN := Gdip_Startup()
g_ID := this.HandleGUIID("INC")
Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %g_ID%: Show, % "x" BoxX " y" BoxY " w" BoxW " h" BoxH
this.HWND := WinExist()
this.HDC := CreateCompatibleDC()
this.HBM := CreateDIBSection(BoxW,BoxH, this.HDC ,32)
this.OBM := SelectObject(this.HDC, this.HBM)
this.GRAPH := Gdip_GraphicsFromHDC(this.HDC)
this.BRUSH := Gdip_BrushCreateSolid(pColor)
Gdip_FillRectangle(this.GRAPH, this.BRUSH,0,0,BoxW,BoxH)
if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
bID:=this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,this.BRUSH, -1,BoxX,BoxY,BoxW,BoxH,"TYP_FILLEDBOX")
If(IsObject(pBorder) && pBorder[1] == True)
this.CreateBoxOutline(BoxX,BoxY,BoxW,BoxH,pBorder[2],pBorder[3])
return bID
}
return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
}
;############################################################################################################
;BorderArray := [State,Size,Color] on Todo!
;TextArray := [State,Text,Font,Size,Pos,Color] - Done
CreateButton(pX,pY,pW,pH,pButtonName,pColor:=0xAA000000,TextArr:="")
{
Default_Values_Text := [False,"Button",Arial,10,"vCentre",0xAA000000]
if(!TextArr)
{
for _i,_v in Default_Values_Text
{
TextArr[_i] <> "" ? continue : TextArr[_i] := _v
}
this.SetLastError("Handling Error: The Text Array Parameter in the Func: " A_ThisFunc " has been setted to Default.`nParams: PosX, PosY, PosW, PosH, TextArray[State,Text,Font,Size,Pos,Color]")
}
if(!Main.GDITOKEN)
Main.GDITOKEN := Gdip_Startup()
if(!pButtonName)
return this.SetLastError("Handling Error: Insert a Label in Function: " A_ThisFunc "`nParams: PosX, PosY, PosW, PosH, Label (for response), ButtonColor, TextArray(Text,Font,Size,Color),BorderArray(UseBorder, Heigth, Color)")
g_ID := this.HandleGUIID("INC")
Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %g_ID%: add, button, w%pW% h%pH% hwndhBTN
_F := Func(DEFAULTBUTTONHANDLE).Bind(pButtonName,(TextArr[2] <> "" ? TextArr[2] : "NONE"))
GuiControl +g, % hBTN, % _F
Gui %g_ID%: Show, % "x" pX " y" pY " w" pW " h" pH
this.HWND := WinExist()
this.HDC := CreateCompatibleDC()
this.HBM := CreateDIBSection(pW,pH, this.HDC ,32)
this.OBM := SelectObject(this.HDC, this.HBM)
this.GRAPH := Gdip_GraphicsFromHDC(this.HDC)
this.BRUSH := Gdip_BrushCreateSolid(pColor)
Gdip_FillRectangle(this.GRAPH, this.BRUSH,0,0,pW,pH)
TextArr[1] ? Gdip_TextToGraphics(this.GRAPH, TextArr[2], "c" (instr(TextArr[6],"0x") ? StrReplace(TextArr[6],"0x","") : TextArr[6]) " s" TextArr[4] " " TextArr[5], TextArr[3], pW,pH) :
if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,this.BRUSH, -1,pX,pY,pW,pH,"TYP_BUTTON")
}
return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc "`nParams(" ("x" pX " y" pY " w" pW " h" pH " g" pLabel " c" pColor) ")")
}
;############################################################################################################
DrawStringEx(pText,pFont,pSize,pColor,pX,pY,pW,pH,pPos:="vCenter")
{
if(!Main.GDITOKEN)
Main.GDITOKEN := Gdip_Startup()
g_ID := this.HandleGUIID("INC")
Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %g_ID%: Show, % "x" pX " y" pY " w" pW " h" pH
this.HWND := WinExist()
this.HDC := CreateCompatibleDC()
this.HBM := CreateDIBSection(pW,pH, this.HDC ,32)
this.OBM := SelectObject(this.HDC, this.HBM)
this.GRAPH := Gdip_GraphicsFromHDC(this.HDC)
RC := Gdip_TextToGraphics(this.GRAPH, pText, "c" pColor " s" pSize " " pPos, pFont, pW,pH)
if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,-1, -1,pX,pY,pW,pH,pSize,pColor,pFont,pPos,"TYP_STRINGEX")
}
return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
}
ADDStruct(pGraph=-1,phwnd=-1,pHDC=-1,pHBM=-1,pOBM=-1,pgID=-1,pBrush=-1,pPen=-1,_X=-1,_Y=-1,_W=-1,_H=-1,pSize=-1,pColor=-1,pFont=-1,pPos=-1,_Typ=-1)
{
this._tmpSTRUCTID := -1
if(_GUISTRUCT.MaxIndex() == ""){
_GUISTRUCT.Push([ 1 , pGraph , phwnd , pHDC , pHBM , pOBM , pBrush , pPen , pgID, _X , _Y , _W , _H , pSize , pColor , pFont , pPos , _Typ])
this._tmpSTRUCTID:= 1
return this._tmpSTRUCTID
}
Loop
{
if(_GUISTRUCT[ A_Index ][1] == "" || _GUISTRUCT[ A_Index ][1] == -1){
_GUISTRUCT.Push([ A_Index , pGraph , phwnd , pHDC , pHBM , pOBM , pBrush , pPen , pgID, _X , _Y , _W , _H , pSize , pColor , pFont , pPos , _Typ])
if(_GUISTRUCT[ A_Index ][1] != -1)
return this._tmpSTRUCTID:=A_Index
break
}
if(A_Index >= 1000)
break
}
if(this._tmpSTRUCTID != -1){
return this._tmpSTRUCTID
}else
return this.SetLastError("Fehler: Keine Freie Strukturen ID gefunden | MaxSize(" _GUISTRUCT.MaxIndex() ")")
}
RemoveID(pID)
{
While(A_Index <= _GUISTRUCT.MaxIndex())
{
if(_GUISTRUCT[ A_Index ][1] == pID)
{
if(_GUISTRUCT[ A_Index ][7] != -1)
Gdip_DeleteBrush(_GUISTRUCT[ A_Index ][7])
if(_GUISTRUCT[ A_Index ][8] != -1)
Gdip_DeletePen(_GUISTRUCT[ A_Index ][8])
SelectObject(_GUISTRUCT[ A_Index ][4], _GUISTRUCT[ A_Index ][6])
DeleteObject(_GUISTRUCT[ A_Index ][5])
DeleteDC(_GUISTRUCT[ A_Index ][4])
Gdip_DeleteGraphics(_GUISTRUCT[ A_Index ][2])
g_ID := _GUISTRUCT[ A_Index ][9]
Gui, %g_ID%: Destroy
this.HandleGUIID("DEC")
Main._ERROR := False
Loop % _GUISTRUCT[ A_Index ].MaxIndex()
_GUISTRUCT[ pID ][ A_Index ] := -1
break
}
}
return
}
GetLastError(){
if(Main._ERROR != False){
Msgbox % Main._ERROR
this.SetLastError(False)
}
return
}
SetLastError(ERRORMSG){
Main._ERROR := ERRORMSG
return
}
HandleGUIID(Typ:="INC",pVal:=0)
{
if(Typ == "INC"){
return GUICOUNT++
}else if(Typ == "DEC"){
return GUICOUNT--
}else if(Typ == "GET"){
return GUICOUNT
}else if(Typ == "SET"){
return GUICOUNT:= pVal
}
return this.SetLastError("Handling ERROR: Wrong Param setted to Func: " A_ThisFunc)
}
}
}
return
BTN_Handle(ButtonName,ButtonText)
{
Msgbox % "ButtonName: " ButtonName "`nButtonText: " ButtonText
}
return
Ich hoffe jemand hat eine Idee, bin derzeit am versuchen das ganze über GetControlFocus(?) zu lösen, aber bisher erfolglos...
[quote="nnnik"]Oh ich habs vergessen zu sagen aber was ich meinte ist in der linken, oberen Ecke der GUI.
Bei der RECT Struktur reicht es eignetlich, wenn du dir anschaust was in MSDN darüber steht.
Wenn du das nicht machst läufst du Gefahr, dass deine Ränder sich z.B. um ein Pixel verschieben und du nicht weißt wieso.[/quote]
Vielen Dank, das werde ich berücksichtigen, lese mich da gleich rein :)
Ich habe eine Frage zur Anordnung der Gui´s,
Wie kann ich es am besten lösen, das die Gui´s eine feste Reihenfolge haben?
Hier ein Test Skript was mein Problem darstellt...
[code]
#Persistent
#SingleInstance force
#include gdip_New.ahk
#NoEnv
global GUICOUNT:=1
global _GUISTRUCT:= Object()
global DEFAULTBUTTONHANDLE := "BTN_Handle"
BTN_POS := {X:25,Y:25,W:55,H:35,Size: 16}
o := new Main.GDICLASS(GDIP_Startup(),DEFAULTBUTTONHANDLE)
Box1 := o.CreateBox(15,15,250,250,0xDD000000,[True,5,0xFFD4FFFF])
Str1 := o.DrawStringEx("HIER KLICKEN","Arial",25,"FFFFFFFFF",30,70,200,30,"Centre vCentre")
BTN1 := o.CreateButton(BTN_POS.X,BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Solo",0xFF000000,[True,"Solo","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
BTN2 := o.CreateButton((BTN_POS.X:=BTN_POS.X + (BTN_POS.W+3)),BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Duo",0xFF000000,[True,"Duo","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
BTN3 := o.CreateButton((BTN_POS.X:=BTN_POS.X + (BTN_POS.W+3)),BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Trio",0xFF000000,[True,"Trio","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
BTN4 := o.CreateButton((BTN_POS.X:=BTN_POS.X + (BTN_POS.W+3)),BTN_POS.Y,BTN_POS.W,BTN_POS.H,"BTN_Squad",0xFF000000,[True,"Squad","Arial",BTN_POS.Size,"Centre vCentre",0xFFD4FFFF])
return
class Main
{
static _ERROR := False
,GDITOKEN
class GDICLASS
{
static HWND,HDC,HBM,OBM,GRAPH,PEN,BRUSH,_tmpSTRUCTID
__New(pToken) {
Main._ERROR := False
Main.GDITOKEN := pToken
if(!Main.GDITOKEN){
return this.SetLastError("Error in __New(" Main.GDITOKEN ") -> GDIP StartUp Failed")
}
}
CreateBoxOutline(BoxX,BoxY,BoxW,BoxH,pSize:=5,pColor:=0xFF000000)
{
if(!Main.GDITOKEN)
Main.GDITOKEN := Gdip_Startup()
g_ID := this.HandleGUIID("INC")
Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %g_ID%: Show, % "w" BoxW " h" BoxH " y" BoxY " x" BoxX ""
this.HWND := WinExist()
this.HDC := CreateCompatibleDC()
this.HBM := CreateDIBSection(BoxW,BoxH, this.HDC ,32)
this.OBM := SelectObject(this.HDC, this.HBM)
this.GRAPH := Gdip_GraphicsFromHDC(this.HDC)
this.PEN := Gdip_CreatePen(pColor,pSize)
Gdip_DrawRectangle(this.GRAPH,this.PEN,0,0,BoxW,BoxH)
if(UpdateLayeredWindow(this.HWND,this.HDC) != 0)
return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,-1, this.PEN,BoxX,BoxY,BoxW,BoxH,"TYP_BORDERONLY")
return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
}
CreateBox(BoxX,BoxY,BoxW,BoxH,pColor:=0xAA000000,pBorder:="")
{
if(!Main.GDITOKEN)
Main.GDITOKEN := Gdip_Startup()
g_ID := this.HandleGUIID("INC")
Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %g_ID%: Show, % "x" BoxX " y" BoxY " w" BoxW " h" BoxH
this.HWND := WinExist()
this.HDC := CreateCompatibleDC()
this.HBM := CreateDIBSection(BoxW,BoxH, this.HDC ,32)
this.OBM := SelectObject(this.HDC, this.HBM)
this.GRAPH := Gdip_GraphicsFromHDC(this.HDC)
this.BRUSH := Gdip_BrushCreateSolid(pColor)
pBorder[1] == True ? this.PEN:=Gdip_CreatePen((pBorder[3] <> "" ? pBorder[3] : 0xFF000000), (pBorder[2] <= 1 || pBorder[2] < 0 ? 2 : pBorder[2])) : ""
Gdip_FillRectangle(this.GRAPH, this.BRUSH,0,0,BoxW,BoxH)
IsObject(pBorder) && pBorder[1] == True ? Gdip_DrawRectangle(this.GRAPH,this.PEN,0,0,BoxW,BoxH) : ""
if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
bID:=this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,this.BRUSH, this.PEN,BoxX,BoxY,BoxW,BoxH,"TYP_FILLEDBOX")
return bID
}
return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
}
CreateEditBox(BoxX,BoxY,BoxW,BoxH,pText,pColor:=0xAA000000,pBorderColor:=0xFFFFFFFF)
{
if(!Main.GDITOKEN)
Main.GDITOKEN := Gdip_Startup()
g_ID := this.HandleGUIID("INC")
Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %g_ID%: Show, % "x" BoxX " y" BoxY " w" BoxW " h" BoxH
this.HWND := WinExist()
this.HDC := CreateCompatibleDC()
this.HBM := CreateDIBSection(BoxW,BoxH, this.HDC ,32)
this.OBM := SelectObject(this.HDC, this.HBM)
this.GRAPH := Gdip_GraphicsFromHDC(this.HDC)
this.BRUSH := Gdip_BrushCreateSolid(pColor)
Gdip_FillRectangle(this.GRAPH, this.BRUSH,0,0,BoxW,BoxH)
if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
bID:=this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,this.BRUSH, -1,BoxX,BoxY,BoxW,BoxH,"TYP_FILLEDBOX")
If(IsObject(pBorder) && pBorder[1] == True)
this.CreateBoxOutline(BoxX,BoxY,BoxW,BoxH,pBorder[2],pBorder[3])
return bID
}
return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
}
;############################################################################################################
;BorderArray := [State,Size,Color] on Todo!
;TextArray := [State,Text,Font,Size,Pos,Color] - Done
CreateButton(pX,pY,pW,pH,pButtonName,pColor:=0xAA000000,TextArr:="")
{
Default_Values_Text := [False,"Button",Arial,10,"vCentre",0xAA000000]
if(!TextArr)
{
for _i,_v in Default_Values_Text
{
TextArr[_i] <> "" ? continue : TextArr[_i] := _v
}
this.SetLastError("Handling Error: The Text Array Parameter in the Func: " A_ThisFunc " has been setted to Default.`nParams: PosX, PosY, PosW, PosH, TextArray[State,Text,Font,Size,Pos,Color]")
}
if(!Main.GDITOKEN)
Main.GDITOKEN := Gdip_Startup()
if(!pButtonName)
return this.SetLastError("Handling Error: Insert a Label in Function: " A_ThisFunc "`nParams: PosX, PosY, PosW, PosH, Label (for response), ButtonColor, TextArray(Text,Font,Size,Color),BorderArray(UseBorder, Heigth, Color)")
g_ID := this.HandleGUIID("INC")
Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %g_ID%: add, button, w%pW% h%pH% hwndhBTN
_F := Func(DEFAULTBUTTONHANDLE).Bind(pButtonName,(TextArr[2] <> "" ? TextArr[2] : "NONE"))
GuiControl +g, % hBTN, % _F
Gui %g_ID%: Show, % "x" pX " y" pY " w" pW " h" pH
this.HWND := WinExist()
this.HDC := CreateCompatibleDC()
this.HBM := CreateDIBSection(pW,pH, this.HDC ,32)
this.OBM := SelectObject(this.HDC, this.HBM)
this.GRAPH := Gdip_GraphicsFromHDC(this.HDC)
this.BRUSH := Gdip_BrushCreateSolid(pColor)
Gdip_FillRectangle(this.GRAPH, this.BRUSH,0,0,pW,pH)
TextArr[1] ? Gdip_TextToGraphics(this.GRAPH, TextArr[2], "c" (instr(TextArr[6],"0x") ? StrReplace(TextArr[6],"0x","") : TextArr[6]) " s" TextArr[4] " " TextArr[5], TextArr[3], pW,pH) :
if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,this.BRUSH, -1,pX,pY,pW,pH,"TYP_BUTTON")
}
return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc "`nParams(" ("x" pX " y" pY " w" pW " h" pH " g" pLabel " c" pColor) ")")
}
;############################################################################################################
DrawStringEx(pText,pFont,pSize,pColor,pX,pY,pW,pH,pPos:="vCenter")
{
if(!Main.GDITOKEN)
Main.GDITOKEN := Gdip_Startup()
g_ID := this.HandleGUIID("INC")
Gui %g_ID%: -Caption +E0x80000 +LastFound +AlwaysOnTop +ToolWindow +OwnDialogs
Gui %g_ID%: Show, % "x" pX " y" pY " w" pW " h" pH
this.HWND := WinExist()
this.HDC := CreateCompatibleDC()
this.HBM := CreateDIBSection(pW,pH, this.HDC ,32)
this.OBM := SelectObject(this.HDC, this.HBM)
this.GRAPH := Gdip_GraphicsFromHDC(this.HDC)
RC := Gdip_TextToGraphics(this.GRAPH, pText, "c" pColor " s" pSize " " pPos, pFont, pW,pH)
if(UpdateLayeredWindow(this.HWND,this.HDC) != 0){
return this.ADDStruct(this.GRAPH,this.HWND,this.HDC ,this.HBM ,this.OBM ,g_ID,-1, -1,pX,pY,pW,pH,pSize,pColor,pFont,pPos,"TYP_STRINGEX")
}
return this.SetLastError("GDIP ERROR: UpdateLayeredWindow() failed to Update the GUI in Func: " A_ThisFunc)
}
ADDStruct(pGraph=-1,phwnd=-1,pHDC=-1,pHBM=-1,pOBM=-1,pgID=-1,pBrush=-1,pPen=-1,_X=-1,_Y=-1,_W=-1,_H=-1,pSize=-1,pColor=-1,pFont=-1,pPos=-1,_Typ=-1)
{
this._tmpSTRUCTID := -1
if(_GUISTRUCT.MaxIndex() == ""){
_GUISTRUCT.Push([ 1 , pGraph , phwnd , pHDC , pHBM , pOBM , pBrush , pPen , pgID, _X , _Y , _W , _H , pSize , pColor , pFont , pPos , _Typ])
this._tmpSTRUCTID:= 1
return this._tmpSTRUCTID
}
Loop
{
if(_GUISTRUCT[ A_Index ][1] == "" || _GUISTRUCT[ A_Index ][1] == -1){
_GUISTRUCT.Push([ A_Index , pGraph , phwnd , pHDC , pHBM , pOBM , pBrush , pPen , pgID, _X , _Y , _W , _H , pSize , pColor , pFont , pPos , _Typ])
if(_GUISTRUCT[ A_Index ][1] != -1)
return this._tmpSTRUCTID:=A_Index
break
}
if(A_Index >= 1000)
break
}
if(this._tmpSTRUCTID != -1){
return this._tmpSTRUCTID
}else
return this.SetLastError("Fehler: Keine Freie Strukturen ID gefunden | MaxSize(" _GUISTRUCT.MaxIndex() ")")
}
RemoveID(pID)
{
While(A_Index <= _GUISTRUCT.MaxIndex())
{
if(_GUISTRUCT[ A_Index ][1] == pID)
{
if(_GUISTRUCT[ A_Index ][7] != -1)
Gdip_DeleteBrush(_GUISTRUCT[ A_Index ][7])
if(_GUISTRUCT[ A_Index ][8] != -1)
Gdip_DeletePen(_GUISTRUCT[ A_Index ][8])
SelectObject(_GUISTRUCT[ A_Index ][4], _GUISTRUCT[ A_Index ][6])
DeleteObject(_GUISTRUCT[ A_Index ][5])
DeleteDC(_GUISTRUCT[ A_Index ][4])
Gdip_DeleteGraphics(_GUISTRUCT[ A_Index ][2])
g_ID := _GUISTRUCT[ A_Index ][9]
Gui, %g_ID%: Destroy
this.HandleGUIID("DEC")
Main._ERROR := False
Loop % _GUISTRUCT[ A_Index ].MaxIndex()
_GUISTRUCT[ pID ][ A_Index ] := -1
break
}
}
return
}
GetLastError(){
if(Main._ERROR != False){
Msgbox % Main._ERROR
this.SetLastError(False)
}
return
}
SetLastError(ERRORMSG){
Main._ERROR := ERRORMSG
return
}
HandleGUIID(Typ:="INC",pVal:=0)
{
if(Typ == "INC"){
return GUICOUNT++
}else if(Typ == "DEC"){
return GUICOUNT--
}else if(Typ == "GET"){
return GUICOUNT
}else if(Typ == "SET"){
return GUICOUNT:= pVal
}
return this.SetLastError("Handling ERROR: Wrong Param setted to Func: " A_ThisFunc)
}
}
}
return
BTN_Handle(ButtonName,ButtonText)
{
Msgbox % "ButtonName: " ButtonName "`nButtonText: " ButtonText
}
return[/code]
Ich hoffe jemand hat eine Idee, bin derzeit am versuchen das ganze über GetControlFocus(?) zu lösen, aber bisher erfolglos...