Solved

HDC mess

Posted on 1997-05-13
1
314 Views
Last Modified: 2013-12-04
i have a HDC i'm working with.
i do WindowFromDC and get a HWND. then after a while
if i do again WindowFromDC on the same HDC. i get a
different HWND then the previous.
in between the two actions i mostly draw and sometime
create a memhdc and release it. i don't have more then 2
HDC at a time so there is probably no error of overwriting
the HDC and besides the only thing that is changed is the HWND
0
Comment
Question by:cyclop
1 Comment
 
LVL 1

Accepted Solution

by:
lwiding earned 100 total points
ID: 1397322
A lot depends on the window class styles and how you got the HDC you are using. If the window you got it from has the CS_CLASSDC style set, and another window of that class did a GetDC() after you first called WindowFromDC(), than the second call you made to WindowFromDC shold return the second window's handle.

If you are not using the CS_CLASSDC flag, than perhaps you could show the code you use to get the HDC, and the code that is seeing this problem. Remember, if you are using GetDC() to get the HDC, the handle should not be used after ReleaseDC() is called.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
This article surveys and compares options for encoding and decoding base64 data.  It includes source code in C++ as well as examples of how to use standard Windows API functions for these tasks. We'll look at the algorithms — how encoding and decodi…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

813 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now