I'm using a PictureBox in my GUI. When other windows covers the GUI, something will happen as the pictures showing below.
I remember I saw some threads in the forum long time ago, but I cannot find them. It looks related with "Redraw". Can someone help? Please!
Redraw problem
- oldbrother
- Posts: 273
- Joined: 23 Oct 2013, 05:08
Re: Redraw problem
GuiControl might help. I have not tried it.
Re: Redraw problem
seems like a shoddily implemented windowproc for the picture control
without seeing the code, no further statements can be made
without seeing the code, no further statements can be made
- oldbrother
- Posts: 273
- Joined: 23 Oct 2013, 05:08
Re: Redraw problem
The problem is related with GDI. same as PhiLho described here: https://autohotkey.com/board/topic/11620-tips-drawing-on-autohotkey-gui-with-gdi32/
My code was written long time ago. I used GDI drawing code modified form a code similar to PhiLho's.
My code was written long time ago. I used GDI drawing code modified form a code similar to PhiLho's.
Code: Select all
WinGet,hGuiWnd,id, A
hGuiWnd := WinExist()
hGuiDC := DllCall("GetDC", "UInt", hGuiWnd)
Code: Select all
writeText(textString,textLen,x,y)
{
global hGuiDC
DPIScale(x,y)
DllCall("TextOut","uint",hGuiDC,"int",x,"int",y,"str",textString,"int",textLen)
}
Line(x1,y1,x2,y2,myColor,lineWidth)
{
global hGuiDC
DPIScale(x1,y1,x2,y2,lineWidth)
hCurrPen := DllCall("CreatePen", "UInt", PS_SOLID, "UInt", lineWidth, "UInt", myColor)
hOldPen := DllCall("SelectObject", "UInt", hGuiDC, "UInt", hPen)
DllCall("SelectObject" ,"UInt",hGuiDC,"UInt",hCurrPen)
DllCall("MoveToEx" ,"UInt",hGuiDC, "UInt",x1,"UInt",y1,"UInt",0)
DllCall("LineTo" ,"UInt",hGuiDC,"UInt",x2,"UInt",y2)
DllCall("SelectObject", "UInt", hGuiDC, "UInt", hOldPen)
DllCall("DeleteObject", "UInt", hCurrPen)
}
rect(x1,y1,x2,y2,framColor,FillColor,BorderWidth)
{
global hGuiDC
DPIScale(x1,y1,x2,y2,BorderWidth)
hPen := DllCall("CreatePen", "UInt", PS_SOLID, "UInt", BorderWidth, "UInt", framColor)
hBrush := DllCall("CreateSolidBrush", "UInt", FillColor)
hOldPen := DllCall("SelectObject", "UInt", hGuiDC, "UInt", hPen)
hOldBrush := DllCall("SelectObject", "UInt", hGuiDC, "UInt", hBrush)
; x, y for top-left, x, y for bottom-right
DllCall("Rectangle", "UInt", hGuiDC, "UInt", x1, "UInt", y1, "UInt", x2, "UInt", y2)
DllCall("SelectObject", "UInt", hGuiDC, "UInt", hOldPen)
DllCall("SelectObject", "UInt", hGuiDC, "UInt", hOldBrush)
DllCall("DeleteObject", "UInt", hPen)
DllCall("DeleteObject", "UInt", hBrush)
}
Last edited by oldbrother on 04 Oct 2020, 21:50, edited 2 times in total.
Re: Redraw problem
very cool, looks like the cross section of a four flute endmill, grinder toolpaths maybe? As someone who only uses endmills and doesn't create them that looks very intriguing
anyway, instead of manually handling the redrawing with gdi directly to the window each needed, I would recommend creating a gui, picture control and draw to a bitmap, then sendmessage the gdi picture data to the control... i've only used gdi+ but i think its the same with pure gdi
anyway, instead of manually handling the redrawing with gdi directly to the window each needed, I would recommend creating a gui, picture control and draw to a bitmap, then sendmessage the gdi picture data to the control... i've only used gdi+ but i think its the same with pure gdi
Code: Select all
SendMessage, 0x172, 0x0, hBitmap,, ahk_id %hPicture%
EitherMouse - Multiple mice, individual settings . . . . www.EitherMouse.com . . . . forum . . . .
- oldbrother
- Posts: 273
- Joined: 23 Oct 2013, 05:08
Re: Redraw problem
Thank you!
You are right. The script is for end mill fluting simulation. It works fine. But my coding is a mess
Re: Redraw problem
there isnt a problem with GDI. the problem stems from the fact that for whatever reason u have opted to circumvent window's standard mechanism for painting win32 apps and have decided to externally draw onto the gui's(why??) DC
there is a proper way of achieving what u need to achieve and none of the techniques in this thread uve linked are it
what u need to do is subclass the picture control, replacing its windowproc with a custom one of ur own https://docs.microsoft.com/en-us/windows/win32/controls/subclassing-overview
of course this may be a total overkill for what u need to do, so if all that is required is to display simply display a non-interactive image without exhibiting said "bug", id stick to @gwarble's advice
there is a proper way of achieving what u need to achieve and none of the techniques in this thread uve linked are it
what u need to do is subclass the picture control, replacing its windowproc with a custom one of ur own https://docs.microsoft.com/en-us/windows/win32/controls/subclassing-overview
of course this may be a total overkill for what u need to do, so if all that is required is to display simply display a non-interactive image without exhibiting said "bug", id stick to @gwarble's advice
Who is online
Users browsing this forum: Assquatch23 and 341 guests