|
Hi
I’m trying to write a program that connects to AutoCAD 2002. I know that automation works with VARIANT data types. Also I found two nice MFC classes ‘COleVariant’ and ‘COleSafeArray’ to work with variants, but I could not find any class with an ‘operator []’ function that can access to elements of a variable of VARINAT type that has VT_ARRAY flag.
However if you have written some codes with VBA, you know that in VBA, with some simple codes like this you can access to elements of VARIANT:
Dim var As VARIANT
set var = MyAutoCADFunction ( … )
var(0) = 1
var(1) = 5
Do you know any predefined class in C++ to access this magic data type?
Thanks for your help
|
|
|
|
|
|
Thanks Anthony
I study _variant_t in 'comutil.h'. This is a very useful class for gathering information about a VARIANT, but I could not find an operator [] for VT_ARRAY variants. However I tried to use one of the exist overloaded operators, for example 'operator double()', but I get an unresolved external message when I build my project. The message says that the function '_com_issue_error' that used by 'CheckError' is missing. Now I need to know name of the library that contains this function. I hope that this works for VT_ARRAY.
Thanks again for your attention.
|
|
|
|
|
Hope this helps.
I guess _variant_t is not suitable for your case.
You are doing VBA right. I did Office Automation which automate Ms Excel before.
You should stick back to COleSafeArray.
The codes is in the MSDN but anyway. I paste it here so that you could refer it.
void CSAProjDlgAutoProxy::Sort(VARIANT FAR* vArray) <br />
{<br />
COleSafeArray sa;<br />
BSTR *pbstr;<br />
TCHAR buf[1024];<br />
LONG cElements, lLBound, lUBound;<br />
<br />
USES_CONVERSION;<br />
<br />
if (V_VT(vArray) != (VT_ARRAY | VT_BSTR))<br />
AfxThrowOleDispatchException(1001, <br />
"Type Mismatch in Parameter. Pass a string array by reference");<br />
<br />
sa.Attach(*vArray);<br />
<br />
if (sa.GetDim() != 1)<br />
AfxThrowOleDispatchException(1002, <br />
"Type Mismatch in Parameter. Pass a one-dimensional array");<br />
<br />
try <br />
{<br />
sa.GetLBound(1, &lLBound);<br />
sa.GetUBound(1, &lUBound);<br />
<br />
sa.AccessData((LPVOID*)&pbstr);<br />
<br />
cElements = lUBound-lLBound+1;<br />
for (int i = 0; i < cElements-1; i++)<br />
{<br />
wsprintf(buf, "%s", OLE2T(pbstr[i]));<br />
OutputDebugString(buf);<br />
}<br />
<br />
sa.UnaccessData();<br />
}<br />
catch (COleException *pEx)<br />
{<br />
AfxThrowOleDispatchException(1003, <br />
"Unexpected Failure in FastSort method");<br />
pEx->Delete();<br />
}<br />
}
Code above shows how to retrieve the VARIANT with array type and access via sa.AccessData((LPVOID*)&pbstr). The pbstr the void* pointer.
I guess there is no easy way out. If you still like the operator[] overload. Try to write your own class by inherit this COleSafeArray;)
|
|
|
|
|
Thanks again Anthony, I will try your suggession.
|
|
|
|
|
i use SHAppBarMessage(ABM_SETAUTOHIDEBAR, &abd) to register an autohide app desktop toolbar,the return code is true,while it seems not success.
while i can use SHAppBarMessage(ABM_NEW, &abd) to register a normal app desktop toolbar.
so what's the problem?and are there any points that should be noticed while register the autohide bar?can anybody tell me?thanks.
Thank everyone who helps me.
|
|
|
|
|
hi,
I am a beginer.
can any one guide me...
what is MakeFile and Where it is useful?
regards
kiran
|
|
|
|
|
|
Thank you for reply.
what is the use of makefile in vc++ environment?.
regards.
|
|
|
|
|
Anonymous wrote:
what is the use of makefile in vc++ environment?
The same use they are anywhere - to build stuff.
The MSVC IDE's aren't only inherently slow, crash-prone and basically unusable as build-system for large projects, they are also inherently proprietary. Makefiles are basically still one of the only (reasonably) portable ways to build any kind of cross-platform code.
If you are only interested in a particular version of a particular vendor's IDE for small-to-medium-sized projects where everyone to build the code uses the same version of IDE, you probably couldn't care less about makefiles, but once you go outside that MS-only environment, makefiles are not just a good thing - they close to a requirement (with the exception that Jam seems to gain ground in some places).
|
|
|
|
|
Hi Mike Nordell,
Thank you for your information.
May I know in more about makefile in this way....
i have an application SomeAbc.exe.This application contains One.cpp,One.h,Two.cpp,Two.h,....etc.Suppose i have to change some code in One.cpp after i intalled my SomeAbc.exe in client machine.In this way,how the Makefile useful for me.
Thanks & regards,
kiran
|
|
|
|
|
It wouldn't be useful for your case because you have only one *.exe and you still need to rebuild your *.exe.
For your case, I think you should divide your program into chunks example into DLLS. Then, say if you were to update a class which is located in DLL A. You only need to update that particular DLL.
Or
You could use some third party software which allows you to develop your patch. Basically this software will allow you to designated which portion of codes to be patched. i have not try this before but I knew it exists.
Try this (I found it in Google)
http://www.workshell.co.uk/products/patchbld/[^]
|
|
|
|
|
Thank you for your Information.
regards,
kiran
|
|
|
|
|
persList.push_back ( person("McDonald","William","4753212") );
persList.push_back ( person("Wellington","Jack","8452334") );
persList.erase(persList.begin()+1);
how do you remove an element from a list of objects
i tried the above code
it doesnt work
any ideas??
|
|
|
|
|
If you are 100% sure the list contains at least two entries, you could try to replace:
persList.erase(persList.begin()+1);
with
persList.erase(++persList.begin());
You can't add an integer to an iterator.
|
|
|
|
|
Hiya I am using CDocument::OnFileSendMail to send an email. But when the email opens up, it has a default temporary file with it.
How do I change this so I can make the file one of my files when It first opens up?? like a .doc or a .txt file.
Also I am using the remove function to remove a file in a directory. i.e
remove( "directory\\pxbatch.pmx" );
But it won't remove the file. if I leave out the directory part, it works fine and removes the file, but when directory is in it fails. The file I want to move is in a directory.
Thanks.
|
|
|
|
|
Does anyone have any ideas on how to do this??
Thanks.
|
|
|
|
|
i'm creating a game that should print numbers in a grid.the problem is i can use the library functions outtext(),outtextxy() for print only strings but not numbers which need to be interchanged during various steps of the game.to be specific,i got to place the cursor at some central position on the screen and print a number.can anyone help me out??
thanx in advance..
|
|
|
|
|
What language/library are you using? I don't recognise outtext() or outtextxy() . The only place I know them from is the old Borland Turbo Pascal/C BGI drivers, but I haven't used them for years.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Ryan Binns wrote:
The only place I know them from is the old Borland Turbo Pascal/C BGI drivers, but I haven't used them for years.
Same here...
John
|
|
|
|
|
For fullscreen games, use OpenGL or DirectX. I found OpenGL was easier to learn. They both deal with 2d and 3d graphics.
I can't help you for non fullscreen games like minesweeper though... perhaps learn GDI+ or something?
dog_spawn
http://hatekill.yojutsu.com[^]
|
|
|
|
|
dog_spawn wrote:
perhaps learn GDI+ or something?
GDI+ is nice and powerful, but much slower than GDI, although for a simple game like minesweeper, I'd hardly say performance was an issue
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
dog_spawn wrote:
They both deal with 2d and 3d graphics.
Uhhh, in all honesty OpenGL is a 3D API. Sure, you can (with some effort) use its 3D functionality (slapping quads) in conjunction with awkward texture-replacing primitives to implement a 2D API, but then you also can use a hammer to pound on the keyboard.
DirectDraw/DirectX deals with 2D gfx in a way more direct, to-the-point and familiar way than any 3D API ever could, or even should, do.
If the game gfx-speed isn't time critical, I'd rather suggest GDI than DirectDraw (since the latter is inherently way more complex and error-prone). Creating a DIBSection and blitting around within only the gfx cards memory can get you quite reasonable speeds also (way faster than screen refresh rate).
|
|
|
|
|
i think that you are using the good old turbo c++.
try the funtion itoa(int val,char* buffer,int base) to convert the integer to a string and then use the string.
for floats you can use ftoa(float val,char* buffer,int base).
to get the int ir the float back use atoi or atof etc.
The Debugger
|
|
|
|
|
hey debugger thanx man..i wanted exactly that!!these guys were talking about openGL and all that stuff.hey but i'm just a tyro..thanx once again.i'll try that out.. ;)
|
|
|
|