1 out of 1 rated this helpful - Rate this topic

DrawFrameControl function

Applies to: desktop apps only

The DrawFrameControl function draws a frame control of the specified type and style.

Syntax

BOOL DrawFrameControl(
  __in  HDC hdc,
  __in  LPRECT lprc,
  __in  UINT uType,
  __in  UINT uState
);

Parameters

hdc [in]

A handle to the device context of the window in which to draw the control.

lprc [in]

A pointer to a RECT structure that contains the logical coordinates of the bounding rectangle for frame control.

uType [in]

The type of frame control to draw. This parameter can be one of the following values.

ValueMeaning
DFC_BUTTON

Standard button

DFC_CAPTION

Title bar

DFC_MENU

Menu bar

DFC_POPUPMENU

Popup menu item.

DFC_SCROLL

Scroll bar

 

uState [in]

The initial state of the frame control. If uType is DFC_BUTTON, uState can be one of the following values.

ValueMeaning
DFCS_BUTTON3STATE

Three-state button

DFCS_BUTTONCHECK

Check box

DFCS_BUTTONPUSH

Push button

DFCS_BUTTONRADIO

Radio button

DFCS_BUTTONRADIOIMAGE

Image for radio button (nonsquare needs image)

DFCS_BUTTONRADIOMASK

Mask for radio button (nonsquare needs mask)

 

If uType is DFC_CAPTION, uState can be one of the following values.

ValueMeaning
DFCS_CAPTIONCLOSE

Close button

DFCS_CAPTIONHELP

Help button

DFCS_CAPTIONMAX

Maximize button

DFCS_CAPTIONMIN

Minimize button

DFCS_CAPTIONRESTORE

Restore button

 

If uType is DFC_MENU, uState can be one of the following values.

ValueMeaning
DFCS_MENUARROW

Submenu arrow

DFCS_MENUARROWRIGHT

Submenu arrow pointing left. This is used for the right-to-left cascading menus used with right-to-left languages such as Arabic or Hebrew.

DFCS_MENUBULLET

Bullet

DFCS_MENUCHECK

Check mark

 

If uType is DFC_SCROLL, uState can be one of the following values.

ValueMeaning
DFCS_SCROLLCOMBOBOX

Combo box scroll bar

DFCS_SCROLLDOWN

Down arrow of scroll bar

DFCS_SCROLLLEFT

Left arrow of scroll bar

DFCS_SCROLLRIGHT

Right arrow of scroll bar

DFCS_SCROLLSIZEGRIP

Size grip in lower-right corner of window

DFCS_SCROLLSIZEGRIPRIGHT

Size grip in lower-left corner of window. This is used with right-to-left languages such as Arabic or Hebrew.

DFCS_SCROLLUP

Up arrow of scroll bar

 

The following style can be used to adjust the bounding rectangle of the push button.

ValueMeaning
DFCS_ADJUSTRECT

Bounding rectangle is adjusted to exclude the surrounding edge of the push button.

 

One or more of the following values can be used to set the state of the control to be drawn.

ValueMeaning
DFCS_CHECKED

Button is checked.

DFCS_FLAT

Button has a flat border.

DFCS_HOT

Button is hot-tracked.

DFCS_INACTIVE

Button is inactive (grayed).

DFCS_MONO

Button has a monochrome border.

DFCS_PUSHED

Button is pushed.

DFCS_TRANSPARENT

The background remains untouched. This flag can only be combined with DFCS_MENUARROWUP or DFCS_MENUARROWDOWN.

 

Return value

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero.

Remarks

If uType is either DFC_MENU or DFC_BUTTON and uState is not DFCS_BUTTONPUSH, the frame control is a black-on-white mask (that is, a black frame control on a white background). In such cases, the application must pass a handle to a bitmap memory device control. The application can then use the associated bitmap as the hbmMask parameter to the MaskBlt function, or it can use the device context as a parameter to the BitBlt function using ROPs such as SRCAND and SRCINVERT.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Painting and Drawing Overview
Painting and Drawing Functions
RECT

 

 

Send comments about this topic to Microsoft

Build date: 3/7/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
DrawFrameControl call takes more than 250 ms on Windows 7

somehow the DrawFrameControl call takes more than 250 ms on Windows 7,
while on Windows XP the call takes less then 1 ms

as with its old-style graphics it does not do many things and so it should not take any time on a modern PC

so it looks like there is an artificial delay placed in the call in Windows 7

I've made a small presentation on this subject: http://www.youtube.com/watch?v=07hjIJygrOA

 

ANSWER: ... or probable answer ... The issue may be due to the DrawFrameControl API internally using old API calls that are penalized in Vista / 7 due to the Desktop Window Manager (DWM). The DWM "double buffers" the top-window (but not children) in the graphic card, and the GPU renders the window to the screen. But few operations, and I am suspecting some bit-blt'ing in the above API does this, may need to read video memory contents directly from the video buffer. This apparently is very expensive, since it uses hardware busses that are not oprimized for transfer (graphic cards are optimized for sending data to them, not the other way) and it also trashes the GPU cache. There are few blogs on the topic, among other this one: http://blogs.msdn.com/b/kamvedbrat/archive/2006/04/02/566788.aspx. Try to disable Aero. Alternatively do the drawing on a memory DC.

undocumented DrawFrameControl styles
  

// undocumented DrawFrameControl styles
#define DFCS_MENUARROWUP    0x0008  /* scroll menu up   */
#define DFCS_MENUARROWDOWN  0x0010  /* scroll menu down */
#define DFCS_INMENU         0x0040  /* modifier for DFC_MENU as captionbtn drawn in systemmenu  */
#define DFCS_INSMALL        0x0080  /* modifier for DFC_MENU as captionbtn for WS_EX_TOOLWINDOW */


UPDATE: I've found the DFCS_INxxx constants at http://www.reactos.org/wiki/Techwiki:Win32k/SERVERINFO
but I can't see any differences in drawing of the buttons so prob' haven't got any meaning in Windows.
The buttons are drawn by vectors so to draw a "menu" close icon simply draw a DFCS_CAPTIONCLOSE button with the size of SM_CXMENUCHECK/SM_CYMENUCHECK.
this api draws only old style frame controls
this api only draws old style frame controls i.e. the style of W2K, even exactly the same  as in NT4

it is never updated to use the theme api introduced with XP...

use theme api for the modern look-and-feel
DFC_POPUPMENU flags
the flags for DFC_POPUPMENU are like the flags mentioned for DFC_CAPTION
i.e. to draw the menu symbols in the system menu:

DFCS_CAPTIONCLOSE
DFCS_CAPTIONRESTORE
DFCS_CAPTIONMAX
DFCS_CAPTIONMIN