Discussion:
VC++ ShapeSheet stuff
(too old to reply)
Amir Soofi
2006-06-22 14:57:45 UTC
Permalink
This is kind of a newbie question, but I'm trying to use the C/C++
wrapper classes to define the custom properties of a shape (that is,
make rows, and fill in values respectively) but no matter what
permutation of commands I execute, I can't get the darned thing working

Could somebody please provide example code of how to modify / set / read
from a shape's Custom Properties?

Thanks!
Michel LAPLANE
2006-06-23 05:55:42 UTC
Permalink
Download the microsoft visio sdk 2003, you will find a bunch of C# code that
can help.
This is kind of a newbie question, but I'm trying to use the C/C++ wrapper
classes to define the custom properties of a shape (that is, make rows,
and fill in values respectively) but no matter what permutation of
commands I execute, I can't get the darned thing working
Could somebody please provide example code of how to modify / set / read
from a shape's Custom Properties?
Thanks!
Michel LAPLANE
2006-06-23 05:57:16 UTC
Permalink
You can also ask me more precise question in unsing C++ Viso api if you
want.
This is kind of a newbie question, but I'm trying to use the C/C++ wrapper
classes to define the custom properties of a shape (that is, make rows,
and fill in values respectively) but no matter what permutation of
commands I execute, I can't get the darned thing working
Could somebody please provide example code of how to modify / set / read
from a shape's Custom Properties?
Thanks!
Amir Soofi
2006-06-23 13:11:13 UTC
Permalink
Yeah, I got the SDK and all that jazz, , but the C# still has some more
versatility than the C wrapper classes.

I'll try to be as specific as possible.
What I'm trying to do is from an arbitrary data structure in C++, fill
in the custom property values with arbitrary data members in an instance
of a particular data structure.

A good example would be

struct person{
int age;
char name[128];
char gender;
}

What I have been able to do successfully is -
- Pull a shape from a stencil I've made beforehand
- Drop that shape on a visio page [so I can actually see it]

Now what I want to do is store the age and name inside of the custom
property fields.

So lets say my declarations are

CVisioShape myShape;
CVisioCell myCell;
person myPerson;


To tie myCell to myShape --

myShape.Cells("Prop.Row_1",myCell);

Now here I run into some qualms.
Assuming I wanted to set the name of the person as a custom property -
in the C# example, to set the cell equivalent to a string, the SDK uses
[without any included libraries] --

formatHelper = new StringValueInCell();
formatHelper.SetCellValueToString(customPropertyCell,
propertyValue.ToString());

VC7 catches an error trying to find StringValueInCell()

Additionally, I've tried
myCell.putResult, but putResult takes two arguments, and the first one,
being of type CONST VARIANT_HELPER_CLASS &UnitsNameOrCode

Okay, so I look in the SDK documentation for Units, and I find
STR - String

But when I try

myCell.putResult(STR, myPerson.getName() )

VC7 throws me an error.

And I try different variations and permutations with the age parameter,
to no avail.

Its a big issue of "I know what I want to set the value to, I know the
functions to set the value, but I can't set the value"

Thanks much for your time / help.
Post by Michel LAPLANE
You can also ask me more precise question in unsing C++ Viso api if you
want.
This is kind of a newbie question, but I'm trying to use the C/C++ wrapper
classes to define the custom properties of a shape (that is, make rows,
and fill in values respectively) but no matter what permutation of
commands I execute, I can't get the darned thing working
Could somebody please provide example code of how to modify / set / read
from a shape's Custom Properties?
Thanks!
Michel LAPLANE
2006-06-26 09:00:58 UTC
Permalink
Try this code. of course it is better to test the hr result for each visio
call.

HRESULT hr;
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value

