| |

VerySource

 Forgot password?
 Register
Search
View: 882|Reply: 4

A rookie question about subclassing

[Copy link]

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-1-2 15:20:02
| Show all posts |Read mode
I handle the WM_CREATE message in the window procedure of my program like this:
case WM_CREATE:
     desktop = GetDesktopWindow ();
     oldPROC = (WNDPROC) SetWindowLon (desktop, GWL_WNDPROC, (LONG) myProc);
     return 0;
Then myProc:
LRESULT CALLBACK myProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
switch (message)
{
case WM_KEYDOWN:
hdc = GetDC (hWnd);
RECT rt;
GetClientRect (hWnd,&rt);
DrawText (hdc, TEXT ("HELLO"), 5,&rt, DT_CENTER);
ReleaseDC (hWnd, hdc);
InvalidateRect (hWnd, NULL, TRUE);
return 0;
}
return CallWindowProc (WndProc, hWnd, message, wParam, lParam);
}
After I run the program, when the desktop is the input focus, I can't get "Hello" by clicking any key. Why?


Also, I have just started to learn win32 programming recently. When I was looking at windows programming, I felt that there are too many WIN32 API functions, and many things are a little bit ignorant. I hope that experts will recommend some good learning methods or good books for me. . .
Reply

Use magic Report

0

Threads

5

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-1-3 11:12:01
| Show all posts
InvalidateRect (hWnd, NULL, TRUE);
Remove this sentence try
Reply

Use magic Report

0

Threads

57

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-3 11:39:01
| Show all posts
Non-self-process windows are not estimated to be so easy to subclass, especially under non-9X
Reply

Use magic Report

1

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

 Author| Post time: 2020-1-4 10:27:02
| Show all posts
Why is it difficult to subclass non-own processes?
Reply

Use magic Report

0

Threads

57

Posts

27.00

Credits

Newbie

Rank: 1

Credits
27.00

 China

Post time: 2020-1-4 11:12:01
| Show all posts
windows protection mechanism
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list