Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
27530 Discussions

CreateWindow does not yield a handle nor an errorcode

Paul_Felz
New Contributor I
112 Views

Hi there,

in my prog I place a number of windows on my screen. For all except one everything works fine, but for the last one CreateWindow neither returns a handle nor an error code. See this excerpt here:

 

 

character*30 :: ccDatenfensterClass = 'DatenfensterClass'C
character*30 :: ccKartenfensterClass = 'KartenfensterClass'C
character*30 :: ccKontrollfensterClass = 'KontrollfensterClass'C
character*30 :: ccStatusfensterClass = 'StatusfensterClass'C

----

cWindowClass = ccDatenFensterClass
tWndClass%style = ior(CS_HREDRAW, CS_VREDRAW)
tWndClass%lpfnWndProc = loc(DatenWndProc)
tWndClass%cbClsExtra = 0
tWndClass%cbWndExtra = 0
tWndClass%hInstance = hhInstance
tWndClass%hIcon = NULL
tWndClass%hCursor = LoadCursor (NULL, IDC_ARROW)
tWndClass%hbrBackground = GetStockObject (WHITE_BRUSH)
tWndClass%lpszMenuName = NULL
tWndClass%lpszClassName = loc (cWindowClass)

iRslt = RegisterClass (tWndClass)


!   Mitte Oben: "Kartenfenster"

cWindowClass = ccKartenfensterClass
tWndClass.lpfnWndProc = loc (KartenWndProc)
tWndClass.lpszClassName = loc (CWindowClass)

iRslt = RegisterClass (tWndClass)

!   Rechte Seite : "Kontrollfenster"

cWindowClass = ccKontrollfensterClass
tWndClass.lpfnWndProc = loc (KontrollWndProc)
tWndClass.lpszClassName = loc (CWindowClass)

iRslt = RegisterClass (tWndClass)

!   Unterer Bereich : "Statusfenster"

cWindowClass = ccStatusfensterClass
tWndClass.lpfnWndProc = loc (StatusWndProc)
tWndClass.lpszClassName = loc (CWindowClass)

iRslt = RegisterClass (tWndClass)


------


!--------------------------------------------------------------------
!           Einrichten des Kontrollfensters
!--------------------------------------------------------------------
            iKontrollTop = 0
            iKontrollWidth = (iWinWidth - iKarteWidth) / 2
            iKontrollHeight = iWinHeight / 2
            iKontrollLeft = iWinWidth - iKontrollWidth

            iStyle = ior (WS_CHILDWINDOW, WS_VISIBLE)                               ! Einrichten als ChildWindow
            iiWindowCount = iiWindowCount + 1

            iiKontrollHandle = CreateWindow (ccKontrollFensterClass,       &
                                ''C,                                    &
                                iStyle,                                 &
                                iKontrollLeft,                          &
                                iKontrollTop,                           &
                                iKontrollWidth,                         &
                                iKontrollHeight,                        &
                                hWnd,                                   &
                                iiWindowCount,                          &
                                hhInstance,                             &
                                NULL)

            print *,' iiKontrollHandle = ', iiKontrollHandle


            iRslt = ShowWindow(iiKontrollHandle, SW_SHOWNORMAL)
            iRslt = UpdateWindow (iiKontrollHandle)

!--------------------------------------------------------------------
!           Einrichten des Statusfensters
!--------------------------------------------------------------------
            iStatusTop = iWinHeight / 2
            iStatusWidth = (iWinWidth - iKarteWidth) / 2
            iStatusHeight = iWinHeight / 2
            iStatusLeft = iWinWidth - iStatusWidth

            iStyle = ior (WS_CHILDWINDOW, WS_VISIBLE)                               ! Einrichten als ChildWindow
            iiWindowCount = iiWindowCount + 1

            iiStatusHandle = CreateWindow (ccStatusFensterClass,        &
                                ''C,                                    &
                                iStyle,                                 &
                                iStatusLeft,                            &
                                iStatusTop,                             &
                                iStatusWidth,                           &
                                iStatusHeight,                          &
                                hWnd,                                   &
                                iiWindowCount,                          &
                                hhInstance,                             &
                                NULL)

            iRslt = GetLastError ()
            print *,' LastError = ', iRslt
            print *,' iiStatusHandle = ', iiStatusHandle

            iRslt = ShowWindow(iiStatusHandle, SW_SHOWNORMAL)
            iRslt = UpdateWindow (iiStatusHandle)

 

 

The prints in line #104 and #105 both yield zero while the window before that ("Kontrollfenster") works just fine. The debugger shows all parameters as they are expected to be.

 

Any Idea on where to start to pinpoint this bug?

 

Cheers

PF

0 Kudos
1 Solution
Paul_Felz
New Contributor I
88 Views

Got it!

This is not an issue with CreateWindow but with the windows procedure attached to the window to be created.

It happens, when the call to DefWindowProc is not performed for unprocessed messages. I had this call in the wrong line.

 

Problem solved.

 

Cheers

PF

View solution in original post

3 Replies
Steve_Lionel
Black Belt Retired Employee
106 Views

CreateWindow returns something - what is it? Zero?

Paul_Felz
New Contributor I
103 Views

Yes. It returns 0.  See attched screenshot of the print to screen.

 

PF

Paul_Felz
New Contributor I
89 Views

Got it!

This is not an issue with CreateWindow but with the windows procedure attached to the window to be created.

It happens, when the call to DefWindowProc is not performed for unprocessed messages. I had this call in the wrong line.

 

Problem solved.

 

Cheers

PF

Reply