Knowledge about cwnd

Source: Internet
Author: User
Cwnd

Cobject
└ C0000target
└ Cwnd

The cwnd class provides the basic functions of all window classes in the Microsoft basic class library.
The cwnd object is different from the Windows window, but the two are closely related. The cwnd object is created or destroyed by the constructor and destructor of cwnd. Windows is an internal data structure created by the create member function of cwnd and destroyed by the virtual destructor of cwnd. The destroywindow function destroys windows Windows windows, but does not destroy objects.
The cwnd class and message ing mechanism hide the wndproc function. The received windows notification messages are automatically sent to the appropriate cwnd onmessage member function through message ing. You can overload the onmessage member function in the derived class to process specific messages of members.
The cwnd class also enables you to create windows subwindows for applications. Inherit a class from cwnd, and add member variables to the derived class to save data related to your application. Implement the message processing member function and message ing in the derived class to specify what actions should be taken when a message is sent to a window.
You can create a subwindow in two steps. First, call the constructor cwnd to create a cwnd object, and then call the create member function to create a subwindow and connect it to the cwnd object.
When closing your subwindow, you should destroy the cwnd object or call the destroywindow member function to clear the window and destroy its data structure.
In the Microsoft basic class library, many other classes are derived from cwnd to provide specific window types. There are many of these classes, including cframewnd, cmdiframewnd, cmdichildwnd, cview, and cdialog, which are used for further derivation. Controls derived from cwnd, such as cbutton, can be directly used or derived from other classes.

# Include

See cframewnd, cviewClass MemberCwnd class member initialization dialog box item Function initialization Message Processing Function
Window status function data binding function system message processing function
Window size and position menu functions general message processing functions
Window Function access tool prompts Function Control Message Processing Function
Update/drawing function timer function input message processing function
Coordinate ing function warning function non-customer zone Message Processing Function
Window text function window message function MDI Message Processing Function
Scroll function clipboard Message Processing Function
Drag-and-drop function ole control menu loop notification
You can reload the function by inserting the symbol.

Data member m_hwnd indicates the hwnd handle associated with the cwnd object

Construct and analyze a cwnd object
Destroywindow: destroy the associated windows window

Initialize create and create a subwindow associated with the cwnd object
Precreatewindow is called before the window associated with the cwnd object is created.
Calcwindowrect calls this function to calculate the rectangle of the window client.
Getstyle returns the current window style
Extended response window style of getexstyle
Attach connects a Windows handle to a cwnd object
Detach detaches a Windows handle from the cwnd object and returns this handle.
Before calling subclasswindow, presubclasswindow allows other necessary sub-classes for chemical engineering.
Subclasswindow connects the window with the cwnd object and enables it to forward messages through the message ing of cwnd
Unsubclasswindow separates the window from the cwnd object
Fromhandle returns the pointer of the cwnd object when a window handle is given. If no cwnd object is connected to this handle, a temporary cwnd object is created and connected to it.
Fromhandlepermanent returns a pointer to the cwnd object when a window handle is given. If no cwnd object is connected to this handle, null is returned.
The idle processing function of deletetempmap cwinapp automatically calls this function to clear any temporary cwnd object created by fromhandle.
Getsafehwnd returns m_hwnd. if the pointer is null, null is returned.
Createex creates a Windows overlapped window, pop-up window, or subwindow, and connects it to a cwnd object
Createcontrol creates an ole control, which is represented by a cwnd object in the MFC program.

Window status function iswindowenabled determines whether a window allows mouse and keyboard input
Enablewindow allows or disables mouse and keyboard input
Getactivewindow
Setactivewindow activation window
Getcapture: Obtain the cwnd that captures the mouse.
Setcapture sends subsequent mouse input to this cwnd
Getfocus obtains the cwnd with the current input focus.
Setfocus requires the input focus
Getdesktopwindow: Windows desktop window
Getforegroundwindow returns the pointer to the front-end window (the top-level window, where the user is working)
Setforegroundwindow changes the thread used to create a window to the foreground and activates the window.
GetIcon obtains the icon handle.
Seticon: Set the handle of the specified icon
Getwindowcontexthelpid: The identifier of the help Context
Setwindowcontexthelpid sets the identifier of the help Context
Modifystyle: modify the current window style
Modifystyleex: Modify the extended window style

