Results 1 to 10 of 10

Thread: [RESOLVED] SetParent vs. ExtFloodFill

  1. #1

    Thread Starter
    Hyperactive Member Fedhax's Avatar
    Join Date
    Aug 2006
    Posts
    293

    Resolved [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:
    1. Private Sub Form_Load()
    2.    
    3.     Dim hBitmap         As Long
    4.     Dim hdc             As Long
    5.     Dim hFraDc          As Long
    6.    
    7.     ' Preparing the image
    8.     hdc = CreateCompatibleDC(GetDC(0))
    9.    
    10.     hBitmap = LoadImage(App.hInstance, App.Path & "\Images\test01.bmp", IMAGE_BITMAP, 300, 200, LR_LOADFROMFILE)
    11.     SelectObject hdc, hBitmap
    12.     TransparentBlt Me.hdc, 10, 30, 300, 200, hdc, 0, 0, 300, 200, vbWhite
    13.    
    14.     Me.Refresh
    15.     DeleteObject hBitmap
    16.    
    17.     mBrush = CreateSolidBrush(crNewColor)
    18.     SelectObject Me.hdc, mBrush
    19.     Me.ScaleMode = vbPixels
    20.    
    21.     ' Showing in Frame, Don't need Me.Show
    22.     'Me.Show
    23.  
    24. End Sub
    25.  
    26. Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    27.     'Floodfill...
    28.     ExtFloodFill Me.hdc, X, Y, GetPixel(Me.hdc, X, Y), FLOODFILLSURFACE
    29.     Me.Refresh
    30. End Sub
    31.  
    32. Private Sub Form_Unload(Cancel As Integer)
    33.     DeleteObject mBrush
    34. End Sub

  2. #2

    Thread Starter
    Hyperactive Member Fedhax's Avatar
    Join Date
    Aug 2006
    Posts
    293

    Re: SetParent vs. ExtFloodFill

    *bump*

  3. #3
    Oi, fat-rag! bushmobile's Avatar
    Join Date
    Mar 2004
    Location
    on the poop deck
    Posts
    5,592

    Re: SetParent vs. ExtFloodFill

    perhaps attach a small example project demonstrating what's happening (to save people having to crack open their API viewer)

  4. #4

    Thread Starter
    Hyperactive Member Fedhax's Avatar
    Join Date
    Aug 2006
    Posts
    293

    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.

    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.
    Attached Files Attached Files

  5. #5
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    342

    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.
    Attached Files Attached Files

  6. #6

    Thread Starter
    Hyperactive Member Fedhax's Avatar
    Join Date
    Aug 2006
    Posts
    293

    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?

  7. #7
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    342

    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...

  8. #8

    Thread Starter
    Hyperactive Member Fedhax's Avatar
    Join Date
    Aug 2006
    Posts
    293

    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...

    [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...
    Last edited by Fedhax; Sep 22nd, 2006 at 12:36 PM. Reason: Additional Information

  9. #9
    Hyperactive Member
    Join Date
    Apr 2004
    Posts
    342

    Re: [RESOLVED] SetParent vs. ExtFloodFill

    Was going to suggest [Edit2]!!

  10. #10

    Thread Starter
    Hyperactive Member Fedhax's Avatar
    Join Date
    Aug 2006
    Posts
    293

    Re: [RESOLVED] SetParent vs. ExtFloodFill

    Quote Originally Posted by tward_biteme1
    Was going to suggest [Edit2]!!
    And beat you to it!!

    (In quasi-TGIF mode ATM)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width