...
// set the age value or the name
....
// visShape is a visio shape
hr = visShape.Section(visSectionProp,visSection);
// set the line
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
hr = visRow.Cell((VVariant)(long)visCustPropsType,visCell);
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(type == visPropTypeNumber)
{
// for the age
hr = visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
}
else
{
// for string value
CString strFormula;
strFormula = '"';
strFormula += szName;
strFormula += '"';
hr = visCell.FormulaForce(VBstr(strFormula));
}
Post by Amir Soofi
Yeah, I got the SDK and all that jazz, , but the C# still has some more
versatility than the C wrapper classes.
I'll try to be as specific as possible.
What I'm trying to do is from an arbitrary data structure in C++, fill in
the custom property values with arbitrary data members in an instance of a
particular data structure.
A good example would be
struct person{
int age;
char name[128];
char gender;
}
What I have been able to do successfully is -
- Pull a shape from a stencil I've made beforehand
- Drop that shape on a visio page [so I can actually see it]
Now what I want to do is store the age and name inside of the custom
property fields.
So lets say my declarations are
CVisioShape myShape;
CVisioCell myCell;
person myPerson;
To tie myCell to myShape --
myShape.Cells("Prop.Row_1",myCell);
Now here I run into some qualms.
Assuming I wanted to set the name of the person as a custom property - in
the C# example, to set the cell equivalent to a string, the SDK uses
[without any included libraries] --
formatHelper = new StringValueInCell();
formatHelper.SetCellValueToString(customPropertyCell,
propertyValue.ToString());
VC7 catches an error trying to find StringValueInCell()
Additionally, I've tried
myCell.putResult, but putResult takes two arguments, and the first one,
being of type CONST VARIANT_HELPER_CLASS &UnitsNameOrCode
Okay, so I look in the SDK documentation for Units, and I find
STR - String
But when I try
myCell.putResult(STR, myPerson.getName() )
VC7 throws me an error.
And I try different variations and permutations with the age parameter, to
no avail.
Its a big issue of "I know what I want to set the value to, I know the
functions to set the value, but I can't set the value"
Thanks much for your time / help.
Post by Michel LAPLANE
You can also ask me more precise question in unsing C++ Viso api if you
want.
Post by Amir Soofi
This is kind of a newbie question, but I'm trying to use the C/C++
wrapper classes to define the custom properties of a shape (that is,
make rows, and fill in values respectively) but no matter what
permutation of commands I execute, I can't get the darned thing working
Could somebody please provide example code of how to modify / set / read
from a shape's Custom Properties?
Thanks!
Amir Soofi
2006-06-26 18:21:14 UTC
Permalink
Hi Michel ~

When I try this code --

HRESULT hr;
CVisioShape visShape
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value


strcpy(szName, "GHENT");
lAgeToSet=(long)12345;

hr = rangeShape.Section(visSectionProp,visSection);
if(!SUCCEEDED(hr))
printf("\n\tFail 1");

lineIndex = 1; // for the first custom property

hr = visSection.Row(lineIndex,visRow);
if(!SUCCEEDED(hr))
printf("\n\t\tFail 2");


hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
if(!SUCCEEDED(hr))
printf("\n\t\t\tFail 3");


hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\tFail 4");

hr =
visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\t\tFail 5");

vsoPage.drop(vsoMaster, x,y,vsoShape);


The result I get is

Fail 1
Fail 2
Fail 3
Fail 4
Fail 5

