|
-
Mar 4th, 2002, 07:16 PM
#1
Thread Starter
Fanatic Member
Redraw Picture Box
I only know the HDC of an object, and I need to redraw it. What API call would I use?
The object would normally be a picture box, but it may also be a form, or any other object with a HDC.
-
Mar 4th, 2002, 07:44 PM
#2
Addicted Member
I'm not sure there is a way, hDC's are pointers to a surface, redrawing is done buy the object.
Some Days, i just get this feeling that i'm helping to write dozens of Viruses...
-
Mar 4th, 2002, 09:18 PM
#3
Good Ol' Platypus
Yes, so you use this:
Public Declare Function RedrawWindow Lib "user32" Alias "RedrawWindow" (ByVal hwnd As Long, lprcUpdate As RECT, ByVal hrgnUpdate As Long, ByVal fuRedraw As Long) As Long
Make a region using the region tutorial on the VBW site. For hwnd, pass the picbox's hWnd property, or Null to redraw the screen. For fuRedraw, I would say it's a safe bet it should be 1, like the ShowCursor API (bShow). Don't quote me on that last one, though
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 4th, 2002, 10:31 PM
#4
Thread Starter
Fanatic Member
I saw that one in the API viewer, but sience I didn't know how to use it I ignored it.
-
Mar 4th, 2002, 10:40 PM
#5
Thread Starter
Fanatic Member
I am unable to find the tutorial on the VBW site (you do mean VB world right?).
-
Mar 4th, 2002, 11:14 PM
#6
Good Ol' Platypus
Okay, if you don't want to specify a current area you can just use "ByVal 0&", I didn't know that at the time.
Call it like this:
VB Code:
RedrawWindow Me.hWnd, ByVal 0&, ByVal 0&, &H1
And that will correctly redraw the window.
By the way, I am looking for an API equivalent to .cls found on pictureboxes, for DCs or HWNDs. If anyone knows, gimme a holler
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 5th, 2002, 06:18 AM
#7
Fanatic Member
FillRect?
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Mar 5th, 2002, 03:48 PM
#8
Good Ol' Platypus
Okay, you could get away with this then:
VB Code:
Declare Function CreateRectRgn Lib "gdi32" Alias "CreateRectRgn" (ByVal X1 As Long, ByVal Y1 As Long, ByVal X2 As Long, ByVal Y2 As Long) As Long
RedrawWindow Me.hWnd, ByVal 0&, CreateRectRgn(X, Y, X + Width, Y + Height), &H1
Just ask me if you have any more trouble.
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 5th, 2002, 06:40 PM
#9
Thread Starter
Fanatic Member
This wount work:
VB Code:
RedrawWindow hdc, ByVal 0&, RedrawRegion, &H1
This is due to the fact that the ByVal 0& is where it wants the UD of rect:
VB Code:
Public Type RECT
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
-
Mar 5th, 2002, 06:49 PM
#10
Good Ol' Platypus
Oh really 
Well then try passing the same parameters for the RECT as you did with the CreateRectRgn API. Here's a quick tip, for creating RECTs on the fly:
VB Code:
Function MKRect(X1 As Long, Y1 As Long, X2 As Long, Y2 As Long) As RECT
With MKRect
.Left = X1
.Top = Y1
.Right = X2
.Bottom = Y2
End With
End Function
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 5th, 2002, 07:21 PM
#11
Thread Starter
Fanatic Member
RedrawWindow hWnd, Rect, ----, &H1
What then do you place where I have the -'s?
-
Mar 5th, 2002, 08:07 PM
#12
Good Ol' Platypus
The region I'd guess.... maybe try ByVal 0&. I don't know why it needs both, but first try with the 0& and then with the region code mentioned before.
Both may work...
All contents of the above post that aren't somebody elses are mine, not the property of some media corporation. 
(Just a heads-up)
-
Mar 5th, 2002, 08:25 PM
#13
Thread Starter
Fanatic Member
-
Apr 4th, 2002, 12:00 AM
#14
Thread Starter
Fanatic Member
-
Apr 4th, 2002, 09:00 AM
#15
Frenzied Member
well all those answeres needed the hwnd, but if you got no window there wont be an hwnd so I think nirces was right.
Sanity is a full time job
Puh das war harter Stoff!
-
Apr 4th, 2002, 10:30 AM
#16
Thread Starter
Fanatic Member
As was said, I was tring to redraw a picture box though use of HDC or HWND, ect.
-
Apr 5th, 2002, 04:14 AM
#17
Fanatic Member
Well, how about this:
WindowFromDC
The WindowFromDC function returns a handle to the window associated with the specified display device context (DC). Output functions that use the specified device context draw into this window.
HWND WindowFromDC(
HDC hDC // handle to window
);
Then use UpdateWindow on the returned handle. UpdateWindow has two 'weird' things:
1. it bypasses the window queue, thus instantly updating
2. it will only update if there is a region to update
To update a window even if Windows thinks it wouldn't have to (had a lot of problems before with this btw) use InvalidateRect:
BOOL InvalidateRect(
HWND hWnd, // handle to window
CONST RECT* lpRect, // rectangle coordinates
BOOL bErase // erase state
);
hWnd
[in] Handle to the window whose update region has changed. If this parameter is NULL, the system invalidates and redraws all windows, and sends the WM_ERASEBKGND and WM_NCPAINT messages to the window procedure before the function returns.
lpRect
[in] Pointer to a RECT structure that contains the client coordinates of the rectangle to be added to the update region. If this parameter is NULL, the entire client area is added to the update region. (!!!)
bErase
[in] Specifies whether the background within the update region is to be erased when the update region is processed. If this parameter is TRUE, the background is erased when the BeginPaint function is called. If this parameter is FALSE, the background remains unchanged.
Teaudirenopossum.Musasapientumfixaestinaure.
(I can't hear you. There's a banana in my ear)
-
Apr 5th, 2002, 10:26 AM
#18
Thread Starter
Fanatic Member
Thats gonna take some time to convert to VB...
Oh well, that just means that I will get a little bit of pratcice with C.
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
|