473,586 Members | 2,681 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Moving windows takbar?

Why can I not move the windows taskbar with the SHAppBarMessage function?
I am able to use the function for hiding it and other things, but not moving it (I have unchecked the lock). The code is below.
Super greatefull for an answer!
KalleD

Declarations:
[StructLayout(La youtKind.Sequen tial)]
public struct APPBARDATA
{
public UInt32 cbSize;
public IntPtr hWnd;
public UInt32 uCallbackMessag e;
public UInt32 uEdge;
public RECT rc;
public Int32 lParam;
}

[DllImport("shel l32.dll")]
public static extern UInt32 SHAppBarMessage (UInt32 dwMessage,ref APPBARDATA pData);
private const int ABM_SETPOS = 0x3;
private const int ABM_GETTASKBARP OS = 0x5;

Code:
APPBARDATA msgData = new APPBARDATA();
msgData.cbSize = (UInt32)Marshal .SizeOf(msgData );
msgData.hWnd = (System.IntPtr) Handle;
SHAppBarMessage (ABM_GETTASKBAR POS, ref msgData);
msgData.uEdge=1 ; //for moving i to the top
msgData.rc.top= 0;
msgData.rc.bott om=34;
SHAppBarMessage (ABM_SETPOS, ref msgData);

Nov 16 '05 #1
2 10453
KalleD wrote:
Why can I not move the windows taskbar with the SHAppBarMessage function?
I am able to use the function for hiding it and other things, but not moving it (I have unchecked the lock). The code is below.
Super greatefull for an answer!
KalleD

Declarations:
[StructLayout(La youtKind.Sequen tial)]
public struct APPBARDATA
{
public UInt32 cbSize;
public IntPtr hWnd;
public UInt32 uCallbackMessag e;
public UInt32 uEdge;
public RECT rc;
public Int32 lParam;
}

[DllImport("shel l32.dll")]
public static extern UInt32 SHAppBarMessage (UInt32 dwMessage,ref APPBARDATA pData);
private const int ABM_SETPOS = 0x3;
private const int ABM_GETTASKBARP OS = 0x5;

Code:
APPBARDATA msgData = new APPBARDATA();
msgData.cbSize = (UInt32)Marshal .SizeOf(msgData );
msgData.hWnd = (System.IntPtr) Handle;
SHAppBarMessage (ABM_GETTASKBAR POS, ref msgData);
msgData.uEdge=1 ; //for moving i to the top
msgData.rc.top= 0;
msgData.rc.bott om=34;
SHAppBarMessage (ABM_SETPOS, ref msgData);

[DllImport("User 32.dll", ExactSpelling=t rue,
CharSet=System. Runtime.Interop Services.CharSe t.Auto)]
private static extern bool MoveWindow(IntP tr hWnd, int x, int y, int cx,
int cy, bool repaint);

[DllImport("Shel l32.dll", CharSet=CharSet .Auto)]
private static extern int SHAppBarMessage (int dwMessage, ref
APP_BAR_DATA abd);

private const int ABM_NEW = 0x00;
private const int ABM_REMOVE = 0x01;
private const int ABM_QUERYPOS = 0x02;
private const int ABM_SETPOS = 0x03;
private const int ABM_SETAUTOHIDE BAR = 0x08;
private const int ABM_SETSTATE = 0x0000000a;
private const int ABE_LEFT = 0;
private const int ABE_TOP = 1;
private const int ABE_RIGHT = 2;
private const int ABE_BOTTOM = 3;
private const int ABS_AUTOHIDE = 0x01;
private const int ABS_ALWAYSONTOP = 0x02;

[StructLayout(La youtKind.Sequen tial)]
private struct APP_BAR_DATA
{
public int cbSize;
public IntPtr hWnd;
public int uCallbackMessag e;
public int uEdge;
public RECT rc;
public IntPtr lParam;
}

[StructLayout(La youtKind.Sequen tial)]
private struct RECT
{
public int left;
public int top;
public int right;
public int bottom;

public RECT(int left, int top, int right, int bottom)
{
this.left = left;
this.top = top;
this.right = right;
this.bottom = bottom;
}

public static RECT FromXYWH(int x, int y, int width, int height)
{
return new RECT(x, y, x + width, y + height);
}
}

