Hi guys
I am developing a program which draws stuff on the screen (outside of the
form).
For this I use the GetDC function of user32.dll to get a handle to the
desktop, and then use GDI+ to draw. So far so good.
The problem is that before drawing, I have to erase what I had previously
drawn. I tried using the InvalidateRect API function, without luck.
I get this error when I run the program:
A call to PInvoke function 'WindowsApplication1.Form1::InvalidateRect' has
unbalanced the stack. This is likely because the managed PInvoke signature
does not match the unmanaged target signature. Check that the calling
convention and parameters of the PInvoke signature match the target
unmanaged signature.
This is what I have in my code:
Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As
System.IntPtr, ByVal lpRect As RECT, ByVal bErase As Boolean) As Boolean
Private Structure RECT
Dim Left As Long
Dim Top As Long
Dim Right As Long
Dim Bottom As Long
End Structure
And then in my function:
Dim ii As New RECT
ii.Bottom = 1280
ii.Top = 0
ii.Left = 100
ii.Right = 700
Dim DesktopHandle As System.IntPtr = GetDC(System.IntPtr.Zero)
InvalidateRect(DesktopHandle, ii, True)
Any ideas? I've tried to google it, but to no avail. I'm new in the Windows
API world, so... It's kinda hard for me to get anywhere.
Thank you for any help you might give me!
Andre Nogueira 3 5448
Long is Integer in VB.NET.
Also I believe this is also available in GDI+. I would use managed class
whenever using COM interop is not required... Similarly the System.Drawing
namespace should allow to retrieve the desktop without having to use interop
(IMO, not tested).
--
Patrice
"Andre Nogueira" <an**@nospam.pt> a écrit dans le message de
news:ux**************@TK2MSFTNGP09.phx.gbl... Hi guys
I am developing a program which draws stuff on the screen (outside of the form). For this I use the GetDC function of user32.dll to get a handle to the desktop, and then use GDI+ to draw. So far so good. The problem is that before drawing, I have to erase what I had previously drawn. I tried using the InvalidateRect API function, without luck. I get this error when I run the program:
A call to PInvoke function 'WindowsApplication1.Form1::InvalidateRect' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
This is what I have in my code:
Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpRect As RECT, ByVal bErase As Boolean) As Boolean
Private Structure RECT
Dim Left As Long
Dim Top As Long
Dim Right As Long
Dim Bottom As Long
End Structure And then in my function: Dim ii As New RECT
ii.Bottom = 1280
ii.Top = 0
ii.Left = 100
ii.Right = 700
Dim DesktopHandle As System.IntPtr = GetDC(System.IntPtr.Zero)
InvalidateRect(DesktopHandle, ii, True) Any ideas? I've tried to google it, but to no avail. I'm new in the
Windows API world, so... It's kinda hard for me to get anywhere.
Thank you for any help you might give me!
Andre Nogueira
Hi,
I tried to change "Long" to "Integer" in the RECT struct, but the same error
occurs...
I did try to find managed replacements for these two functions, but couldn't
find any... I'm using VB.Net 2005.
Any other ideas?
Thanks,
Andre
"Patrice" <a@bc.c> wrote in message
news:On**************@TK2MSFTNGP14.phx.gbl... Long is Integer in VB.NET.
Also I believe this is also available in GDI+. I would use managed class whenever using COM interop is not required... Similarly the System.Drawing namespace should allow to retrieve the desktop without having to use interop (IMO, not tested).
-- Patrice
"Andre Nogueira" <an**@nospam.pt> a écrit dans le message de news:ux**************@TK2MSFTNGP09.phx.gbl... Hi guys
I am developing a program which draws stuff on the screen (outside of the form). For this I use the GetDC function of user32.dll to get a handle to the desktop, and then use GDI+ to draw. So far so good. The problem is that before drawing, I have to erase what I had previously drawn. I tried using the InvalidateRect API function, without luck. I get this error when I run the program:
A call to PInvoke function 'WindowsApplication1.Form1::InvalidateRect' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
This is what I have in my code:
Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpRect As RECT, ByVal bErase As Boolean) As Boolean
Private Structure RECT
Dim Left As Long
Dim Top As Long
Dim Right As Long
Dim Bottom As Long
End Structure And then in my function: Dim ii As New RECT
ii.Bottom = 1280
ii.Top = 0
ii.Left = 100
ii.Right = 700
Dim DesktopHandle As System.IntPtr = GetDC(System.IntPtr.Zero)
InvalidateRect(DesktopHandle, ii, True) Any ideas? I've tried to google it, but to no avail. I'm new in the Windows API world, so... It's kinda hard for me to get anywhere.
Thank you for any help you might give me!
Andre Nogueira
Noticed also that that the RECT structure should be passed byref. Try http://www.pinvoke.net for all the signatures you need...
System.Drawing.Graphics is basically the counterpart of a DeviceContext. IMO
you should be able to get access to the desktop using its FromHwnd. method.
I remember also to have seen an Invalidate method but this is one is likely
a bit harder to use for your intended usage (if I remember this is either
usable throught the painteventargs, likely available as a member of the
sender control).
--
Patrice
"Andre Nogueira" <an**@nospam.pt> a écrit dans le message de
news:uM**************@TK2MSFTNGP12.phx.gbl... Hi,
I tried to change "Long" to "Integer" in the RECT struct, but the same
error occurs...
I did try to find managed replacements for these two functions, but
couldn't find any... I'm using VB.Net 2005.
Any other ideas?
Thanks,
Andre
"Patrice" <a@bc.c> wrote in message news:On**************@TK2MSFTNGP14.phx.gbl... Long is Integer in VB.NET.
Also I believe this is also available in GDI+. I would use managed class whenever using COM interop is not required... Similarly the
System.Drawing namespace should allow to retrieve the desktop without having to use interop (IMO, not tested).
-- Patrice
"Andre Nogueira" <an**@nospam.pt> a écrit dans le message de news:ux**************@TK2MSFTNGP09.phx.gbl... Hi guys
I am developing a program which draws stuff on the screen (outside of
the form). For this I use the GetDC function of user32.dll to get a handle to the desktop, and then use GDI+ to draw. So far so good. The problem is that before drawing, I have to erase what I had
previously drawn. I tried using the InvalidateRect API function, without luck. I get this error when I run the program:
A call to PInvoke function 'WindowsApplication1.Form1::InvalidateRect' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.
This is what I have in my code:
Private Declare Function InvalidateRect Lib "user32" (ByVal hWnd As System.IntPtr, ByVal lpRect As RECT, ByVal bErase As Boolean) As
Boolean Private Structure RECT
Dim Left As Long
Dim Top As Long
Dim Right As Long
Dim Bottom As Long
End Structure And then in my function: Dim ii As New RECT
ii.Bottom = 1280
ii.Top = 0
ii.Left = 100
ii.Right = 700
Dim DesktopHandle As System.IntPtr = GetDC(System.IntPtr.Zero)
InvalidateRect(DesktopHandle, ii, True) Any ideas? I've tried to google it, but to no avail. I'm new in the Windows API world, so... It's kinda hard for me to get anywhere.
Thank you for any help you might give me!
Andre Nogueira
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Peter |
last post by:
I want to draw some lines on a widget.
This works ok, but when I want to redraw, the old lines are still there.
How do I clear or refresh the widget, so I can draw a new set of lines?
Code...
|
by: PHH |
last post by:
Help me, please,
When I redraw a ListviewItem in Listview (redraw items with icon and text
columms).
I used SetStyle(ControlStyle.UserPaint, true) function. And I redraw finish
and run...
|
by: WHITETIGER |
last post by:
Help me, please,
When I redraw a ListviewItem in Listview (redraw items with icon and text
columms).
I used SetStyle(ControlStyle.UserPaint, true) function. And I redraw finish
and run...
|
by: ch424 |
last post by:
Hi,
Does anybody know the fastest way to trigger a DrawingArea redaw in
pygtk? At the moment, I'm using a bit of a hack:
def redraw(self):
self.area.hide()
self.area.show()
Is there a...
|
by: Kevin Chandler |
last post by:
I appologize in advance if this is a novice question. I don't have much
ASP.Net experience.
I have an NCAA tournment selection page that I use asp:button controls. The
problem is that...
|
by: urs |
last post by:
Hi, please look at the ASP.NET 2 site
http://www.prismatest.ch/catalog/EM.ASPX
(user=prismashop, password=minicooper). Use the ">" Button to go to the
next pages.
You will notice that the page...
|
by: Dean Earley |
last post by:
Hi all.
I have just added translucency to one of my applications using the
layered windows API, but I have come across a redraw problem.
Unfortunately, I cant reproduce this in a standalone...
|
by: diogoko |
last post by:
I have some code like:
try {
someButton.disabled = true;
cpuIntensiveCode();
} finally {
someButton.disabled = false;
}
The problem is that someButton is never disabled, because the browser
|
by: Darcy |
last post by:
I am trying to do the following:
1. set the contents of div "displayarea" to show a status update bar
2. process some data and format the result into HTML (this may take
time, depending upon the...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
by: CloudSolutions |
last post by:
Introduction:
For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: Shællîpôpï 09 |
last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
| |