Click here to Skip to main content
15,885,757 members
Home / Discussions / C#
   

C#

 
GeneralRe: sizeof Pin
TJoe5-Sep-07 10:19
TJoe5-Sep-07 10:19 
GeneralRe: sizeof Pin
dino20945-Sep-07 11:54
dino20945-Sep-07 11:54 
QuestionProblem passing data to an activeX Pin
Paolo Vernazza5-Sep-07 6:55
Paolo Vernazza5-Sep-07 6:55 
AnswerRe: Problem passing data to an activeX Pin
TJoe5-Sep-07 8:23
TJoe5-Sep-07 8:23 
GeneralRe: Problem passing data to an activeX Pin
Paolo Vernazza6-Sep-07 1:57
Paolo Vernazza6-Sep-07 1:57 
GeneralRe: Problem passing data to an activeX Pin
TJoe6-Sep-07 2:13
TJoe6-Sep-07 2:13 
GeneralRe: Problem passing data to an activeX Pin
Paolo Vernazza6-Sep-07 4:33
Paolo Vernazza6-Sep-07 4:33 
GeneralRe: Problem passing data to an activeX Pin
TJoe6-Sep-07 5:08
TJoe6-Sep-07 5:08 
You may want to use AllocCoTaskMem[^] instead (and it's associated free method), but I don't think that is your problem.

Looking at the put code:
IntPtr ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(Int32)) * 10);
Marshal.Copy(buffer, 0, ptr, 10);
int bptr = (int)ptr;
axVecad1.PutExData(ref bptr, 10 * 4);


After the first line, ptr points to the allocated block of memory. The array is then copied to the allocated block. Next ptr is cast to an int, so bptr now holds the correct address to the buffer. Now, when passing in the address to the PutExData, the address of the bptr is passed in (ref bptr). What you really want to pass in is the value of bptr. So really you are passing in a pointer to bptr which has a pointer to the actual data (so a pointer to a pointer).

Basically, the signature for the PutExData should have the first parameter as an "IntPtr", not as a "ref Int32". I don't think there is a way to properly pass in the IntPtr address when the signature has the ref value there. Because you would need to create an Int32 value at the same location as the allocated buffer.

I realize that VS generated the signature of the method for you (more specifically, aximp.exe generates it). The best work-around (short of hand-writing all the code you need) I found was here[^]. Be sure to read the whole thread, he talks about activeX controls later in the thread.

Hopefully this helps.

UPDATE: Actually, it looks like aximp.exe can generate C# source code now, so that would probably be your best option.




Take care,
Tom

-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com

QuestionHow to limit maximum size of other windows? Pin
Trickster-SWE5-Sep-07 6:33
Trickster-SWE5-Sep-07 6:33 
AnswerRe: How to limit maximum size of other windows? Pin
TJoe5-Sep-07 8:06
TJoe5-Sep-07 8:06 
GeneralRe: How to limit maximum size of other windows? Pin
Trickster-SWE5-Sep-07 22:33
Trickster-SWE5-Sep-07 22:33 
QuestionRegex replace question Pin
Vodstok5-Sep-07 6:13
Vodstok5-Sep-07 6:13 
AnswerRe: Regex replace question Pin
TJoe5-Sep-07 8:00
TJoe5-Sep-07 8:00 
Questionrow doesn't get deleted Pin
gericooper5-Sep-07 5:27
gericooper5-Sep-07 5:27 
QuestionVisual Studio Menu Layout Pin
DanB19835-Sep-07 5:13
DanB19835-Sep-07 5:13 
AnswerRe: Visual Studio Menu Layout Pin
martin_hughes5-Sep-07 5:54
martin_hughes5-Sep-07 5:54 
QuestionForm problem Pin
sajid.salim.khan5-Sep-07 4:52
sajid.salim.khan5-Sep-07 4:52 
AnswerRe: Form problem Pin
Christian Graus5-Sep-07 5:07
protectorChristian Graus5-Sep-07 5:07 
GeneralRe: Form problem Pin
sajid.salim.khan5-Sep-07 5:53
sajid.salim.khan5-Sep-07 5:53 
GeneralRe: Form problem Pin
Christian Graus5-Sep-07 8:26
protectorChristian Graus5-Sep-07 8:26 
QuestionExcel Layout change Pin
ramdil5-Sep-07 4:34
ramdil5-Sep-07 4:34 
QuestionRead only row in Datagrid Pin
André Stroebel5-Sep-07 4:11
André Stroebel5-Sep-07 4:11 
AnswerRe: Read only row in Datagrid Pin
André Stroebel5-Sep-07 4:32
André Stroebel5-Sep-07 4:32 
QuestionDataGridView(Win app) disable selecting Pin
Stevo Z5-Sep-07 3:24
Stevo Z5-Sep-07 3:24 
AnswerRe: DataGridView(Win app) disable selecting Pin
Judah Gabriel Himango5-Sep-07 3:55
sponsorJudah Gabriel Himango5-Sep-07 3:55 

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.