|
Hi,
I am new to .NET.
I have a managed .NET DLL that I need to use with some of my visual C++ code. (I have both Visual C++ 6.0 and Visual Studio .Net).
My understanding is that all the information (.lib .h) is contained within this .Net DLL and that it is all I need.
How do I incorporate this into my c++ app or solution, reference the calls and link successfully?
First, Can I do this and second, how do I go about doing it?
Thanks for you help
Phil
|
|
|
|
|
Hello,
I have a project that crashes at run-time due to an Access Violation. The violation occurs in a section that looks something like this:
double var;
for (iter = ptrA->getPtrB()->getCList().begin();
iter != ptrA->getPtrB()->getCList().end();
iter++)
{
var = iter->getVar();
}
A, B, and C are classes that have been defined elsewhere.
iter is an iterator of type std::list<c>.
ptrA is a pointer to an object of type A.
ptrB is a pointer to an object of type B.
getCList is a method in the B class that returns a list of C objects.
I have changed the names of the variables for simplicity.
When I debug at run time it brings me to the line starting with "for".
I cannot figure out where the problem is. My only hunch is that it might have something to do with the fact that the list that getCList() returns is actually NOT a list of C objects. Rather, it is a list of "D" objects where D is a class derived from C. Is that a problem? Does anyone else have anything else to suggest checking in the class definitions or anywhere else? I'd be happy to post more code if anyone thinks that would help...
Thank you!
-Jordan Atlas
|
|
|
|
|
I can't figure it out because your codes are too complicated!
I suggest you modify it like this:
somelist listsome& = ptrA->getPtrB()->getCList();
for (iter = listsome.begin();
iter != listsome.end();
iter++)
{
var = iter->getVar();
}
Because the first ptrA->getPtrB()->getCList() may be not as the same as your second ptrA->getPtrB()->getCList().
|
|
|
|
|
Hi Jordan,
I assume that getCList is defined like so:
list<obj> getCList()
Instead of getCList returning a list, I suggest it returns a reference to the list. Meaning, your function will change to this:
list<obj>& getCList() // just a small ampersand added...
I'm sure if you make this change in the function declaration, the rest of your code will work just fine.
Clinton
|
|
|
|
|
Hello,
Thank you both for your replies. It seems like you were both suggesting different flavors of the same idea. I tried both implementations and in both cases I still had a runtime error of "Access Violation". In this case, however, the debugger brought me to a spot in the file XTREE (which I assume is part of the STL?) instead of to the line in my code. Do you have any other suggestions?
Also, I'm still wondering if the iterator is having a problem with the list I am retrieving being a dervied class rather than the class the iterator was created with.
Thanks,
-Jordan
|
|
|
|
|
I 2 global variables:
bool PrintBoard[5][5];
bool MemoryBoard[5][5];
Then I have a function:
void DoMove(int x,int y)
{
x--;
y--;
PrintBoard[x][y] = !PrintBoard[x][y];
if (y > 0) {
PrintBoard[x][y - 1] = !PrintBoard[x][y - 1];
}
if (y < 4) {
PrintBoard[x][y + 1] = !PrintBoard[x][y + 1];
}
if (x > 0) {
PrintBoard[x - 1][y] = !PrintBoard[x - 1][y];
}
if (x < 4) {
PrintBoard[x + 1][y] = !PrintBoard[x + 1][y];
}
return;
}
As you can see, the DoMove function only changes PrintBoard.
I would like it to be able to change either variable with out much more code (I don't see the point of re-using code here).
I was thinking I could do something like adding another argument to the function that I could pass the global to it, but I couldn't figure out how.
Any Ideas? Thanks
|
|
|
|
|
void DoMove(bool Array[][5], int x, int y)
{
x--;
y--;
Array[x][y] = !Array[x][y];
...
}
...
DoMove(PrintBoard, 2, 3);
DoMove(MemoryBoard, 3, 4);
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
|
I have an MFC app that ASSERTS in CWnd::WalkPretranslateTree with a message being sent to main window after my main window is destroyed as I exit the application. The ASSERT is becuase the HWND being checked is no longer a valid window. It is a fairly large application that compiles and executes without problem on my old WinXP Home (SP1) machine with MSVC6 - but does this ASSERT in my new WinXP Pro (SP2) machine - no change in code.
The offending message is in the range of message numbers for Registered Window message. It is not one that is registered by my program.
How can I track what this message is and what program sent this? Is there a way to list all Registerd messages? Is there a way to set SPY+ or some such program to watch for this message?
I would appreciate any help.
|
|
|
|
|
Hello friends
I would like to capture datalink frames passing through my network card using sockets. I have found the following code snippet in a Network Programming book
sd = socket ( AF_INET, SOCK_PACKET, htons(ETH_P_ALL);
to capture all the datalink frames, i.e., frames with source and destination MAC address .(UNIX environment)
Is there an equivalent in Windows ?
|
|
|
|
|
There are four guys trying to get home at night and in order to do so, they MUST cross a bridge. It's very dark and there is only one torch available. The bridge can ONLY support "TWO" person at a time. Now, a bomb has been set on the bridge which will explode in 18 mins. Due to the fact that each person's travelling speeds are different, therefore some will obviously take longer to cross than others.
The time that each person takes are as followed:
A = 1 min
B = 2 min
C = 5 min
D = 10 min
Torch = 1 Qty
Here's how it works: If D & A goes first, it'll require 10 mins for them to cross the bridge together. By the time A gets back with the torch to B&C...11 mins will be passed already.
The total time required is : 17 mins
the solution to it is:
A and B first - 2 minutes (max 2 )
A runs back with torch = 3 minutes
C and D Next = 13 minutes ( max 10 )
B comes back with the torch = 15 minutes ( max 5 )
A and B again = 17 minutes
Can anyone tell me the code to this problem in turbo c or vc urgent please please. many many thanks in advance.
Babur Khan
|
|
|
|
|
Have you tried to solve it yet? Lets see your attempt and we'll try to help you along.
Alex Korchemniy
|
|
|
|
|
Hmm, sounds like you get some interesting HOMEWORK problems.
|
|
|
|
|
I am trying to communicate with a Serial Port, but I need to Delay 80ms (milliseconds) before reading from the port. Does anyone know of a way to Delay 80ms in c++ that isnt system specific? Meaning it can work on any machine regardless of cpu speed?
Thanks
P.S. I tried Sleep() but it seemed to block the data from the port and I couldnt read.
|
|
|
|
|
i face similar problem lik you but i solved that in little different way .
I created a Thread for Serial Port Processing and comunicate with main thread with help of events.
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
any chance you could post an example?
|
|
|
|
|
Can't you use SetTimer , KillTimer and OnTimer ? These work in millisecond units.
The tigress is here
|
|
|
|
|
Aren't windows timers only approximate? The original poster was stating 80ms - if this is a finger in the air value then SetTimer is good, else if it is exactly 80ms they need to wait, then this might cause issues?
From VC++ help :-
"Each time the specified interval (or time-out value) for a timer elapses, the system notifies the window associated with the timer. Because the accuracy of a timer depends on the system clock rate and how often the application retrieves messages from the message queue, the time-out value is only approximate. "
*********************************************
The sooner you fall behind, the longer you have to catch up.
|
|
|
|
|
the problem:
have a SDI application , and need to create a "external" CWnd to the Mainframe (mainframe will recieve messages from the new window)
much like a tool window.
i want the new CWnd to be topmost and remain in the screen on top of all windows even if the application main window (mainframe) is not visible (i.e minimized)
the problem is that the new CWnd gets minimized with the application main window
any ideas?
"There is no sin in making an error - we all do, and that's how we learn. Sin lies in letting stand an error, once we discover it, without correcting it." Roger Wright
|
|
|
|
|
You can use SetWindowPos api with the External Window,you can read it documentation in MSDN
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
I am doing a program for school, and I am to be tested for all situations. I believe that I have all of the otehr errors accounted for, but I have no idea how to handle the error when the user enters a "letter" into the console while they're playing the game(it's a simple guess the number game)... Any help would be greatly appreciated.
|
|
|
|
|
Hi There!
Simply use
IsDigit() function to check the valid charater is entered.
here a little code snippet
char ch;
ch=getch();
if(!isdigit(ch))
{
cout<<"please enter right character";
return;
}
else
{
........
carry on to program
........
}
-----------------------------
"I Think this Will Help"
-----------------------------
Alok Gupta
visit me at http://www.thisisalok.tk
|
|
|
|
|
Hi,
How can I get the handle of the window of a process if I know the process id.
I need either the first window of a process or the topmost window or if there is a function that enumarates all the windows of a process that would also be good.
PS I don't want to enum all the windows on the desktop, that I know how to do but I am keeping it as a last resort option because that would consume a lot of resources unnecesarrily.
there must be a more efective way to do this like some kind of api that lets you enum only the windows from one process, no?
thank you in advance
please reply.
|
|
|
|
|
just get the window by enumerating them, then call GetWindowThreadProcessId() and compare it with your process ID you have. I hope this helps
gabby
|
|
|
|
|
How do I pass a CArray<struct, &struct> as a reference to a function?
I've tried the obvious &m_caArray
The function is defined as:
fn(CArray * caItem, int index)
....
I've tried defining the parameter as CObArray (and type cast the arguement) instead also but that didn't work either.
I keep getting the error:
"cannot convert parameter 1 from 'class CArray<struct,struct &> *' to 'class CObArray *'
-Steven Hicks
CPACodeProjectAddict
|
|
|
|