What do these functions in win32.H do?

8 views
Skip to first unread message

Gonzalo Garramuño

unread,
Feb 1, 2023, 11:10:41 AM2/1/23
to fltkc...@googlegroups.com

extern void fl_release_dc(HWND w, HDC dc);
extern FL_EXPORT void fl_save_dc( HWND w, HDC dc);

They seem to be undocumented in the lasted FLTK1.4 doxygen docs.

--
Gonzalo Garramuño
ggar...@gmail.com

melcher....@googlemail.com

unread,
Feb 2, 2023, 5:18:35 AM2/2/23
to fltk.coredev
As a user, you do not need to call it. As a core dev, see Fl_WIN32.cxx:

///////////////////////////////////////////////////////////////////////

//

//  The following routines help fix a problem with the leaking of Windows

//  Device Context (DC) objects. The 'proper' protocol is for a program to

//  acquire a DC, save its state, do the modifications needed for drawing,

//  perform the drawing, restore the initial state, and release the DC. In

//  FLTK, the save and restore steps have previously been omitted and DCs are

//  not properly released, leading to a great number of DC leaks. As some

//  Windows "OSs" will hang when any process exceeds roughly 10,000 GDI objects,

//  it is important to control GDI leaks, which are much more important than memory

//  leaks. The following struct, global variable, and routines help implement

//  the above protocol for those cases where the GetDC and RestoreDC are not in

//  the same routine. For each GetDC, fl_save_dc is used to create an entry in

//  a linked list that saves the window handle, the DC handle, and the initial

//  state. When the DC is to be released, 'fl_release_dc' is called. It restores

//  the initial state and releases the DC. When the program exits, 'fl_cleanup_dc_list'

//  frees any remaining nodes in the list.


Reply all
Reply to author
Forward
0 new messages