A Big Question about the Secret of ms' GDI

Started by
9 comments, last by michaelj 16 years, 11 months ago
Hello, everyone! I am lately developing windows ce projects, and find some codes of the public part of wince, especially the GDI OwnerDraw part. After I read these codes, I have one question: how is ms windows' common control implemented? I have one uncertain answer by myself, for example a list control: It's just a list of strings and a rect of its own position, and the current top index, etc. Then, the list control uses GDI drawing functions to draw itself when receiving WM_PAINT messages. I am unsure about my answer, and so I wish if anyone could give some tips if you know about it. :)
Advertisement
Quote:Original post by michaelj
I have one uncertain answer by myself, for example a list control: It's just a list of strings and a rect of its own position, and the current top index, etc. Then, the list control uses GDI drawing functions to draw itself when receiving WM_PAINT messages.
That sounds reasonable. Is there any reason you don't think that sounds correct?
Quote:Original post by Evil Steve
Quote:Original post by michaelj
I have one uncertain answer by myself, for example a list control: It's just a list of strings and a rect of its own position, and the current top index, etc. Then, the list control uses GDI drawing functions to draw itself when receiving WM_PAINT messages.
That sounds reasonable. Is there any reason you don't think that sounds correct?


How I wish I am correct! I think so too, so I want some one to make sure.

But I don't know if MS uses GDI to draw all GUI? I don't know, not sure. Anyone support this guessing??
Quote:Original post by michaelj
But I don't know if MS uses GDI to draw all GUI? I don't know, not sure. Anyone support this guessing??
There's no reason they won't. All windows are drawn with standard GDI functions, and controls are just types of windows. Using the GDI to draw these controls means that user themes work correctly.

I'd be very surprised if Microsoft uses anything other than GDI to draw common controls.
As far as I know, most Windows controls are implemented in user mode. Not sure about how it handles password text boxes, though.
Quote:Original post by Catafriggm
As far as I know, most Windows controls are implemented in user mode. Not sure about how it handles password text boxes, though.

The answer is: badly. It's just an EDIT that display stars instead of characters. You can still send the WM_GETTEXT message to the control to retrieve the hidden word.

Quote:Original post by michaelj
But I don't know if MS uses GDI to draw all GUI? I don't know, not sure. Anyone support this guessing??

I'm not sure about that. Of course, some part of the GUI are drawn using the GDI (especially because the programs that display these are living in user land - for example, the explorer) but It seems that for some heavy operation, Windows bypass the GDI and talk directly with the graphic driver in order to achieve maximal speed. For instance, there is no reason to call the GDI to erase the background of a window. Of course, I might be wrong.
Windows uses GDI to draw its GUI items. This can be easily shown using techniques like this program used. Tim's program intercepted calls to the GDI text functions DrawText(), DrawTextEx(), TextOut(), and ExtTextOut() and was able to change the text for the entire system (minus Office and IE).

If you did something similar with the other GDI functions you'd be able to accomplish the same things.
Quote:Original post by Emmanuel Deloget
Quote:Original post by Catafriggm
As far as I know, most Windows controls are implemented in user mode. Not sure about how it handles password text boxes, though.

The answer is: badly. It's just an EDIT that display stars instead of characters. You can still send the WM_GETTEXT message to the control to retrieve the hidden word.
I thought they fixed that in Win2k or XP?


Quote:Original post by Colin Jeanne
minus Office and IE
Fun fact of the day - that's because they both draw the controls themselves in custom ways. There was some MSDN blog about it, I thought it was The Old New Thing or Feng Yuan, but I can't find it.
It was on The Old New Thing. I believe that in IE7 even the select control is windowless.
Windows 2000 WIN32K.SYS System Service Calls (Feng Yuan)

Quote:
It's well known that on Windows NT/2K systems, the interface because user mode code and kernel mode system components are the undocumented system service calls. But much less is known about the fact the Windows NT/2K graphics systems (GDI32, DDRAW) and window manager (USER32) also uses system service calls extensively.

These system service calls are handled by WIN32K.SYS, which lives in kernel mode address space, with the help of display drivers, video port drivers, and printer drivers.

Here is a complete list of 639 system services provided by WIN32K.SYS, on Windows 2000. From this list you can find GDI calls (NtGdixxx), DirectDraw calls (NtGdiDdxxx), Direct3D calls (NtGdiD3dxxx), and USER calls (NtUserxxx).
...


"I thought what I'd do was, I'd pretend I was one of those deaf-mutes." - the Laughing Man

This topic is closed to new replies.

Advertisement