[RESOLVED] SetParent vs. ExtFloodFill
Here's the current arrangement of my form: I have a form (Form1) with a frame (Fra1) on it. I'm using SetParent to insert a second form (Form2) into the frame.
Form1 > Fra1 >Form2
Now, I call TransparentBlt to transfer an image onto Form2. When I want to use ExtFloodFill to fill in a region of that picture, the function executes, returns TRUE, and I call Form2.Refresh, but no colors are updated on the screen. However, if I start Form2 by itself and try the TransparentBlt > ExtFloodFill > Form2.Refresh, everything works as expected.
Would there be a reason the setting the parent of the form is affecting the way it is colored/APIs affect it? If so, what are some possible solutions to this issue?
From Form2:
VB Code:
Private Sub Form_Load()
Dim hBitmap As Long
Dim hdc As Long
Dim hFraDc As Long
' Preparing the image
hdc = CreateCompatibleDC(GetDC(0))
hBitmap = LoadImage(App.hInstance, App.Path & "\Images\test01.bmp", IMAGE_BITMAP, 300, 200, LR_LOADFROMFILE)
SelectObject hdc, hBitmap
TransparentBlt Me.hdc, 10, 30, 300, 200, hdc, 0, 0, 300, 200, vbWhite
Me.Refresh
DeleteObject hBitmap
mBrush = CreateSolidBrush(crNewColor)
SelectObject Me.hdc, mBrush
Me.ScaleMode = vbPixels
' Showing in Frame, Don't need Me.Show
'Me.Show
End Sub
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Floodfill...
ExtFloodFill Me.hdc, X, Y, GetPixel(Me.hdc, X, Y), FLOODFILLSURFACE
Me.Refresh
End Sub
Private Sub Form_Unload(Cancel As Integer)
DeleteObject mBrush
End Sub
Re: SetParent vs. ExtFloodFill
Re: SetParent vs. ExtFloodFill
perhaps attach a small example project demonstrating what's happening (to save people having to crack open their API viewer)
1 Attachment(s)
Re: SetParent vs. ExtFloodFill
Quote:
Originally Posted by bushmobile
perhaps attach a small example project demonstrating what's happening (to save people having to crack open their API viewer)
Of what the Bushmobile asks, I deliver. :cool:
If you start the program using Form 2, you'll see what kind of results I've been expecting. If you start the program using Form 1, then you'll see what I'm getting.
1 Attachment(s)
Re: SetParent vs. ExtFloodFill
Try the attached, basically I set the form to be a child form, and get rid of the Form2.WindowState = vbMaximized.
Re: SetParent vs. ExtFloodFill
Quote:
Originally Posted by tward_biteme1
Try the attached, basically I set the form to be a child form, and get rid of the Form2.WindowState = vbMaximized.
It doesn't give me the appearance I want, but it gives me the functionality I want. I think I understand why setting Form 2 to be a child form helped, but why would Form2.WindowState affect it?
Re: SetParent vs. ExtFloodFill
Not sure about the WindowState. I figured that the Child thing alone would fix it, when I didn't I commented out the resize and then it worked just fine.
You should be able to size the form to fit your needs though...
Re: SetParent vs. ExtFloodFill
Quote:
Originally Posted by tward_biteme1
Not sure about the WindowState. I figured that the Child thing alone would fix it, when I didn't I commented out the resize and then it worked just fine.
You should be able to size the form to fit your needs though...
You're right. I can resize it. It just gives the Frame/Form a 3D frame that I would prefer hiding or a flat frame, but I'm being a sticker for that part.
Strange about the WindowState... :confused:
[Edit]
You can put the Form2.WindowState = vbMaximized after the Form2.Show call and it will work, but you can't do it before that call.
[Edit2]
*blarg* Of course, I could just remove Form2.BorderStyle to give me the graphical representation I need... :blush:
Re: [RESOLVED] SetParent vs. ExtFloodFill
Was going to suggest [Edit2]!!
Re: [RESOLVED] SetParent vs. ExtFloodFill
Quote:
Originally Posted by tward_biteme1
Was going to suggest [Edit2]!!
And beat you to it!! :p
(In quasi-TGIF mode ATM)