|
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
|
|
|
|
|
I haven't compiled and run your code, but a casual inspection seems to reveal several errors:- You check for unescapable mazes by verifying whether you have returned to the start position. This is wrong: consider a maze where you initially face a dead-end corridor; eventually you'll have to come to the start position, but that doesn't mean there are no alternative routes.
- Seems you're not checking whether you stumble into walls; instead you check for free space. If you happen to run into a wall,
solve_maze will just exit.
- Seems like you change direction at every step, so if you start in a position with no walls around, you'll go N-E-S-W and return to the start without exploring anything.
A good way to debug your code is to insert at the beginning of solve_maze a screen dump of the maze, so that you can follow the progression of the algorithm.
Right-hand strategy can be implemented withouth resorting to recursion. Recursion is required, though, for another strategy called depth-first; maybe the following pseudo code will help you write your code:
bool solve_maze(row,col,direction)
{
if(in exit) return true;
if(!(we can advance in direction)) return false;
move in direction;
mark position;
if(solve_maze(row,col,north)||solve_maze(row,col,east)||
solve_maze(row,col,south)||solve_maze(row,col,west)){
return true;
}
else{
unmark position;
return false;
}
}
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
I have a dialog pop up in a SDI. And when i type into a field i want the caption to display what im tying in the field. Like when you send and email and you type the message, the caption displays "Microsoft Outlook - New Message [message]"
|
|
|
|
|
|
Could you like show me the syntax of it, or and example block of code.
|
|
|
|
|
Here ya go:
void CYourDialogBox::OnChangeSomeEditCtrl()
{
CString a_sMessage;
GetDlgItem( IDC_YOUR_EDIT_CONTROL_HERE )->GetWindowText( a_sMessage );
CString a_sCaption( _T("Your New Message - " + a_sMessage );
SetWindowText( a_sCaption );
}
Chris Richardson Terrain Software
|
|
|
|
|
Can that be used also with the main SDI?
|
|
|
|
|
Thanks for the help, but ive ran into yet another delima. I put a rich edit in the dialog and i cant get it to launch. I can get the parent window, but when i click the link, the dialog doesnt Modal, or show. But if i take the rich edit out, then it will pop up.
|
|
|
|
|