CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    May 2024
    Posts
    2

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured