|
I write the sentence "printf("haha\n");" to debug the program !!!
But the recv method can't return an value , and nothing to do but wait.
How to solve it ? And why it will perform like that???
Thank you very much!!!
Jeff Fan
No change is the worst!!!
The principal of mine
msn:fyr000000@hotmail.com
If you like coding , add me.
|
|
|
|
|
If dont want Recv to be blocked, use fcntl call to set the time out. So that Recv will not block and wait.
|
|
|
|
|
|
Hi Folks,
I need your help over an issue,
At what place in an "MFC App Wizard Application(exe)"
The Global varible/function should be defined. So that it is accessible through out the code..
I actully have an issue where i am trying to access Global Function in a cpp file (that was included to the current project,I wrote it for another project )
I compilation issues an Error saying
"Undelared Identifier"
but when i Add that function to my class the Linker error goes like
"Already defined in view.obj"
Got the idea ?
waiting for your response..
JinBaba
|
|
|
|
|
language problem.
if u defined a variable in a h file, such as int i0; then include the file by 2 cpp files, the result is similar to define int i0 in 2 cpp files (but not define in h file)- syntax error.
u can modify declare as
static int i0=0; (no good)
extern int i0; then difine in a cpp file as: int i0=0;
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
-- modified at 11:01 Saturday 22nd April, 2006
|
|
|
|
|
|
In your project there is a file with name CMyDlg.cpp or something like that.
Just open it and declare your function there.
good luck
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Either place the funcion/variable in the main code file or in its own file ( like 'Globals.cpp'). Then either place the declaration (prototypes) in the 'stdafx.h' file or include a header for the 'Globals.cpp' file in it.
If you are dealing with a single variable, just declare it in the main .cpp file and the declare it as external in the 'stdafx.h' file.
If you do not want to make it truely global (everyone knows about it), then declare it in one of the files that needs it and declare it as external in any other file that needs access to it.
INTP
Every thing is relative...
|
|
|
|
|
I maintain a very mature product (over ten years old) that was written in MSVS 6. My team is in the process of giving the app a new look and feel. We decided to try to convert the project to .net to leverage the GUI elements; but had too many issues during this process and forfeit the idea.
This leads to my questions:
1.Could an application that is compiled under MSVS 6 use Win Forms?
2.This is more of a secondary question to number 1). Could controls be written in C# then; built into an assembly; be used by an app compiled in MSVS 6?
3.If you answer yes to either question; is there any documentation?
Thank you ,
-e
-- modified at 8:33 Saturday 22nd April, 2006
|
|
|
|
|
-e wrote: 1.Could an application that is compiled under MSVS 6 use Win Forms?
no
-e wrote: 2.Could controls be written in C# then; built into an assembly; be used by an app compiled in MSVS 6?
no
-e wrote: 3.If you answer yes to either question; is there any documentation?
sorry
in fact, you can't because VC6 doen't know gthe .NET framework at all. so you can't neither use the .NET SDK, nor use some assembly compiled for .NET.
tell me however, why don't you just upgrade the code to VC++2003 (MFC or Win32) without wanting targetting for .NET ?
|
|
|
|
|
Thanks for the input.
To answer your question I had assigned developers to try to convert the application to VC++ 2003. Since the applications is over ten years old it has seen its share of GUI toolkits and some of these toolkits are not converting to the new platform. So one of my goals is to slowly move the application to the new platform. I am trying to make the application co-exist between VC ++ 6 (old code) and VC++ (maybe .net) 2003 or greater (new code). Since I don't have the option to compile the application greater than VC++ 6.
Thanks,
-e
|
|
|
|
|
MSVS is actually a studio and not specificaly intended for only C++. You are able to compile most languages using MSVS including C#, J#, C++, C. Maybe you meant to say MSVC?
It is possible to call C# code from C++. Usually the C# would be in the form of a dll, and you would need to manually register the type library. Also the .NET runtimes would need to be installed on the client machine. The process of doing this is a little complicated, but there are some articles here on CP which demonstrate it.
|
|
|
|
|
Thanks for replying,
I should of been more specific with the development language. The existing application is coded using VC++ 6 (MFC). At the moment I can't covert (promote) the existing code to a greater platform than VC++ 6 (for various reasons). So I am looking for a way to have new development be written in VC++ 2003(or higher) or C# and try to co-exist with the existing code. So I guess what I'm looking for is an application that is compiled with VC++ (MFC) 6 to have mixed code; the existing code to use MFC 6 components (like dialogs etc..) and the new code to use C#, VC++ 7 code (like Win-Forms etc...).
Thanks,
-e
P.S. My goal is to eventually move the application to the newer platform (in baby steps).
|
|
|
|
|
I've done this via Com Callable Wrappers (CCW) around .NET components.
This[^] article is a good starting point.
Michael
CP Blog [^] Development Blog [^]
|
|
|
|
|
Do you know a class like CScrollWindow, which I can use to scroll window view, but I don't want to use the document/view architecture?
Regards
mwgomez
|
|
|
|
|
As i know, no suvh class.
acturally u do'nt need to find it, scroll is easy to do:
1.add scroll-bars if neccessary.
2.show/hide and manage scrolling by a little bit code.
//follwings are my code for your reference
//bar_Vert and bar_Horz are added on a prperty-page
void SheetPreviewPgGragh::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CPropertyPage::OnVScroll(nSBCode, nPos, pScrollBar);
if(pScrollBar!=&bar_Vert) return;
P_ScrollBar(nSBCode,nPos,pScrollBar);
}
void SheetPreviewPgGragh::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
CPropertyPage::OnHScroll(nSBCode, nPos, pScrollBar);
if(pScrollBar!=&bar_Horz) return;
P_ScrollBar(nSBCode,nPos,pScrollBar);
}
void SheetPreviewPgGragh::P_ScrollBar(int iCode, int iPosIn,CScrollBar*pBar)
{
SCROLLINFO si;
si.cbSize =sizeof(SCROLLINFO);
si.fMask=SIF_ALL;
pBar->GetScrollInfo(&si);
int iPos =si.nPos;
switch(iCode)
{
case SB_LINEUP:
iPos-=1;
break;
case SB_LINEDOWN:
iPos+=1;
break;
case SB_PAGEUP:
iPos-=si.nPage;
break;
case SB_PAGEDOWN:
iPos+=si.nPage;
break;
case SB_THUMBTRACK:
iPos=iPosIn;
break;
}
if(iPos<0) iPos=0;
if(iPos>(int)(si.nMax-si.nPage)) iPos=si.nMax-si.nPage+1;
if(iPos==si.nPos) return;
si.nPos=iPos;
pBar->SetScrollInfo(&si);
RedrawPage();
}
A special image tool for C++ programmers, don't miss it!
The world unique Software Label Maker is here for you and me ...
A nice hyper tool for optimizing your MS html-help contents.
|
|
|
|
|
How to output an array of datatype CString and of size[2400]in a Listbox control????
|
|
|
|
|
CString array[2400];
CListBox listbox;
for (int i = 0; i < 2400; i++) {
listbox.AddString(array[i]);
}
Software Zen: delete this;
|
|
|
|
|
Ya thank you very much for ur reply, whatever you have written is correct and i was owrking int he same way, but i was encountering an error while using with two dimensional arrays.How could i use for two dimensional arrays?
CString average[100][100];
CListBox m_stravevalues;
for(i=0;i<60;i++)
for(j=0;j<40;j++)
{
m_stravevalues.AddString(average[i][j]);
}
Is this correct???
|
|
|
|
|
Not Correct, A Listbox is One Dimensional, and cannot display 2 Dimensions. Maybe you're looking for a Multi Colum listbox??
LateNightsInNewry
|
|
|
|
|
So, anybody could help me, to output this two dimensional array in a List box or Edit box.
|
|
|
|
|
Hi again
i'm in trouble again with strings.
What i want to do is read from a file, line by line (each line has only one word)
and compare it with onother string. the problem is that the way i do it is the following
void Html_Parser::dictionary(string tokencheck)
{
FILE *dFile;
bool found=false;
char string_token[50];
dFile = fopen("dictionary.txt","r");
if (dFile == NULL)
perror ("Error opening file");
else
{
do
{
fgets (string_token , 50 , dFile);
puts (string_token);
if (strcmp (string_token,tokencheck) == 0)//incompatible
{
found=true;
cout<<"found"<
|
|
|
|
|
Don't use all this old fashioned fopen and fgets - This is C++ not C!
Here's how I'd do it. I haven't tested this, it's off the cuff; so you may need to add a semicolon or some such:
void TokenCheck(const string &token)
{
ifstream fs("dictionary.txt");
if ( fs )
{
istream_iterator<string> i(fs);
istream_iterator<string> e;
if ( find(i, e, token)!=e )
{
}
}
}</code>
Uses the following includes:
<string>
<fstream>
<iterator>
<algorithm>
Assumes:
using namespace std;
Steve
|
|
|
|
|
Hey Steve thanks a lot appresiate the help.
can u tell me a good c++ library reference site so i can stop using those old fashion functions thanks again
|
|
|
|
|
I'm not sure about a site - I've got a book on C++ and one on The Standard Library.
Steve
|
|
|
|