Getting Size with GetSize() fails for wxBufferedPaintDC Topic is solved

Are you writing your own components and need help with how to set them up or have questions about the components you are deriving from ? Ask them here.
Post Reply
grf
Knows some wx things
Knows some wx things
Posts: 38
Joined: Thu Jun 01, 2006 1:53 pm
Location: Germany

Getting Size with GetSize() fails for wxBufferedPaintDC

Post by grf »

Hi there,

I'm not sure wether it's a bug or a feature of wxMSW (and wxGTK) version 2.8.0...

I use wx(Auto)BufferedPaintDC for painting something into a window (the "buffered" version to avoid flickering).
If I try to get the size of this window GetSize() returns wrong values if the size of the window was decreased before.
For example:

1. Program has been started: GetSize() returns the correct size
2. Program window has been maximized: GetSize() returns the correct size
3. Program window has been made smaller again to the original size: GetSize() returns the wrong size (still the same size like for the maximized window)

This behaviour happens if I use wxBufferedPaintDC and wxAutoBufferedPaintDC with wxMSW 2.8.0 and wxGTK 2.8.0. For wxMSW 2.6.3 and wxGTK 2.6.3 the function GetSize() returns the correct values (using wxBufferedPaintDC).

A code snipplet:

Code: Select all

void DrawArea::draw_something() {

  wxBufferedPaintDC dc_pointer(this);

  wxCoord d_width, d_height;
  
  //set background
  dc_pointer.Clear();
  dc_pointer.SetBackground(*wxWHITE_BRUSH);
  this->SetBackgroundStyle(wxBG_STYLE_CUSTOM); 

  //get the actual size of draw area
  dc_pointer.GetSize(&d_width, &d_height);

...

}
Regards,
Michael
Sowas kommt von sowas.
alamgir99
Experienced Solver
Experienced Solver
Posts: 72
Joined: Tue Feb 20, 2007 2:16 am
Location: Melbourne, Australia

Re: Getting Size with GetSize() fails for wxBufferedPaintDC

Post by alamgir99 »

grf wrote:Hi there,

1. Program has been started: GetSize() returns the correct size
2. Program window has been maximized: GetSize() returns the correct size
3. Program window has been made smaller again to the original size: GetSize() returns the wrong size (still the same size like for the maximized window)
You are talking about the window or the drawing portion on th screen!

Code: Select all

  //get the actual size of draw area
  dc_pointer.GetSize(&d_width, &d_height);
this returns the region on the screen that needs to be redrawn (due to overlapping by other windows or resizing).
It is not always equal to the window size.

In you code:
this->GetClientSize() would give the right size.

al
al
}
[/code]

Regards,
Michael[/quote]
grf
Knows some wx things
Knows some wx things
Posts: 38
Joined: Thu Jun 01, 2006 1:53 pm
Location: Germany

Re: Getting Size with GetSize() fails for wxBufferedPaintDC

Post by grf »

alamgir99 wrote: this returns the region on the screen that needs to be redrawn (due to overlapping by other windows or resizing).
It is not always equal to the window size.

In you code:
this->GetClientSize() would give the right size.
You are right, that was the problem! Now it runs as expected. Thank you! :)

Regards
Michael
Sowas kommt von sowas.
Post Reply