So every hr is failing. I've tried some things as to find out why, but I
would like to think
I have also tried moving the code to below the vsoPage.drop, but that
did not work either.
Post by Michel LAPLANE
Try this code. of course it is better to test the hr result for each visio
call.
HRESULT hr;
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
...
// set the age value or the name
....
// visShape is a visio shape
hr = visShape.Section(visSectionProp,visSection);
// set the line
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
hr = visRow.Cell((VVariant)(long)visCustPropsType,visCell);
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(type == visPropTypeNumber)
{
// for the age
hr = visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
}
else
{
// for string value
CString strFormula;
strFormula = '"';
strFormula += szName;
strFormula += '"';
hr = visCell.FormulaForce(VBstr(strFormula));
}
Post by Amir Soofi
Yeah, I got the SDK and all that jazz, , but the C# still has some more
versatility than the C wrapper classes.
I'll try to be as specific as possible.
What I'm trying to do is from an arbitrary data structure in C++, fill in
the custom property values with arbitrary data members in an instance of a
particular data structure.
A good example would be
struct person{
int age;
char name[128];
char gender;
}
What I have been able to do successfully is -
- Pull a shape from a stencil I've made beforehand
- Drop that shape on a visio page [so I can actually see it]
Now what I want to do is store the age and name inside of the custom
property fields.
So lets say my declarations are
CVisioShape myShape;
CVisioCell myCell;
person myPerson;
To tie myCell to myShape --
myShape.Cells("Prop.Row_1",myCell);
Now here I run into some qualms.
Assuming I wanted to set the name of the person as a custom property - in
the C# example, to set the cell equivalent to a string, the SDK uses
[without any included libraries] --
formatHelper = new StringValueInCell();
formatHelper.SetCellValueToString(customPropertyCell,
propertyValue.ToString());
VC7 catches an error trying to find StringValueInCell()
Additionally, I've tried
myCell.putResult, but putResult takes two arguments, and the first one,
being of type CONST VARIANT_HELPER_CLASS &UnitsNameOrCode
Okay, so I look in the SDK documentation for Units, and I find
STR - String
But when I try
myCell.putResult(STR, myPerson.getName() )
VC7 throws me an error.
And I try different variations and permutations with the age parameter, to
no avail.
Its a big issue of "I know what I want to set the value to, I know the
functions to set the value, but I can't set the value"
Thanks much for your time / help.
Post by Michel LAPLANE
You can also ask me more precise question in unsing C++ Viso api if you
want.
Post by Amir Soofi
This is kind of a newbie question, but I'm trying to use the C/C++
wrapper classes to define the custom properties of a shape (that is,
make rows, and fill in values respectively) but no matter what
permutation of commands I execute, I can't get the darned thing working
Could somebody please provide example code of how to modify / set / read
from a shape's Custom Properties?
Thanks!
Michel LAPLANE
2006-07-06 20:35:47 UTC
Permalink
I'm in vacation till end of july. If you have always problem with C++ ask me
Post by Amir Soofi
Hi Michel ~
When I try this code --
HRESULT hr;
CVisioShape visShape
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
strcpy(szName, "GHENT");
lAgeToSet=(long)12345;
hr = rangeShape.Section(visSectionProp,visSection);
if(!SUCCEEDED(hr))
printf("\n\tFail 1");
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
if(!SUCCEEDED(hr))
printf("\n\t\tFail 2");
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
if(!SUCCEEDED(hr))
printf("\n\t\t\tFail 3");
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\tFail 4");
hr = visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\t\tFail 5");
vsoPage.drop(vsoMaster, x,y,vsoShape);
The result I get is
Fail 1
Fail 2
Fail 3
Fail 4
Fail 5
So every hr is failing. I've tried some things as to find out why, but I
would like to think
I have also tried moving the code to below the vsoPage.drop, but that did
not work either.
Post by Michel LAPLANE
Try this code. of course it is better to test the hr result for each
visio call.
HRESULT hr;
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
...
// set the age value or the name
....
// visShape is a visio shape
hr = visShape.Section(visSectionProp,visSection);
// set the line
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
hr = visRow.Cell((VVariant)(long)visCustPropsType,visCell);
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(type == visPropTypeNumber)
{
// for the age
hr = visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
}
else
{
// for string value
CString strFormula;
strFormula = '"';
strFormula += szName;
strFormula += '"';
hr = visCell.FormulaForce(VBstr(strFormula));
}
Post by Amir Soofi
Yeah, I got the SDK and all that jazz, , but the C# still has some more
versatility than the C wrapper classes.
I'll try to be as specific as possible.
What I'm trying to do is from an arbitrary data structure in C++, fill
in the custom property values with arbitrary data members in an instance
of a particular data structure.
A good example would be
struct person{
int age;
char name[128];
char gender;
}
What I have been able to do successfully is -
- Pull a shape from a stencil I've made beforehand
- Drop that shape on a visio page [so I can actually see it]
Now what I want to do is store the age and name inside of the custom
property fields.
So lets say my declarations are
CVisioShape myShape;
CVisioCell myCell;
person myPerson;
To tie myCell to myShape --
myShape.Cells("Prop.Row_1",myCell);
Now here I run into some qualms.
Assuming I wanted to set the name of the person as a custom property -
in the C# example, to set the cell equivalent to a string, the SDK uses
[without any included libraries] --
formatHelper = new StringValueInCell();
formatHelper.SetCellValueToString(customPropertyCell,
propertyValue.ToString());
VC7 catches an error trying to find StringValueInCell()
Additionally, I've tried
myCell.putResult, but putResult takes two arguments, and the first one,
being of type CONST VARIANT_HELPER_CLASS &UnitsNameOrCode
Okay, so I look in the SDK documentation for Units, and I find
STR - String
But when I try
myCell.putResult(STR, myPerson.getName() )
VC7 throws me an error.
And I try different variations and permutations with the age parameter,
to no avail.
Its a big issue of "I know what I want to set the value to, I know the
functions to set the value, but I can't set the value"
Thanks much for your time / help.
Post by Michel LAPLANE
You can also ask me more precise question in unsing C++ Viso api if you
want.
Post by Amir Soofi
This is kind of a newbie question, but I'm trying to use the C/C++
wrapper classes to define the custom properties of a shape (that is,
make rows, and fill in values respectively) but no matter what
permutation of commands I execute, I can't get the darned thing working
Could somebody please provide example code of how to modify / set /
read from a shape's Custom Properties?
Thanks!
Amir Soofi
2006-07-14 15:21:20 UTC
Permalink
Hi Michel
I hope you're having a good vacation --

I finally got it all figured out, thank you though for all your help.

For anybody this may pertain to, who is also having troubles, this is
how to add a custom property using the C/C++ Wrapper Classes

*********************************************
short int shtRet=0;
CVisioShape myShape;
CVisioSection propSection;
CVisioCell propCell;
CVisioRow propRow;


myShape.AddSection(visSectionProp, &shtRet);
myShape.Section(visSectionProp,propSection);
myShape.AddRow(visSectionProp, 0, 0, &shtRet); //Here the 0 is the row
number, changes this if you want to add more
propSection.Row(0, propRow); //Here the 0 references the row number.
Change this for respective accessing
propRow.putName(VBstr("Name"));
propRow.Cell((VVariant)(long)0,propCell);
propCell.FormulaForce(VBstr("Amir.Soofi"));

*********************************************

It's very similar to what Michel gave me. It might in fact be the same,
but it works, regardless :)

~Amir Soofi
Post by Michel LAPLANE
I'm in vacation till end of july. If you have always problem with C++ ask me
Post by Amir Soofi
Hi Michel ~
When I try this code --
HRESULT hr;
CVisioShape visShape
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
strcpy(szName, "GHENT");
lAgeToSet=(long)12345;
hr = rangeShape.Section(visSectionProp,visSection);
if(!SUCCEEDED(hr))
printf("\n\tFail 1");
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
if(!SUCCEEDED(hr))
printf("\n\t\tFail 2");
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
if(!SUCCEEDED(hr))
printf("\n\t\t\tFail 3");
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\tFail 4");
hr = visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\t\tFail 5");
vsoPage.drop(vsoMaster, x,y,vsoShape);
The result I get is
Fail 1
Fail 2
Fail 3
Fail 4
Fail 5
So every hr is failing. I've tried some things as to find out why, but I
would like to think
I have also tried moving the code to below the vsoPage.drop, but that did
not work either.
Post by Michel LAPLANE
Try this code. of course it is better to test the hr result for each
visio call.
HRESULT hr;
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
...
// set the age value or the name
....
// visShape is a visio shape
hr = visShape.Section(visSectionProp,visSection);
// set the line
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
hr = visRow.Cell((VVariant)(long)visCustPropsType,visCell);
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(type == visPropTypeNumber)
{
// for the age
hr = visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
}
else
{
// for string value
CString strFormula;
strFormula = '"';
strFormula += szName;
strFormula += '"';
hr = visCell.FormulaForce(VBstr(strFormula));
}
Post by Amir Soofi
Yeah, I got the SDK and all that jazz, , but the C# still has some more
versatility than the C wrapper classes.
I'll try to be as specific as possible.
What I'm trying to do is from an arbitrary data structure in C++, fill
in the custom property values with arbitrary data members in an instance
of a particular data structure.
A good example would be
struct person{
int age;
char name[128];
char gender;
}
What I have been able to do successfully is -
- Pull a shape from a stencil I've made beforehand
- Drop that shape on a visio page [so I can actually see it]
Now what I want to do is store the age and name inside of the custom
property fields.
So lets say my declarations are
CVisioShape myShape;
CVisioCell myCell;
person myPerson;
To tie myCell to myShape --
myShape.Cells("Prop.Row_1",myCell);
Now here I run into some qualms.
Assuming I wanted to set the name of the person as a custom property -
in the C# example, to set the cell equivalent to a string, the SDK uses
[without any included libraries] --
formatHelper = new StringValueInCell();
formatHelper.SetCellValueToString(customPropertyCell,
propertyValue.ToString());
VC7 catches an error trying to find StringValueInCell()
Additionally, I've tried
myCell.putResult, but putResult takes two arguments, and the first one,
being of type CONST VARIANT_HELPER_CLASS &UnitsNameOrCode
Okay, so I look in the SDK documentation for Units, and I find
STR - String
But when I try
myCell.putResult(STR, myPerson.getName() )
VC7 throws me an error.
And I try different variations and permutations with the age parameter,
to no avail.
Its a big issue of "I know what I want to set the value to, I know the
functions to set the value, but I can't set the value"
Thanks much for your time / help.
Post by Michel LAPLANE
You can also ask me more precise question in unsing C++ Viso api if you
want.
Post by Amir Soofi
This is kind of a newbie question, but I'm trying to use the C/C++
wrapper classes to define the custom properties of a shape (that is,
make rows, and fill in values respectively) but no matter what
permutation of commands I execute, I can't get the darned thing working
Could somebody please provide example code of how to modify / set /
read from a shape's Custom Properties?
Thanks!
Amir Soofi
2006-07-14 16:13:14 UTC
Permalink
One quick annotation, in the line I have
Post by Amir Soofi
Post by Amir Soofi
propCell.FormulaForce(VBstr("Amir.Soofi"));
It should be
Post by Amir Soofi
Post by Amir Soofi
propCell.FormulaForce(VBstr("AmirSoofi"));
The difference is, the period that is no longer there. The additional
period will yield an error.

