Results 1 to 2 of 2

Thread: How to use XOR drawing in a DIB and then clear it

  1. #1

    Thread Starter
    New Member
    Join Date
    Oct 2022
    Posts
    5

    How to use XOR drawing in a DIB and then clear it

    In a revisited program I use a couple of DIBs for different purposes. Everything is ok but with 2 problems, one minor and and major.

    Major: I need to create a grid to superimpose to the current draw regardless of background colors and later to delete it leaving the original content. With the standard picturebox methods this is easily done using the DrawMode = vbNotXorPen.
    What to do with a DIB?

    I tried the GDI SetROP2 myDIB.hdc, R2_XORPEN but it raises an error like 'Invalid DLL calling convention' ??
    I never used the function; I found some info on th MSDN site (which is not very easy to understand for me) and I got this:
    Public Declare Function SetROP2 Lib "gdi32" (ByVal hdc As Long, rop2 As Long)
    Public Const R2_XORPEN = &H7
    These lines could be wrong or I did not use the call as supposed or even this is not adeguate with a DIB.
    ---
    Minor: How to get the equivalent to myPictureBox.Cls (or myPictureBox.backgroundColor=xxx) with a DIB?
    I implemented a forced solution drawing a full size rectangle with my color, using the FillRect call; it works but there is some overhead due to the brush creation, the call and the cleaning.
    Is there any other way?

    Info: VB6 SP3 on Windows 10 64bit

  2. #2
    Angel of Code Niya's Avatar
    Join Date
    Nov 2011
    Posts
    9,017

    Re: How to use XOR drawing in a DIB and then clear it

    Quote Originally Posted by Sirio View Post
    Public Declare Function SetROP2 Lib "gdi32" (ByVal hdc As Long, rop2 As Long)
    rop2 needs to be passed by value as well. You're passing by reference here which is wrong. You also need to define a return type of Long to this function:-
    Code:
    Public Declare Function SetROP2 Lib "gdi32" (ByVal hdc As Long, ByVal rop2 As Long) As Long
    The above is a corrected version that should work.
    Treeview with NodeAdded/NodesRemoved events | BlinkLabel control | Calculate Permutations | Object Enums | ComboBox with centered items | .Net Internals article(not mine) | Wizard Control | Understanding Multi-Threading | Simple file compression | Demon Arena

    Copy/move files using Windows Shell | I'm not wanted

    C++ programmers will dismiss you as a cretinous simpleton for your inability to keep track of pointers chained 6 levels deep and Java programmers will pillory you for buying into the evils of Microsoft. Meanwhile C# programmers will get paid just a little bit more than you for writing exactly the same code and VB6 programmers will continue to whitter on about "footprints". - FunkyDexter

    There's just no reason to use garbage like InputBox. - jmcilhinney

    The threads I start are Niya and Olaf free zones. No arguing about the benefits of VB6 over .NET here please. Happiness must reign. - yereverluvinuncleber

Tags for this Thread

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