|
Ann66 wrote:
I did'nt change anything in the code expect for I declared the var1 & var2 as static...
My point exactly. Static member variables must be defined and initialized outside of the class declaration.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclang/html/_pluslang_static_data_members.asp
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Ya ..It worked..thanks a lot
|
|
|
|
|
Hello,
Declare your var like this:
<br />
class myclass<br />
{<br />
public:<br />
static int var1, var2;<br />
};<br />
You can access the vars like this
<br />
myclass::var1 = 1;<br />
myclass::var2 = 8457;<br />
Multiply it by infinity and take it beyond eternity and you'll still have no idea about what I'm talking about.
|
|
|
|
|
It worked..thanks a lot..
|
|
|
|
|
I'm writing some sort of firewall, using the hook driver from microsoft.
I want to take the packet received up to the user mode ap to make the filtering there, cause that way, using user mode api i can know which process is holding a connection.
I know this method will slow down the connection... but it's just an experiment
Then... I'd like to know if for every packet there's a new instance of the driver, or they're queued. cause if they are queued the method above, would be slow AND i'll miss some packets
Thank you in advance for your help
|
|
|
|
|
It depends on the type of your driver...
Yours sincerely,
Alex Bash
|
|
|
|
|
|
Hi Guys,
I have a class derived from CStatic that I used to create my own custom static display. I try to use SetBitmap to insert an image into the control as a background and then I draw the text on top of that. The problem is that sometimes the button doesn't show the image that I set into it. Sometimes it shows windows controls(minimize button, maximize button, or just garbage), but this only happens sometimes. I cannot reproduce the problem consistently so maybe I am leaking resources or something, I don't know. Here is my code. Can anyone tell what is wrong?
void CStatusDisplay::SetButton(CString cszFilename, UINT nIDResource)
{
CBitmap cbBitmap;
HBITMAP hBitmap;
HBITMAP hOldBitmap=NULL;
if(cszFilename!="")
{
if(LoadBitmapFromFile(cszFilename, cbBitmap))
{
hBitmap = (HBITMAP)cbBitmap.Detach();
hOldBitmap = SetBitmap(hBitmap);
}
else
{
AfxMessageBox("Error loading bitmap in display status");
}
}
else
{
if(cbBitmap.LoadBitmap(nIDResource))
{
hBitmap = (HBITMAP)cbBitmap.Detach();
hOldBitmap = SetBitmap(hBitmap);
}
else
{
AfxMessageBox("Error loading bitmap in display status");
}
}
if(hOldBitmap!=NULL)
DeleteObject(hOldBitmap);
}
//This gets called in OnPaint!!
void CStatusDisplay::Draw()
{
CClientDC dc(this);
CRect rect;
GetClientRect(&rect);
CMemDC2 memDC(&dc, &rect,TRUE);
//memDC.FillSolidRect(&rect, RGB(72,82,107));
//memDC.FillSolidRect(&rect, RGB(255,0,0));
DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, (LPARAM)0);
//add some text on top of that
CFont font;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = m_nFontSize;
if(m_bBold)
lf.lfWeight = FW_BOLD;
if(m_bItalics)
lf.lfItalic = TRUE;
strcpy(lf.lfFaceName, m_cszFontName);
font.CreateFontIndirect(&lf);
CFont* def_font = memDC.SelectObject(&font);
memDC.SetBkMode(TRANSPARENT);
memDC.SetTextColor(m_crTextColor);
UINT uFormat = NULL;
if(m_cszAlign == "left")
uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER |DT_LEFT | DT_END_ELLIPSIS;
else if(m_cszAlign == "lefttop")
uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_TOP |DT_LEFT | DT_END_ELLIPSIS;
else if(m_cszAlign == "center")
uFormat = DT_SINGLELINE | DT_NOPREFIX | DT_VCENTER |DT_CENTER | DT_END_ELLIPSIS;
else if(m_cszAlign == "wordbreak")
uFormat = DT_NOPREFIX | DT_VCENTER |DT_CENTER | DT_WORDBREAK;
memDC.DrawText(m_cszStatus, &rect, uFormat);
memDC.SelectObject(def_font);
BOOL bRet = font.DeleteObject();
}
CStaticDisplay::OnPaint()
{
CPaintDC dc(this);
Draw();
}
|
|
|
|
|
I am trying to create an owner draw List Box in a dialog so I can have the option of displaying lines in bold font. I am using the OnDrawItem but this function does not get called by the framework. Why is this so?
|
|
|
|
|
In addition, when I select Owner Draw (fixed) and Has Strings for the control properties, I cannot even bring up the dialog. I get the error: The exception Breakpoint: A breakpoint has been reached. (0x800000003) occured in the application at location... etc.
|
|
|
|
|
Use the "DrawItem" not the OnDrawItem
and you can use the "MeasureItem" to set the height of the items
|
|
|
|
|
Hi.
I have read an MS Project XML file and would now like to create a nice view of the tasks. I really don’t know how to start.
Anyone know if there is any MS Project-like view that I could start from?
The View I would create should look like (see URL):
http://www.ceco.se/bilder/Task.jpg
All tips are helpful!
_____________________________
...and justice for all
APe
|
|
|
|
|
Binding a multicast socket to a specific network adapter on w2k boxes with two (or more) network adapters with tcp protocol installed does not work properly. The in/outbound multicast traffic is sometimes going to the wrong adapter. The only way to get this working is to disable the other adapter, send at least one multicast packet through the specified card and then enable the other adapter again. After reboot the same problem appears again. I think that's a Windows bug but I haven't found any prove for that.
Any help would be more than appreciated.
|
|
|
|
|
I have text file with several lines.
I want to read this file using CFile object line by line i.e. read one line and copy it to CString object, read next line and copy to CString object....
How to do this?
Thanks & Regards,
Neeraj
|
|
|
|
|
Neeranjan wrote:
How to do this?
Use CStdioFile instead.
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
Do you need to use CFile ? Can't you use CStdioFile instead (it derives from CFile) ?
With CStdioFile, you can read a text file line by line.
|
|
|
|
|
Due to the fact that CFile does not have a read line implementation you will need to read one character at a time from the stream and look for '\r' once you find that character you have found the end of the line.
Remember on Windows a Line is delimited by \r\n
so after you find a \r you need to skip the next character in the buffer.
Something like this
CFile x;
//Load your File for processing
CString y;
char temp[1];
ZeroMemory(temp, sizeof(temp));
for(int i = 0; i < x.GetLength(); i++);
{
x.Read(temp, 1);
if (x != '\r')
y += temp;
else
{
x.Read(temp, 1); //Skip the next character it should be \n;
//Do something with your new line
}
}
Forever Developing
|
|
|
|
|
We have an application on Solaris and Windows that uses the fopen family of calls to perform file I/O operations. However it was discovered that fopen has a limit of 255 open file handles for a process. We therefore need to replace fopen with C++ fstreams to circumvent this problem. However the MSDN reveals that a fstream object internally uses a basic_filebuf object for stream buffering which in turn uses the fopen family of calls for file I/O. We therefore wrote a test program to validate this fact. Surprisingly however the test program, which uses fstream objects to open files does NOT fail at the limit of 255 but instead goes on to open more than 2000 files. This apparently contradicts with what MSDN says about fstream objects internally using fopen family of calls for file manipulation. Can someone provide me some pointers in this regard?
|
|
|
|
|
What is it that you are wanting to know? If you needed more than 255 files opened simultaneously and your test application proved that more than 2,000 files could be, isn't your problem solved?
"When I was born I was so surprised that I didn't talk for a year and a half." - Gracie Allen
|
|
|
|
|
I can not directly answer your question, but I have a suggestion.
You can load the visual studio and the source code to the C runtime library and maybe see what the basic_filebuf calls are doing. The fopen calls eventually use the CreateFile API, but because of using the pseudo file handles, you run into the problem with a file open limitation. Maybe the other calls using the basic_filebuf do something different to avoid the limitation. After examining the source code, you can assure yourself that the MSDN is indeed wrong.
|
|
|
|
|
What OS are you on? The MSDN infomation may give you the maximum number for a windows 9X machine. MSDN seems to always state the lowest common denomionator when giving information.
The only way to know if your solution is viable is to try it out on all the OS's it will be deployed on. Noting Service Pack Level and Version of IE installed.
Best of Luck
Forever Developing
|
|
|
|
|
int _setmaxstdio(int newmax) is your friend . On .NET 2003 fopen defaults to 512 simultaneously open files which can be increased to 2,048 using this method. fopen() etc. are low-level C routines that C++ fstream is built on top of, therefore it probably just sets the default to the upper limit when it initialises 'for maximum simplicity'.
Hope that helps ya,
Al.
"When I left you I was but the learner, now I am the master" - Darth Vader
|
|
|
|
|
Thanks guys for reply.
Thank you Alan Chambers for giving right pointer.
|
|
|
|
|
Hello to all.
I'm a "Last-becomers" in VC++.
During my first try using MFC and VC++ ,I found this linker error.
------------------------------------------------------------------------
Linking...
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __endthreadex
nafxcwd.lib(thrdcore.obj) : error LNK2001: unresolved external symbol __beginthreadex
---------------------------------------------------------------------
What must I do to solve this problem?
My program isn't an application created by the MFC wizard.
It is small and i post it for let you know the caos that I had create.
-----------------------------------------------------------------------
MyFirst.h
class CMyFirst : public CWinApp
{
public:
virtual BOOL InitInstance();
};
//the window
class CMyMainWnd : public CFrameWnd
{
public:
CMyMainWnd();
protected:
afx_msg void OnPaint();
DECLARE_MESSAGE_MAP();
};
-------------------------------------------------------------------------
MyFirst.cpp
------------------------------------------------------------------------
#include<afxwin.h>
#include"myFirst.h"
CMyFirst first;
BOOL CMyFirst::InitInstance()
{
m_pMainWnd = new CMyMainWnd();
m_pMainWnd->ShowWindow(m_nCmdShow);
m_pMainWnd->UpdateWindow();
return true;
}
BEGIN_MESSAGE_MAP(CMyMainWnd,CFrameWnd)
ON_WM_PAINT()
END_MESSAGE_MAP()
CMyMainWnd::CMyMainWnd()
{
Create(NULL, _T("My beautiful application"));
}
void CMyMainWnd::OnPaint()
{
CPaintDC *dc=new CPaintDC(this);
CRect *rect=new CRect();
GetClientRect(rect);
dc->TextOut(30,30, CString (_T("La prima scemenza stucchevole")));
delete dc;
}
----------------------------------------------------------------------
I'm waiting for responses...
Thanks a LOT..
Jenie_net
|
|
|
|
|
I am not sure which IDE you are using but you need to include nafxcwd.lib in your linker settings. Unresolved external sysmbols come from the linker not being able to find the implementation of the function in the header file.
I am using MSVS 2003. So I go to Project on the file menu then Properties. I then select linker from the listview. Then under general there is an Option for additional Library Directories. Add the path to nafxcwd.lib. This should fix it.
Best of Luck
Forever Developing
|
|
|
|