IonicWind Software

IWBasic => General Questions => Topic started by: DominiqueB on June 22, 2011, 11:44:09 AM

Title: AppBar sample
Post by: DominiqueB on June 22, 2011, 11:44:09 AM
Hello,

could someone hellp with the Appbar sample.
It compiles ok but crash on running ?

i use vista and the .exe is crashing even with administrator rights . . .

Could someone help ?

Thank's

dominique
Title: Re: AppBar sample
Post by: pistol350 on June 28, 2011, 08:12:00 AM
Same problem here.
Title: Re: AppBar sample
Post by: LarryMc on June 28, 2011, 09:55:28 AM
Well guys, don't feel bad.

I compiled and ran the appbar on my xp and it didn't crash
It didn't do anything.  When I move the cursor over the bar I get an hour glass and that's all.

I had seen it work before in EB so I went to my EB1.737 version, compiled and ran it.
I get the exact same thing.

To make sure the program hadn't changed I went to the source code disk from one of the firesale deals way back and got that copy of appbar (which appears to be the same. 
Compiling and runing in either version (IWB, EB) had the same outcome. I don't know what is going on. 

So, from my standpoint it is not a IWB2.0 specific problem; at least for me anyway.


LarryMc
Title: Re: AppBar sample
Post by: LarryMc on June 28, 2011, 10:28:01 AM
I think I found  the problem:

In the RegisterAppBar subroutine
at line 471 you should see this statement:
SENDMESSAGE hWnd,@WMSETTINGCHANGE,@SPI_SETWORKAREA,0
it should be this:
SENDMESSAGE win,@WMSETTINGCHANGE,@SPI_SETWORKAREA,0

Sapero is out of pocket right now. I'll ask him to look at it.
In the meantime, you that are having trouble can change it and see if it cures your crash.

LarryMc
Title: Re: AppBar sample
Post by: DominiqueB on June 28, 2011, 11:36:56 AM
Yes ! ! !

thank's a lot this is the good solution ! ! !

Dominique
Title: Re: AppBar sample
Post by: sapero on June 28, 2011, 11:44:13 AM
hwnd = @HWND_BROADCAST
SENDMESSAGE hwnd,@WMSETTINGCHANGE,@SPI_SETWORKAREA,0

This code is correct, it should send a message to all top level windows on current desktop.

I am running Win7 x64. The appbar hungs for two-five seconds at startup (while loading the CPLs), but then I can use it. Does not crash, only dislayed some error messages that an ordinal cannot be found.

A simple fix for the error above is to change the default error mode:
SetErrorMode(SEM_FAILCRITICALERRORS)

Attached is a modified, more secure version of the appbar - a bit of security added to prevent possible buffer overflows - the CopyStr function.
Title: Re: AppBar sample
Post by: LarryMc on June 28, 2011, 12:06:04 PM
Sapero,
Your example has the exact sample problem as I described above.

From what I'm reading in the SDK the sendmessage should be going to all windows except child windows.
So this should work but it doesn't.
SETID "HWND_BROADCAST",0xFFFF
DEF hwnd:INT
hwnd = @HWND_BROADCAST
SENDMESSAGE hwnd,@WMSETTINGCHANGE,@SPI_SETWORKAREA,0

But I have to use Task Manager to shut the appbar down.

When I make the change I suggested above to the actual WINDOW that contains the appbar, it works.
LarryMc
Title: Re: AppBar sample
Post by: DominiqueB on June 28, 2011, 12:11:01 PM
i was ready to say the same thing but you've been quicker than me :-)

Same for me, if i apply the same correction to sapero's update, it work ok !
If not, i only get the appbar with the waiting icon . . .

Dominique
Title: Re: AppBar sample
Post by: sapero on June 28, 2011, 12:39:13 PM
If it hangs at SENDMESSAGE, then some other application must be hung.
If we change it to PostMessage (only if we can), the appbar will continue its work.

Because WM_SETTINGCHANGE does not require any buffers, we can use PostMessage.
Change the line to:
PostMessageA(hwnd,@WMSETTINGCHANGE,@SPI_SETWORKAREA,0)
Then add the declaration:
declare import, PostMessageA(int hWnd, int Msg, int wParam, int lParam),int
Title: Re: AppBar sample
Post by: sapero on July 01, 2011, 10:36:28 AM
There is one more bug - the appbar may be initially positioned outside the visible screen area.

In the AppBarPosChange subroutine, the "rc" variable is partially initialized (right and bottom members) and the uninitialized left,top members are used in a switch below.

DEF rc:WINRECT
...
GETSCREENSIZE rc.right, rc.bottom
...
rc.bottom = rc.top/*not initialized*/ + height
...
rc.right = rc.left/*not initialized*/ + width


To fix it, change the declaration toDEF rc=0:WINRECTOr initialize rc.left and rc.top to zero.