473,805 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Get notification buttons info - c# & api

I need some help trying to figure out why the code below does not work.

I'm trying to cycle through the icons in the notification area
and get button information.

Everything runs fine, but my TBUTTONINFO struct does not get
populated. iIndex:False is further evidence that things aren't working,
and I think I'm not setting the dwMask correctly.

Thanks!!

*************** *************** *************** *************
Here is the output of the log from Spy++
spying on ToolbarWindow32 :
*************** *************** *************** *************
<00001000D007 8 S TB_BUTTONCOUNT
<00002000D007 8 R TB_BUTTONCOUNT nCount:5
<00003000D007 8 S TB_GETBUTTONINF OW iID:0 lptbbi:001E9610
<00004000D007 8 R TB_GETBUTTONINF OW iIndex:False
<00005000D007 8 S TB_GETBUTTONINF OW iID:1 lptbbi:001E9610
<00006000D007 8 R TB_GETBUTTONINF OW iIndex:False
<00007000D007 8 S TB_GETBUTTONINF OW iID:2 lptbbi:001E9610
<00008000D007 8 R TB_GETBUTTONINF OW iIndex:False
<00009000D007 8 S TB_GETBUTTONINF OW iID:3 lptbbi:001E9610
<00010000D007 8 R TB_GETBUTTONINF OW iIndex:False
<00011000D007 8 S TB_GETBUTTONINF OW iID:4 lptbbi:001E9610
<00012000D007 8 R TB_GETBUTTONINF OW iIndex:False
*************** *************** *************** *************

*************** *************** *************** *************
Here is the full code:
*************** *************** *************** *************
using System;
using System.Collecti ons.Generic;
using System.Windows. Forms;
using System.Runtime. InteropServices ;
using System.Text;
using System.Componen tModel;
using System.Diagnost ics;
using System.Threadin g;

namespace CloseExe
{
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
IntPtr shelltraywnd = Win32Api.FindWi ndow(
"shell_traywnd" , null);
IntPtr traynotifywnd = Win32Api.FindWi ndowEx(
shelltraywnd, IntPtr.Zero, "traynotifywnd" , null);
IntPtr traysyspager = Win32Api.FindWi ndowEx(
traynotifywnd, IntPtr.Zero, "syspager", null);
IntPtr toolbarwindow32 = Win32Api.FindWi ndowEx(
traysyspager, IntPtr.Zero, "toolbarwindow3 2", null);

int buttoncount = (int)Win32Api.S endMessage(
new HandleRef(null, toolbarwindow32 ),
Win32Api.TB_BUT TONCOUNT,
IntPtr.Zero,
IntPtr.Zero);

Win32Api.TBBUTT ONINFO[] buttons =
new Win32Api.TBBUTT ONINFO[buttoncount];

for (int i = 0; i < buttoncount; i++)
{
Win32Api.TBBUTT ONINFO ti = new Win32Api.TBBUTT ONINFO();
ti.dwMask = Win32Api.TBIF_B YINDEX | Win32Api.TBIF_T EXT;
ti.cbSize = (uint)Marshal.S izeOf(ti);

Win32Api.SendMe ssage(
new HandleRef(null, toolbarwindow32 ),
Win32Api.TB_GET BUTTONINFO,
(IntPtr)i,
ref ti);

buttons[i] = ti;
}

}// Main
}

public static class Win32Api
{
public const int WM_USER = 0x0400;

//**Tried using WM_USER + 65 but gives error**
public const uint TB_GETBUTTONINF O = 0x043F;

public const uint TB_BUTTONCOUNT = WM_USER + 24;

public const int TBIF_IMAGE = 0x0001;
public const int TBIF_TEXT = 0x0002;
public const int TBIF_STATE = 0x0004;
public const int TBIF_STYLE = 0x0008;
public const int TBIF_LPARAM = 0x0010;
public const int TBIF_COMMAND = 0x0020;
public const int TBIF_SIZE = 0x0040;
public const uint TBIF_BYINDEX = 0x0000;

[StructLayout(La youtKind.Sequen tial)]
public struct TBBUTTONINFO
{
public uint cbSize;
public uint dwMask;
public int idCommand;
public int iImage;
public byte fsState;
public byte fsStyle;
public short cx;
public IntPtr lParam;
[MarshalAs(Unman agedType.LPTStr )]
public string lpszText;
public int cchText;
}

[DllImport("user 32.dll", CharSet =
CharSet.Auto, SetLastError = false)]
public static extern IntPtr SendMessage(
HandleRef hWnd,
uint Msg,
IntPtr wParam,
IntPtr lParam);

[DllImport("user 32.dll", SetLastError = true)]
public static extern IntPtr SendMessage(
HandleRef hWnd,
uint Msg,
IntPtr wParam,
ref TBBUTTONINFO lParam);
}
}
Jul 26 '07 #1
0 3284

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

Similar topics

2
2510
by: Grady | last post by:
Help. I need to create a simple database that tracks equipment arrivals (and departures) at my facility. What I want is to create a simple form, which the receptionist could fill out, every time someone delivers something at the front door. The form would simply have a place to put the time/date, delivery method, addressee, and a brief description. Once the receptionist filled it out and hit enter it would create a new record and then...
6
3866
by: Jon | last post by:
Hello, I have a datagrid and the data in it is dynamically created at runtime... For iCounter = 0 To dataset.Tables(0).Columns.Count - 1 Dim objbc As New BoundColumn() With objbc .DataField = dsAllPastReplies.Tables(0).Columns(iCounter).ColumnName .HeaderText = dsAllPastReplies.Tables(0).Columns(iCounter).ColumnName If .DataField = dsAllPastReplies.Tables(0).Columns("ReplyID").ColumnName Then
1
1671
by: Hai Ly Hoang [MT00KSTN] | last post by:
Different between Notification & Message is a bit hazy for me. Anyone can explain in detail for me ? Thanks in advance !
0
1453
by: Eric | last post by:
Hi, For my program I use the notification control to show the user at least an icon or if (s)he decides to, a balloon as wel with some info. In the balloon I have two linkbuttons en the problem comes when the user taps on one of them. One linkbutton is to show a form, the other is to stop the program. After tapping on STOP the notification should go away and a messagebox appears with the question if the user really wants to stop.
5
20019
by: Alex Maghen | last post by:
In ASPX 2.0 with MasterPages and all that, my entire page only has one actual <FORM>. But there are several different sections of the page that provide what are functionally separate forms with separate Submit buttons. In basic HTML, I can have multiple forms on a page and the browser knows that if any of the fields for Form A have the focus, then pressing ENTER will send a Click to the submit button for Form A. Same for Form B, etc. ...
1
1890
by: MikeY | last post by:
Hi Everyone, I'm having a problem trying to place text with in my custom buttons. The problem is that I'm trying to display my text just as if it were a regular 'win' button, I have tried using Rectangle (which is good) & also by inputting regular attributes. The thing is that, it is unknown how many words will be displayed & breaks between the words, if there are any.at runtime. I have tried developing the syntax to account for all...
16
2883
by: browntown | last post by:
so I have this application I'm nearly finished with. The only thing the client has requested is the ability to submit the form by pressing "enter". I didn't think this would be a huge pain in the ass and the app will be used internally so I'm not too worried about users who aren't using javascript. I'm using the following javascript to detect whether or not they've hit enter: if(document.layers) {
1
2646
by: ansc1 | last post by:
Hello, I'm new to using php coding. I need help with the following: 1. There is a submit button on the form and is saves information to my database. After clicking on "Save Measurement" it redirects me to another page in my site. What I would like to do is change what page directs it to. Currently the submit button redirects me to page /measure/men_measure. I would like to be able to change this. Please see below my page below:...
2
2923
beacon
by: beacon | last post by:
Hi everybody, I've searched and searched for the answers to these questions until I've turned blue in the face, so I finally decided to come here for some assistance. Here's the info I'm working with: MS Access 2003 Call log database using data access pages One table called tblCRS_Data_Log Primary key is CallNo An assortment of other fields, including check, text, and combo boxes
0
10614
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10369
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9186
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6876
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4327
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
2
3847
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.