Step by step notepad word change

Source: Internet
Author: User

I like Notepad very much. I like to use him to read code, write code, and change code. I used him to write letters and write articles. I almost used him in addition to tables and charts.

I recently learned something that doesn't count. It can be used to modify the content of other programs. So I plan to strengthen notepad.

It's a little time. Let's get started. The process of understanding things is from simple to complex, so it's easy for me to accept things.

[No. 2006-4-6]

So I will use the simplest example to prove that it is very easy to change notepad.

Display Hello world on notepad!

The Code is as follows:

Hwnd =: findwindow ("Notepad", null );

Tchar szbuf [256];
If (hwnd! = NULL)
{
Cwnd * pwnd = cwnd: fromhandle (hwnd );
CDC * PDC = pwnd-> getdc ();
: Getclassname (hwnd, szbuf, 256 );
M_hroot = m_tcwnd.insertitem (szbuf );
Enumchildwindows (hwnd, enumwindow, (lparam) (void *) This );
Crect RT;
Pwnd-> getwindowrect (& RT );
PDC-> textout (10, 10, "Hello world! ");
}

Void cfindwnd03dlg: addonewnd (hwnd)
{
Tchar szbuf [512];
: Getclassname (hwnd, szbuf, 512 );
If (lstrcmpi (szbuf, "edit") = 0)
{
Cwnd * pwnd = cwnd: fromhandle (hwnd );
Pwnd-> showwindow (sw_hide );
}
M_tcwnd.insertitem (szbuf, m_hroot );
}

Bool callback cfindwnd03dlg: enumwindow (hwnd, lparam)
{
Cfindwnd03dlg * PFD = (cfindwnd03dlg *) lparam;
If (hwnd! = NULL)
{
PFD-> addonewnd (hwnd );
}
Return true;
}

You must be familiar with it. You have no idea at all. If you are a newbie, I will write comments later.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.