TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Billy
NA
1
0
Window Notification Application - Height Defined by Taskbar Question
Apr 26 2007 5:14 PM
I have a type of application that seems to be gaining popularity lately that displays a semi-transparent window with whatever message in the bottom corner of the user's desktop.
I've been trying to get the windows to "sit on top" of the taskbar. I got it to work just fine so far, except for users who autohide their taskbar. What I've been trying to do is figure out how to get the height of the taskbar during runtime (so if the user is looking in the taskbar, the windows will know where to be and still be sitting on the taskbar).
I've looked everywhere online, and no one seems to be able to answer this seemingly simple question for anyone with similar issues. Here is what I've done so far, I feel like I'm inches away from the answer...
//this is how to use functions found in .dlls
//need to return IntPtr instead of long. long works with this function alone seemingly fine.
[DllImport("user32.dll")] private static extern IntPtr FindWindow(string className, string windowText);
//I read some online resources that used ref instead of out, ref doesn't work. You NEED IntPtr as an argument, not long. It also MUST return bool. This is the way I got it to work.
[DllImport("user32.dll")] private static extern bool GetWindowRect(IntPtr hWnd, out RECT rc);
//You also have to create your own RECT class like this. I don't know if all the variables are named correctly, but all I needed was height, so...
[StructLayout(LayoutKind.Sequential)]
public struct RECT
{
public int left;
public int top;
public int width;
public int height;
}
//elsewhere:
RECT temp = new RECT();
//returns the taskbar window
IntPtr hWndStartBar = FindWindow("Shell_TrayWnd", "");
//fills temp with the dimensions of the taskbar window
GetWindowRect(hWndStartBar, out temp);
That works just fine and dandy, just the returned height for the supposedly Start Menu's Taskbar is the same height as the screen resolution. This seems reasonable since you could potentially drag the size of your taskbar to the top of the screen...
I used the following given variables to figure out another system:
SystemInformation.PrimaryMonitorSize.Height //monitor size
Screen.PrimaryScreen.WorkingArea.Heigh //screen size not including the taskbar
That seems to be easy, subtract work area from monitor size, right? Wrong! Doesn't take into account the taskbar being "open" when autohide is on and gives the same value as if it were still hiding away.
If anyone has anything to add to this, please fill us in. This is a handy piece of information to have, just how do you get it...?
Thanks,
Billy
Reply
Answers (
0
)
display image on picture box control which got From Biometric device in c# (urgent)
Recovering deleted files using c# ?