|
Uh this won't work. Sending a message to a window is not like retrieving a HDC, so it won't return the HDC of the window.
|
|
|
|
|
dude
u pass the hdc in as athe wparam and the app _might_ paint on it
if ur lucky
i thought that was what u wanted?
"there is no spoon" biz stuff about me
|
|
|
|
|
Whatever, any serious responses please?
|
|
|
|
|
I don't think it'll work with WM_PRINT. HDCs are inprocess handles I believe (not entirely sure about that though). Sending an HDC from one process to another will at best result in nothing. I think the only way is to grab a handle to the window, and then acquire a HDC from that window handle.
--
Seraphim Shock. Gold for your ears.
|
|
|
|
|
hmmmmmmm
i remember doing it a whiles ago and it worked
some apps dont handle those messages tho so it isnt guaranteed
"there is no spoon" biz stuff about me
|
|
|
|
|
Hi all, happy new year!
I need to sequentially load a set of CMyObject files created using the objects' serialization mechanism, but have hit trouble. It's getting a bit tricky for me. I've managed to enumerate the file names i wish to load, but can't load them into the CDocument object because I need the information for data processing. What I need is to load the files into a separate CDocument object. Does anybody know how to go about this?
Any help would be much appreciated
Thanks.
Paul/
|
|
|
|
|
You want to load a file using MFC's serialization and load the file and read it's raw data also???
I believe when you use serialization...it initializes CMyObject members for you automagically.
So why don't you just use you CMyObject objects?
I'm missing something here I think
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
As hockey says I am also especially about this: "What I need is to load the files into a separate CDocument object."
Why? Loading of files should not have to depend on a CDocument and you do not need a CDocument to load files. If you need the information when the CDocument is closed you can load your data in the Main Application...
John
|
|
|
|
|
Is there a way to programmatically reboot the PC??
|
|
|
|
|
ExitWindowsEx
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
I am asking again,
maybe nobody noticed the question.
Or maybe the problem is really 'real'
An Edit control of Microsoft ( both normal or RichEdit ) is not able to count right the CRLF characters ! Yes, just the ones that Microsoft itself keeps alive !
What it does is just to ignore the '\r' characters in the count, both when using EM_GETSEL and EM_SETSEL
Does anyone knows how to do it right ?
Thank you very much for any answer
Marcello
|
|
|
|
|
Marcello wrote:
Does anyone knows how to do it right ?
What do you mean do it right?
You want to use both \r\n inside your CEdit control?
Why?
Are you saving content to a file and need the CRLF?
If so, why not just (before saving) search and replace all \n with \r\n and then save to file?
Cheers : )
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
Thank you for the answer.
I use the multiplatform VCF library and helping on it.
The fact is the in the library we need to introduce a Control that has the data model separated from the view ( which is the Microsoft's Edit control ).
In this way this bug becomes really evident.
For multipurpose need we cannot put the text in a canonized form ( like replacing all the \r\n with \n and similar things.
I made a workaround, which is to count all the CR characters both before the beginning of a selection and inside the selection itself, and then make some adjust to the counts. But this code is CPU consuming and more orrible than it seems.
Because I it is the third time I am posting this problem
and you are the only (nice) person who answered, I guess this is just another of Microsoft's bugs.
Cheers,
Marcello
|
|
|
|
|
Perhaps you could look at some of the edit controls here on CP and modify them enough to suit your needs?
Cheers
The word of the day is legs, let's go back to my house and spread the word
|
|
|
|
|
Yes. It is a good idea.
Maybe I will find something.
Thank you !
Marcello
|
|
|
|
|
Hi everyone!
I'm trying to do a Speech application. It must read what the user writes in the edit box or the content from a text file. When it reads the text from that file and then tries to fill the edit box I get the file content but I get some garbage too. The part of the code in with I use files is this:
CFileDialog m_ldFichero(TRUE);
CFile m_Fichero;
char buffer[200];
int iTexto = 0;
DWORD nBytesLeidos;
CString m_snombre;
CFileException e;
DWORD longFichero;
if (m_ldFichero.DoModal() == IDOK)
{
m_snombre= m_ldFichero.GetFileName();
m_Fichero.Open(m_snombre, CFile::modeRead, &e);
longFichero = m_Fichero.GetLength();
nBytesLeidos = m_Fichero.Read(buffer,longFichero);
m_sTexto=buffer;
m_Fichero.Close();
UpdateData(FALSE);
}
When running the application I get the text and "ÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÌÄÈJ_X" too.
I don't know what could I do or how could I eliminate that garbage... Please, some help!.
Thank you in advance
I'm lost... SOS
|
|
|
|
|
This happens because of the way you create the receiving buffer. You just create a variable that gets placed somewhere on your computer's memory. The memory contents, however, is NOT cleared. So, when you create the buffer, you can instantly use it to read and/or write characters to the memory it reserves for itself.
In order to clear the targetted area, you need to use some memory handling routines. Here is an example of how to clear the memory area:
char buffer[200];<DIV>
ZeroMemory( &buffer[0], sizeof(buffer) );<DIV>
It will be filled from the first character up to the amount 'longFichero',
and the rest of the buffer is left empty (null characters). Hope this will help you out. An alternative method is to create a CString object, and read your data into that one. The CString object can automatically grow as a result of string operations (Append, Format, Insert etc), so you don't necessarily need to specify the amount of bytes to read.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Thank you very much, the application is OK now
Can you tell me how could I save a text in an inexistent file? It is, it must create a File and save the text from the Text editor with a click in a button.
Best regards!!!
|
|
|
|
|
You can do this by creating a CFile object and opening a file with it. On the CFile's constructor or the Open member function, you can specify a flag to tell the program that it is to create a new file.
Here's an excerpt from MSDN:
CFile::modeCreate - Directs the constructor to create a new file. If the file exists already, it is truncated to 0 length.
I think this is what you wanted. See the CFile constructor for additional flags that you might find useful. As for the implementation, just create a message handler for the button click, then open and write to the file in there.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Well, finally it works!! But I've got a problem with buffer... I need to save the text from the Edit Box but it is a CString by definition and what I have to save in the file is char buffer[lenght] and they aren't compatible. I can't do
buffer=m_sTexto;
and the sentence
m_Fichero.Write(m_sTexto, sizeof(m_sTexto));
is no OK, so I'm lost again!! How could I convert the type or write the Edit Box content in my file?
Thank you
|
|
|
|
|
In here you need a conversion routine..
The CString object can be cast into type LPCTSTR by adding the conversion operation in front of the object. Then just use some sort of string copying routine, such as strcpy to copy characters. LPCTSTR is defined as const char* .
Here's a code fragment to help you get the idea:
char buffer[length];
CString m_sTexto;<DIV>
strcpy( &buffer[0], (LPCTSTR)m_sTexto );<DIV>
m_Fichero.Write( &buffer[0], sizeof(buffer) );
m_Fichero.Write( (LPCTSTR)m_sTexto, sizeof(m_sTexto) ); I am not 100% sure of the lower implementation, as I have never used it. According to the documentation, it should work properly.. Test it if you feel brave
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Well, I felt brave at the beginning but it seems to be for really brave people
I've tried with
m_Fichero.Write( (LPCTSTR)m_sTexto, sizeof(m_sTexto) );
but nothing is saved in the new file.
Then I used the other one implementation, but there is some trouble with my code (That's no strange, isn't it? ). Well I think the trouble is the CString variable. Must it be initialized? Where could I do it? I can't use ZeroMemory function (can I?). If it has to be initialized, it must be done before the user could write in the edit box...
When I've tried
strcpy( &buffer[0], (LPCTSTR)m_sTexto );
m_Fichero.Write( &buffer[0], sizeof(buffer) );
lots (200) of identical symbols (squares) have been saved but I had written some words in the edir box
Thanks
(I'm very sorry because I have lots of foolish doubts but I've just begun with Visual C++ and all of this is new to me. I hope you'll not be fed up with me & my questions . Thanks a lot!)
I have no idea
|
|
|
|
|
It is ok to ask questions and seek for answers, as long as you do it politely and with a gentelmanic approach. I'm not fed up with you or with your questions either. Afterall, when I get you to understand this, I have someone else who can give advice to another person asking perhaps the same thing.
Now, off with the question. I was quite sure that the second implementation would not work, but the first one should have. Like you said, there were some squares written into the file. This means that the writing routine works properly and something gets saved. In the start of your routine, have you called UpdateData( TRUE ) to tell your program to move the data from the edit box to the CString member ? If you did not already know, there is a system called Dialog Data Exchange (or DDX, for short) at work in your dialog. This system is responsible for moving data and control between (to and back) the actual controls of the dialog and the variables bound to them. You can find a function called DoDataExchange from your dialog's implementation.
In order to determine that the data gets moved corretly, you can use the TRACE-macros in a debug build of your application. These macros are very useful in dumping object or other data into the output window of the debugger. For example, after calling UpdateData , you could use TRACE1-macro to determine that the correct text was copied into the CString variable. Then, you can use the same macro again to see that data gets copied into the character buffer properly.
Perhaps these will help, most importantly, learn about and get to know how to use the TRACE-macros properly. They are an important key to displaying debug-time status information, if you don't want to use message boxes. Try adding a few of those macros inbetween the function calls in your application and see what get's printed into the output window.
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|
|
Well, it works!
I'd written UpdateData(TRUE) in the wrong place (my brain and me... ) and when you have suggested me about this I realised!
The squares are blank spaces. I was using wordpad instead of notepad and there, in wordpad, they appear in this squared way, but if I open the file in the application or in notepad it is OK, so we got it and the files work perfectly!
I just only need to change voices in my speech application to finish this phase (I have 4 phases in total in this project ).
Do you know something about speech with Visual C++? I've asked here in other threads but nobody reply them
I only have some doubts.
Thank you for your great help!
I have no idea
|
|
|
|
|
Good that it works.
As for the text-to-speech conversion, I would start from the Microsoft Speech[^] site. Register for a download of the MS Speech API SDK, then consult it's documentation to learn how to use it.
I can't give you any source code on this matter, because I neither have any nor do I have the SDK installed. You must explore the SDK yourself.. But isn't that part of the fun ?
EDIT: The Microsoft Speech SDK doesn't require registration, it seems. Here's a link to the actual download site: download here[^]
-Antti Keskinen
----------------------------------------------
The definition of impossible is strictly dependant
on what we think is possible.
|
|
|
|