Window size and position getwindowplacement get the display status and normal (restored), maximized, and minimized position of the window.
Setwindowplacement
Getdomainwrgn get a copy of the window area of the window
Setmediawrgn: Set the window area
Isiconic determines whether cwnd is minimized (icons)
Iszoomed determines whether cwnd is maximized
Movewindow changes the position and size of cwnd.
Setwindowpos: change the size, position, and sequence of subwindows, pop-up windows, and top-level windows.
Arrangeiconicwindows lists all sub-windows with minimized icons.
Bringwindowtotop enables cwnd to reach the top of the overlapping window Stack
Getwindowrect: Obtain the screen coordinate of cwnd.
Getclientrect obtains the size of the cwnd customer region.

The window access function childwindowfrompoint determines which Child Window contains the specified vertex. If so
Findwindow returns the handle of the window identified by the window name or window class.
Getnextwindow: Return to the next (or previous) window in the window manager list.
Getowner obtains the pointer of the cwnd owner.
Setowner changes the owner of cwnd.
Gettopwindow returns the first subwindow to which cwnd belongs.
Getwindow returns the window with a specific relationship with the window.
Getlastactivepopup determine whether the pop-up window owned by cwnd has been activated recently
Ischild indicates whether cwnd specifies a Child Window of the window or other sub-objects.
Getparent obtains the parent window of cwnd (if any)
Getsafeowner obtains the Security owner of a given window.
Setparent change parent window
Windowfrompoint indicates the window containing the specified point
Getdlgitem get the control with the specified ID in the specified dialog box
Getdlgctrlid if cwnd is a subwindow, this function is used to return its id value.
Setdlgctrlid is the window (which can be any sub-window, not only the control in the dialog box), set the window ID or control ID
Getdescendantwindow: search all subwindows and return the window with the specified ID.
Getparentframe: Get the parent frame window of the cwnd object
Sendmessagetodescendants sends messages to all subwindows in the window.
Gettoplevelparent obtains the top-level parent window of the window.
Gettoplevelowner obtains the top-level window
Getparentowner returns the pointer of the parent window of the Child Window.
Gettoplevelframe obtains the top-level frame window of the window.
Updatedialogcontrols calls this function to update the status of the buttons and other controls in the dialog box.
Updatedata initialization dialog box or get the data in the dialog box
Centerwindow sets the window to the center of the parent window

Update/plot function beginpaint prepare cwnd for drawing
Endpaint indicates the drawing ends.
Print draws the current window in the specified device Environment
Printclient draws any window in the specified device environment (usually the printer device environment)
Lockwindowupdate disables or restores plotting in a given window
Unlockwindowupdate unlock the window locked by cwnd: lockwindowupdate
Getdc obtains the device environment of the customer Zone
Getdcex obtains the display device environment of the customer zone and allows cropping during plotting.
Redrawwindow updates the specified rectangle or area in the customer area.
Getwindowdc obtains the display environment of the entire window, including the title bar, menu, and scroll bar.
Releasedc whether the customer and window device environments enable other applications to use them
Updatewindow
Setredraw enables the change of cwnd to be re-painted, or disables the change of the re-painting.
Getupdaterect obtains the coordinates of the smallest rectangle that completely closes the update area in cwnd.
Getupdatergn obtains the update area of cwnd.
Invalidate invalidates the entire customer Zone
Invalidaterect adds a given rectangle to the current update area, making the given rectangle in the customer area invalid.
Invalidatergn adds a given region to the current update region, making the specified region of the customer zone invalid.
Validaterect deletes the given rectangle in the current update area so that the given rectangle in the customer area is valid.
Validatergn deletes a given region in the current update region, so that the given region of the customer zone is valid.
Showwindow display or hide a window
Iswindowvisible: Determine whether the window is visible
Showownedpopups: show or hide all the pop-up windows in this window
Enablescrollbar allows or disables one or two arrows of a scroll bar.

