|
Try adding this to your resource (.rc) file
#include "afxres.rc"
If it's already there, make sure you don't have _AFX_NO_TRACKER_RESOURCES
defined somewhere.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Damn your good!
It's working now.
Thanks for taking the time out to help.
|
|
|
|
|
hi,
i tried to execute the following program(which was given in turbo c++ documentation) in vc++. but it gives an error, that graphics.h can't be found.
so i copied that graphics.h from turbo c to the vc++'s include folder. now it is showing many errors, which i can't resolve(i even don't understand these errors). i am studying c++ in my college. our syllabus include everything from file handling to all oops concepts. but graphics is not covered in out syllabus. so i decided to learn it on my own. but don't know how to start
someone help me please
the following code works perfectly in turbo c, but not in vc++
<br />
#include <graphics.h><br />
#include <stdlib.h><br />
#include <stdio.h><br />
#include <conio.h><br />
<br />
int main(void)<br />
{<br />
<br />
int gdriver = DETECT, gmode, errorcode;<br />
int xmax, ymax;<br />
<br />
<br />
initgraph(&gdriver, &gmode, "");<br />
<br />
<br />
errorcode = graphresult();<br />
<br />
if (errorcode != grOk)<br />
{<br />
printf("Graphics error: %s\n", grapherrormsg(errorcode));<br />
printf("Press any key to halt:");<br />
getch();<br />
exit(1);<br />
}<br />
<br />
setcolor(getmaxcolor());<br />
xmax = getmaxx();<br />
ymax = getmaxy();<br />
<br />
<br />
line(0, 0, xmax, ymax);<br />
<br />
<br />
getch();<br />
closegraph();<br />
return 0;<br />
}<br />
|
|
|
|
|
C++ does not have any "native" "Graphics" support. Most graphics libraries are either vendor specific or API's exposed by the OS.
The Turbo C++ graphics library will be borland specific. You will need to refer to Borlands documentation on how to use it correctly.
A majority of the programmers here probably (just a guess) have more experience and better command of GDI and GDI+ either directly or through avenues such as MFC classes, GDI+ wrapper classes, or .NET.
|
|
|
|
|
Good old Turbo C++ came with its own DOS/Console graphics library. You would need to port/include probably the whole thing for there to be any chance of this working. If all the source was provided, I seem to remember it was, then there's no reason in principle why this wouldn't compile under MSVC. Things have moved on though in the C++ language and you may hit really tricky problems down the line if you persue this.
Functions you're calling in the above code like initgraph , setcolor and graphresult are from the Borland graphics library.
I still have a copy of Turbo C++ on a Win 3.11 virtual PC with many of my old university projects which were developed in Borland Turbo C++ 0.99 and ported to Unix, Solaris and NextStep platforms with no problems although they didn't make use of the graphics library.
Enjoy.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
as mentioned you cannot copy a vendor graphics library for use elsewhere. TurboC's was for itself only. It didn't even work with the borland C compiler after a few versions later.
You can use OpenGL, or DirectX, or a variety of other graphics libraries with VC++.
_________________________
Asu no koto o ieba, tenjo de nezumi ga warau.
Talk about things of tomorrow and the mice in the ceiling laugh. (Japanese Proverb)
|
|
|
|
|
Thanks for the help.
I am trying to use the following code to read an array of file names. However,
I found all the ftitle[i] used the same memery as ftitle[0]. So after the code read all the array, all array of ftitle[0],ftitle[1],ftitle[2] have all the same value of ftitle[2]: "dogfile3"
CString ftitle[10];
for (i=0;i {
fscanf( f_ptr3,"%s\n", ftitle[i]);
}
//
input data file:
dogfile1
dogfile2
dogfile3
Please help me how to read array of filenames correctly with array of CString?
Thanks a lots
|
|
|
|
|
a CString is not a buffer of char's, and you can't treat it like one.
if you want to use CString, you should use the MFC file classes (ex. CStdioFile).
|
|
|
|
|
Thanks a lots for your lighting me up. I have a MFC program
interface. That is why I have to use CString. Also I am not
too familar with MFC. So could you teach me more on the code
with CStdioFile. I am using:
f_ptr6 = fopen(dogfile1,"r");
to use the array of file names.
Thanks again!
-- modified at 12:15 Monday 24th September, 2007
|
|
|
|
|
here is a sample that reads all lines in a file: http://simplesamples.info/Beginners/CStdioFile.php
|
|
|
|
|
"CString is not a buffer of char's, and you can't treat it like one."
I am sure this is not a good correct statement.
|
|
|
|
|
on the contrary, it is both correct and good.
|
|
|
|
|
Aside from a misplaced apostrophe, how is it any worse than, "...a good correct statement?"
"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
|
|
|
|
|
Actually, the code compiles and run. Yes, I did not copy correctly, here is:
CString ftitle[100];
for (i=0;i
|
|
|
|
|
mrby123 wrote: Actually, the code compiles and run.
Which is no guarantee that it is correct.
Use my suggestion and you'll find that it works correctly.
mrby123 wrote: Yes, I did not copy correctly, here is:
And how is this any better? Do the for() loops not look odd?
"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
|
|
|
|
|
It is something odd, when I copied the loop is looked good. However,
after I posted, it changed to odd looking and lost some bits.
my for loop was OK.
The code looks like this now after your guys help:
for (i=0;i
|
|
|
|
|
mrby123 wrote: It is something odd...
There's nothing odd about it. You are clicking the Post Message button instead of the Preview button.
mrby123 wrote: for (i=0;i {
After three times now, can you not see anything wrong with your code snippet?
"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
|
|
|
|
|
And your code actually compiles?
Very strange for loop.
Unless you did not copy your entire code snippet correctly I cannot see an index i increment
|
|
|
|
|
Did you even bother to preview your post before submitting it? Does it not look strange to you at all?
mrby123 wrote: fscanf( f_ptr3,"%s\n", ftitle[i]);
Try:
fscanf(f_ptr3, "%s\n", ftitle[i].GetBuffer(MAX_PATH));
ftitle[i].ReleaseBuffer();
Why use FILE* and fscanf() with MFC when CStdioFile is available.
"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
|
|
|
|
|
Firstly, Thanks for your help. Your code works for me. I am not familar with MFC. I guess MAX_PATH is a system built variabler ? So I do not need to define it.
Why use FILE* and fscanf() with MFC when CStdioFile is available - I am hybrid my old c++ code of some meth calculations with MFC interface, so I get into these troubles.
Thanks a lots from your guys for lighting me up.
|
|
|
|
|
mrby123 wrote: I guess MAX_PATH is a system built variabler ? So I do not need to define it.
Correct. It's defined in windef.h .
mrby123 wrote: I am hybrid my old c++ code...
Perhaps you meant old C code. Same here.
"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
|
|
|
|
|
hi i have create an activex. how to open it in browser ie internet explorer. im newbie to this activex. pls help me
|
|
|
|
|
You need to use the OBJECT tag in HTML. For ex. the following code will load the adobe flash player in internet explorer.
If you want to load you activex control, just change the following classid with your control classid.
<html>
<body>
<OBJECT height=150 width=150 align=middle classid=clsid:D27CDB6E-AE6D-11cf-96B8-444553540000>
<PARAM NAME="background" VALUE="transparent">
<PARAM NAME="BGCOLOR" VALUE="#CCCCFF">
</OBJECT>
</body>
</html>
|
|
|
|
|
I know this is not a serious warning, if you could even call it that, but it's annoying.
First-chance exception at ... Access violation reading location ...
Is there any way to find the cause and make the thing go away so that I can have my output window filled with something useful?
Waldermort
|
|
|
|
|
It may indeed indicate a serious problem. To find out what's causing it (VS 2005) tick the check box under Debug->Exceptions, Win32 Exceptions for c0000005 Access violation in the Break when Thrown column. Run your code and see where the exeception is being raised.
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|