June 13, 2024, 01:13:43 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Conflicts between iwbasic functions and windows api

Started by DominiqueB, March 16, 2011, 10:25:38 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DominiqueB

Hello,

trying to use api functions, i see some of them conflicting with iwbasic v2:

SHOWWINDOW(win as WINDOW,nCmdShow as INT,OPT id=0 as UINT) conflict with
API declare import, _ShowWindow alias ShowWindow(HWND hWnd, int nCmdShow),BOOL
in winuser.inc (from sapero includes)

PRINTWINDOW(win as WINDOW) conflict with
API declare import, _PrintWindow alias PrintWindow(HWND hwnd, HDC hdcBlt, UINT nFlags),BOOL
in winuser.inc (from sapero includes)

I suppose there are some others ?

Dominique

LarryMc

In my designer project I use showwindow and _showwindow a total of 52 times (split about equally) without any problem whatsoever.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

Brian

Dominique,

Have you got Sapero's latest Includes? They fixed a few problems for me

http://www.sendspace.com/file/k3ixff

Brian

DominiqueB

Larry,

if i do this :
ShowWindow(MainWin,SW_SHOWNORMAL) where MainWin is a INT
i get this :

Compiling...
Browser.iwb
File: C:\Mes Programmes\iwbdev2\Mes exemples\Browser\Browser.iwb (117) Error: Unable to convert int to structure
Variable name: MainWin
File: C:\Mes Programmes\iwbdev2\bin\iwbstd.incc (268) See previous declaration
Error(s) in compiling "C:\Mes Programmes\iwbdev2\Mes exemples\Browser\Browser.iwb"

it works if i use :
_ShowWindow(MainWin,SW_SHOWNORMAL)


Don't forget the syntax for the iwbdev :
SHOWWINDOW(win as WINDOW,nCmdShow as INT,OPT id=0 as UINT)

they are not the same . . .

And Brian yes i already have isntalled the last Sapero includes.

Did you try to load the winuser.inc include file from Sapero, you will see the function name ShowWindow()coloured in blue . . .

Thank's

LarryMc

QuoteShowWindow(MainWin,SW_SHOWNORMAL) where MainWin is a INT
That would be an incorrect implementation
The proper way would be:
window MainWin
CREATEWINDOW(MainWindow,.....)
ShowWindow(MainWin,SW_SHOWNORMAL)

That's because the IWB SHOWWINDOW command expects a UDT of type window variable to be passed.

The compiling error code you get is telling you that.

The _showwindow api expects a handle to be passed.
Using the api this is correct:
window MainWin
CREATEWINDOW(MainWin,.....)
_ShowWindow(MainWin.hwnd,SW_SHOWNORMAL)


The reason this worked:
_ShowWindow(MainWin,SW_SHOWNORMAL)
is because the first element in the window structure is the hwnd.
That means MainWin and MainWin.hwnd have the same memory address
and the api is only using the hwnd so there is no crash because it doesn't try to access the other parts of the UDT.

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

DominiqueB

thank's for the explainations, i new all of that :-)

The question is : won't these 2 functions with same name but 2 differents syntaxes from api and from iwbasic do troubles for new users that will try to use api for the first time . . .

Dominique

LarryMc

Quote from: DominiqueB on March 16, 2011, 01:09:46 PM
thank's for the explainations, i new all of that :-)

The question is : won't these 2 functions with same name but 2 differents syntaxes from api and from iwbasic do troubles for new users that will try to use api for the first time . . .

Dominique
If you knew all that then you knew they don't have the same name
one is showwindow and one is _showwindow

If you want to use showwindow then you follow the rules established in iwb
iF you want to use _showwindow then you have to follow the rules established in the windows API

So, other than your improper use of the IWB showwindow command, what problem are you having that needs to be resolved?

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

DominiqueB

Well i don't want to be in conflict with you . . .

The api windows function is ShowWindow() and iwbasic is also ShowWindow(),
so there is (i think) a problem ?
It's the same for PrintWindow() . . .

I just want to help make iwbasic better because i like it . . . so don't be hungry


Dominique

LarryMc

Quote from: DominiqueB on March 16, 2011, 03:17:04 PM
Well i don't want to be in conflict with you . . .

The api windows function is ShowWindow() and iwbasic is also ShowWindow(),
so there is (i think) a problem ?
It's the same for PrintWindow() . . .

I just want to help make iwbasic better because i like it . . . so don't be hungry


Dominique

your are right and you are wrong; here's the point you are missing
Anytime you use SHOWWINDOW you are automatically using the IWB command
If you want to use the API SHOWCOMMAND you have to alias it because the names are indeed the same.

The 'windows.inc' and 'windowssdk.inc' will automatically do the alias for you.
So, for all the IWB commands that have an API command with exactly the same name the two include files prepend an underscore to the api  name.
It's that way in IWB; it was that way in EBasic; and was that way in IBPro before that.
That accounts for 10 years I know of that it hasn't been an issue.

So, you have no issue for us to address other than how to properly use api's in IWB.

I'll make a note to add an explanation in the help file if I ever decide to work on it again.

LarryMc

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

DominiqueB