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.