From: Jimbo on 6 May 2010 02:21 Hello I have something to do that is a little complex to explain but I'll try to explain it as clearly as possible. But I REALLY need some help with this, I have been trying to find a solution for ages. Explanation: I have a Win32 control that I have made that right now is similar to a list box(its a white rectangle ,with cells & text inside the cells). When the 'list box' is created I do the normal thing of creating a class object 'listBoxObject'(called 'LBO') & hook/link it to the window. When I right click the control a new window opens which is called the 'property dialog' & this has its own WNDPROC. This dialog is very simple, it allows the user to change the background colour of the 'list box'. There is a button on the 'property dialog' called "Change Bk Colour". When this button is clicked a standard colour dialog appears & the user selects a new background colour for the 'list box'. So now my 'property dialog' knows the new background colour(COLORREF variable) the user wants for the 'list box' background. But my 'list box' WNDPROC doesn't know what this color is yet. And my 'list box's linked object 'LBO' doesnt know this new COLORREF value? How can I pass this COLORREF variable from the 'property dialog' to the 'list box' window, so I can then set the 'LBO's member variable bkColour to this COLORREF variable (change the background colour)? Possible solution?: - From the 'Property Dialog' can I get obtain the handle to the 'listbox' window - Suppose I have created a constant called #define LB_CHANGEBKCOL 11 & I store the new background colour in thios variable COLORREF newBKCol; - Then I send a message to the 'listbox' window SendMessage(listboxHWND,WM_COMMAND,(WPARAM)LB_CHANGEBKCOL, (LPARAM)newBKCol); - From the 'list box' WNDPROC, when I receive a WM_COMMAND & the wParam equals LB_CHANGEBKCOL I change the objects background colour by doing this: LBO->bkColour = lParam; InvalidateRect(hwnd,NULL,true); UpdateWindow(hwnd); Is this how I can achieve what I want to do? If not, can you suggest how I can do this. If you think my solution will work, how do I get a handle to the 'list box' window? Can I send a COLORREF variable as a LPARAM parameter? Any advice & code examples would be extremely helpful.
From: Leslie Milburn on 6 May 2010 03:30 "Jimbo" <nilly16(a)yahoo.com> wrote in message news:d14b2dc0-8c65-4f81-a415-476af379b10d(a)h9g2000yqm.googlegroups.com... > Hello > Explanation: > I have a Win32 control that I have made that right now is similar to a > list box(its a white rectangle ,with cells & text inside the cells). > When the 'list box' is created I do the normal thing of creating a > class object 'listBoxObject'(called 'LBO') & hook/link it to the > window. When I right click the control a new window opens which is > called the 'property dialog' & this has its own WNDPROC. This description is a little confusing, so to clarify a little ...... When you say "hook/link" do you mean you subclass/superclass the listbox control window or are you running as a seperate program and hooking into another ? If you are subclassing there is a WNDPROC for the listbox control. If so then you already have the Window handle of the listbox. If you are doing something else, then how are you detecting the right click ? At the point of right click detection the Window Handle of the listbox would also be available to you.
From: Alf P. Steinbach on 6 May 2010 03:57 * Jimbo: > Hello > > I have something to do that is a little complex to explain but I'll > try to explain it as clearly as possible. But I REALLY need some help > with this, I have been trying to find a solution for ages. > > Explanation: > I have a Win32 control that I have made that right now is similar to a > list box(its a white rectangle ,with cells& text inside the cells). > When the 'list box' is created I do the normal thing of creating a > class object 'listBoxObject'(called 'LBO')& hook/link it to the > window. When I right click the control a new window opens which is > called the 'property dialog'& this has its own WNDPROC. The details of setting the background color will depend on your listbox object. But you can do it via the API level. > This dialog is very simple, it allows the user to change the > background colour of the 'list box'. There is a button on the > 'property dialog' called "Change Bk Colour". When this button is > clicked a standard colour dialog appears& the user selects a new > background colour for the 'list box'. > > So now my 'property dialog' knows the new background colour(COLORREF > variable) the user wants for the 'list box' background. But my 'list > box' WNDPROC doesn't know what this color is yet. And my 'list box's > linked object 'LBO' doesnt know this new COLORREF value? > > How can I pass this COLORREF variable from the 'property dialog' to > the 'list box' window, so I can then set the 'LBO's member variable > bkColour to this COLORREF variable (change the background colour)? The straightforward solution is to pass a pointer to the dialog when you create it. Some frameworks have various support for exchange data with a dialog. E.g. MFC has some ugly macros. > Possible solution?: > - From the 'Property Dialog' can I get obtain the handle to the > 'listbox' window You can but that's the wrong way to go about it. Pass the information that X needs, to X. Cheers & hth., - Alf
From: ScottMcP [MVP] on 6 May 2010 10:09 The property dialog can call GetParent to get the window handle of its parent. Controls do this and then use SendMessage to notify their parent of events.
From: r_z_aret on 6 May 2010 16:14 On Wed, 5 May 2010 23:21:37 -0700 (PDT), Jimbo <nilly16(a)yahoo.com> wrote: >Hello > >I have something to do that is a little complex to explain but I'll >try to explain it as clearly as possible. But I REALLY need some help >with this, I have been trying to find a solution for ages. > >Explanation: >I have a Win32 control that I have made that right now is similar to a >list box(its a white rectangle ,with cells & text inside the cells). >When the 'list box' is created I do the normal thing of creating a >class object 'listBoxObject'(called 'LBO') & hook/link it to the >window. When I right click the control a new window opens which is >called the 'property dialog' & this has its own WNDPROC. > >This dialog is very simple, it allows the user to change the >background colour of the 'list box'. There is a button on the >'property dialog' called "Change Bk Colour". When this button is >clicked a standard colour dialog appears & the user selects a new >background colour for the 'list box'. > >So now my 'property dialog' knows the new background colour(COLORREF >variable) the user wants for the 'list box' background. But my 'list >box' WNDPROC doesn't know what this color is yet. And my 'list box's >linked object 'LBO' doesnt know this new COLORREF value? > >How can I pass this COLORREF variable from the 'property dialog' to >the 'list box' window, so I can then set the 'LBO's member variable >bkColour to this COLORREF variable (change the background colour)? > >Possible solution?: >- From the 'Property Dialog' can I get obtain the handle to the >'listbox' window You can use FindWindow to get the HWND for the "list box". This works especially well when the window being sought has a unique window class name (see the RegisterClass function) that can be used in the second argument for FindWindow. >- Suppose I have created a constant called #define LB_CHANGEBKCOL 11 & >I store the new background colour in thios variable COLORREF >newBKCol; >- Then I send a message to the 'listbox' window >SendMessage(listboxHWND,WM_COMMAND,(WPARAM)LB_CHANGEBKCOL, >(LPARAM)newBKCol); >- From the 'list box' WNDPROC, when I receive a WM_COMMAND & the >wParam equals LB_CHANGEBKCOL I change the objects background colour by >doing this: If you are going to use a message from the properties dialog to the list box, I suggest using a private message that passes the COLORREF and triggers the action. For example: SendMessage( listboxHWND, WM_PLEASECHANGEBACKGROUNDCOLOR, (WPARAM)newBKCol, 0 ); Note that if you use SendMessage, the property dialog will hang until the list box finishes processing the message. You can avoid this problem by using PostMessage, but then need to worry about scoping (objects being passed must exist when they are used, not passed) and possible timing issues. > >LBO->bkColour = lParam; Variation on something posted earlier: If you have a pointer to an object for the list box, I think you should make it available in the WndProc for the properties class. Then you can define a method/function that takes the COLORREF as an argument and does the appropriate work, and the WndProc can call the method/function directly. ----------------------------------------- To reply to me, remove the underscores (_) from my email address (and please indicate which newsgroup and message). Robert E. Zaret, MVP PenFact, Inc. 20 Park Plaza, Suite 400 Boston, MA 02116 www.penfact.com Useful reading (be sure to read its disclaimer first): http://catb.org/~esr/faqs/smart-questions.html
|
Pages: 1 Prev: Application disappears without any crash dump Next: Any way to validate data of a wmf file? |