|
printf("%s", hd);
This doesn't work because sending a CString to printf() is meaningless. You must cast it to (LPCTSTR).
--Mike--
http://home.inreach.com/mdunn/
This must be Thursday. I never could get the hang of Thursdays...
|
|
|
|
|
Thanks for quick reply mike,
if you notice I did cast it to LPCTSTR in the next printf function, but all i still got was the first character of the string.
To Code or not to code, that is the question
|
|
|
|
|
Ah, it's probably because you're using printf() when you should be using wprintf(). CE is a Unicode OS, so when you pass a Unicode string to printf(), it views the string as an ANSI string. The first byte is 't' and the second byte is 0.
Also, use wcout instead of cout, and add (LPCTSTR) casts to your CStrings to make sure they're being passed as C strings instead of C++ objects.
--Mike--
http://home.inreach.com/mdunn/
This must be Thursday. I never could get the hang of Thursdays...
|
|
|
|
|
I'm developing a program required to use Synchronization function WaitForSingleObject(). It may take several seconds or longer to run this function, therefore, I want to add a Progress Bar control to let the user knows how long do they need to wait. However, I cannot find the source code of this WaitForSingleObject() function, so I cannot put the progress bar SetPos() in that function. I've tried to set the progress bar move by timer...but when the program run WaitForSingleObject(), the progress bar stopped and start move again after WaitForSingleObject().
Can I do it in this way???::
If originally the timeout value is 16000....(WaitForSingleObject(xxxx, 16000)), then I split it into ... let say....5 ......e.g.:
WaitForSingleObject(xxxx, 3200);
Call ProgressBarControl;
WaitForSingleObject(xxxx, 3200);
Call ProgressBarControl;
WaitForSingleObject(xxxx, 3200);
Call ProgressBarControl;
WaitForSingleObject(xxxx, 3200);
Call ProgressBarControl;
WaitForSingleObject(xxxx, 3200);
Call ProgressBarControl;
So that the progress bar can update every 3200 time interval?.....
Or do anyone have another suggestion on using WaitForSingleObject with Progress Bar?? I must use this WaitForSingleObject function......
Sorry...I just a beginner in MFC programming;P
|
|
|
|
|
Instead of WaitForSingleObject could you not use MsgWaitForMultipleObject just before the thread is about to do it's stuff create a Timer that fires every second. when MsgWaitForMultipleObjects returns determine what's happened has the thread finished or do you have a windows msg i.e. WM_TIMER.
if this is appropriate you could have a class variable that indicates what step the thread is up to - wrapped by a CriticalSection so you can update your UI accordingly.
|
|
|
|
|
How can I create a Microsoft Visual C++ style build log window?
Thanks
|
|
|
|
|
Check out the BCGControlBar library at BCGSoft (it used to be housed here at CP, but it's been taken down.)
--Mike--
http://home.inreach.com/mdunn/
This must be Thursday. I never could get the hang of Thursdays...
|
|
|
|
|
I visited the site, and the library seems very good, but what I need is not an EXACT copy of the visual c++ build window. I only need to know how to create a window with an edit control in it, that moves, docks and behaves similar to the one in visual c++.
|
|
|
|
|
I'm kind of new to MFC. I used to using Borland.
How can I convert a CString to a char array[40].
To be used as a filename I will open using old style ansi C fopen.
Additionally I noticed that in Microsoft VC++ you can not write a int long or double using fstream or iostream. This is pretty Lame. In Borlands compiler you write a double
somefile lessthan operator somedouble lessthan operator endl
Is there an easier way than using the old ansi style C fprintf to get your double written to a file.
Switching over to MFC is a pain when your used to using datatypes as other than characters.
JLS
Student/Part time programmer
Major Programming.
|
|
|
|
|
How about:
char *s = strdup(LPCTSTR(MyCString));
(don't forget to free s later...)
As far as I remember it should work...
- Anders
|
|
|
|
|
char array[40];
CString str = "whatever";
lstrcpy ( array, str );
But, if you're just passing the filename to a function - that is, the argument is a const char* - you can just pass the plain CString, since CString has a conversion operator to LPCTSTR.
--Mike--
http://home.inreach.com/mdunn/
This must be Thursday. I never could get the hang of Thursdays...
|
|
|
|
|
I don't understand your problem. fstreams with ints, doubles, and longs work fine.
It sounds like you're using the wrong operators. Please, don't make condescending comments when you don't even understand what you're doing.
#include <fstream>
int main(void)
{
std::ofstream s("myfile.txt");
int i = 1;
double d = 2.0;
long l = 3;
s << i << " " << d << " " << l << std::endl;
return 0;
}
|
|
|
|
|
I'm kind of new to MFC. I used to using Borland.
How can I convert a CString to a char array[40].
To be used as a filename I will open using old style ansi C fopen.
Additionally I noticed that in Microsoft VC++ you can not write a int long or double using fstream or iostream. This is pretty Lame. In Borlands compiler you write a double
somefile<
|
|
|
|
|
I'm kind of new to MFC. I used to using Borland.
How can I convert a CString to a char array[40].
To be used as a filename I will open using old style ansi C fopen.
Additionally I noticed that in Microsoft VC++ you can not write a int long or double using fstream or iostream. This is pretty Lame. In Borlands compiler you write a double
somefile<
|
|
|
|
|
I'm kind of new to MFC. I used to using Borland.
How can I convert a CString to a char array[40].
To be used as a filename I will open using old style ansi C fopen.
Additionally I noticed that in Microsoft VC++ you can not write a int long or double using fstream or iostream. This is pretty Lame. In Borlands compiler you write a double
somefile<
|
|
|
|
|
Simply copy, ie assuming your CString object is cstringObject...
ASSERT(cstringObject.GetLength() < 40);
if (cstringObject.GetLength() < 40)
lstrcpy(array, cstringObject);
Regards,
Paul.
Paul Selormey, Bsc (Elect Eng), MSc (Mobile Communication) is currently Windows open source developer in Japan, and open for day job or programming contract anywhere!
|
|
|
|
|
How to known when CStatusBar Text change by Internal OS RedrawWindow or UpdateWindow
I don't know the message for this.
I know ON_WM_PAINT when statusbar is painting but afx_msg void OnPaint( ); block the internal RedrawWindow
|
|
|
|
|
I Think its
WM_SETMESSAGESTRING or WM_SETTEXT
good luck
|
|
|
|
|
Hi expert,
I have a problem with the CList class. Microsoft does not provide a copy constructor for CList. Is there any way or alternatives that i can use beside than CList. I have tried to return a CList from a function but the compiler told me that there is no constructor to copy the list. I dont want to develop my own list because i dont have time for that. STL list is tedious to use and compatibility errors often pop up.
So please help.
thank you.
leonwoo
|
|
|
|
|
Create a CList in the fn that calls this fn, then
pass the CList by ref or by a pointer to the fn,
then fill the list in the fn. You can return the
number of items added to the list as a success/
failure check.
Regards,
Daniel
|
|
|
|
|
hi,
Thanks for your solution Daniel but i don't understand what it means by fn. Can you please give me an example code so that i can get the whole picture.
Thank you
leonwoo
|
|
|
|
|
Any more Suggestion??
Please........
leonwoo
|
|
|
|
|
I was wondoring, how do i implant Music in a dialog??
I try to do it with "PlaySound"
It worked, but i could control the Dialog right, when the Wav file played,
it was like it locked up. Is the a way to avoid this??
Thank you.
|
|
|
|
|
Hi,
if you want to have access to the window/dialog while playing a sound you have to play the sound asynchron. That causes the function to return just after the sound has started. If you want to lock the window while playing use the synchron-playing feature.
Hope it helps - Mario
--------------------
www.klangwerker.de
rocknix@lycos.de
--------------------
|
|
|
|
|
Ok, how do i implant that, i didnt find any info on MSDN.
??
Thank you.
|
|
|
|