locked
Desktop Toolbar and Window RRS feed

  • Question

  • Hi everybody

    I'm trying to create desktop toolbar window using SHAppBarMessage and Window class. I send NEW then QUERYPOS and SETPOS messages. Then I'm trying to set new position for a window (I tried Window Top, Left etc properties, MoveWindow and SetWindowPos functions) but after window position has changed Window receives WM_MOVE message with old coordinates and changes it's position back.

    Is there any way to make Window ignore this message or probably WM_MOVE is sent because I'm doing something wrong?

    Thanx

    Wednesday, September 5, 2007 6:49 AM

Answers

  • Artem,

     

    I'm not sure what you are doing wrong, but I took some SHAppBarMessage code from TheCodeProject (this purgatory article - "AppBar using C#") and reapplied it to WPF. The link to the solution:

     

    http://cid-29d3817d88e30c6c.skydrive.live.com/self.aspx/WPF_Forum/SHAppBarMessageSolution.zip 

     

     

    This solution includes a Windows Forms project and a WPF Application project. The Win32 interoperability code is shared between the two projects. Both projects demonstrate using SHAppBarMessage to "dock" your main window to the top of the desktop, and the common interop code looks very similar to that shown in the article. Neither project shows the problem you describe of Windows moving the window back to its "old" coordinates.

     

    I happen to think the WPF solution looks a little nicer, plus it can use XAML to define the contents of the window. Let me know if this works for you, or at least unblocks you.

     

    Greg

     

     

    Standard disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, September 11, 2007 1:09 AM

All replies

  • Artem,

     

    I'm not sure what you are doing wrong, but I took some SHAppBarMessage code from TheCodeProject (this purgatory article - "AppBar using C#") and reapplied it to WPF. The link to the solution:

     

    http://cid-29d3817d88e30c6c.skydrive.live.com/self.aspx/WPF_Forum/SHAppBarMessageSolution.zip 

     

     

    This solution includes a Windows Forms project and a WPF Application project. The Win32 interoperability code is shared between the two projects. Both projects demonstrate using SHAppBarMessage to "dock" your main window to the top of the desktop, and the common interop code looks very similar to that shown in the article. Neither project shows the problem you describe of Windows moving the window back to its "old" coordinates.

     

    I happen to think the WPF solution looks a little nicer, plus it can use XAML to define the contents of the window. Let me know if this works for you, or at least unblocks you.

     

    Greg

     

     

    Standard disclaimer: This posting is provided "AS IS" with no warranties, and confers no rights.

    Tuesday, September 11, 2007 1:09 AM
  • I have the same problem with this example, as soon as I change anything in th code, for examplke adding a button and setting windowstate of the Window, the window is set to the new Zero coordinateswhich in my case are 50 pixels below display Top. So I can see the top 50pixels height of the wallpaper and below that is my window

    It seems he doesn't like if I change the ResizeMode or WindowStyle, which both are essential for my application. SOmetimes if I change something and it has a problem I then Undo the changes but the problem remains. Only if I revert the change completely to your given code the problem goes away sometimes. Strange thing
    Wednesday, January 21, 2009 1:34 PM
  • It seems he doesnt like when the Windowstyle is something else than ToolWindow. So I tried to change into ToolWindow before docking and changing back to None after docking. In my Testproject it worked without any problems, but in my actual project when I dock it twice he cries that None is the only possible value for Windowstyle if AllowTransparency is true. He also doesn't let me change AllowTransparency, because he says it cant be changed after the window has been shown. Any suggestions?
    Thursday, January 22, 2009 10:09 AM
  • I'm having the same problem. Using something other than ToolWindow would seem to be somewhat fundamental to a dokcing window, so this is a big problem.
    Friday, February 27, 2009 6:03 AM
  • I figured it out -- you have to call SHAppBarMessageHelper.ABSetPos again some number of messages after RegisterBar. I called it the first time Window.ContentRendered is fired; that seems to work.

    Of course, you have to set ABSetPos to be a public method if you're using Greg's sample code.
    • Proposed as answer by Rei Miyasaka Friday, February 27, 2009 8:54 AM
    Friday, February 27, 2009 8:54 AM