|
The 'using' statement should do the trick. Why do you have it commented out?
gmileka
|
|
|
|
|
I had this commented out, and some other parts, because i've been trying to combine different examples I found on the net.
And the "using" doesn't seem to make a difference, while I still get the same "error C2065: 'InDesign' : undeclared identifier
" error.
Erik
|
|
|
|
|
The following line:
InDesign.Application app = (InDesign.Application) COMCreateObject("InDesign.Application");
should be:
InDesign::Application app = (InDesign::Application) COMCreateObject("InDesign.Application");
(not sure what COMCreateObject returns).
In general, whenever you are qualifying something with a namespace, use the scope operator ::. Unlike C#, C++ differentiates between types and instance of types.
For type qualification, it's type::identifier or namespace::identifier
For instance qualification, it's instance.identifier or instance->identifier
(those are only examples of course).
C# always uses the dot operator no matter what...
gmileka
|
|
|
|
|
|
I have added the reference to the com object, what do I have to do to get an object of the type InDesign.Application? Or am I going wrong way with this
Let me clearify what I'm trying to get:
I want a simple webservice, that will allow me to call the 'runscript' method on the Adobe InDesign COM object.
The webservice I was able to create, now I only need to call the runscript from the webservice and return it's results.
So if someone knows a different way to do this in c++, your help is more than welcome...
TIA Erik
|
|
|
|
|
I have a problem. I have been trying to output a triangle using asterisks. However I know I need to use nesting. For example: What other instructions do I need to finish this problem?
#include '<iostream>'
using namespace std;
void main()
{
int = '*';
int = counter + 1;
for(counter + 1; counter >= 10; counter = counter + 1)
{
cout << '*' << endl;
}
}
Charles Reese
|
|
|
|
|
1. Try to avoid double posting (Don't worry, sometimes it happend to me)
2. This thread should be in "Visual c++/MFC" not in "C++/CLI"
3. Is this C or C++
Charles Reese wrote: int = '*';
int = counter + 1;
4. I don't get it, something is missing.
5. The problem is very simple you need 3 for loops
<br />
for (int i = 0; i>= 10; i++)<br />
{<br />
int h=i/2;<br />
int numberofasterix = i*2+1;<br />
for (int j= 1; j>=numberofasterix ; j=++)<br />
{<br />
for (int k=h; k>=0; k--)<br />
{<br />
cout << " ";<br />
}<br />
cout << "*";<br />
}<br />
cout << endl;<br />
}
ps: I hope this works, because i currently didn't install Visual Studio 2005. Maybe the code will not work propeperly, but it is still better than yours.
|
|
|
|
|
I have a problem. I have been trying to output a triangle using asterisks. However I know I need to use nesting. For example: What other instructions do I need to finish this problem?
#include <iostream>
using namespace std;
void main()
{
int = '*';
int = counter + 1;
for(counter + 1; counter >= 10; counter = counter + 1)
{
cout << '*' << endl;
}
}
Charles Reese
|
|
|
|
|
I'm now doing a project, and what I need to do is firstly read a txt file using i/o stream. I've include the lib and since I need to do it in the .NET form (header) and I want to make it such that when I click the button, it will do the file read-in.
But I cannot add file declaration such things into the header, as there's no main func there. What should I do? Coz I wanna relate the file read-in to the button.
Million thanks!!
|
|
|
|
|
kkyeung wrote: But I cannot add file declaration such things into the header, as there's no main func there. What should I do? Coz I wanna relate the file read-in to the button.
The main func only show one form. Then the form is handling evrything else.
declare in a forn inside class of the form.
kkyeung wrote: I've include the lib and since I need to do it in the .NET form
you don't need to include lib. you can use .net:
using namespace System::IO;
StreamReader;
-- modified at 2:39 Thursday 4th May, 2006
|
|
|
|
|
I have a form called form1.h, and respectively form1.cpp. I have the following code:
#include "stdafx.h"
#include "Form1.h"
#include <windows.h>
#include <iostream>
#include <fstream>
using namespace fyp1;
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
System::Threading::Thread::CurrentThread->ApartmentState = System::Threading::ApartmentState::STA;
ifstream iFile("test.txt");
Application::Run(new Form1());
return 0;
}
I wanna add ifstream into above so that I can read-in a file, then pass the parameter into Form1(). But how can I do that? (ignore the button problem, i don't need it now)The above code cannot be compiled.
Thanks again.
-- modified at 15:09 Thursday 4th May, 2006
|
|
|
|
|
As i told you, you will need StreamReader. It is .NET class, not MFC or other, so there you musn't include iostream, fstream and windows.h. Include file Windows.h often couses compile problem in .Net framework project. so remove all these include
you will Need to add in form1.h file not in form1.cpp.
using namespace System::IO;
public ref class Form1: public System::Windows::Forms::Form
{
public:
Form1(void) ...
...
Private: StreamReader ^streamFile;
Private: String ^streamReadLine;
...
public: ReadFile(void)
{
streamFile = File::OpenText("test.txt");
while (streamFile->EndOfStream != true)
{
streamReadLine = streamFile->ReadLine();
}
}
};
If you still don't know, at least tell me witch .net framework you are using.
|
|
|
|
|
I maintain a Visual C++ Version 6 app. It takes data structures from an Excel app, processes results, and returns structures to Excel. I must now write a C++ .Net wrapper, to take datasets from a VB.Net calling app, create structures from the datasets, send the structures to the Visual C++ Version 6 app, get the return structures, then create and return a dataset to the VB.Net calling app.
I have not been able to expose a public function in the C++ .Net wrapper.
The C++ .Net header code is:
using namespace System;
using namespace System::Data;
using namespace System::Runtime::InteropServices;
namespace TK_DLL_Header {
public class TK_DLL
{
public:
// constructor
TK_DLL();
// destructor
~TK_DLL();
unsigned short ProcessResults (DataSet dsStudyParm, DataRow drFinParms);
};
}
The C++ .Net .cpp code is:
#include "StdAfx.h"
#include "TK_CPlusPlus_Class_Library.h"
using namespace System;
using namespace System::Runtime::InteropServices;
const unsigned short TK_TRUE = 1;
const unsigned short TK_FALSE = 0;
//#define BDS_TK_API __declspec(dllexport)
using namespace TK_DLL_Header;
//namespace TK_DLL_Header {
unsigned short TK_DLL::ProcessResults(System::Data::DataSet dsStudyParm, System::Data::DataRow drFinParms)
{
BDS_ClearAggreg();
return TK_TRUE;
}
[DllImport("BDS_TK.dll", EntryPoint="BDS_ClearAggreg")]
short BDS_ClearAggreg();
I have attempted to access the ProcessResults function in a VB.Net app, in two ways. First, using intellisense:
‘ this statement works
Dim tk As New TK_DLL_Header.TK_DLL
‘ this statement does not work; ProcessResults is not in the list of items after tk.
result = tk.ProcessResults(dsStudyParm, drFinParms)
tk.ProcessResults has a blue line under it; a mouse-over message says “ProcessResults is not a member of TK_DLL_Header.TK_DLL”
In the same VB.Net app, I have added the following declaration at the top of the file:
Private Declare Function ProcessResults Lib "TK_CPlusPlus_Class_Library.dll" (ByRef dsStudyParm As DataSet, ByRef drFinParms As DataRow) As Integer
Using the following call:
result = ProcessResults(dsStudyParm, drFinParms)
Raises the error message:
“Unable to find an entry point named ‘ProcessResults’ in DLL ‘TK_CPlusPlus_Class_Library.dll’
I am missing something very fundamental here. If anyone can help, re how to expose a public function from VC++ .Net, it would be greatly appreciated.
Thanks.
ppanke
|
|
|
|
|
Your assumption is very correct that you are missing something very fundamental here .
The class you declared is not a managed class. it is an unmanaged. To make it a managed type change the class declaration by adding the modifer ref (for .Net 2.0) or __gc (for .Net 1.1) .
so the new class declaration will be:
.net 1.1<br />
namespace TK_DLL_Header {<br />
<br />
public __gc class TK_DLL<br />
{<br />
public: <br />
TK_DLL();<br />
~TK_DLL();<br />
<br />
unsigned short ProcessResults (DataSet dsStudyParm, DataRow drFinParms);<br />
};<br />
}<br />
<br />
.net 2.0:<br />
<br />
namespace TK_DLL_Header {<br />
<br />
public ref class TK_DLL<br />
{<br />
public: <br />
TK_DLL();<br />
~TK_DLL();<br />
<br />
unsigned short ProcessResults (DataSet dsStudyParm, DataRow drFinParms);<br />
};<br />
}
cheers..mil10
|
|
|
|
|
Thanks, but when I added the ref keyword, the class would not compile (it compiles fine without ref). I got an "unresolved externals" error. I do not know why.
P. Panke
|
|
|
|
|
what is he unresoleved external sybal. I meant which function is unresolved ?
|
|
|
|
|
I want to use the timeSetEvent in the C++/CLI for a 1msec timing resolution.
I seem to have a problem in the CALLBACK function and when i try to replace it with a delegate i have other problems.
Can anyone show me the way to use timeSetEvent with a CALLBACK/Delegate function that actually work?
|
|
|
|
|
SampleForm::SampleForm()
{
InitForm();
}
void SampleForm::InitForm()
{
Timer* timer1;
timer1 = new Timer();
timer1->Interval = 3000; // 3 seconds resolution
timer1->add_Tick(new EventHandler(this,OnTimer));
timer1->Start();
}
void SampleForm::OnTimer(System::Object* obj,System::EventArgs* ea) //declare as static method in .h file
{
}
^-^
@|@
- redCat
|
|
|
|
|
this is now the timeSetEvent, but the Timer class.
The Timer class accuracy is very poor, unlike the timeSetEvent.
Can anybody show me how to use it in c++/cli .net 2005?
|
|
|
|
|
First of all, you should note that accuracy is not the same as precision[^]. 10ms is pretty much the most accurate you can get with Win32, without screwing with the operating system metrics or reinstalling the HAL.
But anyway, you use timeSetEvent in C++/CLI the same way you use it in Win32.
#include <windows.h>
#pragma comment(lib, "winmm")
public ref class TimerWrapper
{
EventHandle ^eventHandle;
public:
TimerWrapper()
: eventHandle(false, EventResetMode::AutoReset)
{
}
int TimerFunc()
{
for( ; ; )
{
eventHandle->WaitOne();
...
}
}
void UseTimeEvent()
{
timeSetEvent(100, 55, reinterpret_cast<LPTIMECALLBACK>(
eventHandle->SafeWaitHandle->DangerousWaitHandle().ToPointer()),
0, TIME_ONESHOT | TIME_CALLBACK_EVENT_SET);
...
}
};
-- modified at 17:31 Saturday 13th May, 2006
|
|
|
|
|
can anyone tell me how do i get the current directory in VC++ managed code?
|
|
|
|
|
String^ strCurDir = System::IO::Directory::GetCurrentDirectory();
cheers...mil10.
|
|
|
|
|
This is a C++/CLI forum. So it is asumed that all questions will be related to Managed platform. Anyway your post will be helpful for him, if he need the answer in Win32.
rgds...milton.
|
|
|
|
|
I have just recently started Computer Science as my major in college. I love playing online games and many people that I know program games online. I am using Dev-C++ as well as VB 6. My question is does anyone know where i can start on programming a videogame online.I have an encryption for a game I am curious on how to get and encryption and how to input it into text in C++ to build the game and the proxy.
Thanks
|
|
|
|
|
I am trying to use http: to retrieve a web site in html into a buffer in memory.
My code is as follows:
int Socket = clientSock(url.c_str(), 80);
if (send(Socket, (char*)str.c_str(), str.size(), 0) == SOCKET_ERROR)
{
//throw an error exception
}
Sleep(1000);
char buf[500];
int sizeOfBuf = sizeof(buf);
int bytes_read = 0;
int total_bytes_read = 0;
do
{
bytes_read = recv(Socket, buf, sizeOfBuf, 0);
myStrBuffer += RCString(buf);
total_bytes_read+=bytes_read;
memset(buf, 0, sizeof(buf));
}
while (bytes_read != 0);
where url is the host (ie "www.bbc.co.uk")
page is the relative url (ie "/sport/football")
However I cannot rerieve the information required... what i actually get is
"HTTP/1.1 400 Bad Request".
can anyone help me as to why this is happening as well as how to fix it.
Also i need to retrieve a web site with parameters
''[^]'
where 'epp.eurostat.cec.eu.int' is the host and '/portal/page' is the relative url. and everything else is a parameter list and i am unsure of how to do this.
any help would be greatly appreciated
cheers
anthony
|
|
|
|