|
Are you sure that you are not deleting the same memory pointer twice???
or are you deleting the pointer in another thread and created it another thread?
or are you allocating the pointer in .exe file and deleting it in the dll ?
All the above cases can lead to problems.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Hi all,
When using the CreateThread within a class, is it possible to provide a method of the class as the lpStartAddress?
m_hBroadcastThread = CreateThread(0,0,<br />
(LPTHREAD_START_ROUTINE)BroadcastThread,<br />
0,0,&id);
... where BroadcastThread is the name of a method within the class. It's header is as follows:
DWORD CNotificationsHandler::BroadcastThread(LPDWORD param)
I keep getting the following compiler error:
error C2440: 'type cast' : cannot convert from '' to 'unsigned long (__stdcall *)(void *)'
Your help would be greatly appreciated.
Mark
|
|
|
|
|
If the thread method is in the class then it should be declared as static.
The member functions of the class has the calling convention as thiscall too, which need to be removed by making it static.
and while creating the thread pass 'this' pointer to the thread so that the thread function can access the member functions and variables of the class.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
Worked wonderfuly.
Thanks
|
|
|
|
|
|
Also, if you are using the C Runtime Library AT ALL, you might want to be using beginthreadex instead of CreateThread. CreateThread does NOT initialize some thread local data used by each thread in the C run time library.
|
|
|
|
|
hi
i have a CRichEditCtrl in my app and it can't open UNICODE files properly (opens ANSI files ok). what do i have to do ?
here's part of my code:
CRichEditCtrl * richedit = (CRichEditCtrl *)GetDlgItem(IDC_RICHEDIT1);
CFile file(filename, CFile::modeRead);
EDITSTREAM es;
es.dwCookie = (DWORD) &file;
es.pfnCallback = MyStreamInCallback;
richedit->StreamIn(SF_TEXT, es);
richedit->SetReadOnly();
the callback is straight from msdn i think ..
static DWORD CALLBACK
MyStreamInCallback(DWORD dwCookie, LPBYTE pbBuff, LONG cb, LONG *pcb)
{
CFile* pFile = (CFile*) dwCookie;
*pcb = pFile->Read(pbBuff, cb);
return 0;
}
|
|
|
|
|
If you know it's UNICODE for certain, and you also know it's a RichEdit v2.0 or later, then try
richedit->StreamIn( SF_TEXT|SF_UNICODE, es );
instead.
(This isn't in the on-line help for CRichEditCtrl, but it is for EM_STREAMIN in the platform SDK docs)
Steve S
|
|
|
|
|
thank you.
now i have to find a way to check if the text is unicode or not - istextunicode() doesnt seem to work correctly
|
|
|
|
|
First off, you can check for a BOM (byte order mark), and if there isn't one, scan for EOL ('\n') BYTE using memchr(). If you find one, and there are NUL ('\0') bytes either side of it, it's almost certainly UNICODE.
If your text contains only one line, this won't work, of course.
Steve S
|
|
|
|
|
thank you agan.
i decided not to detect if it is unicode programmatically, but still a have a small problem left - when i display unicode string there is some garbage at the beginning of the text (1-2 bytes, "FF FE" usually), any idea how to avoid it?
may be i should start reading the file with StreamIn from the first ASCII code ?
|
|
|
|
|
How can i save save a text string with formatting to a tga file using GDI??
Rashid
It is necessary once in one's life to put every thing in doubt, so far as possible, in order to reach the truth. DesCartes
|
|
|
|
|
You can't save a TGA file using GDI, if you can't use GDI+, you need to use another library like Paintlib.
To save the string, you need to draw it onto the bitmap.
Christian
I have drunk the cool-aid and found it wan and bitter. - Chris Maunder
|
|
|
|
|
I used a program that accesses the internet form a book called "Sams teach your self Visaul C++ 6
Online in Web time" ( isbn 067231668) The program is at page 496. I also used the sample program off the CD rom and get the same result. Every time I use the program I get "URL Does not use a Recognized protocol" Where do I go from here to solve this problem?
Thank you,
doug@evansville.net
|
|
|
|
|
Perhaps you're using a misspelled protocol, eg: htpt://foo.com ?
/ravi
My new year's resolution: 2048 x 1536
Home | Articles | Freeware | Music
ravib@ravib.com
|
|
|
|
|
1.These two are supposed to take int args: Yet I see them being used a as isalpha('t') etc, i.e we are giving it a char arg. Why is that?
2.I did:
char r[256] ;
int t;
cout << " enter string ";
char c = cin.peek();
cin >> r;
while (c != '\n')
{
c = cin.peek();
if (isalpha(c))cin >> r;
}
cout << " tr" << r << endl;
}
but when I put in 'abc%def' i got back the identical thing, not 'abcdef' which is what I expected...
3.Also I wanted to weed out spl chars using isalnum so that an input like
abd$ef would get fed in and come out like abdef:
char s[256];
cin >>s;
but isalnum wont work either...
thanks,
ns
|
|
|
|
|
nss wrote:
These two are supposed to take int args: Yet I see them being used a as isalpha('t')
The original C library has some, shall we say, "interesting" designs. One of them being that the character-oriented functions (most notably getchar() ) actually operate on int s. This is because of EOF , which is a special value that cannot be a legal char value. So the parameter type is something that can hold all legal char values, plus EOF , and they chose int .
--Mike--
Personal stuff:: Ericahist | Homepage
Shareware stuff:: 1ClickPicGrabber | RightClick-Encrypt
CP stuff:: CP SearchBar v2.0.2 | C++ Forum FAQ
----
You cannot truly appreciate Dilbert unless you've read it in the original Klingon.
|
|
|
|
|
As an answer to the first reply:
I wouldn't say 'interesting'. I find it extremely useful that I can use both character symbols and integers to a character stream. Using an integer variable with a character conversion gives me access to symbols that are not normally available in the C/C++ coding syntax, such as scandinavian characters.
Now, for the other questions. Firstly, you should consider using some other stream input function. Read the entire input string in first, then go through the string, removing all invalid characters. The problem with your function above is that when you peek the character, and then test it in against the alphanumeric conversion, you don't explicitly convert the character into an integer. Add an (int) conversion operator before c . This might solve the problem, but an even better implementation is to read the entire string first.
What happens now is that you peek the character, and if it is alphanumeric, it is read into the input stream. If it is not alphanumeric, the character is left into the input stream, and you peek for the next character. As it happens now, the next character is considered alphanumeric, and the cin >> operation executes, and it actually reads everything from the input stream into the buffer, because r has lots of space available.
Here is an alternative implementation that is a bit closer on what you are trying to accomplish:
char buffer[256];
char c;
int nIndex = 0;<DIV>
cout << "Enter string: ";<DIV>
while (c != '\n')
{
cin >> c;
if ( isalpha( (int)c ) )
{
buffer[nIndex] = c;
nIndex++;
}
} Not sure if that will work, but test it out & debug if needed.. But you should get the big picture
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
|
i want to create a window that when the application or dialog is deactivated
or when mouse is clicked ont over of menu rect this window automatically
close.
thanks
|
|
|
|
|
you need to add a handler for WM_KILLFOCUS event and then post WM_QUIT message to your application.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
i am making a application which takes input from serial port and stores it in access database, Now i have been asked whether its possible to give user option to choose database to feed data into (through FILE->Open)
Also if it is possible to create a new database ( new .mdb file )in File->new
This is my first professional project and i dont have any other technical inputs except this site. I want to know whether its allowed/possible ( copyright issues ?) to create file in Ms access format ? and if yes how ? which classes will be useful to me ?
Heuriskeinner
|
|
|
|
|
heuriskeinner wrote:
if it is possible to create a new database ( new .mdb file )in File->new
yes it is possible, you need to use the appropriate sql command i.e "Create database..." to create a new database.
heuriskeinner wrote:
which classes will be useful to me ?
CDaoDatabase and its supporting classes will be usefull for you.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|
|
hi,
do someone know witch DLL file can contains all nio functions?
like this one: int _kbhit( void ); //Checks the console for keyboard input.
i want to import this function in my c# application.
thank u in advance!
|
|
|
|
|
LIBC.LIB Single thread static library, retail version
LIBCMT.LIB Multithread static library, retail version
MSVCRT.LIB Import library for MSVCRT.DLL, retail version
anyways i belive in C# there must be something similar to kbhit.
MSN Messenger.
prakashnadar@msn.com
|
|
|
|