Thread: Some wxWidgets Questions.

  1. #1
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901

    Some wxWidgets Questions.

    If I'm going to be painting to a window (panel, etc.) will I need to create a Member DC and associate it with the window or is it okay to create a local copy in the paint event? What if it is buffered?

    Also, should I dynamically allocate message boxes and modal dialogues, or have pointers and destory them at the end of their cycle.

  2. #2
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by indigo0086 View Post
    If I'm going to be painting to a window (panel, etc.) will I need to create a Member DC and associate it with the window or is it okay to create a local copy in the paint event?
    You should create a wxPaintDC stack object on the onPaint event if you wish to only paint the window during OnPaint events. When you wish to paint outside OnPaint events you create a wxClientDC stack object on those events. Check the documentation for the proper constructors and usage.

    What if it is buffered?
    Here is just a tad little different. You have two; wxBufferedDC and wxBufferedPaintDC.

    The first is to be used outside OnPaintEvent and you simply create it on the stack after creating a wxClientDC. The constructors for the wxBufferedDC take a pointer to a wxDC object. You usually fill that in with that wxClientDC.

    The latter is to be used inside OnPaint events and you simply declare it on the stack instead of a wxPaintDC.

    Also, should I dynamically allocate message boxes and modal dialogues, or have pointers and destory them at the end of their cycle.
    I'm drawing a blank here. But will confirm when I get home if nobody else does it in the mean time, but modal boxes should be created on the stack, modeless in the heap.
    Last edited by Mario F.; 02-22-2008 at 09:46 AM.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  3. #3
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Cool. I have been just mixing it up, error modal dialogs were on the stack since they have a small scope, and heap allocated ones for longer use, but I guess it makes sense.

    Have you ever tried wxFormBuilder, it's a very nice tool that allows you a lot of freedom with it's subclassing feature.

  4. #4
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Quote Originally Posted by indigo0086 View Post
    Have you ever tried wxFormBuilder, it's a very nice tool that allows you a lot of freedom with it's subclassing feature.
    I decided to invest some money on wxWidgets. I bought DialogBlocks (from library author) and their Book.

    I really can't stress this enough Indigo, buy the book! It's very well written. Your knowledge and understanding of this library will increase by leaps and bounds. It leaves very little to be explained. And what it doesn't talk about you rarely will have a need to use. And if you do, its on the web at the distance of a google search string. The book is the main reason why I have so much fun programming with this library. If not for it I would still be in pain.

    I know, I sound like I'm advertising it. You got that right. I am!
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  5. #5
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Does the book teach to only DialogBlocks or does it leave it open to use anything you want?

  6. #6
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    It teaches you not to need it

    Really, it teaches you from the perspective of the source code. No layout aiding software is assumed.

    Let me tell you however that I don't suggest you rely too much on wxFormBuilder. DialogBlocks is, in my opinion, superior and I still don't. I only use these type of tools (and I used them extensively on other environents like WYSIWIG web editors) to design my dialogs and windows. Then I move them away and rename variables, tweak the code, change it if I need to, and such. You'll end with a more robust and simpler code structure.

    Only use them for what otherwise would be the boring part of visual design. After that, you want to take control over your own code and not have any tool tell you how you should program.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  7. #7
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    Well you kind of have to with wxFormBuilder. It only lays out the windows, then you have to use the inhereted class and implement it. Codeblocks has a project generator for it so you just generate the files, lay it out, and then go in and handle the advanced properties and events.

  8. #8
    (?<!re)tired Mario F.'s Avatar
    Join Date
    May 2006
    Location
    Ireland
    Posts
    8,446
    Yes, but after you read the book you'll find out the generated code is not the best on either tool. Neither could it be. These are generic tools.
    Originally Posted by brewbuck:
    Reimplementing a large system in another language to get a 25% performance boost is nonsense. It would be cheaper to just get a computer which is 25% faster.

  9. #9
    Ethernal Noob
    Join Date
    Nov 2001
    Posts
    1,901
    well, same could be said for any code generator, as long as you have the ability to override the settings in a derived class it's all good.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. A very long list of questions... maybe to long...
    By Ravens'sWrath in forum C Programming
    Replies: 16
    Last Post: 05-16-2007, 05:36 AM
  2. Borland & wxWidgets!!! Help!!!
    By Matt3000 in forum C++ Programming
    Replies: 5
    Last Post: 07-31-2006, 09:17 PM
  3. Several Questions, main one is about protected memory
    By Tron 9000 in forum C Programming
    Replies: 3
    Last Post: 06-02-2005, 07:42 AM
  4. Trivial questions - what to do?
    By Aerie in forum A Brief History of Cprogramming.com
    Replies: 23
    Last Post: 12-26-2004, 09:44 AM
  5. questions questions questions.....
    By mfc2themax in forum A Brief History of Cprogramming.com
    Replies: 1
    Last Post: 08-14-2001, 07:22 AM