October 30, 2025, 05:37:09 PM

News:

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


AppBar sample

Started by DominiqueB, June 22, 2011, 11:44:09 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

DominiqueB

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

pistol350

Regards,

Peter B.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

DominiqueB

Yes ! ! !

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

Dominique

sapero

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.

LarryMc

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
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

DominiqueB

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

sapero

June 28, 2011, 12:39:13 PM #8 Last Edit: July 01, 2011, 10:25:58 AM by sapero
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

sapero

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.