|
Hi,
Now ,I have a problem.
I am programming the project need multi-COM ports.So far ,my useing programming computer is Laptop ,has one COM1 and one Modem COM2,and one Virtural Infrared COM port.But in Programming Project,I add a MSComm ActiveX controls assume it is COM5,Because there is no COM5(and there is no logic errors),so when the project compiling,the whole system is down,and blue screen,display the VxD errors,For solveing the problem ,I install a multi-COM port driver ,can add some virtual COM ports,See the attached pic(there is a link)
But I Compiled it again ,the system is down and blue screen display VxD errors!There is good solution?
|
|
|
|
|
Hi All,
I have a dilemma. I'm wrapping existing code that prints to stdout. I don't want those prints to show up on the screen, so I've redirected it using:
// redirect stdout to bit bucket
FILE* f = freopen("nul", "w", stdout);
I then created my own stream that prints to the console using:
// create a new stream to the console
fstream myStream;
myStream.open("CONOUT$");
Whatever I print using myStream shows up on the screen, which is what I want.
My problem? I can't redirect that output to a file! I push a ton of data out myStream, and really need the ability to redirect it.
Is there a limitation where only file handles associated with stdout itself, and not "CONOUT$", can be redirected to files?
Any insight on this would really, really be appreciated.
|
|
|
|
|
The following is an extract from "Conversations: Redirections", by Jim Hyslop and Herb Sutter from CUJ, to see the whole artical goto
http://www.cuj.com/experts/1903/hyslop.htm?topic=experts[^]
#include <iostream>
#include <fstream>
int main()
{
std::ofstream logFile("out.txt");
std::streambuf *outbuf = std::cout.rdbuf(logFile.rdbuf());
std::streambuf *errbuf = std::cerr.rdbuf(logFile.rdbuf());
// do the actual work of the program;
std::cout << "This would normally go to cout but goes to the log file\n";
std::cerr << "This would normally go to cerr but goes to the log file \n";
logFile << "This goes to the log file\n";
// restore the buffers
std::cout.rdbuf(outbuf);
std::cerr.rdbuf(errbuf);
}
|
|
|
|
|
Hi all. First, thanks for all the cool articles around. Really helpful.
Second, I got a dumb question:
I created a CStatic-derived class because I hate the normal groupbox MFC provided. Lets call it CBetterGroupbox.
I put in CBetterGroupbox::addMember(CWnd* member) which does member->SetParent(this). For everything that is supposedly "in" the groupbox, I call addMember. I have to do this since the draw order of MFC put all my buttons "under" the CBetterGroupbox background. It works fine. The controls are now drawn after CBetterGroupbox::OnPaint is done.
However, now when I click a button, the handler in the main dialog is not called, probably since the message map now sends the ON_BN_CLICKED messages only to the CStatic level, not to CDialog level. How do I fix this? Is there any easy way to pass all the messages a class receives up to its parent?
Desperately looking for help.
|
|
|
|
|
You can do this overriding OnCommand() and send a WM_COMMAND messages to the parent in response, such as
CBetterGroupbox::OnCommand(WPARAM wParam, LPARAM lParam)
{
CWnd *pParent = GetParent();
ASSERT_VALID(pParent);
pParent->SendMessage(WM_COMMAND, wParam, lParam);
}
This should take care of any control command messages, but it won't help with common controls that use WM_NOTIFY messages.
However, a better way would be to call SetOwner() on the child windows to set their owner to the dialog box. This will cause all the control messages to be sent to the dialog box instead of the group box. I'm not sure if this works for common controls, though. I think it does, but perhaps you can test it
Hope this helps
Ryan
Being little and getting pushed around by big guys all my life I guess I compensate by pushing electrons and holes around. What a bully I am, but I do enjoy making subatomic particles hop at my bidding - Roger Wright (2nd April 2003, The Lounge)
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"
|
|
|
|
|
A CGI program written in C++, printing using the Win32 API, is run by IIS. Instead of routing the output printer file to the printer it tries to return it to the browser. Apache and Tomcat successfully route the printer file to the printer. Does anyone know why IIS is doing this?
|
|
|
|
|
How are you opening and printing to the printer? Remember that CGI hosts remap and capture the standard output streams (for ease of development of CGI progs) and redirect the output back to the browser. Also, remember that typically IIS runs under the LocalSystem account and does not have access to network resources.
|
|
|
|
|
I am trying to copy contenst of the client area in the window, from a C++ appliation to the MS Word. I am trying to copy to a clipboard using CMetaFileDC and I would like to paste it to the word project. This is what I have so far.
if ( OpenClipboard() )
{
EmptyClipboard();
//create the metafile DC
CMetaFileDC * cDC = new CMetaFileDC();
cDC->CreateEnhanced(GetDC(),NULL,NULL,"the_name");
//DRAWING PROCEDURE USING cDC....
//close meta CMetafileDC and get its handle
HENHMETAFILE handle = cDC->CloseEnhanced();
//place it on the clipboard
SetClipboardData(CF_ENHMETAFILE,handle);
CloseClipboard();
//delete the dc
delete cDC;
}
_Application objWord;
COleVariant vtOptional((long)DISP_E_PARAMNOTFOUND,VT_ERROR),
vtTrue((short)TRUE),
vtFalse((short)FALSE);
// Get the IDispatch pointer and attach it to the objWord object.
if (!objWord.CreateDispatch("Word.Application"))
{
AfxMessageBox("Couldn't get Word object.");
return;
}
objWord.SetVisible(TRUE); //This shows the application.
I am suck in opening the MS Word project and I can't seem to paste the contents of the clipboard. Is this logic correct. Does anybody have a suggestion on how to paste the contents of the metafile??? Thanks.
|
|
|
|
|
Okay I'm totally new to MFC and I have no idea how I can stop my program from quitting everytime I press Enter Anyway, I have two Edit controls, one is for entering the text and the other is more of an info box (I'm making a game if you really want to know).
Also if anyone could help me figure out what the best way of appending the message text to the main text, it would help a lot I'm just planning on using Copy() and Paste atm...
|
|
|
|
|
One solution is GetWindowText() and SetWindowText().
Kuphryn
|
|
|
|
|
|
hello
i had find an interesting class ,i want to add it to a project that i made ,but i had a problem when i add the file source and the headers of this class to my project.
i have the following error message when i compile and it is only in the *.cpp files it ask:
fatal error C1010: unexpected end of file while looking for precompiled header directive
and i include the header files of the source code.
can you help me
|
|
|
|
|
Add this:
#include "stdafx.h"
at the top of the file that's causing the error.
|
|
|
|
|
Try including stdafx.h into the class file.
Do Lipton employees get coffee breaks?
|
|
|
|
|
Try this:
if it complains something about precompiled headers then
choose the file, press the right mouse button, settings and
change Category to Precompiled Headers, and check
Not using precompiled headers
jhaga
|
|
|
|
|
ok it's run thank you for your help
|
|
|
|
|
i have another problem ,when i want to add OpelGL lib like glut and glu, when i go to "Project Setting" and link and in Object/library modules i can't add the lib i find it empty.
what is the problem in that?
|
|
|
|
|
i have another problem ,when i want to add OpelGL lib like glut and glu, when i go to "Project Setting" and link and in Object/library modules i can't add the lib i find it empty.
what is the problem in that?
|
|
|
|
|
In the Object/library modules, just type in "glu32.lib" and if you need it, also add "glaux.lib".
Chris Richardson Terrain Software
|
|
|
|
|
Hi!
Can someone show me how to launch a thread in a dll? I kept get a message when I compile:
"Error AfxBeginThread' : none of the 2 overloads can convert parameter 1 from type 'unsigned int'"
thanks, peter.
|
|
|
|
|
Because parameter 1 is your function pointer, parameter 2 is the parameter pointer and parameter 3 is the ID (an int).
Elaine
The tigress is here
|
|
|
|
|
This is simply a code error that the compiler is complaining about, and has nothing to do with the code being in a DLL. Param 1 is either AFX_THREADPROC or CRuntimeClass* depending on which overload you are using. VC++ is saying you are passing an 'unsigned int' here.
Neville Franks, Author of ED for Windows. www.getsoft.com
Make money with our new Affilate program
|
|
|
|
|
UPDATED!!!! Now with
Exact excercise instructions:
In the preceding double-subscripted array, the #s represent the walls of the maze and the dots represent squares in the possible paths through the maze. Moves can only be made to a location in the array that contains a dot.
There is a simple algorithm for walking through a maze that guarantees finding the exit (assuming there is an exit). If there is not an exit, you will arrive at the starting location again. Place your right hand on the wall to your right and begin walking forward. Never remove your hand from the wall. If the maze turns to the right, you follow the wall to the right. As long as you do not remove your hand from the wall, eventually you will arrive at the exit of the maze. There may be a shorter path than the one you have taken, but you are guaranteed to get out of the maze if you follow the algorithm.
Write a recursive function mazeTraverse to walk through the maze. The function should receive as arguments a 12-by-12 character array representing the maze, and the starting location of the maze. As mazeTraverse attempts to locate the exit from the maze, it should place the character x in each square in the path. The function should display the maze after each move so the user can watch as the maze is solved.
Important data:
'S' represents the starting point of the maze
'E' represents the ending (exit) point of the maze
'#' represents walls
'.' dots represents the path where you can walk
My file looks somthing like this:
(please copy these characters and past them in to a word processor (e.g. notepad) to see it correctly.
############
#...#......#
S.#.#.####.#
###.#....#.#
#....###.#.E
####.#.#.#.#
#..#.#.#.#.#
##.#.#.#.#.#
#........#.#
######.###.#
#......#...#
############
This is a 12 x 12 2-D array.
So far, I can read/print the maze w/o problems, but the recursive function is a mess. Here's my code.
Please help!! I don't know how to work w/ this recursive func.
// My code: Find the way out of the maze using recursion
//*************************************************************************************************
**************** THIS IS THE PART THAT DOESN'T WORK ********************************
//Thanks to those that have offered me their comments. I understand now this code doesn't work at all. So please focus on the instructions and not this code. I'm leaving the code just so you can understand previous comments. Thanks!
//Function solve maze
char solve_maze (char maze [ROW][COL], char coming_from_pos, int actual_row, int actual_col, int end_row, int end_col, bool start)
{
if (! start)
{
if (maze[actual_row][actual_col] == 'E' || maze[actual_row][actual_col] == 'e')
{
cout<<"Congrats!! You have found your way out!" <<endl;
return (maze);
}
if="" (maze[actual_row][actual_col]="='S'" ||="" maze[actual_row][actual_col]="='s')
{
cout<<"There" is="" no="" way="" out="" on="" this="" maze,="" please="" check="" your="" \"maze.txt\"="" file"<<endl;
return="" (maze);
}
}
else="" if="" (coming_from_pos)="" {
case="" 'n':
case="" 'n':
{
if="" (actual_col="">0) {
start=0;
maze[actual_row][actual_col-1]='x';
coming_from_pos='E';
return solve_maze(maze, coming_from_pos, actual_row, actual_col-1, end_row, end_col, start);
}
break;
}
case 'W':
case 'w':
{
if (actual_row <11) {
start=0;
maze[actual_row+1][actual_col]='x';
coming_from_pos='N';
return solve_maze(maze, coming_from_pos, actual_row+1, actual_col, end_row, end_col, start);
}
break;
}
case 'S':
case 's':
{
if (actual_col <11) {
start=0;
maze[actual_row][actual_col+1]='x';
coming_from_pos='W';
return solve_maze(maze, coming_from_pos, actual_row, actual_col+1, end_row, end_col, start);
}
break;
}
case 'E':
case 'e':
{
if (actual_row >0) {
start=0;
maze[actual_row-1][actual_col]='x';
coming_from_pos='S';
return solve_maze(maze, coming_from_pos, actual_row-1, actual_col, end_row, end_col, start);
}
break;
}
default:
cout<<"ERROR: Switch case is not working properly!"<<endl;
}
}
} end="" of="" function="" solve_maze
<b="">I'll appreciate if you take your time and try to give me a solution for this function.
|
|
|
|
|
Hello,
One problem I see right away is that when you pass maze to your recursive funcion, you are passing it as a pointer to the array, not a copy of the array. When you set a point in the maze matrix to 'x', you are setting it globally, so that the maze matrix is permantly altered. This means, that the more times you are calling your recursion function, you are setting more and more of your maze to all 'x', and removing the path of '.'. When dealing with arrays in C/C++, you will always pass them as pointers to the underlying data, as opposed to passing a copy. If you want to stick with the method you are using above, you would have to make a new copy of the maze matrix before calling solve_maze each time. Check out the docs for memcpy()!
maze[12][12];
newMaze[12][12];
memcpy(newMaze, maze, sizeof(newMaze));
// Do your switch to make the move, and apply the changes to the newMaze copy
solve_maze(newMaze, ...);
Note: Solving a huge maze with this method will eat a lot of memory, as you will make a new copy on each recusion level, leading to lots of copys when you get down deep in your tree.
Good luck!
Nick.
|
|
|
|
|
Sounds like homework for a Programming with Data Structures class.
Base case: found a path through maze - return true.
Your algorithm should go something like this:
0-Base Case?
Yes - return true.
No - continue.
1-Select a direction to move [iterate through all directions].
2-Can you move in that direction?
Yes - Move, then recurse.
If function returns true - return true.
If function returns false - undo move, loop to 1.
No - Loop to 1
3-Return false [You've tried all directions at this level of recursion].
-Sean
----
Shag a Lizard
|
|
|
|
|