C++ Learning Community Forum
August 01, 2010, 03:25:17 AM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Hello. Smiley
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Edit controls and WM_SETTEXT  (Read 649 times)
Joel
Coding from an Igloo
Jr. Nerd
***
Posts: 47


Linux coder


View Profile WWW
« on: August 07, 2009, 12:11:12 AM »

I'm trying a new thing here.
I'm trying to get user input from console and send the data to notepad.

That part is done Cheesy

Now, I'm making a method which using x and y coordinates of the edit control, will write the data...
any ideas how?

Right now, I'm using this:
Code
GeSHi (cpp):
#include <windows.h>
#include <iostream>
 
using std::cout;
using std::endl;
 
class ToNotepad
{
private:
   HWND m_hNotepad;
public:
   ToNotepad()
   {
       m_hNotepad = FindWindow (TEXT("Notepad"), NULL);
   }
   bool IsGood() const
   {
       return IsWindow (m_hNotepad) ? true : false;
   }
   void SendString (const TCHAR* data, int const x = 0, int const y = 0)
   {
       HWND m_hEditor = FindWindowEx(m_hNotepad, NULL, TEXT("Edit"), NULL);
       SendMessage (m_hEditor, WM_SETTEXT, NULL, reinterpret_cast<LPARAM>(data));
   }
protected:
};
 
int main()
{
   ToNotepad *pnp = new ToNotepad;
   if (pnp->IsGood())
   {
       cout << "Notepad located..." << endl;
       pnp->SendString(TEXT("Hola mundo"));
   }
   else
   {
       cout << "Notepad is not running..." << endl;
   }
   delete pnp;
   return 0;
}
 
 
Created by GeSHI 1.0.7.18
Logged


* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM
* Ubuntu 9.04; Kernel 2.6.28-15-generic.
* lighttpd, php5, perl, eruby, python.
* geany, HTML & CSS & JavaScript, mono, gtk+, QT4, wxWidgets, bash, gcj.
* Coming soon: Kubuntu 9.10 or Dragora 1.1
FrozenKnight
ASM Freak
Global Moderator
Dr. of C++ology
*****
Posts: 546


Do it yourself it's the only way to learn.


View Profile
« Reply #1 on: August 08, 2009, 04:48:46 AM »

Hmm, well I'm not entirely sure what you mean by
Quote
I'm making a method which using x and y coordinates of the edit control, will write the data...
However it's easy to get xy cords of an edit control from a window. for instance you can get a windows x,y cords using GetWindowRect()
But I am not really sure that this is what you are after, if i am right you want to get a window (specifically a edit control) from a screen point.
I have use a method for this in my "Kill" application (a program that you drag a red x over a window and it instantly terminates "kills" the application) but to be honest I really know 2 methods for this with a possible third. The first method (used in my kill app) is to use the api WindowFromPoint() in my "Kill" app I used SetCapture() and GetCursorPos() to get the mouse position, but you may be able to use GetCursorPos().
The other method would be to use a mouse hook inside a .dll, I'm not sure but there may be a method where you could use hooks without the .dll but I've never tried that. If you like I can post the source to my "Kill" app (warning it's in ASM) but it may still give you ideas of how to do this.
Logged


Imagine the impossible, then make it happen.
Joel
Coding from an Igloo
Jr. Nerd
***
Posts: 47


Linux coder


View Profile WWW
« Reply #2 on: August 08, 2009, 03:19:15 PM »

Thanks FK...let me explain a little bit.

I'm trying to write some string into the editor of notepad using x position and y values..
I think is also called it cols and rows position, based on the EDIT control.
Logged


* Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM
* Ubuntu 9.04; Kernel 2.6.28-15-generic.
* lighttpd, php5, perl, eruby, python.
* geany, HTML & CSS & JavaScript, mono, gtk+, QT4, wxWidgets, bash, gcj.
* Coming soon: Kubuntu 9.10 or Dragora 1.1
FrozenKnight
ASM Freak
Global Moderator
Dr. of C++ology
*****
Posts: 546


Do it yourself it's the only way to learn.


View Profile
« Reply #3 on: August 09, 2009, 10:37:42 PM »

Hmm, I had to do a little research for this one. Try taking a look at the following messages.
EM_CHARFROMPOS
EM_LINEFROMCHAR
EM_POSFROMCHAR
those are what i found for now i'll try to look-up the edit control subclass messages and see if there is anything there when i have time.
Logged


Imagine the impossible, then make it happen.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!