I'm modifying a Tk widget on Windows. I need to get the corresponding HDC given either a Tk Window, Drawable, or GC. I've tried poking around in the Tk internals but can't find anything helpful. The closest I've gotten is using Tk_GetHWND
from tkPlatDecls.h
and passing that to GetDC
from windows.h
. However, the result seems to always be null.
Does anyone have any experience with this?
I figured it out! For anyone stumbling across this in the future, you can use:
#include <tkWinInt.h> // from tk-private/win
// Other code
TkWinDCState state;
HDC hdc = TkWinGetDrawableDC(display, drawable, &state);