internal static void DockAppBar(IntP tr hWnd, int edge, Size idealSize)
{
APP_BAR_DATA abd = new APP_BAR_DATA();
abd.cbSize = Marshal.SizeOf( abd);
abd.hWnd = hWnd;
abd.uEdge = edge;

if (edge == ABE_LEFT || edge == ABE_RIGHT)
{
abd.rc.top = 0;
abd.rc.bottom = SystemInformati on.PrimaryMonit orSize.Height;
if (edge == ABE_LEFT)
{
abd.rc.right = idealSize.Width ;
}
else
{
abd.rc.right = SystemInformati on.PrimaryMonit orSize.Width;
abd.rc.left = abd.rc.right - idealSize.Width ;
}

}
else
{
abd.rc.left = 0;
abd.rc.right = SystemInformati on.PrimaryMonit orSize.Width;
if (edge == ABE_TOP)
{
abd.rc.bottom = idealSize.Heigh t;
}
else
{
abd.rc.bottom = SystemInformati on.PrimaryMonit orSize.Height;
abd.rc.top = abd.rc.bottom - idealSize.Heigh t;
}
}

// Query the system for an approved size and position.
SHAppBarMessage (ABM_QUERYPOS, ref abd);

// Adjust the rectangle, depending on the edge to which the
// appbar is anchored.
switch (edge)
{
case ABE_LEFT:
abd.rc.right = abd.rc.left + idealSize.Width ;
break;
case ABE_RIGHT:
abd.rc.left= abd.rc.right - idealSize.Width ;
break;
case ABE_TOP:
abd.rc.bottom = abd.rc.top + idealSize.Heigh t;
break;
case ABE_BOTTOM:
abd.rc.top = abd.rc.bottom - idealSize.Heigh t;
break;
}

// Pass the final bounding rectangle to the system.
SHAppBarMessage (ABM_SETPOS, ref abd);

// Move and size the appbar so that it conforms to the
// bounding rectangle passed to the system.
MoveWindow(abd. hWnd, abd.rc.left, abd.rc.top, abd.rc.right -
abd.rc.left, abd.rc.bottom - abd.rc.top, true);
}

Cheers

Arne Janning
Nov 16 '05 #2
Thanks!!!
KalleD
Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2311
by: Mark S Pryor | last post by:
hello c.l.p., I'm using: Python 2.2 (ActiveState) Win2k sp3 P4 2GHz, 512 RAM Matrox p550 (dual head video card) I run my desktop at 2560 x 1024. When I get involved manually resizing and moving windows about,
5
1990
by: Pablo Cedeno | last post by:
Hi all, I'm having a problem with a form position. I need to prevent the user to drag the window. I tried to maximize the window but i still can move the window. I found something about override the WndProc method, but there are many messages returned by the OS, and i don't know which messages should i override. Maybe i'm working in a...
4
1549
by: Ron Mexico | last post by:
Hi, Currently have an app that maintain that is written in VB6 and uses an access db (backend db only used as a data store not writing to the db). This app is a client app not server multi-teir app. It multi-form app that takes in a lot of user input and gives out high end calculations (engineering app). This app is starting to grow beyond...
6
1456
by: Woody Splawn | last post by:
I have been using SQL Server 2000 on my stand-alone machine as a back-end to a VS.net application. It is time to switch environments and take the application to the customer. I need to install SQL Server 2000 on the server of the client's local area network, which is a Windows 2000 machine. I am concerned about doing this right. On my own...
3
3023
by: Just Me | last post by:
If I move the mouse cursor over a control and stop moving I get a MouseHover event. If I then move the cursor while staying within the control and then stop moving I do not get another MouseHover event. To get a Mousehover I must leave and reenter the control. I'd like to get an event each time the cursor stops moving.
2
3100
by: Carl Gilbert | last post by:
Hi I have a math kinda problem where I'm trying to split some lines when two or more lines connect two shapes. The reason I am doing this is to make it clear that there are multiple lines connecting the two shapes. http://www.blackwaterbadgers.co.uk/image1.bmp Image 1 shows how if you have a line between two shapes, the line is...
4
1186
by: Nathaniel | last post by:
How do i move windows in vb.net?
1
3788
by: rsteph | last post by:
I bought a book to help me learn to use DirectX with windows programming. It's first trying to walk me through some basic windows programming and graphics before getting into DirectX. I'm trying to expand on one of the example programs in the book but I'm having some problems. I can get a frame to appear, then an image gets randomly placed in...
4
2008
by: summerchase | last post by:
Hi. Has anyone ever seen a problem with Windows Vista where you can't close a window with the X, nor can you move a small window by dragging? Any answers?
0
7912
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7839
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8202
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
6614
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5710
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.