=D
Post by Amir Soofi
Hi Michel
I hope you're having a good vacation --
I finally got it all figured out, thank you though for all your help.
For anybody this may pertain to, who is also having troubles, this is
how to add a custom property using the C/C++ Wrapper Classes
*********************************************
short int shtRet=0;
CVisioShape myShape;
CVisioSection propSection;
CVisioCell propCell;
CVisioRow propRow;
myShape.AddSection(visSectionProp, &shtRet);
myShape.Section(visSectionProp,propSection);
myShape.AddRow(visSectionProp, 0, 0, &shtRet); //Here the 0 is the
row number, changes this if you want to add more
propSection.Row(0, propRow); //Here the 0 references the row number.
Change this for respective accessing
propRow.putName(VBstr("Name"));
propRow.Cell((VVariant)(long)0,propCell);
propCell.FormulaForce(VBstr("Amir.Soofi"));
*********************************************
It's very similar to what Michel gave me. It might in fact be the same,
but it works, regardless :)
~Amir Soofi
Post by Amir Soofi
I'm in vacation till end of july. If you have always problem with C++
Post by Amir Soofi
Hi Michel ~
When I try this code --
HRESULT hr;
CVisioShape visShape
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
strcpy(szName, "GHENT");
lAgeToSet=(long)12345;
hr = rangeShape.Section(visSectionProp,visSection);
if(!SUCCEEDED(hr))
printf("\n\tFail 1");
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
if(!SUCCEEDED(hr))
printf("\n\t\tFail 2");
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
if(!SUCCEEDED(hr))
printf("\n\t\t\tFail 3");
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\tFail 4");
hr = visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\t\tFail 5");
vsoPage.drop(vsoMaster, x,y,vsoShape);
The result I get is
Fail 1
Fail 2
Fail 3
Fail 4
Fail 5
So every hr is failing. I've tried some things as to find out why,
but I would like to think
I have also tried moving the code to below the vsoPage.drop, but that
did not work either.
Post by Michel LAPLANE
Try this code. of course it is better to test the hr result for each
visio call.
HRESULT hr;
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
...
// set the age value or the name
....
// visShape is a visio shape
hr = visShape.Section(visSectionProp,visSection);
// set the line
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
hr = visRow.Cell((VVariant)(long)visCustPropsType,visCell);
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(type == visPropTypeNumber)
{
// for the age
hr =
visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
}
else
{
// for string value
CString strFormula;
strFormula = '"';
strFormula += szName;
strFormula += '"';
hr = visCell.FormulaForce(VBstr(strFormula));
}
Post by Amir Soofi
Yeah, I got the SDK and all that jazz, , but the C# still has some
more versatility than the C wrapper classes.
I'll try to be as specific as possible.
What I'm trying to do is from an arbitrary data structure in C++,
fill in the custom property values with arbitrary data members in
an instance of a particular data structure.
A good example would be
struct person{
int age;
char name[128];
char gender;
}
What I have been able to do successfully is -
- Pull a shape from a stencil I've made beforehand
- Drop that shape on a visio page [so I can actually see it]
Now what I want to do is store the age and name inside of the
custom property fields.
So lets say my declarations are
CVisioShape myShape;
CVisioCell myCell;
person myPerson;
To tie myCell to myShape --
myShape.Cells("Prop.Row_1",myCell);
Now here I run into some qualms.
Assuming I wanted to set the name of the person as a custom
property - in the C# example, to set the cell equivalent to a
string, the SDK uses [without any included libraries] --
formatHelper = new StringValueInCell();
formatHelper.SetCellValueToString(customPropertyCell,
propertyValue.ToString());
VC7 catches an error trying to find StringValueInCell()
Additionally, I've tried
myCell.putResult, but putResult takes two arguments, and the first
one, being of type CONST VARIANT_HELPER_CLASS &UnitsNameOrCode
Okay, so I look in the SDK documentation for Units, and I find
STR - String
But when I try
myCell.putResult(STR, myPerson.getName() )
VC7 throws me an error.
And I try different variations and permutations with the age
parameter, to no avail.
Its a big issue of "I know what I want to set the value to, I know
the functions to set the value, but I can't set the value"
Thanks much for your time / help.
Post by Michel LAPLANE
You can also ask me more precise question in unsing C++ Viso api
if you want.
Post by Amir Soofi
This is kind of a newbie question, but I'm trying to use the
C/C++ wrapper classes to define the custom properties of a shape
(that is, make rows, and fill in values respectively) but no
matter what permutation of commands I execute, I can't get the
darned thing working
Could somebody please provide example code of how to modify / set
/ read from a shape's Custom Properties?
Thanks!
Michel LAPLANE
2006-09-04 08:17:41 UTC
Permalink
I'm back
Do you have always problems ?
Post by Amir Soofi
One quick annotation, in the line I have
Post by Amir Soofi
Post by Amir Soofi
propCell.FormulaForce(VBstr("Amir.Soofi"));
It should be
Post by Amir Soofi
Post by Amir Soofi
propCell.FormulaForce(VBstr("AmirSoofi"));
The difference is, the period that is no longer there. The additional
period will yield an error.
=D
Post by Amir Soofi
Hi Michel
I hope you're having a good vacation --
I finally got it all figured out, thank you though for all your help.
For anybody this may pertain to, who is also having troubles, this is how
to add a custom property using the C/C++ Wrapper Classes
*********************************************
short int shtRet=0;
CVisioShape myShape;
CVisioSection propSection;
CVisioCell propCell;
CVisioRow propRow;
myShape.AddSection(visSectionProp, &shtRet);
myShape.Section(visSectionProp,propSection);
myShape.AddRow(visSectionProp, 0, 0, &shtRet); //Here the 0 is the row
number, changes this if you want to add more
propSection.Row(0, propRow); //Here the 0 references the row number.
Change this for respective accessing
propRow.putName(VBstr("Name"));
propRow.Cell((VVariant)(long)0,propCell);
propCell.FormulaForce(VBstr("Amir.Soofi"));
*********************************************
It's very similar to what Michel gave me. It might in fact be the same,
but it works, regardless :)
~Amir Soofi
Post by Amir Soofi
I'm in vacation till end of july. If you have always problem with C++
Post by Amir Soofi
Hi Michel ~
When I try this code --
HRESULT hr;
CVisioShape visShape
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
strcpy(szName, "GHENT");
lAgeToSet=(long)12345;
hr = rangeShape.Section(visSectionProp,visSection);
if(!SUCCEEDED(hr))
printf("\n\tFail 1");
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
if(!SUCCEEDED(hr))
printf("\n\t\tFail 2");
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
if(!SUCCEEDED(hr))
printf("\n\t\t\tFail 3");
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\tFail 4");
hr =
visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\t\tFail 5");
vsoPage.drop(vsoMaster, x,y,vsoShape);
The result I get is
Fail 1
Fail 2
Fail 3
Fail 4
Fail 5
So every hr is failing. I've tried some things as to find out why, but
I would like to think
I have also tried moving the code to below the vsoPage.drop, but that
did not work either.
Post by Michel LAPLANE
Try this code. of course it is better to test the hr result for each
visio call.
HRESULT hr;
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
...
// set the age value or the name
....
// visShape is a visio shape
hr = visShape.Section(visSectionProp,visSection);
// set the line
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
hr = visRow.Cell((VVariant)(long)visCustPropsType,visCell);
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(type == visPropTypeNumber)
{
// for the age
hr =
visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
}
else
{
// for string value
CString strFormula;
strFormula = '"';
strFormula += szName;
strFormula += '"';
hr = visCell.FormulaForce(VBstr(strFormula));
}
Post by Amir Soofi
Yeah, I got the SDK and all that jazz, , but the C# still has some
more versatility than the C wrapper classes.
I'll try to be as specific as possible.
What I'm trying to do is from an arbitrary data structure in C++,
fill in the custom property values with arbitrary data members in an
instance of a particular data structure.
A good example would be
struct person{
int age;
char name[128];
char gender;
}
What I have been able to do successfully is -
- Pull a shape from a stencil I've made beforehand
- Drop that shape on a visio page [so I can actually see it]
Now what I want to do is store the age and name inside of the custom
property fields.
So lets say my declarations are
CVisioShape myShape;
CVisioCell myCell;
person myPerson;
To tie myCell to myShape --
myShape.Cells("Prop.Row_1",myCell);
Now here I run into some qualms.
Assuming I wanted to set the name of the person as a custom
property - in the C# example, to set the cell equivalent to a string,
the SDK uses [without any included libraries] --
formatHelper = new StringValueInCell();
formatHelper.SetCellValueToString(customPropertyCell,
propertyValue.ToString());
VC7 catches an error trying to find StringValueInCell()
Additionally, I've tried
myCell.putResult, but putResult takes two arguments, and the first
one, being of type CONST VARIANT_HELPER_CLASS &UnitsNameOrCode
Okay, so I look in the SDK documentation for Units, and I find
STR - String
But when I try
myCell.putResult(STR, myPerson.getName() )
VC7 throws me an error.
And I try different variations and permutations with the age
parameter, to no avail.
Its a big issue of "I know what I want to set the value to, I know
the functions to set the value, but I can't set the value"
Thanks much for your time / help.
Post by Michel LAPLANE
You can also ask me more precise question in unsing C++ Viso api if
you want.
Post by Amir Soofi
This is kind of a newbie question, but I'm trying to use the C/C++
wrapper classes to define the custom properties of a shape (that
is, make rows, and fill in values respectively) but no matter what
permutation of commands I execute, I can't get the darned thing working
Could somebody please provide example code of how to modify / set /
read from a shape's Custom Properties?
Thanks!
Amir Soofi
2006-09-05 15:01:50 UTC
Permalink
Nope! I got it all fixed. Thank you very much for your help MIchel.

~Amir
Post by Michel LAPLANE
I'm back
Do you have always problems ?
Post by Amir Soofi
One quick annotation, in the line I have
Post by Amir Soofi
Post by Amir Soofi
propCell.FormulaForce(VBstr("Amir.Soofi"));
It should be
Post by Amir Soofi
Post by Amir Soofi
propCell.FormulaForce(VBstr("AmirSoofi"));
The difference is, the period that is no longer there. The additional
period will yield an error.
=D
Post by Amir Soofi
Hi Michel
I hope you're having a good vacation --
I finally got it all figured out, thank you though for all your help.
For anybody this may pertain to, who is also having troubles, this is how
to add a custom property using the C/C++ Wrapper Classes
*********************************************
short int shtRet=0;
CVisioShape myShape;
CVisioSection propSection;
CVisioCell propCell;
CVisioRow propRow;
myShape.AddSection(visSectionProp, &shtRet);
myShape.Section(visSectionProp,propSection);
myShape.AddRow(visSectionProp, 0, 0, &shtRet); //Here the 0 is the row
number, changes this if you want to add more
propSection.Row(0, propRow); //Here the 0 references the row number.
Change this for respective accessing
propRow.putName(VBstr("Name"));
propRow.Cell((VVariant)(long)0,propCell);
propCell.FormulaForce(VBstr("Amir.Soofi"));
*********************************************
It's very similar to what Michel gave me. It might in fact be the same,
but it works, regardless :)
~Amir Soofi
Post by Amir Soofi
I'm in vacation till end of july. If you have always problem with C++
Post by Amir Soofi
Hi Michel ~
When I try this code --
HRESULT hr;
CVisioShape visShape
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
strcpy(szName, "GHENT");
lAgeToSet=(long)12345;
hr = rangeShape.Section(visSectionProp,visSection);
if(!SUCCEEDED(hr))
printf("\n\tFail 1");
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
if(!SUCCEEDED(hr))
printf("\n\t\tFail 2");
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
if(!SUCCEEDED(hr))
printf("\n\t\t\tFail 3");
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\tFail 4");
hr =
visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
if(!SUCCEEDED(hr))
printf("\n\t\t\t\t\tFail 5");
vsoPage.drop(vsoMaster, x,y,vsoShape);
The result I get is
Fail 1
Fail 2
Fail 3
Fail 4
Fail 5
So every hr is failing. I've tried some things as to find out why, but
I would like to think
I have also tried moving the code to below the vsoPage.drop, but that
did not work either.
Post by Michel LAPLANE
Try this code. of course it is better to test the hr result for each
visio call.
HRESULT hr;
CVisioSection visSection;
CVisioRow visRow;
CVisioCell visCellVal,visCell;
long lType;
int lineIndex;
long lAgeToSet; // Your age value
char szName[128]; // Your name value
...
// set the age value or the name
....
// visShape is a visio shape
hr = visShape.Section(visSectionProp,visSection);
// set the line
lineIndex = 1; // for the first custom property
hr = visSection.Row(lineIndex,visRow);
hr = visRow.Cell((VVariant)(long)visCustPropsValue,visCellVal);
hr = visRow.Cell((VVariant)(long)visCustPropsType,visCell);
hr = visCell.ResultInt((VVariant)(long)visNumber,0,&lType);
if(type == visPropTypeNumber)
{
// for the age
hr =
visCellVal.ResultFromIntForce((VVariant)(long)visNumber,lAgeToSet);
}
else
{
// for string value
CString strFormula;
strFormula = '"';
strFormula += szName;
strFormula += '"';
hr = visCell.FormulaForce(VBstr(strFormula));
}
Post by Amir Soofi
Yeah, I got the SDK and all that jazz, , but the C# still has some
more versatility than the C wrapper classes.
I'll try to be as specific as possible.
What I'm trying to do is from an arbitrary data structure in C++,
fill in the custom property values with arbitrary data members in an
instance of a particular data structure.
A good example would be
struct person{
int age;
char name[128];
char gender;
}
What I have been able to do successfully is -
- Pull a shape from a stencil I've made beforehand
- Drop that shape on a visio page [so I can actually see it]
Now what I want to do is store the age and name inside of the custom
property fields.
So lets say my declarations are
CVisioShape myShape;
CVisioCell myCell;
person myPerson;
To tie myCell to myShape --
myShape.Cells("Prop.Row_1",myCell);
Now here I run into some qualms.
Assuming I wanted to set the name of the person as a custom
property - in the C# example, to set the cell equivalent to a string,
the SDK uses [without any included libraries] --
formatHelper = new StringValueInCell();
formatHelper.SetCellValueToString(customPropertyCell,
propertyValue.ToString());
VC7 catches an error trying to find StringValueInCell()
Additionally, I've tried
myCell.putResult, but putResult takes two arguments, and the first
one, being of type CONST VARIANT_HELPER_CLASS &UnitsNameOrCode
Okay, so I look in the SDK documentation for Units, and I find
STR - String
But when I try
myCell.putResult(STR, myPerson.getName() )
VC7 throws me an error.
And I try different variations and permutations with the age
parameter, to no avail.
Its a big issue of "I know what I want to set the value to, I know
the functions to set the value, but I can't set the value"
Thanks much for your time / help.
Post by Michel LAPLANE
You can also ask me more precise question in unsing C++ Viso api if
you want.
Post by Amir Soofi
This is kind of a newbie question, but I'm trying to use the C/C++
wrapper classes to define the custom properties of a shape (that
is, make rows, and fill in values respectively) but no matter what
permutation of commands I execute, I can't get the darned thing working
Could somebody please provide example code of how to modify / set /
read from a shape's Custom Properties?
Thanks!
Loading...