|
Hi all,
I'm using fgetwc to get characters from a file.
In ALL cases BUT 1, It calls this like it is supposed to (in _FGETWC.C):
if ((stream->_cnt -= sizeof(wchar_t)) >= 0)
-----> return *((wchar_t *)(stream->_ptr))++;
else
return (wint_t) _filwbuf(stream);
In this single case (and there's about 300 of them), this gets called:
if ((stream->_cnt -= sizeof(wchar_t)) >= 0)
return *((wchar_t *)(stream->_ptr))++;
else
-------------> return (wint_t) _filwbuf(stream);
And my application goes out the window, along with my monitor
I can move the information around in the data file, and it's fine, but when in a specific order I get this every time.
I really have no idea what is going on here. My gut says it has something to do with the wide character buffer going out of whack. Any ideas or suggestions?
Thanks alot!
|
|
|
|
|
When CRTL (C-Runtime Library) routines start to crash, it almost always means you have other bugs in your program that is trashing memory. Data structures used by the CRTL are getting trashed and thus crashing.
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
Yes that is true. I found a really weird case though.
As it turns out, the FILE stream buffer is allocated in 4k segments. When you do an fread, the fread checks the size left in the buffer and puts as much as it can into that buffer and sets a flag saying the buffer is full. At that point a new buffer is allocated and fread continues along it's merry way.
In my case I'm using fgetwc, which gets 2 characters (4 bytes). It checks to see if there is enough space in the buffer for the 2 characters, and if so puts it in. If there is not enough space (meaning there is only 2 bytes left in the buffer), it returns 2 chars worth of jargen, causing the application to bomb.
Becuase it only occurs when there I am calling fgetwc and there is only 2 bytes left in the buffer, I am rarely seeing this case but am able to easily reproduce the problem.
My solution, to not use fputwc and fgetwc anymore, but to use fwrite and fread.
You can find this in the _FGETWC.C that came with VC++ 6.0
|
|
|
|
|
Hi all,
GDI has a way of making you feel stupid. I have been struggling with this the whole day and have not found a way to do this.
I have a custom control on top of a main window. It has a bitmap as a background. I can initialize it and it shows just fine.
Now, I have another custom control which has the first control as the parent and is displayed on top of the parent. Now, I want the control to be transperant i.e. the user should be able to see the parent's bitmap background. However, it grays out the client area of the second control.
I tried everything from all kinds of brushes and SetBkMode(TRANSPARENT) but to no avail. If anyone with some experience in this area and might have an idea to what I need to do, I would REALLY appreciate it. If they live near Stuttgart, I would do their laundry for a month and bring the morning coffee and bagels!
Thanks,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
There's some things you can do with regard to "layered windows". Here's an article that deals with them a little bit, to create a transparent window, but I'm not sure if it will help:
http://www.codeproject.com/useritems/forecast.asp[^]
Chris Richardson
You can stash and you can seize
In dreams begin, responsibilities U2 - Acrobat[^]
Stop being PC and accounting for everyone and his momma's timeframe. Just enjoy your - Rohit Sinha in the content-challenged thread
|
|
|
|
|
Hi,
Thanks for your reply. I tried setting the window creation style and adding the transparent parameter to the _exStyle member..but nothing..still the gray area at the child control.
Thanks anyways I appreciate you taking the time.
Sincerely,
Pankaj
Without struggle, there is no progress
|
|
|
|
|
Someone else mentioned using layered windows. As a footnote, layered windows only work with top-level windows, not child windows.
Try overridding the WM_ERASEBKGND message and doing nothing. If this is not enough, then try sending a WM_PRINT message to the parent window which basically asks it to render itself into a HDC of your choosing. Then use the resulting image to draw your background.
Joel Lucsy
|
|
|
|
|
When handling the OnEraseBkgnd, return a Hollow brush, rather than doing nothing.
EX:
return (HBRUSH)GetStockObject(HOLLOW_BRUSH);
|
|
|
|
|
Greeting,
I am working on a project that need to restore a CTreeCtrl to its previous state when my application starts up. The state of CTreeCtrl will be saved when application exits and restored when application starts up.
Is anyone have any ideas how this is being done?
Thanks alot,
J. Wei
|
|
|
|
|
|
Thank you so much!
J. Wei
|
|
|
|
|
Hello...I'm declaring a class array of size 80,000,000...when compiling there is an error that the size exceeds the allowed one and the program may not run.
I tried but it really does not work..it says that the program is not a win32 application.
My solution is to declare the class array dynamically:
myclass1 = new myclass[size]
When I tried with this there is no memory allocated and the program aborts.
As myclass has some double data and other classes embedded, I guess I need to overload the operator new so to create the needed space.
Can anyone help me how to do this, assuming the class is defined as:
class myclass{
public:
myclass2 curr_data2;
myclass3 curr_data3;
myclass2 new_data4;
myclass3 new_data5;
}
and the other classes
class myclass2{
public:
double x;
double y;
double z;
}
class myclass3{
public{
double motionX;
double motionY;
double motionZ;
}
Thanks,
Eric Manuel Rosales Pena Alfaro
PhD student
Unversity of Essex
Wivenhoe Park
Colchester, CO4 3SQ
Essex, Uk
email: emrosa@essex.ac.uk
tel: +44-01206-87311
|
|
|
|
|
A quick calculation yields that for the array alone, the program will use approximately 3.6G of memory. I think you need to re-think your array size to bring it down to a much smaller number.
Chris Meech
"what makes CP different is the people and sense of community, things people will only discover if they join up and join in." Christian Graus Nov 14, 2002.
"Microsoft hasn't ever enforced its patents. Apparently they keep them for defensive reasons only. Or, they could be waiting 'til they have a critical mass of patents, enforce them all at once and win the game of Risk that they're playing with the world." Chris Sells Feb 18, 2003.
|
|
|
|
|
The default stack size is 1MB, hence the compiler error. Allocating much more than that (100s of MBs) from the heap is possible but I would still question the need. That's not to say that a need doesn't actually exist, but to just nonchalantly ask the OS for GBs, or even MBs, of memory all at once is questionable.
|
|
|
|
|
easy dude, that's pretty nuts. are you sure you NEED 80 MILLION of your class thingy's, or are you just allocating that many "to be on the safe side" ?
I suggest you look into std::vector. It just may provide all the answers you seek.
i.e., if you need another one of your classes, just do something like:
std::vector<MyClass*> vpMyClass;
for(int i=0; i<iSomeNumberOfNeededClasses; i++)
vpMyClass.push_back(new CMyClass);
just remember to delete everything and empty the vector when you're done.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
Hmm..
Has anyone written an add-in wizard for Visual C++ 6.0 Enterprise, which allows you to generate blank MFC projects ?
The same in english: I want to create MFC projects from scratch, but I cannot do this, as the ClassWizard is not available by default. How can I activate ClassWizard for a project that does not have anything in it ?
I already know that I can add MFC-support to a Win32-project (EXE/DLL) by choosing it from the project settings. However, for some strange reason, this doesn't always work. What I want to do, is to be able to write an MFC-application from scratch using the ClassWizard..
-Celorfie
|
|
|
|
|
um... my version of VC++ has an "MFC Appwizard"
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I have a program which is installed on a Windows 2000 server which has Terminal Services installed. The question is: How can I limit the number of instances of the program opened by all users. (eg. 4 concurrent users can use the program at the same time)
Your soonest help is appreciated...
~~~~~~~~~~~~~~~
CDRom
|
|
|
|
|
Read here:
http://www.flounder.com/nomultiples.htm
|
|
|
|
|
I have a float value which is say 1.21000 and I want to print it as 1.21 only . I am using CString Format function to make it printable
like
float x;
..
..
CString myData;
myData.Format("%f",x);
How do I get to print 1.21 instead of 1.21000 . Please help .
|
|
|
|
|
act_x wrote:
myData.Format("%f",x);
Change to:
myData.Format("%.2f",x);
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Hallo!!
I want to select items in a ListCtrl not by the user , i want select the whole items in row in Report style by the programm. Not the user should select the row,
the programm must do this. There are Columnes, and the whole row must be selected.
The second problem is thsize of the items, there are only
labels (text) in the control, no imiges.
How can I change the size of the items/text ??
Thank You for helping me,
Dirk from Germany
|
|
|
|
|
schoni wrote:
I want to select items in a ListCtrl not by the user , i want select the whole items in row in Report style by the programm. Not the user should select the row,
the programm must do this. There are Columnes, and the whole row must be selected.
SetSelectionMark(...)
I'm not sure if it's the right method
schoni wrote:
The second problem is thsize of the items, there are only
labels (text) in the control, no imiges.
How can I change the size of the items/text ??
Ownerdraw!
Rickard Andersson8
Here is my card, contact me later!
UIN: 50302279
E-Mail: nikado@pc.nu
Interests: C++, ADO, SQL, Winsock, 0s and 1s
|
|
|
|
|
Something like:
CListCtrl &ctrlList = GetListCtrl();
BOOL x;
for (int nItem = 0; nItem < 10; nItem += 2)
{
x = ctrlList.SetItemState(nItem, LVIS_SELECTED, LVIS_SELECTED);
TRACE("x = %d\n", x);
}
|
|
|
|
|
Make sure you set LVS_FULLROWSELECT (or something like that) also to select the whole row.
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|