|
-
Feb 24th, 2025, 10:19 AM
#1
Thread Starter
New Member
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
-
Feb 24th, 2025, 02:21 PM
#2
Re: How to use XOR drawing in a DIB and then clear it
 Originally Posted by Sirio
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.
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|