-
May 19th, 2024, 10:16 AM
#1
Error 1425: Invalid device context (DC) handle
Hi,
if this is not the right place to post my question I would appreciate if someone could direct me to the proper forum.
I am using FORTRAN to build my code, but the win32 API is used by interfaces to C/C++ provided with the compiler. So my code may look a little awkward to you, but it is not so very different from C.
My prog evaluates some data by running in cycles with a new set of data for each cycle. The total number would be 8760 corresponding with the number of hours in one year. I have some output to screen, where I use win32 API to show some diagrams and textual data just for control. And I have output to disk for further use. It is a single thread application using about 14 MB of memory and uses less than 5 % of CPU time. I am using Visual Studio 2017 in a Windows 11 environment.
This prog does its job for about 1250 cycles and then the screen freezes while the app carries on. Upon checking the return value of BeginPaint() I receive 1425, which indicates an invalid device context handle.
Now I am at a loss how this can happen:
Code:
hDC = BeginPaint (hWnd, tPS)
if (hDC .eq. 0) then
iRslt = GetLastError()
print *,'DiagrammWndProc: Error in Begin Paint. Code: ',iRslt
endif
I understand that BeginPaint failed but I could not find any clue as to why this happened and how to spot the root cause.
Anybody any idea?
Thanks in advance
Norbert
Last edited by 2kaud; May 20th, 2024 at 03:29 AM.
Reason: Changed quote to code tags
-
May 20th, 2024, 12:41 AM
#2
Re: Error 1425: Invalid device context (DC) handle
Problem solved.
Just for your files in case anybody encounters the same problem.
By an error of mine i coded
Code:
iRslt = EndPaint (hDC, tPS)
which should be
Code:
iRslt = EndPaint(hWnd, tPS)
Apparently EndPaint failed and each BeginPaint started a new device context. And eventually there were too many. But this did not show in memory needed.
-
May 20th, 2024, 02:27 AM
#3
Re: Error 1425: Invalid device context (DC) handle
I'm glad you could solve your problem.
Please next time use CODE tags rather than the QUOTE ones while posting the code snippets.
Victor Nijegorodov
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|