|
Probally you need a custom class:
you can neme it MyDC , you have to link to it a DC and then specify the rectangle that sets its position.
Then you can create 2 DC ( points 1), 2) and 3) ).
The point 4) require that you prepare a function like
MyDC GetIntersect(MyDC dc1, MYDC dc2){...}
to create the new DC.
This function will extract the rectangle that describes the intersection (if exists), and it has to prepare the contents of the DC. To do this you can work pixel per pixel to get the color of the new pixel according on your intersection logic.
Remember that the function CDC::BitBlt[^] can help you here (look also the Binary Raster Operations[^])
Russell
|
|
|
|
|
i am new to vc++ and i havent worked in active X.. so can anybody help me how to create a gantt chart from vc++
thanks in advance
|
|
|
|
|
First: Read this[^]
Second: Try google or using "search in forum" or read some articles in this website. There is a lot of info
Third: If you try it and put the code where you are having problems you will have more help than now
Greetings.
--------
M.D.V.
If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about?
Help me to understand what I'm saying, and I'll explain it better to you
|
|
|
|
|
Someone would like to tell me how to check a directory is existed or not?
I use GetFileAttributes().
But it need a wide character set string as its paramter,otherwise,it does not work.
Now,I want to using one byte char string as the path,how should I do?(in pure C style)
Thanks.
GOOD LUCK.
|
|
|
|
|
|
You can check using the following code -
bool bPathExist = true;
CFileException Ex;
if (!File.Open (FileName, CFile::modeCreate, &Ex))
{
if (Ex.m_cause == CFileException::badPath)
{
bPathExist = false;
}
}
and to make sure that each directory exist in the whole path, use Api -
::MakeSureDirectoryPathExists
|
|
|
|
|
|
Unfortunately there is no POSIX or standard method for doing this. boost::filesystem is as close as it gets.
However you may try using this:
http://msdn2.microsoft.com/en-us/library/1w06ktdy(VS.80).aspx[^]
example usage:
TCHAR *file = _T("c:\\test.txt");
if((-1 != _access(file, 0)))
_stprintf(_T("%s file exists.\n"), file);
else
_stprintf(_T("%s file does not exist.\n"), file);
Best Wishes,
-Randor (David Delaune)
|
|
|
|
|
but I will use it in a .c file.
When the codes were compiled,it would post an error,that ATL only can be used in .cpp file!
|
|
|
|
|
I will have a try imediately.
Thank you very much.
|
|
|
|
|
try PathIsDirectory()
Regards,
Pankaj Sachdeva
"There is no future lies in any job"
"but"
"future lies in the person who holds the job"
|
|
|
|
|
kcynic wrote: but I will use it in a .c file.
When the codes were compiled,it would post an error,that ATL only can be used in .cpp file!
_access() has nothing to do with ATL, or whether it's used in a .c or .cpp file.
Posting the actual error message, as well as the code snippet that produced it, will go a long way towards helping you. Anything short of that, good luck.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
TCHAR* fpath=_T("C:\\WINDOWS");
if(PathIsDirectoryW(fpath)==TRUE)
cout<<"Is a directory"<
|
|
|
|
|
kcynic wrote: if(PathIsDirectoryW(fpath)==TRUE)
Have you tried:
if (PathIsDirectoryW(fpath) != FALSE)
... kcynic wrote: ...but it does not work.
Which means what?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
use this code this will work actually this function returns some value but not TRUE if direstory exists else it returns 0
TCHAR* fpath=_T("C:\\WINDOWS");<br />
if(PathIsDirectory(fpath))<br />
cout<<"Is a directory"<<endl;<br />
Regards,
Pankaj Sachdeva
"There is no future lies in any job"
"but"
"future lies in the person who holds the job"
|
|
|
|
|
I you want to use of a directory and also your are not sure its exist or no use SetCurrentDirectory and check return value of this function.
|
|
|
|
|
kcynic wrote: I use GetFileAttributes().
But it need a wide character set string as its paramter,otherwise,it does not work.
It will work with either Unicode or ANSI builds.
kcynic wrote: Now,I want to using one byte char string as the path,
Most paths are comprised of more than one byte. Perhaps you meant something else.
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Im trying to create a simple program the reads a string of integers from the board and store them in an array, then out put to the screen each integer from that string. It compiles fine but then crashes with an error. This is my code:
<br />
<br />
#include "stdafx.h"<br />
#include conio.h<br />
#include iostream<br />
using namespace std;<br />
<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
int aArray[4];<br />
int n;<br />
cout << "Input 5 digits: "; cin >> aArray[4];<br />
for ( n=0; n<0; n++ )<br />
{<br />
cout << "Integer: " << aArray[n] << endl;<br />
}<br />
<br />
_getch();<br />
return 0;<br />
}<br />
this is the error
Run-Time Check Failure #2 - Stack around the variable 'aArray' was corrupted.
|
|
|
|
|
The last element of aArray if aArray[3], but not aArray[4].
And what do you mean by:
Herboren wrote: for ( n=0; n<0; n++ )
|
|
|
|
|
forgive me I had noticed that earlier I corrected it. Edit:
<br />
<br />
#include "stdafx.h"<br />
#include <<conio.h>><br />
#include <<iostream>><br />
using namespace std;<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
int aArray[4];<br />
int n;<br />
<br />
<br />
cout << "Input 5 digits: "; cin >> aArray[0];<br />
<br />
for ( n=0; n<5; n++ )<br />
{<br />
cout << "Integer: " << aArray[n] << endl;<br />
}<br />
_getch();<br />
return 0;<br />
}<br />
of course knowing the array is 5 integers long '01234'. Basically the program is supposed to read a string of integers from the user, for example, input '12345' all together on the first line. Then each value within that string is stored in an array therefore if I wanted to print the first value of that array the value would come out as the '1' and so on. Now when you build the code it asks for an input the downside to this is it asks for 5 elements as a string or individual, in 5 different columns. so if you typed '12345' you would have to press enter and repeat that 4 more times, which is what im trying to avoid. The operation of the program is supposed to ask for the string of integers once and place each element of the string into an array therefor the string '12345' would be placed in aArray[4] thus giving me 5 elements in in one column. smell my drift?
|
|
|
|
|
The program is working fine but the logic in your code is not correct.
All you need to do is to parse the string to extract it's digits, store them in array and then print.
|
|
|
|
|
Herboren wrote: cin >> aArray[4];
NO
You have to prepare a for loop to input the 4 numbers one after the other.
Russell
|
|
|
|
|
Herboren wrote: Im trying to create a simple program the reads a string of integers
...
int aArray[4];
These two seem to contradict each other. You either meant to say, "Im trying to create a simple program the reads an array of integers," or you need to declare:
Herboren wrote: for ( n=0; n<0; n++ )
This loop will not do what you expect, unless you expect it to execute 0 times.
string aArray[4]; In any case, consider:
int aArray[4];
cin >> aArray[0];
cin >> aArray[1];
cin >> aArray[2];
cin >> aArray[3]; or
for (int n = 0; n < 3; n++)
cin >> aArray[n]; Notice the benefits of the latter example?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Russel *Sigh*, if you have a little more to tell me than just "NO" i might actually listen to you. Crow even turning it to a string wouldnt that mean its still in char format and not int. I should be able to add an unspecified amount to each element of the string inside the array. Like adding a 1 to 12345 making it 22345.
<br />
#include "stdafx.h"<br />
#include <conio.h><br />
#include <sstream><br />
#include <string><br />
#include <iostream><br />
#include <cstdlib><br />
using namespace std;<br />
<br />
<br />
int _tmain(int argc, _TCHAR* argv[])<br />
{<br />
int aArray[4];<br />
int u,d,t,q,c,a;<br />
string st;<br />
<br />
cout << "Input 5-digits: "; cin >> st; cout << st << endl; _getch();<br />
istringstream ss(st);<br />
<br />
<br />
ss >> u;<br />
aArray[0] = u;<br />
if ( ss.peek() != '\n' )<br />
{<br />
cerr<<"Invalid format"<<endl;<br />
return EXIT_FAILURE;<br />
}ss.ignore();<br />
<br />
ss >> d;<br />
aArray[1] = d;<br />
if ( ss.peek() != '\n' )<br />
{<br />
cerr<<"Invalid format"<<endl;<br />
return EXIT_FAILURE;<br />
}ss.ignore();<br />
<br />
ss >> t;<br />
aArray[2] = t;<br />
if ( ss.peek() != '\n' )<br />
{<br />
cerr<<"Invalid format"<<endl;<br />
return EXIT_FAILURE;<br />
}ss.ignore();<br />
<br />
ss >> q;<br />
aArray[3] = q;<br />
if ( ss.peek() != '\n' )<br />
{<br />
cerr<<"Invalid format"<<endl;<br />
return EXIT_FAILURE;<br />
}ss.ignore();<br />
<br />
ss >> c;<br />
aArray[4] = c;<br />
cout << u << d << t << q << c << " "<br />
<< aArray[0] <br />
<< aArray[1]<br />
<< aArray[2]<br />
<< aArray[3]<br />
<< aArray[4]<br />
<< endl;<br />
cout << aArray[0] << endl;<br />
_getch();<br />
return 0;<br />
}<br />
<br />
-- modified at 10:49 Tuesday 18th September, 2007
|
|
|
|
|
Herboren wrote: *Sigh*, dont worry bout it dude, I must not be making myself clear enough I dont know any other basic way to put it. I got better results somewhere else. sheesh!
That's fine, but remember, you're the one asking for help, not us.
Herboren wrote: Crow even turning it to a string...
I was not suggesting using one type over another. I was merely pointing out that the type you do use ultimately determines what API/classes you need. For example, if you say you want to add a bunch of numbers together, but provide a code snippet that uses string s, there's obviously going to be extra work involved.
Herboren wrote: I should be able to add an unspecified amount to each element of the string inside the array. Like adding a 1 to 12345 making it 22345.
And how does the code snippet you've shown do any of this? What exactly are you wanting the user to input (there's a big difference between five numbers or digts, and a 5-digit number)?
This all may sound pedantic, but if we can't understand what it is that you want, how could you possibly expect an answer?
"A good athlete is the result of a good and worthy opponent." - David Crow
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|