Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

huahsin68

how to use SendMessage

This topic is 5110 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Advertisement
Hi Iliak!! Nice to meet you...

Hmm~ Actually I been there before.. I couldn''t find out what I should pass into SendMessage().. Hmm~ Can I do in this way?

SendMessage(WM_NOTIFY, NM_CUSTOMDRAW);

That means I want to send a WM_NOTIFY message to hits the NM_CUSTOMDRAW message. Hmm~ In other words, the NM_CUSTOMDRAW message is send by WM_NOTIFY message.. This is what I get from the MSDN.. Please correct me if I am wrong..

THank YOu @!

Share this post


Link to post
Share on other sites
SendMessage is used to send messages to a window or controls message pump.

Say you were writing a Macro Creator, you''d need to use SendMessage to post your macro''s commands to the window / control you want to interact with.

The parameters are clearly shown on the MSDN. You need a window''s handle (HWND), your message, than your message parameters.

For example, to send a key to your own window, you''d do:
SendMessage(hWnd, WM_CHAR, ''A'', 0);

Assuming hWnd is the handle to your own window.

You can find window''s handles using FindWindow().

Share this post


Link to post
Share on other sites
He''s using MFC. I told him on a different forum that he should create, fill, and pass an NMHDR structure for the 3rd parameter.


Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud

Share this post


Link to post
Share on other sites
Yeah !! I got it.. I do pass NMHDR structure as 3rd parameter.. like this:

NMHDR pNMHDR;
m_list.SendMessage(WM_NOTIFY, NM_CUSTOMDRAW, (LPARAM)&pNMHDR);

But this is not work because it is NULL... Am I right? I must fill in the member of pNMHDR... The members are:

hwndFrom
idFrom
code

First thanks to GroZZleR.. Nice to meet you.. Thanks for introduce FindWindow() to me.. Now I know how to fill in hwndFrom, I do it in this way:

pNMHDR.hwndFrom = ::FindWindow(NULL, "customDraw");

Am I do the right way?
Now there is 2 more left which is idFrom and code.. I dont know what stuff to put it in?

According to MSDN, idFrom is "Identifier of the control sending a message." Then I do put in IDC_LIST1 like this:

pNMHDR.idFrom = IDC_LIST1;

and now still left notification code member.. I don know what is this? But I guess is like this:

pNMHDR.code = NM_CUSTOMDRAW;

Then I compile with no error... greating... but it didn send the message... how I know it didn send the messsage?... I do TRACE() in that function if the function is being call..

So I don know whether I am right or not.. Please correct me...

THank YOu @!

[edited by - huahsin68 on May 26, 2004 6:46:23 AM]

Share this post


Link to post
Share on other sites
Now I have a question here, since I am posting NM_CUSTOMDRAW, so I have to repaint it... Am I right?

So the whole will be like this:

NMHDR pNMHDR;
pNMHDR.hwndFrom = ::FindWindow(NULL, "customDraw");
pNMHDR.idFrom = IDC_LIST1;
pNMHDR.code = NM_CUSTOMDRAW;

m_list.SendMessage(WM_NOTIFY, NM_CUSTOMDRAW, (LPARAM)&pNMHDR);
m_list.Invalidate();

Am I doing the right way? Please correct me if I am wrong...

THank YOu @!

[edited by - huahsin68 on May 27, 2004 5:02:04 AM]

Share this post


Link to post
Share on other sites
Sending this message will cause the OnNotify() function of you CListView to be called.

However, you do not want to send NM_CUSTOMDRAW to your CListView - CListView sends this message to its parent window.

What are you trying to do?


Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud

Share this post


Link to post
Share on other sites
Huh? CListView.. I am using CListCtrl?
Basically I want to send NM_CUSTOMDRAW message to CListCtrl for redraw purpose... do you have any opinion? Am I doing the right way?

THank YOu @!

Share this post


Link to post
Share on other sites
I thought you were using a CListCtrl. If not, no matter. If you are trying to draw the window then you only need to call m_list.Invalidate(). Sending NM_CUSTOMDRAW will do nothing.


Thanks Salsa!Colin Jeanne | Invader''s Realm
"I forgot I had the Scroll Lock key until a few weeks ago when some asshole program used it. It even used it right" - Conner McCloud

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!