473,770 Members | 1,996 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

C# SendMessage(... ) question

Hi,

I am trying to write code to retrieve the small icon for an
application in C#. I am using SendMessage with WM_GETICON for this
purpose but the return value I get is 0. I don't understand this. Is
that expected? What am I doing wrong?
Any help would be appreciated. Here is the snippet of code that I am
using -

[DllImport("user 32")] public static extern int SendMessage(int
hwnd,int msg,int wparam,int lparam);

Process p = Process.GetProc essById(a.getPI D()); //the requisite process and
//the value returned is valid
IntPtr hwnd = p.MainWindowHan dle;
int icn = SendMessage((in t)hwnd,127,0,0) ; //I realize WM_GETICON = 127

Thanks!
Nidhi
Jul 21 '05 #1
1 15652
Just try this :

int WM_GETICON = 0x7F;
int WM_SETICON = 0x80;
int ICON_SMALL = 0; //(16x16)
int ICON_BIG = 1; //(32x32)

IntPtr handle = pro.MainWindowH andle;
int IconHandle = SendMessage(han dle.ToInt32(),W M_GETICON,ICON_ SMALL -or- ICON_BIG,0);
Icon icn = Icon.FromHandle (new IntPtr(IconHand le));

Note : I can't retrieve the most icon's handle.

- Good Kiss from Switzerland -

--
Message posted via http://www.dotnetmonster.com
Jul 21 '05 #2

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

Similar topics

2
2863
by: Newsgroup | last post by:
I have a multiline textbox with 10 lines of text in it. I want to search Line by Line for the word" ". How do I process one line in a text box at a time? I DON'T want to just search the whole textbox for my word, because when I find it, I want to stop the cursor there until the user decides to continue to find the next instance. MY QUESTION IS: How can I search for text line by line in a textbox? Thank You, Paul
0
1198
by: Nidhi | last post by:
Hi, I am trying to write code to retrieve the small icon for an application in C#. I am using SendMessage with WM_GETICON for this purpose but the return value I get is 0. I don't understand this. Is that expected? What am I doing wrong? Any help would be appreciated. Here is the snippet of code that I am using - public static extern int SendMessage(int
18
6567
by: Lars Netzel | last post by:
Hello! Thanx to this newgroup I have finally, with the help of you guys, gotten this to work halfway.. but the final action is still not working, clicking the "Button2" thru SendMessage(). Private Declare Auto Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer Private Declare Auto Function FindWindowEx Lib "user32" (ByVal hWnd1 As
25
2515
by: MuZZy | last post by:
Hi, I'm currently rewriting some functionality which was using multithredaing for retrieving datasets from database and updating a grid control. I found that the grids (Infragistics UltraGrid, though it doesn't matter) were updated (i.e. grid.DataSource = dsDataSet;) and used for different purposes in the worker thread, so now i'm wrapping all those calls to grid's methods thru invoking which is a pain in the a$$ considering number of...
2
1482
by: Abubakar | last post by:
Hi, in my application, different threads send notifications to GUI thread through sendmessage api. They have special integer numbers inside the wParam arg of sendmessage which the gui thread uses to display messages in the textboxes etc. My question is that in case the threads send messages very fast (which does NOT always happen in my app), faster than the gui thread is processing them, are the messages qued automatically (btw the gui...
6
5403
by: Jack | last post by:
I want to write code that can be compiled as C and C++. In the Windows API, there are many macros that help with scope resolution. For example: #ifdef __cplusplus #define SNDMSG ::SendMessage #else #define SNDMSG SendMessage #endif
4
2136
by: Abubakar | last post by:
Hi, My application has a lot of threads which at some point call SendMessage api passing it the handle of the gui window. The calls r a lot. My question is that should I call the SendMessage api by protecting it in a critical section, or the SendMessage api itself handles this kind of situation where a lot of threads in the same process r calling it. Regards,
2
4267
by: Dave King | last post by:
Hi All- I'm trying to customize this project ( http://www.codeproject.com/shell/IEMenuButton.asp ) and I'm getting an access voilation and was hoping somebody would be able to give me some idea Here's the method I'm trying to work with STDMETHODIMP CMasterObject::Exec(const GUID*, DWORD nCmdID, DWORD, VARIANTARG*, VARIANTARG*)
11
48069
by: NVergunst | last post by:
Hello everyone. I have what I believe to be a simple question, yet I can not find anything that is helpful to me. Basically I have an application, that I want to use to control external applications. My program will run either embedded within another program or minimized to the system tray. So SendKeys is out because it only works if the controlled application has focus, which it will not. So my conclusion is the windows API. I have...
0
9618
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9454
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10259
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...
1
10038
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
9906
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8933
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...
1
7456
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5482
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2849
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.