|
Thank you for the tips guys i will try them out i just have to figure a way fo getting it to give the user 8 trys max. Thanks for not talking to clever for me lol
This Better ******* Work!
|
|
|
|
|
bobski2200 wrote:
i just have to figure a way fo getting it to give the user 8 trys max.
Change
while(guess!=random); to
while(guess!=random && num_tries < 8); Start num_tries at 0 and increment it after each guess.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Graham - Slow
Rick - Slower
Cohen - Slowest
|
|
|
|
|
Hi!
I've got a struct which needs to be byte swapped, so I figured, why not overload the conversion functions to take my struct as a param, byte swap the fields, then return a new struct. However, I keep getting an error that the compiler doesnt know how to convert one parameter 1 (of htons) from unsigned int to myStruct. Below is my code:
typedef struct
{
u_8 protocol_id;
u_8 msg_type;
u_16 length;
} FrameHdr;
_inline FrameHdr ntohs (FrameHdr i_param)
{
FrameHdr mObj;
mObj.length = ntohs (i_param.length);
return (mObj);
}
The compiler error is:
error C2664: 'ntohs' : cannot convert parameter 1 from 'unsigned short' to 'FrameHdr'
I tried adding 'const' at the end of the function definition but that didnt work either.
Any ideas?? TIA!
-C
|
|
|
|
|
typedef struct FrameHdr
{
u_8 protocol_id;
u_8 msg_type;
u_16 length;
FrameHdr ntohs (FrameHdr i_param);
} FrameHdr;
FrameHdr FrameHdr::ntohs (FrameHdr i_param)
{
FrameHdr mObj;
mObj.length = ::ntohs (i_param.length);
return (mObj);
}
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I cannot add a function definition to my struct. The structs are used for data to send in a msg and in byte aligned etc.
Any other way of doing this w/o adding a function definition to my struct?
Thanks.
-C
|
|
|
|
|
Why not a wrapper to your structure
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I know there's a much simpler answer to this. I only want to overload a function and its not letting me. I only want a simple solution to this compiler error. Thanks.
-C
|
|
|
|
|
A namespace would serve in your case
this way you separate your symbols from the global ones.
No?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I've never used namespaces before.
|
|
|
|
|
Hello,
I've made a windows app with Visual C++ using the MFC's. Everything works grand.
The problem is when I send the program i.e. the .exe to someone who dosen't have Visual Studio on their machine the app won't work saying it needs something like "mfc40.dll".
My question is, how do I compile my program so that the required stuff is compiled into the .exe???
Any ideas??
Cheers.
|
|
|
|
|
Very easy.
Go to your "Project Settings" for your project, and there will be a setting called "Use of MFC" or something. Change it to "Use MFC in a static libary". Note that you will have to do this for both debug and release configurations.
Then do a complete clean and rebuild. If you need to verify your program is no longer looking for Mfc40.dll or anything, run the Dependency Walker on it.
Now, if you have the crippleware version (er, the Standard version),
this[^] article will help.
"Fish and guests stink in three days." - Benjamin Franlkin
|
|
|
|
|
Why does it work that way b) and not a)?
a)
// SomeClass.h
#ifndef _SOMECLASS_
#define _SOMECLASS_
class some_class
{
public:
some_class(){}
~some_class(){}
template<class t="">
void callfunc(T var);
};
template<class t="">
void some_class::callfunc(T var)
{
}
#endif
b)
// SomeClass.h
#ifndef _SOMECLASS_
#define _SOMECLASS_
class some_class
{
public:
some_class(){}
~some_class(){}
template<class t="">
void callfunc(T var){}
};
#endif
//main.cpp
#include "SomeClass.h"
void main(void)
{
some_class example;
int nt=4;
example.callfunc(nt);
}
|
|
|
|
|
Because templates are expanded as they are compiled - just including the .h with the function declared (not defined) is not enough
This is the pain the arse problem that you usually have. Really, its much easier if you stick to the thin template pattern - short template code. Then, put it in at the same time as decliration - as in b). If you really want to split it up - you can put the defination at the bottom of the .h its declared in. Or, if you really want the defination in a .CPP file - you can (uck) #include the .CPP into the other CPP you are using the template in.
|
|
|
|
|
I am trying to develop an ActiveX control using Visual C++ 6 for usage on a web page which will display info on our Exchange Servers.
The client computers are Win2K & WinXP.
Initially I want this control to be "trivial" and only display the status of the Exchange servers ie up/down. In the future I would like to extend this information to possibly throughput/load etc.
Which API should I use for maximum usability and compatibility ??
Any help or URLs for tutorials on accessing this kind of info from an ActiveX control would be greatly appreciated.
Thanks,
Dels
|
|
|
|
|
Related to my earlier question, when the focus for a dialog is on a Date/Time Picker control, or any 'entry style' control for that matter, how can I make the 'Enter' key act like a data entry key. In other words, I simply want pressing 'Enter' to finalize data entry in that control and possibly send the cursor to the next tab stop.
|
|
|
|
|
Try catching the DTN_WMKEYDOWN notification message. If that doesnt work, try using a message hook for messages like WM_KEYDOWN/WM_KEYUP...
HTH
Bikram Singh
|
|
|
|
|
Hello I have a MFC dialog based app.
I need the user to move it by dragging in any point.
I tried with this code, but didn't work:
UINT CMainMenu::OnNcHitTest(CPoint point)
{
CRect r;
GetClientRect(&r);
ClientToScreen(&r);
if(r.PtInRect(point))
return HTCAPTION ;
return CDialog::OnNcHitTest(point);
}
Any suggestion about?
Thanks,
Marco.
by the way do you know why (only in release configuration)
i get an error from the application when executing the line
fscanf(fp,"%s",s);
when the line in the file is 9 chars or longer ?????
Thanks again
|
|
|
|
|
marcomars wrote:
Any suggestion about?
I assume you've seen this article.
marcomars wrote:
by the way do you know why (only in release configuration)
i get an error from the application when executing the line
fscanf(fp,"%s",s);
when the line in the file is 9 chars or longer ?????
Not without knowing at least what s is.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
It should
This:
UINT CSssDlg::OnNcHitTest(CPoint point)
{
CRect rc;
GetClientRect(&rc);
ClientToScreen(&rc);
return rc.PtInRect(point) ? HTCAPTION :
CDialog::OnNcHitTest(point);
}
Does. In the dialog its self - with ON_WM_NCHITTEST() added to the dialogs messgae map
|
|
|
|
|
Hi,
I have build an ACTIVEX control using Visula Basic and i had taste it perfectly with Visual Basic Project But when I am trying to use it in VC++, It displays & functioning perfectly.
The ACTIVEX control consists of Directory Listbox and File Listbox.
Now, I want to access the value that user is selecting in ACTIVE X control in VC++ for further processing. For that I have created the Control Variable using ClassWizard that automatically create OCX header & Source files to access the OCX GET & LET properties.
I had created object of the OCX file and trying to call the Get Property.
My code snippet as below...
C_ocxFileExplorer objOcx;
objOcx.GetDirName();
It calls the function in _ocxfileExplorer.cpp as given below...
CString C_ocxFileExplorer::GetDirName()
{
CString result;
InvokeHelper(0x68030001, DISPATCH_PROPERTYGET, VT_BSTR, (void*)&result, NULL);
return result;
}
Now the problem is here.... I am getting an error in InvokeHelper function and when I am trying to Debug it...it shows me that ...
ASSERT(m_pCtrlSite != NULL); // not an OLE control (not yet, at least)
in WINOCC.cpp.
I will be very thanksful if anyone guide me...or any other idea to solve the problem.
Thanks in advance
|
|
|
|
|
I am trying to figure out if this is a computer problem or a (another) bug in Windows. My ultimate goal is to print a mirror image of a calibration tape using SetWorldTransform. Displayed output is fine, but when printed, all text is simpy rendered upside-down. Simply calling SetGraphicsMode without any transforms causes the same bug! Can someone create a simple SDI app and past this code into the OnDraw function. You will get a triangle and the word 'test' displayed. Now do a print preview. Is the word 'test' now shown upside-down?
TIA
Eric
void CTransformView::OnDraw(CDC* pDC)<br />
{<br />
pDC->SetMapMode(MM_LOENGLISH);<br />
SetGraphicsMode(pDC->GetSafeHdc(), GM_ADVANCED);<br />
pDC->MoveTo(150, -130);<br />
pDC->LineTo(260, -110);<br />
pDC->LineTo(260, -220);<br />
pDC->LineTo(150, -130);<br />
pDC->SetTextColor(RGB(0,0,0));<br />
<br />
CFont num_font_upper;<br />
num_font_upper.CreateFont(20 , 0, 0,0, FW_NORMAL, FALSE, FALSE, 0,<br />
ANSI_CHARSET, OUT_TT_PRECIS, CLIP_DEFAULT_PRECIS | CLIP_LH_ANGLES,<br />
PROOF_QUALITY, VARIABLE_PITCH |TMPF_TRUETYPE|FF_DONTCARE, "Arial"); <br />
<br />
CFont *pFont = pDC->SelectObject(&num_font_upper);<br />
pDC->TextOut(150,-130, CString("test"));<br />
pDC->SelectObject(pFont);<br />
}<br />
|
|
|
|
|
hi, guys,
In my current Winsock-based TCP program, on the client side, after I send my request data packet to the Server side using the send socket function, I attempt to get the socket status to see if it has something to read using the select function, and the select function always return 0 meaning the time limit expired on some users' computers, but it's just fine on another users' computers.
Why? Does anybody can tell me why and how to fix it? Thanks!
here's the code...
//...
SOCKET sckClient = socket(AF_INET, SOCK_STREAM, 0);
int nOne = 1;
setsockopt(sckClient, IPPROTO_TCP, TCP_NODELAY, (char *)&nOne, sizeof(int)); // just_say_no
struct sockaddr_in addr_to = { 0 };
//...
connect(sckClient, (struct sockaddr *)&addr_to, sizeof(addr_to));
char *buf;
//...
send(sckClient, (const char *)((char*)buf), nDataToSend, 0);
int nRetCode = ::select((int)sckClient + 1, &fdsRead, NULL, NULL, &tvTimeOut);
if (nRetCode==0 )
{ //ERROR: the time limit expired
//Here's the problem! some computers meet the error, but some don't! WHY???
}
recv(sckClient,(char *)buf,nDataToRead, 0);
//...
|
|
|
|
|
Does the second system receive the packets okay?
Kuphryn
|
|
|
|
|
With this message I would like to appologise to everyone that tried to download my article about the chat program. I will post it tonight and it will work. I am sorry for the dissapointment. It was a problem with the attachement.
gabby
|
|
|
|