Click here to Skip to main content
16,005,149 members
Home / Discussions / C#
   

C#

 
GeneralRe: osql.exe Pin
Heath Stewart26-Jun-04 14:19
protectorHeath Stewart26-Jun-04 14:19 
GeneralRe: osql.exe Pin
Anonymous26-Jun-04 14:41
Anonymous26-Jun-04 14:41 
Generalchange data in C++ dll by C# program Pin
ting66825-Jun-04 17:13
ting66825-Jun-04 17:13 
GeneralRe: change data in C++ dll by C# program Pin
Heath Stewart26-Jun-04 14:13
protectorHeath Stewart26-Jun-04 14:13 
GeneralRe: change data in C++ dll by C# program Pin
ting6687-Jul-04 4:19
ting6687-Jul-04 4:19 
GeneralRe: change data in C++ dll by C# program Pin
Heath Stewart7-Jul-04 4:31
protectorHeath Stewart7-Jul-04 4:31 
GeneralRe: change data in C++ dll by C# program Pin
ting6687-Jul-04 5:21
ting6687-Jul-04 5:21 
GeneralRe: change data in C++ dll by C# program Pin
Heath Stewart7-Jul-04 5:38
protectorHeath Stewart7-Jul-04 5:38 
There is a solution, and that's what I've been trying to tell you. This is actually quite an easy problem and I deal with interop problems more difficult than this almost daily.

The big problem is that I'm not really understanding what you're trying to do, so let me pose what I'm hearing and tell me if I'm right:

You've defined a set function (C-style export?) in a native DLL that is resolvable and being P/Invoked by a managed assembly written in C#. The C# code calls set which changes a variable. This native function returns true or false (1 or 0, respectively). The C# code then sends WM_PAINT to the HWND that displays the string. Your handler for the WM_PAINT message draws the string value.

If I'm right and if the string value is truly being changed unmanaged process space, then the only problem could be invalidation of the client area. Depending on the WM_PAINT handler, only invalidated regions may be redrawn (this is common for most controls - only redraw what needs to be redrawn). If you don't invalidate the area of the control that displays the string, it may not get redrawn. This is why you must invalidate the region as I mentioned before.

You can try a simple test, too. After the variable is changed, minimize or otherwise hide the window (perhaps with another window). Then show it again. Is the correct string displayed now? If so, it's definitely a drawing problem and you need to invalidate the area. It could also be that, if you're using double-buffering, you're not clearing the back buffer so that even though the client area is invalidated the old back buffer is still being rendered with the old string.

All this talk about handles now is confusing me. Before you said you had a simple function declared (IIRC) like bool set(int), correct? Now you're talking about handles (addresses).

If you need to set the address of a string, you should pin it and use something liket his:
GCHandle handle = GCHandle.Alloc("Some string or variable");
IntPtr ptr = handle.AddrOfPinnedObject();
set(ptr);
handle.Free();
If the string is to be allocated in a certain way (either using GlobalAlloc or COM's CoTaskMem object), then you can use the respective methods defined on the Marshal class to help.

 

Microsoft MVP, Visual C#
My Articles
GeneralRe: change data in C++ dll by C# program Pin
ting6687-Jul-04 15:58
ting6687-Jul-04 15:58 
GeneralRe: change data in C++ dll by C# program Pin
ting6687-Jul-04 15:52
ting6687-Jul-04 15:52 
GeneralRe: change data in C++ dll by C# program Pin
Heath Stewart7-Jul-04 17:02
protectorHeath Stewart7-Jul-04 17:02 
GeneralExtending Windows.Form DataGrid class Pin
ronin177025-Jun-04 16:10
ronin177025-Jun-04 16:10 
GeneralRe: Extending Windows.Form DataGrid class Pin
Heath Stewart26-Jun-04 14:08
protectorHeath Stewart26-Jun-04 14:08 
Questionedit box problem ? Pin
kendao25-Jun-04 14:38
kendao25-Jun-04 14:38 
AnswerRe: edit box problem ? Pin
Dave Kreskowiak25-Jun-04 17:49
mveDave Kreskowiak25-Jun-04 17:49 
GeneralWindows Service that detects domain logons Pin
lnong25-Jun-04 12:54
lnong25-Jun-04 12:54 
GeneralRe: Windows Service that detects domain logons Pin
Dave Kreskowiak25-Jun-04 17:48
mveDave Kreskowiak25-Jun-04 17:48 
GeneralRe: Windows Service that detects domain logons Pin
lnong25-Jun-04 23:01
lnong25-Jun-04 23:01 
GeneralRe: Windows Service that detects domain logons Pin
Dave Kreskowiak26-Jun-04 17:53
mveDave Kreskowiak26-Jun-04 17:53 
GeneralRe: Windows Service that detects domain logons Pin
lnong27-Jun-04 1:46
lnong27-Jun-04 1:46 
GeneralRe: Windows Service that detects domain logons Pin
Dave Kreskowiak27-Jun-04 14:16
mveDave Kreskowiak27-Jun-04 14:16 
Generalpicking random colors Pin
vista2725-Jun-04 12:27
vista2725-Jun-04 12:27 
GeneralRe: picking random colors Pin
Colin Angus Mackay25-Jun-04 12:48
Colin Angus Mackay25-Jun-04 12:48 
GeneralRe: picking random colors Pin
Nick Parker25-Jun-04 19:07
protectorNick Parker25-Jun-04 19:07 
GeneralRe: picking random colors Pin
Anonymous26-Jun-04 7:00
Anonymous26-Jun-04 7:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.