|
WM_SETTEXT is used to set the text of a window.
|
|
|
|
|
Which is precisely why I'd use it.
Recall that an edit control may be created thusly:
hwndEdit = CreateWindowEx(0, WC_EDIT, 0, WS_VISIBLE | WS_CHILD | WS_TABSTOP | WS_BORDER | ES_AUTOHSCROLL, 11, 11, 147, 23, hwnd, (HMENU)IDC_EDIT1, hInst, 0);
Where
- hwndEdit is derclared of type HWND
- hwnd holds the parents HWND
- hInst holds HINSTANCE of the program
- IDC_EDIT has been defined as an integer used to identify messages from this control
|
|
|
|
|
Yes, I originally made an error in using SendMessage in the way that I set up lParam !!! I've got it working now ! (Much neater than using the clipboard !) So, if ::SetWindowText() ultimately uses WM_SETTEXT, then it begs the question as to why MS doe not allow it to act on "other applications" windows ??
Doug
|
|
|
|
|
Probably because SETTEXT needs a pointer to the text, and that pointer must be valid in the destination app's address space.
|
|
|
|
|
<< Probably because SETTEXT needs a pointer to the text, and that pointer must be valid in the destination app's address space. >>
But if SetWindowText() ends up using SendMessage, the text is in lParam. I'm confused ......... !!
Doug
|
|
|
|
|
you're welcome.
FYI: there are Win32 system calls that help you pass arbitrary amounts of data from one process to another; my LP#TrayIconBuster[^] article has an LP_Process class that shows how it's done in C#; similar techniques could be used in C/C++.
|
|
|
|
|
lParam holds the pointer to the text, and is assumed to be a valid pointer within the process' address space. It can not be an address in some other process.
|
|
|
|
|
>>Param holds the pointer to the text, and is assumed to be a valid pointer within the process' address space. It can not be an address in some other process.<<
Thanks for your patience, Luc !!
So that I can just FULLY understand this, let me describe it back to you with a few extra words (!!):-
The issuer of SendMessage() holds the variable containing the text (my app, in this case), and lParam is set up containing an address to this variable (within the senders address space ?). The receiver of SendMessage()(the 3rd party app, with which i'm endeavouring to interact) has access to lParam which contains the address of the original text, but as I'm alluding to above, is this address within the sender's address space ? I suspect that somewhere within the process, the text is COPIED to some global address space and it is THIS address that is contained within lParam. I can't see how else the process can work whilst protecting each app's memory space.
I await your words of wisdom, and to be "sorted out" !!
Again, thanks for your patience !
Doug
|
|
|
|
|
Hey, Iam looking for a function i could use that is just as easy to use as UrlDownloadToFile() on windows.
C or C++ doesnt matter.
Thanks.
|
|
|
|
|
|
Iam aware of curl, its not as easy to use as UrlDownloadToFile().
|
|
|
|
|
It may not be as easy to use but on the CURL website there's a simple HTTP[^] client in about 6 lines. Open a file to write to and use CURLOPT_WRITEDATA and snip snip, bob's your Aunty:
#include <stdio.h>
#include <curl/curl.h>
int main(void)
{
CURL *curl = curl_easy_init();
FILE *output_to = fopen( "output.txt", "w" );
if( curl && output_to )
{
curl_easy_setopt(curl, CURLOPT_URL, "curl.haxx.se" );
curl_easy_setopt(curl, CURLOPT_WRITEDATA, output_to );
curl_easy_perform(curl);
}
if( curl ) curl_easy_cleanup(curl);
if( output_to ) fclose( output_to );
}
Bundle that lot up in a function and you're done...
Cheers,
Ash
PS: There's no error reporting if the transfer goes pear shaped
PPS: I haven't programmed in C in years and not having cURL handy on my home computer I haven't checked the code compiles and runs but it's not far off
|
|
|
|
|
Search for a C++ library offering a HTTP client[^], see if it helps.
|
|
|
|
|
Hi all,
I'm using C++ with Win32 API, no MFC. I have a game with a normal game loop in the WinMain function. Within the loop I call all the processing and drawing and such. But for some reason, when I grab the edge of the application window with my mouse and resize it, the game loop just pauses. I still seem to be receiving WM_SIZING and WM_PAINT messages, which doesn't make sense because my PeekMessage is in the game loop and is not being called. I don't understand what's going on. Anyone have any ideas?
Thanks!!
KR
|
|
|
|
|
Can you post the snippet of the loop? I have the suspect you are using the Win32 message dispatching improperly
2 bugs found.
> recompile ...
65534 bugs found.
|
|
|
|
|
I might be wrong but as far as i know when you grab the window or size it, an "internal message loop" starts (probably it's somewhere inside one of the system DLLs, just a guess too) that handles the move/size operation, filters out some messages and lets others reach your window(s).
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> "It doesn't work, fix it" does not qualify as a bug report. <
> Amazing what new features none of the programmers working on the project ever heard of you can learn about when reading what the marketing guys wrote about it. <
|
|
|
|
|
Is their any application that can retrieve class names for running Windows.
|
|
|
|
|
|
|
Hi,
While performing the print operation my application is crashing(only some times).
In logs i have found the following error:
Violation address: 0x7c93426d
Exception code: 3221225477
Description: EXCEPTION_ACCESS_VIOLATION: The thread tried to read from or write to a virtual address for which it does not have the appropriate access.
Access violation error at READING from 0x0.
Can somebody suggest me what may be the possible cause of error.
|
|
|
|
|
Why don't you use the debugger to find the offending line?
Have you more detailed info coming from the log file?
With the info you provided it is really hard guessing the reason of the error.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
Actually in my system it is not crashing.
The logs i got from the client machine.
I checked on the net and got the clue that it may the problem with installed drivers.
|
|
|
|
|
Actually at one place i am using the follwing code and dcRef is NULL in my case so it is going to the else part.
mDC = new CMetaFileDC();
if (mDC != 0)
{
HDC myhdl;
if (dcRef != 0)
{
myhdl = dcRef->m_hAttribDC;
}
else
{
myhdl = getDC();
dcRef = CDC::FromHandle(myhdl);
}
mDC->CreateEnhanced(dcRef, 0, bounds, description);
mDC->SetAttribDC(myhdl);
mDC->SetMapMode(MM_HIMETRIC);
}<pre>
Is there any problem in passing a pointer acquired from CDC::FromHandle to CreateEnhanced.
At some other place i am using
<pre>mMetaFileHandle = mDC->CloseEnhanced();
delete mDC;
mDC = 0;
do something .....
if (mMetaFileHandle != 0)
{
::DeleteEnhMetaFile(mMetaFileHandle);
mMetaFileHandle = 0;
}
HDC myhdl = getDC();
CDC dc;
dc.Attach(myhdl);
dc.DeleteDC();
In the above code getDC is returning a handle to the device context.
|
|
|
|
|
Hi every one.
I'm tring to save IHTMLElement which has IMG tag to hard drive. I'm not tring to save the entire web page as image. NO. I'm tring to save single image (IHTMLElement of Tag IMG) to hard drive.
I tried IHTMLElementRender::DrawToDC(), but it works only if the IHTMLElement size is less than the physical size of my computer screen. If the IHTMLElement (the single image or picture) size is larger than my computer's screen, the function ( DrawToDC() ) draws partial image.
Any help????????
Thanks
|
|
|
|
|