The coordinate ing function mapwindowpoints converts some coordinates from the coordinate space of cwnd to the coordinate space of other windows.
Clienttoscreen converts the client Region coordinates of the fixed point or the rectangle on the display to screen coordinates.
Screentoclient converts the screen coordinates of the rectangle on the fixed point or display to the customer coordinates.

The window text function setwindowtext sets the text or title text (if any) of the window to the specified text.
Getwindowtext returns the text or title Text of the window (if any)
Getwindowtextlength returns the length of the window text or title text.
Setfont: set the current font
Getfont to get the current font

The rolling function getscrollpos obtains the current position of the Rolling Block.
Getscrollrange copying specifies the maximum and minimum positions of the scroll bars.
Scrollwindow
Scrollintowex: the content in the rolling customer area, similar to scrollwindow, and other functions
Getscrollinfo
Getscrolllimit
Setscrollinfo
Setscrollpos sets the current position of the Rolling block. If it is specified, repeat the scroll bar to reflect the new position.
Setscrollrange: sets the minimum and maximum positions of the specified scroll bar.
Show or hide a scroll bar
Enablescrollbarctrl allows or disables a scroll bar control.
Getscrollbarctrl
Repositionbars re-set the central control bar position in the customer Zone

The drag-and-drop function dragacceptfiles indicates that the window will receive the dragged files.

The createcaret function creates a new shape for the system plug-in and obtains its ownership.
Createsolidcaret creates a solid block for the system plug-in and obtains its ownership.
Creategraycaret creates a gray block for the system plug-in and obtains its ownership.
Getcaretpos obtains the coordinates of the customer zone at the current position of the characters inserted.
Setcaretpos: Move the characters to the specified position
Hidecaret hides it by removing characters from the display screen.
Showcaret displays the characters at the current position. Once displayed, the inserted characters will automatically flash

The checkdlgbutton function of the dialog box is placed next to the button control or the check mark is cleared.
Checkradiobutton: select the specified single button and clear the check mark of all other single buttons in the specified button group.
Getcheckedradiobutton returns the ID of the currently selected single button in a group of buttons.
Dlgdirlist fills a list box with a file or directory list
Dlgdirlistcombobox fills in the list box in a combo box with a file or directory list
Dlgdirselect
Dlgdirselectcombobox
Getdlgitemint converts the text of the control in the given dialog box to an integer.
Getdlgitemtext get the title or text related to the control
Getnextdlggroupitem searches for the next (or previous) control in a group of controls
Getnextdlgtabitem: the first control with the ws_tabstop style after obtaining the specified control (or before)
Isdlgbuttonchecked: determines whether the button control has a check mark.
Isdialogmessage: determines whether the specified message is sent to the modeless dialog box. If yes, process it.
Senddlgitemmessage sends a message to the specified control.
Setdlgitemint sets the control text to a string representing an integer.
Setdlgitemtext: Set the title or text of the control in the specified dialog box
Subclassdlgitem connects a Windows Control to the cwnd object, and then enables it to forward messages through the message ing of cwnd.
Executedlginit initialization dialog box resource
Runmodalloop obtains, converts, or distributes messages from the mode window.
Continuemodal continues the mode status of a window
Endmodalloop ends the mode status of a window

The data binding function binddefaultproperty binds the default Simple moving property of the called object and the cursor related to the data source control, as marked in the Type Library.
Bindproperty binds a cursor movement property to the data movement control, and registers the contact in the MFC binding manager.
Getdsccursor obtains the cursor, which is defined by the datasource, username, password, and SQL attributes of the data source control.

The menu function getmenu gets the pointer to the specified menu.
Setmenu: Set the menu to the specified menu
Drawmenubar
Getsystemmenu allows applications to access control menus for copying and modifying
Hilitemenuitem highlight a top-level (menu bar) menu item, or cancel highlight display

