|
Since there's only one instance of a static variable, it doesn't matter where it's stored.
It's counterintuitive because neither instance variables NOR "ordinary" static variables require two declarations, and the thousands of people who have had their time wasted by this quirk support this assertion.
|
|
|
|
|
Alan Balkany wrote: and the thousands of people who have had their time wasted by this
Thousands? I thought EVERYONE went through it at least once
I get where you're coming from - I just do not agree that there's two declarations. There's
a distinct difference between declaration and an actual instance of an object.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
This linked fine for me:
class Test : public CDialog
{
DECLARE_DYNAMIC(Test)
public:
static int cnt;
};
class Test1
{
void GetData()
{
int cnt = Test::cnt;
}
}; Can you compare it to what you have?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi David,
I fix the problem. Please refer the above.
|
|
|
|
|
That shouldn't link, at least not if you actually use one of those classes
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Mark Salsbery wrote: ...at least not if you actually use one of those classes
I didn't.
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Anyone know of an x64 PKWare compatible compression library (or a library with source code that would allow me to build the x64 version). I currently use an old version of the PKWare Data Compression Library that allows blocks of data to be compressed and restored but there isn't a 64bit version and PKWare don't list 64 bit versions of anything on their website.
|
|
|
|
|
Hi,
I have created a LIB using Win32 Static Library in which i have overriden the CWnd ::Create method.
when i use this LIB in MFC application to create the Window its giving ASSERSETION
due to parent window handle is becoming NULL.
|
|
|
|
|
Window handles don't just "become NULL".
The problem could be anything from mismatched or multiple MFC libraries
to errors in your code. Have you tried to debug it?
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hi,
I have created the Win32 Static Library which has MFC Support and Using Precompiled Header
(This LIB has been created by selecting Win32 Static Library from MFC Project Option )
I have added one class to library which is derived from CWnd, In Derived Class i have overriden the
Create()method to create the window.
At Application side
I have MFC SDI application which has multiple splitters where each pane of splitter corrsoponds to one class.
One of the class wants to create the window using the LIB that i have created.
when i give call to the Create from application side it is giving assertion on
ASSERT(afxCurrentInstanceHandle != NULL)
To Test LIB,i have tried for following things
I have created the TestApp using MFC SDI and while generating the Application CTestView is derived from the CFormView.
here call to Create of LIB is working fine.
|
|
|
|
|
Hello,
I need to parse a data file which contains reals.
The decimal separator use is always the dot '.'
I try to extract the values using a stringstream to get the result into a double.
As you probably know, stringstream use the current locale to determine the decimal seperator to use...
and that is my problem !
How can I tell to my stringstream to use the dot separator regardless the current locale ?
I can not find a "simple" snippet to do this.
Any idea ?
|
|
|
|
|
jeremie.delaitre wrote: Any idea ?
I don't know the specific answer. Based on my limited knowledge of STL I would think you could create a specific locale and make the stream use it. I think streams have like imbue() function or something to make them use specific locales.
led mike
|
|
|
|
|
Yes there is an imbue method and I can, in theroy, create my own.
Indeed, the documentation I have on it is vague so I wonder if a simpler solution exists.
|
|
|
|
|
jeremie.delaitre wrote: so I wonder if a simpler solution exists.
Depends on your definition of simpler. You could certainly parse the data yourself, perhaps using Regular Expressions.
led mike
|
|
|
|
|
Dear All,
My requirement is to change the bitmap of the button on mouse move and mouse over. I have used TrackMouse event to do this. But I have problem in this, that is, when I place a mouse over the button the bitmap is changed and again when I take mouse over the button the bitmap is again changed. This looks bad due to painting and re-painting continously. Please advice me a good way. The code is below :
void Test::OnMouseMove(UINT nFlags, CPoint point)
{
TRACKMOUSEEVENT trackmouseevent;
if(!click2)
{
trackmouseevent.cbSize = sizeof(trackmouseevent);
trackmouseevent.dwFlags = TME_LEAVE;
trackmouseevent.hwndTrack = GetSafeHwnd();
trackmouseevent.dwHoverTime = HOVER_DEFAULT;
_TrackMouseEvent(&trackmouseevent);
}
GetDlgItem (IDC_BUTTON3)->GetWindowRect (&rect);
ScreenToClient (&rect);
if ((!rect.PtInRect(point)))
{
bool val=but2.LoadBitmaps(IDB_BITMAP23,0,IDB_BITMAP23,0);
but2.Invalidate();
but2.UpdateWindow();
}
GetDlgItem (IDC_BUTTON2)->GetWindowRect (&rect);
ScreenToClient (&rect);
if ((!rect.PtInRect(point)))
{
bool val=input.LoadBitmaps(IDB_BITMAP22,0,IDB_BITMAP22,0);
input.Invalidate();
input.UpdateWindow();
}
CDialog::OnMouseMove(nFlags, point);
}
LONG Test::OnMouseLeave(WPARAM , LPARAM)
{
POINT point;
GetCursorPos(&point);
ScreenToClient(&point);
CRect rect;
GetDlgItem (IDC_BUTTON2)->GetWindowRect (&rect);
ScreenToClient (&rect);
if (rect.PtInRect(point))
{
bool val=input.LoadBitmaps(IDB_BITMAP57,0,IDB_BITMAP57,0);
input.Invalidate();
input.UpdateWindow();
click2=false;
}
GetDlgItem (IDC_BUTTON3)->GetWindowRect (&rect);
ScreenToClient (&rect);
if (rect.PtInRect(point))
{
bool val=but2.LoadBitmaps(IDB_BITMAP58,0,IDB_BITMAP58,0);
but2.Invalidate();
but2.UpdateWindow();
click2=false;
}
|
|
|
|
|
Unless I'm mistaken, you're reloading the button's bitmap each and every time the mouse sends a move event. Why don't you only draw the bitmap when it changes?
You could either keep a track of the mouse position last move, and compare the last pos to the current pos, to see if the mouseOver status has changed for either button.
Or, you simply could add some flags to hold the current mouseOver status of each button. Comparing the current status with the last to determine if the bitmap needs to be changed to reflect the mouse position.
|
|
|
|
|
Hi
I am creating plugin for VS2005 in which i want to handle the Click event of Window->New Vertical Tab. i.e. Whenever user click on plugin icon, "New Vertical Tab's events should call. So Is there any API for handling above events.
Regards
aaa
|
|
|
|
|
HI,
in CString Find Function can i use variable insted of fixed text.
Just for example .
CString str = _T("ABCD edbd CDE ~");
int nPosition = str.Find("~",0);
instead of passing " ~ " can i use any varible ?
Just like this CString EndDelimeter = _T("~");
int nPosition = str.Find(EndDelimeter ,0);
Because user can change any special charecter as End delimeter.
Plz advice me
Preethi
|
|
|
|
|
Hi,prithi
U can use Replace() function of CString Class.
|
|
|
|
|
hi Atul,
I dont want to Replace The string , I just want to find the Special character position.
|
|
|
|
|
Yes, you can use any text variable with the CString::Find() method. Are you not able to do something? What do you need advice with?
|
|
|
|
|
Thank u , Iam able to do that now. while i run first time i got errors. Sorry to disturb u .
|
|
|
|
|
I am creating object for CStatic, but I am not able to set the Text for that CStatic control through another function of ButtonClicked.
I am getting an error as :
Unhandled exception at 0x7c2399ba (mfc71d.dll) in hit.exe: 0xC0000005: Access violation reading location 0x000042ba.
In short I am getting Access violation error.
Please reply.
|
|
|
|
|
Member 4370385 wrote: I am creating object for CStatic
How did you do that ?
|
|
|
|
|
Member 4370385 wrote: ...but I am not able to set the Text for that CStatic control...
How are you doing this?
Member 4370385 wrote: In short I am getting Access violation error.
Have you used the debugger to step through the code to find out where the access violation is happening?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|