- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I'm working on an application using CVF v6.6b that has several windows, all with custom color controls generated with createWindowEX calls and responding the the CTLCOLORxxxxx messaging. During the course of using the application, it might be necessary to open and close one or more of the secondary windows several times. After doing this many times (more than 100), the custom control graphics start to draw themselves elsewhere on the window other than where they belong and fonts change, even though the the 'hot' area for the button remains where it belongs.
I'd sure appreciate any help that's out there to resolve this.
I'm working on an application using CVF v6.6b that has several windows, all with custom color controls generated with createWindowEX calls and responding the the CTLCOLORxxxxx messaging. During the course of using the application, it might be necessary to open and close one or more of the secondary windows several times. After doing this many times (more than 100), the custom control graphics start to draw themselves elsewhere on the window other than where they belong and fonts change, even though the the 'hot' area for the button remains where it belongs.
I'd sure appreciate any help that's out there to resolve this.
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Heh, it's so common error -- you have a GDI memory leak. Every object created with CreateXXX (probably CreateSolidBrush in your case) must be destroyed using DeleteObject -- and you are responsible for that. I bet you're using Win9x/ME, where this problem is exposed very quickly, due to small GDI memory poll.
So, instead of
you need something like:
Implementation details may vary (for example, you could use SetWindowLong/SetProp APIs to keep hBr's instead of saved array) but the principle is same -- create once, use as necessary, delete once.
HTH
Jugoslav
So, instead of
case (WM_CTLCOLOREDIT) hBr = CreateSolidBrush(...) MyWindowProc = hBr
you need something like:
integer, save:: hBr(as_much_as_you_need) ... case (WM_CREATE) hBr(1) = CreateSolidBrush(...) hBr(2) = CreateSolidBrush(...) ... case (WM_CTLCOLOREDIT) select case(GetDlgItemId(hWnd, lParam)) case (IDC_CONTROL1) MyWindowProc = hBr(1) case (IDC_CONTROL2) MyWindowProc = hBr(2) ... case (WM_DESTROY) do i = 1, as_much_as_you_need b = DeleteObject(hBr(i)) end do ...If the colors should change at run-time, make sure to DeleteObject(hBr(x)) before creating a new one on its place.
Implementation details may vary (for example, you could use SetWindowLong/SetProp APIs to keep hBr's instead of saved array) but the principle is same -- create once, use as necessary, delete once.
HTH
Jugoslav
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You appear to be a hero. I've still got quite a bit of cleaning up to do, but the first test results look very promising. Thanks a lot!
![](/skins/images/DC0E2679F7049B943291D1ED082A478E/responsive_peak/images/icon_anonymous_message.png)
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page