Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As VBRUN.RasterOpConstants) As Long
Private Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long
What that code is attempting to do is
1. Have textbox draw its content to a memory DC.
:: I assume some other custom drawing is being done in that DC, then...
2. Render the DC back onto the textbox.
This can't just be used as is because any change to the textbox (i.e., text change, gain/loose focus, repainting, etc) would just erase completely/partially what was just sent there. Subclassing is the right answer and vbAccelerator's project does that.
Last but not least. It is best practice to call ReleaseDC on any call to GetDC as not doing it can prevent the DC from updating.
Insomnia is just a byproduct of, "It can't be done"
Yes, one can paint anything on any window, even the desktop. That's the easy part. But if you don't have control on how it refreshes/repaints, it does you very little good and is very temporary at best. That is where subclassing comes into play.
Insomnia is just a byproduct of, "It can't be done"
If you really want to see a flicker or change, make m_cWorkDC all black or red and don't call WM_PRINT. From what I can see, unless something is being done to m_cWorkDC between the WM_PRINT and BitBlt call, and the code works, you are copying & pasting the same "stuff".
Edited: Ignore this, we posted at same time and I see you now have results.
Insomnia is just a byproduct of, "It can't be done"
One More Thing Im Stuck In Is How To Enumerate Style From GetWindowLong Like The Api Spy++ Do. Means How Can I Check If Specific Style Is There Or Not?
Get a list of all the common window styles. Then loop thru the returned style to see if those common style bits are included.
Simple example, using fake values. This is one example. Building your list will be time consuming.
Code:
Private Sub Command1_Click()
Dim lStyle As Long ' < returned from GetWindowLong
Dim Styles(0 To 4) As Long
Styles(0)=0 ' WS_OVERLAPPED
Styles(1)=1 ' WS_somethingElse1
Styles(2)=2 ' WS_somethingElse2
Styles(3)=4 ' WS_somethingElse3
Styles(4)=8 ' WS_somethingElse4
For x = 0 To Ubound(Styles)
If (lStyle And Styles(x)) Then ' has this style
Select Case X
Case 0: List1.AddItem "WS_OVERLAPPED"
Case 1: List1.AddItem "WS_somethingElse1"
Case 2: List1.AddItem "WS_somethingElse2"
Case 3: List1.AddItem "WS_somethingElse3"
Case 4: List1.AddItem "WS_somethingElse4"
End Select
End If
Next
End Sub
Insomnia is just a byproduct of, "It can't be done"
MSDN my friend. Type in the API you want to learn more about, in this case; SetBkMode and you can learn more about constants too: WM_CTLCOLOREDIT. In both cases, the code is preparing the textbox DC.
With traditional subclassing, never place messageboxes or breakpoints in the subclass routine. Use Debug.Print instead.
Last edited by LaVolpe; Feb 19th, 2010 at 09:12 PM.
Insomnia is just a byproduct of, "It can't be done"