|
Well, I have a game window opened and minimized, I'm using ::FindWindow to get its HWND value, I tried all possible ways to get the window's DC, but couldn't.
Would it be possible to get a bitmap or a BitBlt and get the pixel I want from it? If so, how could I do it?
Thanks a lot for your help
~Mike
|
|
|
|
|
i think u can send it a wm_paint message and pass a dc in
then it draws to that dc
and u can grab what u like
"there is no spoon" biz stuff about me
|
|
|
|
|
Uh? Pass a DC in a WM_PAINT message?
How do you do that?
I doubt it's possible...
~Mike
|
|
|
|
|
|
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.
|
|
|
|