C Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesC Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old May 25th, 2003, 10:27 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 94
win32 windows with buttons

I have a button class that creates a child window like this...
hButtonWnd = CreateWindow
(
TEXT("button"),
mCaption,
WS_CHILD|BS_DEFPUSHBUTTON,...etc


i want to take an action when the button is clicked. im trying to figure out how this button recieves messages. it does not have a WndProc. when the user does click in the space where the button is, no message gets send to the parent window WndProc. or at least not the WM_BUTTONUP messages taht are usually sent when a mouse button is clicked. reason why i have this class that doesnt fully work is b/c my teacher started working on it and never finished it, so all i have is code to create and show it.

Reply With Quote
  #2  
Old May 26th, 2003, 03:54 AM
TechNoFear TechNoFear is offline
Offensive Member
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2002
Location: in the perfect world
Posts: 618 TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 13 h 50 m
Reputation Power: 26
>> it does not have a WndProc.

Yes it does. All windows with the WS_CHILD use the WNDPROC defined for the parents HWND.

>>no message gets send to the parent window WndProc

Did you cast the HMENU param as an int ID#?

#define IDC_BUTTON1 40001//defined so as to not conflict with the values in resource.h (ie no repeats)
ie (HMENU)IDC_BUTTON1

Then msg's will be routed through the WM_COMMAND of the parents wndproc.



Code:
//Look for the resource ID in the msg
idControl	= GET_WM_COMMAND_ID( wParam, lParam) ;
//switch ctrl ID#'s
case IDC_BUTTON1:
if (BN_CLICKED == HIWORD(wParam))//button was clicked


Else use

SetWindowLong() to retrieve the current wndproc and subclass it to one you specify.

origButtonWndProc = (WNDPROC) SetWindowLong( hButton, GWL_WNDPROC, (DWORD) NewButtonWndProc);
__________________
The essence of Christianity is told us in the Garden of Eden history. The fruit that was forbidden was on the Tree of Knowledge. The subtext is, All the suffering you have is because you wanted to find out what was going on. You could be in the Garden of Eden if you had just kept your f***ing mouth shut and hadn't asked any questions.

Frank Zappa

Reply With Quote
  #3  
Old May 26th, 2003, 02:27 PM
infamous41md's Avatar
infamous41md infamous41md is offline
not a fan of fascism (n00b)
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Feb 2003
Location: ct
Posts: 2,756 infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level)infamous41md User rank is Second Lieutenant (5000 - 10000 Reputation Level) 
Time spent in forums: 2 Days 11 h 4 m 29 sec
Reputation Power: 94
hey thanks man that made my life a lot easier. that's cool how easy it is to do that, i was thinking i was going to have to write a whole other wndproc.

edit: do you know how i could have it so that when a user right clicks on a name in my listbox i can have a small menu pop up like windows does? i understand how to realize the right click, and how to get the idx of the name selected, but how do get the menu there? is that a window class ?
also, i have an edit box class that is a child window as well. when the user types text into it, i want them to be able to push enter and have that send the text. when the edit box gets focus it sends a ID_ED_SEND_MSG message to my wndProc which i can handle in WM_COMMAND. but how can i obtain the action that the user took on that edit box? like if it is just a mouse click or if it is the enter which is what im looking for. i tried looking at the various wParam, lParam fields but none worked.

Last edited by infamous41md : May 26th, 2003 at 03:07 PM.

Reply With Quote
  #4  
Old May 26th, 2003, 09:25 PM
TechNoFear TechNoFear is offline
Offensive Member
Dev Shed Novice (500 - 999 posts)
 
Join Date: Oct 2002
Location: in the perfect world
Posts: 618 TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level)TechNoFear User rank is Sergeant (500 - 2000 Reputation Level) 
Time spent in forums: 3 Days 13 h 50 m
Reputation Power: 26
>>when a user right clicks on a name in my listbox i can have a small menu pop up like windows does?

the LV sends WM_NOTIFY msg's. Look for NM_RCLICK in the code member of the NM_LISTVIEW struct.

Code:
case	WM_NOTIFY:
switch(wParam)
{
	case IDC_LISTVIEW:
	LView = (NM_LISTVIEW FAR *) lParam; 
	switch (LView->hdr.code) 
	{
		case NM_RCLICK:



or look for the WM_PARENTNOTIFY in the owners (parents) callback, depending on how you set up the Listview

Code:
case	WM_PARENTNOTIFY:
if(WM_RBUTTONDOWN == (WPARAM)wParam)
{
	GetCursorPos(&point);//find mouse pos to display menu
	hPopup=LoadMenu( hInst, MAKEINTRESOURCE( IDR_POPUPMENU1) );//load your menu
hTrackPopup = GetSubMenu( hPopup, 0 );//has to be a pop-up of the menu
iReturn = TrackPopupMenu( hTrackPopup, TPM_LEFTALIGN |TPM_RETURNCMD ,point.x ,point.y, 0, hWndParent ,0 );//find out the menu item clicked
//process


the menu has to be a pop-up. That is the items go down the menu (not across) with no header (top item you click to get the pop-up)


>> i want them to be able to push enter and have that send the text.

I would sub class the edit's WNDPROC and switch the WM_CHAR msg's.

Look for the WM_KEYDOWN, switch them looking for the VK_RETURN.

Make sure you have the ES_WANTRETURN | ES_MULTILINE style on the edit.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesC Programming > win32 windows with buttons

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap