Hello,
The issue is related to Windows GDI, actually about repainting "framed" regions (HRGN framed with "FrameRgn" function)
I'm making application using BCB including VCL library. I put TImage component/object on an empty form and loaded proper bitmap image to Picture property of that image.
Then i wrote form's method that paints a frame around 'img':
Wanting always to have frame around my image, i am calling this method in OnPaint event.
When OnPaint event occurs everything is repainted fine, except in one situation. When my forms window is not top most (i drag some other opened window above it - like windows explorer), those region frame around image is being redrawed on top of the foreground window. I understand that it is normal because of the nature of an OnPaint event, but don't know the way to avoid this situation.
I mean, how to disable that repainting regions frame on top of foreground window - window that's not my applications window?
Appreciate any help or advice.
The issue is related to Windows GDI, actually about repainting "framed" regions (HRGN framed with "FrameRgn" function)
I'm making application using BCB including VCL library. I put TImage component/object on an empty form and loaded proper bitmap image to Picture property of that image.
Then i wrote form's method that paints a frame around 'img':
Code:
void __fastcall drawFrame()
{
rgb = 0x00ffeeff; // light gray RGB color code
// creating region on image area, 26 is width of caption in pixels
// frame will be 4 pixels width around image
rgn = CreateRoundRectRgn(form->Left + img1->Left + 2,
form->Top + 26 + img1->Top + 2,
form->Left + img1->Left + img1->Width + 11,
form->Top + 26 + img1->Top + img1->Height + 11,
4 , 4);
hdc = GetDC(hWnd);
brush = CreateSolidBrush(rgb);
FrameRgn(hdc, rgn, brush, 4, 4);
ReleaseDC(hWnd,hdc);
DeleteObject(rgn);
}
Code:
void __fastcall TfrmMainForm::FormPaint(TObject *Sender)
{
drawFrame();
}
I mean, how to disable that repainting regions frame on top of foreground window - window that's not my applications window?
Appreciate any help or advice.