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

Issues with RegisterClass(wndclass)

Paul_Felz
New Contributor I
882 Views

Hi there,

I just started to work on my first Windows app with the intel compiler. In that I encounter an issue when starting my Windows app: More often than not RegisterClass fails to do what it is expected to do. The error code is 87: "The parameter is incorrect".

But I failed to track down any glitch in my parameters - and after some retries the App starts without any problem. I fail to recognize any pattern in the messed starts: sometimes I can have 5 Starts in a row without a single one failing, at another time I need 5 or more tries to have my app running. Note: Without any modifications of my code prior to registering the class.

Any way to repair this unnerving behavior?

I am using Visual Studio 2017 in a windows 11 environment. This happens under debug-mode compilation. In release mode I did not succeed yet - but did not try very hard - to get it running. 

Cheers

PF

0 Kudos
8 Replies
Steve_Lionel
Honored Contributor III
866 Views

There's little we can do to help you without a (hopefully small) but complete test case that demonstrates the problem. The best guess I can offer is that there's a field in your WNDCLASS structure you're not initializing. 

0 Kudos
Paul_Felz
New Contributor I
861 Views

Yes, I know. I was under way to compile such an extract - and spotted my error. The variable receiving the return value from RegisterClass was of the wrong type: boolean instead of integer.

 

I had

logical lRslt

.

lRslt = RegisterClass(tWndClass)

 

instead of

integer iRslt

.

iRslt = RegisterClass(tWndClass)

 

At least since I adjusted the type, the prog works well.

Thanks for your rapid response anyway.

Cheers

PF

 

 

0 Kudos
andrew_4619
Honored Contributor II
858 Views

The return value if register class is a 16 bit integer, the default Fortran integer is 32 bit, the default logical is also 32 bit so I think your diagnosis/fix is not correct.  integer(USHORT) ::  iRslt  or integer(C_INT16_T) :: iRslt  is what you should have. 

 

Show your initialisation of tWndClass

0 Kudos
Paul_Felz
New Contributor I
831 Views

Yes, that is what I thought too. That is why I did not give it too much thought if I used integer or logical as return variable. Any integer > 1 to be considered as true, 0 as false. But here I am. Works now.

 

Cheers

PF

0 Kudos
Steve_Lionel
Honored Contributor III
821 Views

@Paul_Felz wrote:

Yes, that is what I thought too. That is why I did not give it too much thought if I used integer or logical as return variable. Any integer > 1 to be considered as true, 0 as false. 

Not quite - at least not unless you also enabled /standard-semantics. See Doctor Fortran in "To .EQV. or to .NEQV., that is the question", or "It's only LOGICAL" - Doctor Fortran (stevelionel.com)

0 Kudos
Paul_Felz
New Contributor I
750 Views

Steve,

unless there was a glitch I did not recognize but inadvertantly eradicated, there was nothing else I did than change this logical to intgeger declaration. Since then I had long working hours with my code and dozens of builds per day - and this malfunction never occurred again.

 

Cheers

PF

0 Kudos
andrew_4619
Honored Contributor II
749 Views

Whatever the problem was changing to default integer (integer(4)) is not a solution as the return value is integer(2) as I noted upthread. With corruption/ initialised type errors any edit changes the code and may  make it work because the thing that is getting corrupted changes to something that is not important. Such errors often come back  on futures edits.....

Paul_Felz
New Contributor I
746 Views

... I will keep my fingers crossed (hard to type this way, though).

Thank for your support anyway.

 

Cheers

PF

0 Kudos
Reply