|
Try to get your control's device context and use GetPixel()
rrrado
|
|
|
|
|
GetRValue, GetBValue and GetGValue are used to get the color from the return value of GetPixel()
Don't try it, just do it!
|
|
|
|
|
thanx Alexander
canu give me the code so that it will help me alot coz i m a bit new to VC++
its a bit urgent dear.
waiting for ur reply
thanx again
bye
regards
tahir
|
|
|
|
|
Hi,
I have a question regarding reading and writing to the same (text)file. I know it is not Visual C++ (just C++) but I still hope someone will respond.
I have a project which I run from the command promp. The same exe file is run twice, with different parameters sent to the main() function, so that I have two dos windows open at the same time.
Below P1 is the first program and P2 the second program.
P1 output file is P2 inputfile and vice versa.
P1 reads a line with cin and then output it to a file. P2 does the same.
Everything works fine so far but...
...the question is how I would code a loop so that P1 reads a line from P2 output file with i.e. getline() until the textfile is updated(changed) by P2 and ONLY then print it out on P1 screen and vice versa???
This might seem to be a stupid program but it is for studying purpose.
Thanks in advance for any hints or solutions
Regards
Lars
|
|
|
|
|
I've never tried it, but I'm sure that there's some function in windows API which will setup notifications for you when choosen file is changed.
(most of the editors use this to reload the file when it's modified outside the editor,
maybe you would find this in wordpad sample soure code)
rrrado
|
|
|
|
|
But I think better way to send data from one program to another is using the pipe (p1.exe | p2.exe - stdin of p2 is connected to stdout of p1), but I've tried this only in unix, I'm not sure how will this run in Win)
rrrado
|
|
|
|
|
rrrado wrote:
I'm not sure how will this run in Win
In much the same way. See these two MSDN articles for examples:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/creating_a_child_process_with_redirected_input_and_output.asp
http://support.microsoft.com/default.aspx?scid=kb;en-us;190351
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
Thanks for the suggestions!
Lars
|
|
|
|
|
Hi, I have a peculiar problem ! I'm developing a specialised backup facility which uses formatted CD's (created by Adaptec DirectCD) as the backup medium. I am testing the program as the CD reaches it's limit space-wise. Naturally, I test the available space on the CD using GetDiskFreeSpace() and compare it against the file size using CFile::GetLength() before embarking upon the write (using CFile::Write()) for that particular file. However, BEFORE I hit failure on the size comparison,I get an exception (diskFull) during a write operation. i.e.
CFile exception: diskFull, File E:\C\Data\Clipart\Christmas\Candle and holly.bmp, OS error information = 112.
First-chance exception in MyBackup.exe (MFC40D.DLL): 0xE06D7363: Microsoft C++ Exception.
However, using Explorer AFTER the event, I find that the free space on the CD is VASTLY greater than the size of the file being written at the time of failure (eg 300Kb vers 32Kb). If I rerun the backup (which SHOULD occur in the same file order), I get the failure in a different file (VERY suspicious,don't you think ?) I'm stumped as to how to persue this problem - can anyone make any suggestions ?
Doug
|
|
|
|
|
You cannot write on CDs directly like this, i wish we could
Search for some CD writer API
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
why E: should be a "CD reader". i personnaly have 3 hard disks where two of them have two partitions...
C: , D: , E: , F: , and G: are HDD for me !
TOXCCT >>> GEII power
|
|
|
|
|
Because you didnt read his post, you just wanted to answer
He said
"Hi, I have a peculiar problem ! I'm developing a specialised backup facility which uses formatted CD's (created by Adaptec DirectCD) as the backup medium"
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
ok ok.
but if directCD is intalled, it permits to do so, no ?
TOXCCT >>> GEII power
|
|
|
|
|
Apparently no, unless it exports some API that he can use
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hey guys, Adaptec DirectCD allows you to read and write files to a formatted CD just like you would to any other disk - it DOES work !!! (DirectCD is used to format the CD - not the normalformat.com) Anyway, the REAL problem is the disk full situation, where it clearly isn't.
Doug
I still haven't had any suggestions about identifying the cause of this problem, so I have taken the defensive route !! I made the last 5Mb a "no-go" area when checking the CD free space. This seems to work O.K. (Being a curious sort of person, I'd STILL like to know the reason why I've hit this problem). Hope that this will be of some help to anybody who has this problem in the future !
|
|
|
|
|
I need help!
1)In visual C++, how do i input a string of characters and then print it back out once it reaches a certain character and replacing each double space by a single space.
2)write a program that prints its input (up until it reaches the EOF character) one word per line.
3)Write a function that times a with b, and b with a when the user enters the numbers.
4) using a function, a program to remove trailing blanks and tabs from each line of input (up until it reaches the # or EOF character), and to delete entirely blank lines
please email me: JonesAnd5@hotmail.com if you can help!
|
|
|
|
|
We do not do homework
|
|
|
|
|
|
toxcct wrote:
"We don't do homework" is quite a great answer ... too bad, it was posted as an anonymous...
What difference does it make how it was posted? It's factual regardless.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
I could argue that the response is as bad as the recent response I gave to much the same sort of question, yet you, with another, had a shot at crucifying me for it....
at least in my response to his post (below this)I have tried to get the person started, without giving them the answer on a plate
I'm sorry, David, maybe you should practice what you preach
'G'
|
|
|
|
|
I had no intention at responding to A. Jones. My response was intended for, and sent to, toxcct. Please read both posts again for a full understanding of what was said and what was responded to. In other words, while "We don't do homework" was a great response by the anonymous poster, toxcct implied that something was wrong with it simply because of that. I simply responded that it did not matter how it was posted, whether it was by an anonymous or not.
Garth J Lancaster wrote:
I'm sorry, David, maybe you should practice what you preach
I do. What does my response to toxcct have to do with you having been a tad rude in a previous post? Perhaps you know of a contradictory example.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
well, looks like we will disagree here - while I know exactely who the response was for, AND what was said, on the basis of what you said to me the other night, its simply not a good response - for the reason as you put it 'A. Jones may not be as web literate' (as some of us), and 'asking questions is what the Codeproject is for'
.. its how WE choose to answer them that makes this a good (or bad) place
'G'
|
|
|
|
|
Garth J Lancaster wrote:
'A. Jones may not be as web literate' (as some of us)...
Again, my response had nothing to do with A. Jones. Why are you failing to see this? I was responding to toxcct's comment about "We don't do homework" being a "too bad" answer simply because it was posted by an anonymous.
Garth J Lancaster wrote:
...and 'asking questions is what the Codeproject is for'
Ask away, but just because I do not reply to a question hardly implies that I don't "practice what I preach." Had I responded directly to A. Jones with something on the order of "Learn how to type; Use Google first; We don't do homework here; Post some proof of code", then you might have a case. Since I did none of that, I'm curious just what type of point you are trying to make.
"The pointy end goes in the other man." - Antonio Banderas (Zorro, 1998)
|
|
|
|
|
DavidCrow wrote:
I'm curious just what type of point you are trying to make.
Well, I obviously appear to be in the wrong here, so, Im sorry, its late down here, and Im going to bed
|
|
|
|
|
While 'Anonymous' is technically correct, we do help people who show us some code they have attempted..
I'm providing a link to a site that has a fairly good intro to c++ - my suggestion is that you go there first, read the notes etc - you probably have some notes your teacher gave you - read those as well - dont be worried about it not sounding right the first time - take a break, read and re-read ...
http://cplus.about.com/library/blcplustut.htm[^]
Once you've done that, you should then break down your question into individual 'logical' operations - for example, you might start like this for Q1 :-
a) define the 'stop'/'certain' character
b) read a character from the keyboard
c) test if the character is the character defined at (a)
d) if (c) is false, store the character - you may need an array for this, then you/the program need to go back to (b)
e) if (c) is true, you may need to look (loop) through all the elements in the array, printing them out .. you may decide that at (d), you may also need to keep a count of the elements .. so modify step (a) to now read
(a) define the 'stop'/'certain' character, a counter to count how many characters are being entered (hint : int), and an array of characters (you may need to define a large array if you havnt thought of how man characters you want to store),
and modify step d) to include 'increment the counter'
you may decide that the easy way to do the test and 'loop' bit is to take a look at 'while loops'
once you have something that can save and print every character, then, make a copy of it for safe keeping, and alter it to handle the double space reduction issue .. again, write down what you need to achieve, break it into logical steps, then its easier to convert into code .. this goes for any language, wether thats c++, perl, whatever
many people will offer you solutions to the problem - there are a lot of ways to solve it .. but you are better off (as we say down here in Australia) 'having a go' and posting back here with something you've attempted.
think 'what can go wrong' - 'what have I assumed' - if you manage to declare a counter at 'a', is it fair to assume the the compiler set it to zero (I tell you its not, so, at (a), you might also want to add the step 'set the counter to zero')
do you see what Im doing - breaking down the problem, designing and then refining my design ...
I hope this has started you on the right foot - other people will probably shoot me for doing it this way ..
if all else fails, see your teacher/lecturer, even then, you shouldnt go to them with no ideas of your own
'G'
|
|
|
|
|