Tooltip function enabletooltips allows tooltip controls
Canceltooltips disable the tooltip Control
Filtertooltipmessage obtains the title and text related to the control in the dialog box.
Ontoolhittest determines whether a vertex is located in the boundary rectangle of the specified tool and obtains the tool information.

The timer function settimer installs a system timer and sends a wm_timer message when it is activated.
Killtimer destroys a system timer

The warning function flashwindow flashes the window once.
MessageBox is created and displayed, which contains the message and title provided by the application.

The window message function getcurrentmessage returns the pointer to the Message currently processed in this window. It should be called only within the onmessage message processing function.
Default calls the default Window Process. It provides default processing for any window messages that are not processed by the application.
Before a message is sent to the Windows functions translatemessage and dispatchmessage, cwinapp uses this function to filter window messages.
Sendmessage sends a message to the cwnd object until the message is processed.
Postmessage puts a message into the message queue of the application, and then directly returns the message without waiting for a window to process the message.
Sendpolicymessage sends a message to the window and returns it as soon as possible. The returned speed depends on whether the window is created by the calling thread.

The clipboard function changyunboardchain clears cwnd from the chain of the clipboard observer.
Setclipboardviewer adds cwnd to a window chain, which is notified whenever the content of the clipboard changes.
Open the clipboard on openclipboard. Other applications cannot modify the clipboard until the closeclipboard function of Windows is called.
Getclipboardowner obtains the pointer to the current owner of the clipboard.
Getopenclipboardwindow: Get the pointer of the window currently opening the clipboard
Getclipboardviewer obtains the pointer of the first window in the clipboard observer chain.

OLE Control setproperty setting properties of OLE Control
Onambientproperty implements the surrounding property value
Getcontrolunknown get pointer to unknown OLE Control
Getproperty: Obtain the properties of the ole control.
Invokehelper method or attribute for activating the OLE Control

The reload function windowproc provides a window process for the cwnd object. The default Window Process distributes messages through message ing.
Defwindowproc calls the default Window Process, which provides default processing for any window messages not processed by the application.
The postncdestroy virtual function is called by the default onncdestroy function after the window is destroyed.
The onnotify Framework calls this function to notify the parent window that an event occurs in one of its controls, or the control needs messages.
Onchildnotify the parent window calls this function to give the notified control a chance to respond to the notification message of the control.
Dodataexchange is used for dialog box data exchange and validation. Called by updatedata

Initialize the message processing function oninitmenu. This function is called when the menu is to be activated.
Oninitmenupopup: This function is called when the pop-up menu is to be activated.

The onsyschar function is called when a key is converted to a system character message.
Onsyscommand: This function is called when you select a command from the control menu or when you select the maximize or minimize button.
Onsysdeadchar calls this function when a key is converted to a system dead key (such as an accent character) message.
Onsyskeydown this function is called when you press the Alt key and other keys.
Onsyskeyup this function is called when the user releases a key and the Alt key is pressed.
Oncompacting calls this function when Windows detects that the system memory is small.
Ondevmodechange when the user changes the device Mode settings, this function is called for the top-level window.
Onfontchange: This function is called when the font resource pool changes.
Onpaletteischanging
Onpalettechanged when calling this function, all the windows in the palette can implement their logical palette and update their customer zones.
Onsyscolorchange this function is called by all top-level windows when the system color settings change.
Onwindowposchanging calls the setwindowpos function or other window management functions, so the window size, position, and order will change.
Because onwindowposchanged calls the setwindowpos function or other window management functions, this function is called when the window size, position, and order change.
Ondropfiles this function is called when you release the left mouse button above the window registered to receive drag-and-drop files
Onspoolerstatus the print manager calls this function whenever a job is added to or removed from the queue of the print manager.
Ontimechange calls this function for all top-level windows after the system time changes
Onwininichange calls this function for all top-level windows after the Windows initialization file Win. INI is changed.

Generally, the message processing function oncommand is called when a command is selected.
Onactivate: This function is called when cwnd is to be activated or exited.
Onactivateapp calls this function when the application is to be activated or exited.

