|
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
|
|
|
|
|
Hi guys,
I'm looking for some ASCII characters that can be used as some sort of separator delimiters. For example, I have few string fields I'd concatenate into one long string and put into CListBox. Then I'd need to be able to retrieve the string and break them up back to original fields. So ideally, those separators should be invisible on the display.
(S)Hi, The(E)(S) Code (E)(S)Project is Cool!(E)
would display as
Hi, The Code project is Cool!
where (S) is invisible start delimiter and (E) is the end delimiter.
I tried "Unit Separator" and "Record Separator" (0x1F and 0x1E respectively), they work fine in Windows XP, where these are not displayed. However, when I moved the app to Windows 98, they are shown visibly as rectangle blocks.
I'm wondering if the difference is due to the uses of unicode and not.
If so, are there any ASCII I can use for my purpose?
Thanks alot!
|
|
|
|
|
There are no characters you can use for non-UNICODE, the ANSI-fonts are supposed to show a "dummy"-character for codes they don't define. So, yes, you are right, this is a question of UNICODE and non-UNICODE
What I would have done would be to create an owner-drawn listbox (which is not at all difficult once you've done it once or twice, if you hesitate). There, I would have split the strings according to some of me defined delimiter.
|
|
|
|
|
Thanks alot Johan,
I'm trying to think very hard to how Owner Draw on CListCtrl (it's actually CCtrlList I'm using) can help me. But you were right. Since I haven't done this before, I have trouble to figure out a way. I'd really appreciate some hints here
Do you mean that I could somehow display the string and "hide" those delimiters? My understanding to Owner Draw is being able to draw images and customise text. I don't really know how it can help in my case.
Thanks again
|
|
|
|
|
Consider a listbox containing the string
Alpha|beta
In a draw handler, we get the string, and want to use the bar as a delimiter.
CString left;
CString right;
int found = str.Find( _TCHAR( "|" );
if( found != -1 )
{
left = str.Left( find );
right = str.Right( str.GetLength() - ( found + 1 ) );
dc->TextOut( left, ...
dc->TextOut( right, ...
}
You might want to check the articles in http://www.codeproject.com/listctrl/[^], I notice that the very first one discusses owner-drawing.
|
|
|
|
|