WxWidgets Programming Problems and Solutions

Source: Internet
Author: User
Tags wxwidgets

1. Solution to the failure to receive button events in the main form: () wxevthandler: setnexthandler method. This is the method for specifying the next handler in the event processing chain. Thanks to this facility provided by the class that is more ancestor than the base class wxwindow of all windows, let those subforms directly connect to the main form after accepting the event. Traverse all sub-forms of the main form (obtained using the getchildren method), call-> setnexthandler (this) for each of them, and input the main form string into its event processing chain: mainframe () {//...... Wxwindowlist children = getchildren (); For (wxwindowlist: node * I = children. getfirst (); I; I = I-> getnext () {I-> getdata ()-> setnexthandler (this) ;}} tested and solved the problem. The logic is correct, you do not need to define additional functions or derived classes. In addition, for the form object structure such as "child and child", this process should be changed to recursive. Maybe the same or better solution already exists on the Internet, but I am too stupid to find it, so I will list all the keywords I have tried as much as possible to facilitate search engine indexing, convenience for others: wxWidgets, wxwindow, window, form, control, focus, buttons, keyboard, events, interception, keypreview, wxframe, wxdialog, events, wxkeyevent, evt_key_down, evt_key_up, onkeyup, onkeydown

From: http://www.cnblogs.com/ioriliao/archive/2009/10/09/1579843.html

2. full Screen implementation: The wxmediactrl control is in the wxpanle control, and the wxpanle control is under the wxframe control. The steps to implement the full screen wxmediactrl control are as follows: First, save the current node obtained from the wxframe, hide unnecessary controls in wxframe. Then, use showfullscreen () to obtain the width and height of the display. Then, move the position of the entire control to the screen and set the window excluding the border to the size obtained in the previous step.

3. Minimal event implementation: wxiconizeevent

4. Code errors: the pointer is not initialized. A public pointer is defined in the class and is not initialized. When the pointer is called for use, an error type is displayed. "The exception not handled at 0x004141c2 ".

5. Pass the RESPONSE event of the Child Window to the parent window of the previous layer. You can set a flag in the Child Window and operate according to the flag in the parent window.

6. pass the parent class object in the parent window to the child form. You can use setparent (parent * parent) in the child form. Call this function in the parent window, you can pass the parent form to the child form. 7. implement void pipdialog: onmove (wxmouseevent & event) {wxpoint Pt = event. getposition (); If (event. dragging () & event. leftisdown () {wxpoint Pos = clienttoscreen (PT); move (wxpoint (POS. x-m_delta.x, POS. y-m_delta.y) ;}} void pipdialog: onleftdown (wxmouseevent & evnt) {capturemouse (); // printf ("Mouse captured/N "); wxpoint Pos = clienttoscreen (evnt. getposition (); wxpoint origin = getpositi On (); int dx = POS. x-origin. x; int DY = POS. y-origin. y; m_delta = wxpoint (dx, Dy);} void pipdialog: onleftup (wxmouseevent & event) {If (hascapture () releasemouse ();} 8. if you do not want the child form to respond to the event of the parent form (such as the double-click event of the mouse), you only need to add the event you do not want to respond to in the child form (such as the double-click event of the mouse ), but no code is required in the function.

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.