Handling a mouse click in a child window
-
Hi everyone! This is my first foray into 'The Code Project'. I learned windows programming through MFC and I'm just now going back and trying to relearn it without MFC (so that presumably when I return to using it I will have a much higher appreciation.) Anyway, I have a simple problem and I would be grateful for help with it. I made the default MSVC 6.0 SDK 'Hello World' project. Then I put some controls on it using CreateWindow("EDIT"...) and "STATIC" and "BUTTON". Now I want a window that simply sends a message to the parent giving client x,y coordinates when it is clicked on. The way I used to do this was just to capture the clicks in the main window and do the calculations to see whether the click was in any of the child windows. I tried subclassing (I just learned what subclassing is) a "STATIC" window to handle the WM_LBUTTONDOWN, but it acts like it's not even there . I know the subclassing worked though because it handles WM_PAINT fine. Thank you!
-
Hi everyone! This is my first foray into 'The Code Project'. I learned windows programming through MFC and I'm just now going back and trying to relearn it without MFC (so that presumably when I return to using it I will have a much higher appreciation.) Anyway, I have a simple problem and I would be grateful for help with it. I made the default MSVC 6.0 SDK 'Hello World' project. Then I put some controls on it using CreateWindow("EDIT"...) and "STATIC" and "BUTTON". Now I want a window that simply sends a message to the parent giving client x,y coordinates when it is clicked on. The way I used to do this was just to capture the clicks in the main window and do the calculations to see whether the click was in any of the child windows. I tried subclassing (I just learned what subclassing is) a "STATIC" window to handle the WM_LBUTTONDOWN, but it acts like it's not even there . I know the subclassing worked though because it handles WM_PAINT fine. Thank you!
When you create the static control add the SS_NOTIFY style. This will make the control send the STN_CLICKED notification message when the window gets clicked on. -Ben --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)
-
When you create the static control add the SS_NOTIFY style. This will make the control send the STN_CLICKED notification message when the window gets clicked on. -Ben --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)
I saw that option while I was poking around (though it doesn't help that SS_NOTIFY isn't in the MSDN help index :mad: ) and I dismissed it after looking at the scant offerings of STN_* (I think they were 'click' 'dblclick' 'enable' and 'disable' or something) since I needed more information (like *where* they clicked and which button) which is why I decided to learn about subclassing. Anyway, I tried the SS_NOTIFY style just for the hell of it, and lo and behold all of the subclassing stuff I was trying to do started working! I guess the subclassing doesn't work unless you have SS_NOTIFY on, though I can't find that in the help anywhere. Thank you, Benner! :cool: