Witam. Mam pytanie, jak powinna działać funkacja getMenu() ?
Jako parametr przysyłam jej uchwyt okna i zwraca 0. Jeżeli jako parametr podam jej uchwyt menu zdobyty troche w inny sposób, zwraca poprawną wartość, czyli defakto tą samą co w argumencie. Czyli takie działanie jest bezsensu. Podobnie jest z funkcją getSubMenu() - jeżeli wstawiam jej jako argument uchwyt do menu pobraną w inny sposób i tak zwraca mi zero. PRzesyłam kod. Czy ktoś wie co robie nie tak ?
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
IntPtr uchwytOkna;
IntPtr uchwytMenu;
IntPtr uchwytSubMenu;
[DllImport("user32.dll", SetLastError = true)]
private static extern IntPtr FindWindowEx(IntPtr parent, IntPtr previousChild, string className, string title);
[DllImport("user32.dll", SetLastError = true)]
private static extern int FindWindow(string nazwaKlasy, string nazwaOkna);
[DllImport("user32.dll", CharSet = CharSet.Auto)]
private static extern IntPtr SendMessage(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
[DllImport("user32.dll")]
private static extern IntPtr GetMenu(IntPtr uchwyt);
[DllImport("user32.dll")]
private static extern IntPtr GetSubMenu(IntPtr uchwyt, int cos);
private void button1_Click(object sender, EventArgs e)
{
uchwytOkna = (IntPtr)FindWindow(null, textBox1.Text);
textBox2.Text = uchwytOkna.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
IntPtr uchwutMenu = GetMenu(uchwytOkna);
textBox3.Text = uchwytMenu.ToString();
}
}
}