|
This might help but certainly there is a more elegant way to achieve this:
public ref struct structExample
{
public:
structExample()
{
x = gcnew array<unsigned char>(arraysize);
}
array<unsigned char>^ x;
private:
literal int arraysize = 2;
};
|
|
|
|
|
Can anyone point me to some reading material or examples that would allow me to change a simple test menu program like this:
<br />
#include <iostream><br />
using namespace std;<br />
<br />
void main()<br />
{<br />
int iChoice;<br />
<br />
cout << "Choose one... " << endl << endl;<br />
cout << "1. First" << endl;<br />
cout << "2. Second" << endl;<br />
cout << "3. Third" << endl;<br />
cout << "4. Fourth" << endl << endl;<br />
<br />
cin >> iChoice;<br />
<br />
switch (iChoice)<br />
{<br />
case 1:<br />
if (iChoice == 1)<br />
cout << "First" << endl;<br />
break;<br />
case 2:<br />
if (iChoice == 2)<br />
cout << "Second" << endl;<br />
break;<br />
case 3:<br />
if (iChoice == 3)<br />
cout << "Third" << endl;<br />
break;<br />
case 4:<br />
if (iChoice == 4)<br />
cout << "Fourth" << endl;<br />
break;<br />
default:<br />
cout << "Not a valid choice." << endl;<br />
}<br />
}<br />
into a console application that uses the up and down arrows to make a selection inside of the menu box instead of typing in "1" and then "Enter"? I would like to be able to open the program with the list of options inside of a colored box and output the result into another colored box.
-- modified at 4:36 Friday 10th March, 2006
|
|
|
|
|
is your question .NET framework relative ?
|
|
|
|
|
I am working in the Visual Studio .net environment. No matter where I look, it seems I can't find any solid information on creating a simple DOS shell console application that uses keyboard events to make an up down selection menu.
|
|
|
|
|
I'd be surprised if there is such support in .NET for menus on a console window.
The way it was done in DOS is to output the hi-lighted menu item with inverted colors.
Mainly your program will wait for a key stroke and then pass the stroke when it arrives to a switch statement. The switch statements determines which menu items need to be re-output to the console screen - and with what colors (inverted/regular).
Note that you need to use positioning functions to be able to output text in the same spot with different colors.
I have not implemented this with the recent CRTs - so, I'm not sure what the exact function names are.
gmileka
|
|
|
|
|
If you need menu in doos shel, then you must use graphic ap0proach of programing and itersept cursor key.
or:
when you press up or down key, then clear scrren and selected menu shoud be diffrent color or higlitet
|
|
|
|
|
Hi,
i have an application which is running as a windows service,
it's purpose is to poll different sensors in a specific interval. No problem so far and with .Net memory profiler i was able to reduce the memory consumption drastically (allocs are almost -> 0 byte/s).
But now the downside, my idea was to present the sensors data on a ASP.NET page. My first thought was using a webservice to connect the windows service with the IIS. However after reading a comparison between Remoting vs. Webservices i decided to do remoting with an IPC channel.
So far so good, i have implemented a very light Remoting object, in addition i use the IPC channel and binary formatters. But when my application was finally running i discoverd that each remoting call will take around 8 KB of memory! Furthermore it allocates at least 178! Instances of differnt .Net classes for each call.
Imagine that i have to update my data on the IIS every second and addionally i have more than one sensor. This would mean for example that 5 Sensors would cost 40 KB or more memory per second, surely the garbage collector will take care of it. But how long will it take until i get in serious memory trouble (like Memory Pressure by the framework)? I saw that the garbage collector is triggered every 10 s in the current setup (without remoting it's between 45 min - 2h)
There are a couple of Questions:
1. Is it possible to reduce the memory consumption of .Net remoting? (i saw no difference between singleton & singecall)
2. Is remoting not the right choice for my task?
BTW: The service is written in C++/CLI, the logic and pages on the IIS are in C#.
I would really appreciate any help! If needed i could also publish some code to resolve the issue.
ThanX Tobias
the remoting Interface (each call of GetIndex costs 8KB):
public interface class IRemotingLink
{
ArrayList^ GetSensorKeys (void);
array <unsigned char>^ GetIndex (String^ pSensorGuid, unsigned char pIndex);
array <array <unsigned char>^>^ GetIndices (String^ pSensorGuid);
bool SetIndex (String^ pSensorGuid, unsigned char pIndex, array <unsigned char>^ pIndexContent);
};
-- modified at 2:34 Friday 10th March, 2006
|
|
|
|
|
|
You really think people here will do your homework for you ?
If you want an answer, post specific questions and post what you already did.
|
|
|
|
|
thk for u all...i knw my fault...
i cant do tat like tis...sorry for disturd u all....
very apologize wit it....
|
|
|
|
|
|
|
yup, typo...
|
|
|
|
|
cusack! this is professor ulhas from the university. it told all of student to not cheat by gone to cpian and make others doubt the homework. but here i see u cheating. when i heard of this i wanted to slice my tongue open and a salted knife. that is how much ur cheatin hurts me. now u get black grade and fail.
Sincelery yours, Computer Information conSciences Professor and grader, Sharada Ulhas
|
|
|
|
|
thk for u all...i knw my fault...
i cant do tat like tis...sorry for disturd u all....
very apologize wit it....
im 2 care of my homework...
i scare will fail...i really no idea how 2 done..
whatever,i will take more time to revision all the things...
thk a lot
|
|
|
|
|
This CP forum is for people who can't continue their work, becase of the problem they can't solve. If you have a problem then ask if you want to other make your program, then don't even ask and start thinking.
|
|
|
|
|
i will not give up, i will convet this if its the last thing i do....
i am getting better though!!
void ManagedReadVoltage::ManagedDAQmxBaseCreateTask(const char taskName __gc[], TaskHandle *taskHandle)
{
DAQmxBaseCreateTask(taskName,taskHandle);
}
i am stuck here, i get this error...
'DAQmxBaseCreateTask' : cannot convert parameter 1 from 'const char __gc[]' to 'const char []'
the orginal code...
void UnmanagedReadVoltage::UnmanagedDAQmxBaseCreateTask(const char taskName[], TaskHandle *taskHandle)
{
DAQmxBaseCreateTask(taskName,taskHandle);
}
i have looked on google, but i can't get it working..anyway i need some sleep
thanks
|
|
|
|
|
|
Here is the code:
<br />
#include "class2.h"<br />
<br />
class A<br />
{<br />
public:<br />
A(void) {}<br />
~A(void) { if ( _cls2) delete _cls2; }<br />
public:<br />
void Create(void) { _cls2 = new B(this); }
void Display(void) { printf("from A"); }<br />
private:<br />
B * _cls2;<br />
};<br />
<br />
#include "class1.h"<br />
<br />
class B<br />
{<br />
public:<br />
B(A * ptr) : _cls1(ptr) {}<br />
~B(void) {}<br />
public:<br />
void Do(void) { _cls1->Display(); }<br />
private:<br />
A * _cls1;<br />
};<br />
But I got error on compiling
How to solve it?
|
|
|
|
|
in one of the files, before the definition of the class, declare the other one.
for example :
class A;
class B {
};
|
|
|
|
|
You mean combine two .h files into one .h file?
Is it possible to solve it in two .h files?
THX for your quick reply
|
|
|
|
|
shaohao wrote: You mean combine two .h files into one .h file?
no
file A.h
#include "B.h"
class A {
};
file B.h
#include "A.h"
class A;
class B {
};
|
|
|
|
|
But I think it should be:
<br />
file A.h<br />
<br />
#include "B.h"<br />
<br />
class A {<br />
};<br />
<br />
file B.h<br />
<br />
class A;<br />
<br />
class B {<br />
};<br />
Any idea?
Is it right?
-- modified at 9:11 Friday 10th March, 2006
|
|
|
|
|
Yes - this is correct. It compiles without a problem.
gmileka
|
|
|
|
|
i thought it would be better to make a new tread for this one.
i am trying to get this code to work, but i don't know what i'm doing wrong..
i know this much....
i have a class library(.net) called fooManaged and its automatical created fooManaged.h. and i created UnManaged.h
in the UnManaged.h file i have this code.....
#include iostream
#include vcclr.h
using namespace std;
class Foo
{
public:
Foo();
~Foo();
void DoSomeFoo();
};
// constructor
Foo::Foo()
{
cout<<"Constructor called!"<<endl;
}
destructor
foo::~foo()=""
{
cout<<"destructor="" called"<<endl;
}
="" some="" method
void="" foo::dosomefoo(void)
{
cout<<"do="" something="" funny!"<<endl;
cout<<"burrrp!"<<endl;
}
in="" foomanaged.h="" i="" have="" this="" code....
="" foomanaged.h
#pragma="" once
using="" namespace="" system;
namespace="" foomanaged
{
public="" __gc="" class="" mfoo
{=""
private:
foo="" *="" _foo;
public:
mfoo();
~mfoo();
void="" manageddosomefoo();
};
="" constructor
mfoo::mfoo()=""
{
_foo="new" foo();
}
="" destructor
mfoo::~mfoo()
{
delete="" _foo;
}
="" mfoo::manageddosomefoo()=""
{
_foo-="">DoSomeFoo();
}
}
the fooManaged.cpp file just has...
#include "stdafx.h"
#include "Unmanagedfoo.h"
#include "fooManaged.h"
#using mscorlib.dll
it all compiles...but there is a big linking error!!
Compiling...
fooManaged.cpp
Linking...
LINK : error LNK2020: unresolved token (0A000005) _CxxThrowException
LINK : error LNK2020: unresolved token (0A000019) free
LINK : error LNK2020: unresolved token (0A00001A) strlen
LINK : error LNK2020: unresolved token (0A00001B) memmove
LINK : error LNK2020: unresolved token (0A00001C) memcpy
LINK : error LNK2020: unresolved token (0A00001D) delete
LINK : fatal error LNK1120: 6 unresolved externals
i must be doing something wrong, some help with this will be very wecome
thanks
|
|
|
|