Generally, the message processing function oncancelmode calls this function to allow cwnd to cancel any internal mode, such as Mouse capture status.
Onchildactivate when the size and position of the cwnd change or the cwnd is activated, this function is called for the child windows of the Multi-Document Interface (MDI ).
Onclose calls this function as a signal to disable cwnd
Oncopydata copies data from one application to another
Oncreate is called as part of the window creation process.
Onctlcolor if cwnd is the parent window of a control, this function is called when the control is to be repainted.
Ondestroy: This function is called when cwnd is to be destroyed.
Onenable calls this function when cwnd is allowed or disabled
Onendsession calls this function when the session is about to end
Onenteridle calls this function to notify the application of the Main Window Process. The mode dialog box or menu is in idle state.
Onerasebkgnd: This function is called when the background of the window needs to be erased.
Ongetminmaxinfo calls this function whenever Windows needs to know the maximum position and size, or the minimum or maximum tracking size.
Oniconerasebkgnd this function is called when cwnd is minimized (icons) and the background of the icon must be filled before the icon is drawn.
Onkillfocus: This function is called immediately when cwnd loses the input focus.
Onmenuchar calls this function when you press the next menu mnemonic character but cannot match any predefined mnemonic in the current menu.
Onmenuselect: This function is called when a menu item is selected.
Onmove: This function is called when the position of cwnd changes.
Onmoving indicates that the user is moving the cwnd object
Ondevicechange notifies the application or device driver that the hardware configuration of the device or computer has changed.
Onstylechanged indicates windows: The setwindowlong function has changed one or more window styles.
Onstylechanging indicates that the: setwindowlong function of Windows will change the style of one or more windows.
Onpaint calls this function to redraw a part of the window.
Onparentnotify: This function is called when a subwindow is created or destroyed, or when a user clicks the mouse button above the subwindow.
Onquerydragicon this function is called when a minimal (icon-based) cwnd is to be dragged by users.
Onqueryendsession: This function is called when the user chooses to end a windows session.
Onquerynewpalette notifies cwnd that it will receive the input focus
Onqueryopen this function is called when cwnd is an icon and the user requests to open this icon.

Generally, the message processing function onsetfocus is called when cwnd obtains the input focus.
Onshowwindow: This function is called when cwnd is hidden or displayed.
Onsize: This function is called when the cwnd size is changed.
Onsizing indicates that the user is changing the size of the rectangle
Onstylechanged indicates that one or more windows styles have been changed.
Onstylechanging indicates that one or more windows styles will be changed.

Control Message Processing Function onchartoitem this function is called by a sub-list box with lbs_wantkeyboardinput style to respond to wm_char messages
Oncompareitem calls this function to determine the relative position of the new items in the sorted self-drawn combo box or list box
Ondeleteitem: This function is called when a self-drawn sub-list box or combo box is destroyed or an item is deleted from the control.
Ondrawitem this function is called when the control of the Self-drawn sub-button, the control of the combo box, the control of the list box, or the visible part of the menu needs to be drawn.
Ondscnotify is called in response to an event triggered by the data source control. This event is generated when the control bound to the data source control is modified or the cursor to be modified.
Ongetdlgcode calls this function for the control so that the control can process the input arrow keys and Tab keys by itself.
Onmeasureitem: When a control is created, this function is called in a list box or menu item. Cwnd notifies windows of the size of the control
Sendchildpolicylastmsg provides notification messages from the parent window to the Child Window, enabling the child window to process a task
Reflectchildnotify is a helper function that reflects a message to its source.
Onwndmsg indicates whether a window message has been processed
Reflectlastmsg reflects the previous message to the subwindow
Onvkeytoitem is called by the list box owned by cwnd to respond to the wm_keydown message.

Input message processing function onchar this function is called when a key is converted to a non-system character
Ondeadchar calls this function when a key is converted to a non-system dead key (such as an accent character ).
Onhscroll: This function is called when the user clicks the horizontal scroll bar of cwnd.
Onkeydown: This function is called when a non-system key is pressed.
Onkeyup: This function is called when a non-system key is released.
Onlbuttondblclk calls this function when you double-click the left mouse button.

Input message processing function onlbuttondown. This function is called when you press the left mouse button.
Onlbuttonup: This function is called when you open the left mouse button.
Onmbuttondblclk: This function is called when you double-click the key.
Onmbuttondown: This function is called when you press the middle mouse button.
Onmbuttonup: This function is called when you open the middle mouse button.
Onmouseactivate this function is called when the mouse is in the inactive window and the user presses the mouse key.
Onmousemove: This function is called when the cursor moves.
Onmousewheel calls this function when the user rotates the mouse wheel. Use windowsnt4.0 for Message Processing
Onregisteredmousewheel calls this function when you rotate the mouse wheel. Use Windows 95 and Windows NT 3.51 for Message Processing
Onrbuttondblclk calls this function when you right-click
Onrbuttondown this function is called when you right-click it
Onrbuttonup: This function is called when you right-click it.
Onsetcursor calls this function if it does not capture the mouse input and causes the cursor to move in the window.
Ontimer calls this function when it reaches the time interval specified by settimer
Onvscroll calls this function when you click the vertical scroll bar in the window.
Oncapturechanged

Onncactivate, a non-customer message processing function, calls this function when a non-customer region needs to be changed to indicate activity or inactivity.
Onnccalcsize this function is called to calculate the size and location of non-customer zones.
Onnccreate: Before oncreate, this function is called to create a non-customer partition.
Onncdestroy calls this function when the non-customer zone is to be destroyed.
Onnchittest if cwnd contains the cursor or uses setcapture to capture the mouse input, Windows calls this function whenever the mouse moves.
Onnclbuttondblclk: When the cursor is located in the non-customer area of cwnd, you can double-click the left mouse button to call this function.
Onnclbuttondown: When the cursor is located in the non-customer area of cwnd and the user presses the left mouse button, this function is called.
Onnclbuttonup: When the cursor is located in the non-customer area of cwnd, you can call this function when you release the left mouse button.
Onncmbuttondblclk: When the cursor is located in the non-customer area of cwnd, you can double-click the key and call this function.
Onncmbuttondown: When the cursor is located in the non-customer area of cwnd, you can call this function when you press the middle mouse button.
Onncmbuttonup: When the cursor is located in the non-customer area of cwnd, you can call this function when you open the middle mouse button.

Onncmousemove, the message processing function in the non-customer region, calls this function when the cursor moves in the non-customer region of cwnd.
Onncpaint calls this function when non-customer areas need to be repainted.
Onncrbuttondblclk: When the cursor is located in the non-customer area of cwnd, you can right-click the cursor and call this function.
Onncrbuttondown: When the cursor is located in the non-customer area of cwnd, you can call this function by right-clicking the cursor.
Onncrbuttonup: When the cursor is located in the non-customer area of cwnd, you can call this function when you right-click it.

The message processing function onmdiactivate calls this function when the MDI sub-window is activated or out of active status.

Clipboard message processing function onaskcbformatname when the clipboard owner displays the clipboard content, the clipboard observer calls this function.
Onchangecbchain notification the specified window will be deleted from the chain
Ondestroyclipboard this function is called when the clipboard is cleared through the emptyclipboard function in windows.
Ondrawclipboard calls this function when the content changes
Onhscrollclipboard this function is called when the clipboard owner wants to scroll the image of the clipboard, invalidate the appropriate part, and update the scroll bar value.
Onpaintclipboard this function is called when the client area of the clipboard viewer needs to be re-painted.
Onrenderallformats calls this function when the owner application is destroyed and all formats of the application need to be submitted
Onrenderformat when a delayed submission format needs to be submitted, the clipboard owner calls this function.
Onsizeclipboard this function is called when the client area size of the clipboard Viewer window changes
Onvscrollclipboard this function is called when the owner wants to scroll the image of the clipboard, invalidate the appropriate part, and update the value of the scroll bar.

This function is called when the menu loop notifies onentermenuloop to enter a menu mode loop.
Onexitmenuloop: This function is called when a menu mode loop is exited.

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.