Common Controls 6 and buddy windows

I suspect I have been committing a heinous crime.   It's a bit of a story, 
but it may give someone a laugh.  :-(

I have been using a CStatic as a buddy window of a spin button, with a 
slight "enhancement" which was fine hitherto, but does not work in common 
controls 6.   The standard way Microsoft designed it is

The spin button sends a WM_GETTEXT to the static buddy window, extracts the 
number from the text, increments/decrements it, puts it in a string and 
sends WM_SETTEXT to the static which displays it.

This is fine if you want to display  n=1,2,3,4,5,6...

But I want to display some function f(n) for n=1,2,3,4,5,6...

The "imaginative method"  I have been using is to derive a class 
CStaticBuddy from CStatic and handle the WM_GETTEXT and WM_SETTEXT myself

The CStaticBuddy::OnSetText handler gets n from the string being sent, 
computes f(n), writes it to a string and then uses

DefWindowProc( WM_SETTEXT,.....);

to set the revised text in the window (without sending another WM_SETTEXT - 
which would loop indefinitely).  This text is then displayed.

The CStaticBuddy::OnGetText() handler has to do the reverse and return n, 
not f(n), in a string..

I now realise that this only ever worked because the code which draws a 
CStatic does NOT use a WM_GETTEXT to find the text to draw - it may have 
called DefWindowProc( WM_GETTEXT...).   That is why it draws f(n).   In 
common controls 6, it appears things have changed - it is drawing n, 
probably because it is sending WM_GETTEXT and my CStaticBuddy override is 
handling it and returning n.

In the absence of an "owner draw static control" it looks like I'll have to 
use an owner draw button.  But I have used this trick in numerous places, 
and an easier solution would be welcome if there's an obvious one I haven't 
thought of.   Any ideas?

Dave [Hoist by his own petard.]
-- 
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm









0
dave1 (356)
4/11/2007 3:41:45 PM
vc.mfc 33608 articles. 0 followers. Follow

2 Replies
560 Views

Similar Articles

[PageSpeed] 13

Hi.

Just an idea - create your own CSpinButtonCtrl-derived class and create a 
handlers for the up/down button clicks. In these handlers you could get the 
f(n) from CStatic buddy, compute n, increment/decrement, compute a new f(n) a 
set the value back to the CStatic as before. No need to handle the WM_GETTEXT 
or WM_SETTEXT message in CStaticBuddy...

Furas

"David Webber" wrote:

> I suspect I have been committing a heinous crime.   It's a bit of a story, 
> but it may give someone a laugh.  :-(
> 
> I have been using a CStatic as a buddy window of a spin button, with a 
> slight "enhancement" which was fine hitherto, but does not work in common 
> controls 6.   The standard way Microsoft designed it is
> 
> The spin button sends a WM_GETTEXT to the static buddy window, extracts the 
> number from the text, increments/decrements it, puts it in a string and 
> sends WM_SETTEXT to the static which displays it.
> 
> This is fine if you want to display  n=1,2,3,4,5,6...
> 
> But I want to display some function f(n) for n=1,2,3,4,5,6...
> 
> The "imaginative method"  I have been using is to derive a class 
> CStaticBuddy from CStatic and handle the WM_GETTEXT and WM_SETTEXT myself
> 
> The CStaticBuddy::OnSetText handler gets n from the string being sent, 
> computes f(n), writes it to a string and then uses
> 
> DefWindowProc( WM_SETTEXT,.....);
> 
> to set the revised text in the window (without sending another WM_SETTEXT - 
> which would loop indefinitely).  This text is then displayed.
> 
> The CStaticBuddy::OnGetText() handler has to do the reverse and return n, 
> not f(n), in a string..
> 
> I now realise that this only ever worked because the code which draws a 
> CStatic does NOT use a WM_GETTEXT to find the text to draw - it may have 
> called DefWindowProc( WM_GETTEXT...).   That is why it draws f(n).   In 
> common controls 6, it appears things have changed - it is drawing n, 
> probably because it is sending WM_GETTEXT and my CStaticBuddy override is 
> handling it and returning n.
> 
> In the absence of an "owner draw static control" it looks like I'll have to 
> use an owner draw button.  But I have used this trick in numerous places, 
> and an easier solution would be welcome if there's an obvious one I haven't 
> thought of.   Any ideas?
> 
> Dave [Hoist by his own petard.]
> -- 
> David Webber
> Author MOZART the music processor for Windows -
> http://www.mozart.co.uk
> For discussion/support see
> http://www.mozart.co.uk/mzusers/mailinglist.htm
> 
> 
> 
> 
> 
> 
> 
> 
> 
> 
0
Furas (7)
4/12/2007 2:12:01 PM
"Furas" <Furas@discussions.microsoft.com> wrote in message 
news:00FCC6DE-B039-4097-BF33-59DFEB030DBD@microsoft.com...

> Just an idea - create your own CSpinButtonCtrl-derived class and create a
> handlers for the up/down button clicks. In these handlers you could get 
> the
> f(n) from CStatic buddy, compute n, increment/decrement, compute a new 
> f(n) a
> set the value back to the CStatic as before. No need to handle the 
> WM_GETTEXT
> or WM_SETTEXT message in CStaticBuddy...

Nice idea - thanks.  In fact I used to do it something like that many years 
ago.  However I could only make the up/down arrow keys work properly by 
doing in a way closer to what Microsoft intended.

So I am going through replacing them all by owner draw buttons which store 
the text of the spin position directly, and compute the mapping in their 
DrawItem() member.   That works fine, but it is keeping me busy: I had 
forgotten in how many places I had used this class!.

Dave
-- 
David Webber
Author MOZART the music processor for Windows -
http://www.mozart.co.uk
For discussion/support see
http://www.mozart.co.uk/mzusers/mailinglist.htm




0
dave1 (356)
4/12/2007 3:19:52 PM
Reply:

Similar Artilces:

How to change the language of common dialog box?
When I show a common dialog box, such as Open/Save file dialog and choose color dialog, how can I change the language displayed in these dialog boxes? Thanks! You'll have to either run on the OS that has the language you want or install the version of MFC that has the language you need. This article might help you: http://msdn2.microsoft.com/en-us/library/ms235264.aspx Tom "Hooyoo" <zhao_huyong@126.com> wrote in message news:1159508128.489403.150360@h48g2000cwc.googlegroups.com... > When I show a common dialog box, such as Open/Save file dialog and > choose c...

Multipage, controls-collection and events (XL2003, VBA)
Dear Group, I have a Userform with a Multipage control, which is dynamically filled with textboxes and comboboxes using Controls.Add like this: Set aTextBox = aUserForm.aMultiPage.Pages(strCurrentRegister).Controls.Add("Forms.TextBox.1", "txt" & strText, True) Set aComboBox = aUserForm.aMultiPage.Pages(strCurrentRegister).Controls.Add("Forms.ComboBox.1", "txt" & strText, True) This is working fine, but what I miss is any way to assign eventhandlers. Is there any way to do this? If not, I could use existing controls, which...

SOP Window Error
I have updated my system to SP2 but getting an odd error with the SOP transaction entry window. If a user opens the window, but then closes it again without doing anything, an error is popping up saying "An error occurred execting update statements" I think it may be related to some security, but I don't where where as it only happens to some users. Has anyone seen this? Hits -- I found the problem running a trace. Tables SVC00660 and SVC00661 had no permissions at all, and I added them for Dyngroup. Hitesh Varsani wrote: > I have updated my system to SP2 but getting...

adding a ListCtrl into a splitter window pane
I have a splitter window and in pane 0,0 i would like to add a CListCtrl class. I wrote the code to do this, however, when I call the Create method for the ListCtrl the app crashes on the Create. I'm wondering about the pointer I am passing it to the parent window. Where should this pointer come from? I believe I passed it the poitner to the CSplitterWnd, but I wasn't sure that was correct. Thanks, Chris I am doing the create right after I add it to the CSplitterWnd. I add a View and this ListCtrl to the Splitter and then right after that call, I call the Create method ...

Capture Control Name Clicked
I am looking to sort a subform based on the column of data clicked. In the past, I have created a separate but nearly identical OnClick event for each label. In the interest of condensing code, since i have 25 columns, which may or maynot be shown depending on the SQL string built through code, and I don't want 25+ more Subs, all nearly identical... I would like to set the same function as the OnClick event of every label, and have the name of the label be passed to the function, from which I can get the column selected through a MID function. I can get this to work if I use Text B...

Windows in Taskbar Problem
Windows in Taskbar Problems O/S : WinXP-Home Edition (All SP's and SR's installed) Office Suite : MS OfficeXP (All SP's and Critical Patches installed) Problem : Task (window) switching from the taskbar. When opening several documents in Word 2002 OR several spreadsheets in Excel 2002 the active document window is displayed on the desktop and the inactive documents are minimized to the taskbar. To move from one document to another I seem to have three choices. The first choice is to use the "Window" menu and select the document I want to be the Active documen...

Tree Control (How To)
How does one control the activation or scroll bars in a tree control. When creating the control one can disable the scroll bars with TVS_NOSCROLL or TVS_NOHSCROLL. However what if one wanted to activate the scrollbars when the control gains focus. I have not been able to find a way to toggle the scrollbars. I have tried creating my own scrollbars which I can toggle on activation, however, I have not been able to have the scrollbar scroll the tree items. Can anyone provide some hints as to how this is done. Thanks ...

MDI with predefined windows size
Hi all, I have created a MDI application using the MFC doc/view architecture. The Views I am using are derived from CFormView. Each view is created as Dialog resource at design time, each having different size. My problem is when each view is opened during the runtime, the predefined size of the view is ignored by the application. All the views opened are displayed in cascade, all having the same size. How should I keep the size of each view as it was defined at design time (as from resource dialog)? Thank you, Chris //here is the way I am calling the view to open... if (0 == m_pMapDisp...

Using the Common Feed List in Excel
Is it possible to collect items from the Common Feed List (RSS feeds) generated by IE into Excel? I would like to screen a bunch of feeds from Craigslist and eBay and none of the readers I've tried seem to do it very well. TIA ed I have used the IE application with Excel to read 1000's of webpages. Depending on the Website it can be very simple, not so simple, or very complicated. Not all webpages are the same even though the make look similar. I don't know what you mean by "to do it very well". The code may not be simple. I would have to see the U...

Windows Installer Runs / Show Office as a "Hybrid"
I am having serveral issues. All started when I noticed my Start menu button was lagging for at least 30 sec before expanding, and/or whenever I click on an office program the Windows Installer would run, and then try to re install/config Office, but as a Hyrid program. I have uninstalled and reinstalled and nothing has been fixed, just made worse. I have associated my Excel file with the office program. I click on the file IE excel file, and as it opens the Config screen pops up. I cancel it. I get an error message that I should repair/restore the program. The file cont...

HOWTO localize common dialogs
hi all! I have a core application with no resources. I have a couple of DLLs containing the resources (one for each language i need to support). Now: 1. system is win2k and i develop with visual c++ 6.0 2. the application uses mfc as shared dll 3. the dlls containing the resources use mfc as shared dll too. 4. everything has been built using appwizard. i exactly display the correct GUI for the chosen language. but i'm trying to get the localized mfc resources in order to have the same language also for the common dialogs (es. FileOpen, the buttons of AfxMessageBox, etc). I applied su...

I cannot receive or send email with Windows Mail.
I checked and all my account information was gone. I tried multiple times to add the account information but I always get and error message, "An error occured while reading the new account information. No changes have been made." Help, please. Answered in your thread "All my account information disappeared". Please use only one thread per issue. --=20 Gary VanderMolen, Microsoft MVP (Mail) Microsoft MVP Program: http://mvp.support.microsoft.com "Rick Lathrop" <RickLathrop@discussions.microsoft.com> wrote in message = news:384D9BDA-3FD4-44...

Outlook Express 6 error
I get this message when trying to start Outlook Express 6: ---------------------------------------------------------- Outlook Express could not be started. It may not be installed correctly. Make sure that your disk is not full or that you are not out of memory. Contact Microsoft support for further assistance. (0x80084005, 126) ---------------------------------------------------------- It came with XP Home Edition and I don't know of any way I could reinstall it. I have 512 megs of memory. Please help if possible! MJ In article <031f01c34573$32a64960$a101280a@phx.gbl>, oldnav...

OnPaint in child window paints over parent?
As far as I know painting in child window in OnPaint using the DC obtained from CPaintDC dc(this); should be limited to the child window area. In my case it does not when the same code is compiled for PC, but does seem to work on a WindowsCE device. Specifically: Code for PC and WinCE is the same. Child window is created in an MFC extension dll. Handle to parent window is passed to dll from main executable and child window is created as follows: CTestWindow* p= new CTestWindow; int size=120; int w=size*2; if( p->CreateEx(0,_T("STATIC"), _T("TEST"), WS_BORDER|WS_CHI...

color of controls in DialogBar
hi, How the color of controls in a DialogBar and its bakground can be changed ? thanks Behzad >How the color of controls in a DialogBar and its bakground can be changed ? Generally, by handling the WM_CTLCOLOR* messages (WM_CTLCOLOR/OnCtlColor in MFC). Dave -- MVP VC++ FAQ: http://www.mvps.org/vcfaq ...

Controlling the attachments
Hi I running Outlook 2003 against an Exchange Server, and the message telling me that Outlook blocking attachments appear from time to time. Is there a way to control what attachment to pass by the filter? TIRislaa See http://www.slipstick.com/outlook/esecup/getexe.htm -- Sue Mosher, Outlook MVP Author of Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Tor Inge Rislaa" <tor.inge.nospam@rislaa.no> wrote in message news:%23dcvwVhqEHA.2856@TK2MSFTNGP10.phx.gbl... > Hi ...

Common Change
Hi, I have over a 200 files, where I need to just change my e-mail address within the file. Is there any thing that I can use/run to go automatically through the files individually, open them up, find & replace my e-mail address, then save the files again ? Hope someone can help. Thanks ...

Common Exchange Deployment on NAS?
Hi, What is the most common way to deploy a large exchange installation... is it common to use NAS? As I understand, Exchange stores all its data in a few very large .edb files... if so, does exchange transfer these large files back and forth over the network in a NAS? Thanks David NAS devices that make the volumes appear as local storage will work and are used with Exchange - NetApp filers being one of them. NetApp uses a software util called "SnapDrive" to make this possible. -- Bharat Suneja MCSE, MCT www.zenprise.com blog: www.suneja.com/blog ------------------------------...

excel 2000 on windows 98se
When I try to exit the program I get the message: This program has performed an illegal operation and must shot down Any one out there has a solution for this? thanks Shotgun? "Cesar Culqui" <cculqui@aol.com> wrote in message news:0a0a01c3775c$a3727630$a101280a@phx.gbl... : When I try to exit the program I get the message: : This program has performed an illegal operation and must : shot down : Any one out there has a solution for this? : : thanks One of the things that excel does when it's closing is to update your customized toolbar file. Maybe that file has gott...

Re: New Beta Release Of Windows Live -- Version 2011 (Build 15.4.3002.0810) 08-23-10
The problem of WLM’s “stepping on itself” when compacting and freeing up empty space seems to have been fixed as well. Nancy ...

Password problem #6
I am on the phone right now with MS, actually I am on hold with them. So far they have asked everything to me about who I am and what software I have, but have given me NO answer. They even asked for the PID for the software which they specifically say you must LOG IN to Money to get it. (Little Ironic) or should I say Moronic. So I ended up having to give the part number off the CD and she come back and tells me there are no items in here database referring to my part number. You would think they would just look up Money 2004 instead of some random part number on my CD!!!!! Sti...

Can I use the Exchange 2000 admin tools on a Windows Server 2003 box?
Hi all, My network is has a Windows 2000 Server domain controller and we're are running Exchange 2000. I have one Windows Server 2003 server (it's not a domain controller). Can I install and run the Exchange 2000 management tools (Exchange System Manager) on this server? Thanks in advance for any assistance! On Wed, 25 May 2005 21:36:12 -0500, "Admin" <admin@mailinator.com> wrote: >Hi all, > >My network is has a Windows 2000 Server domain controller and we're are >running Exchange 2000. I have one Windows Server 2003 server (it's not a >domai...

Security Update for Windows XP (KB956572)
I have searched previous statements and many others have had the same issue. I've also tried to file a "free" support request but it keeps asking for $210 (because its in extended support???) and was wondering if anyone came up witha clear solution. I've tried completely removing antivirus and then isntalling and that did not resolve the issue. ajr wrote: > I have searched previous statements and many others have had the > same issue. I've also tried to file a "free" support request but it > keeps asking for $210 (because its in extend...

UpdatePanel and controls
Is it best to always have the web control completely encased in the UpdatePanel, or is it possible to just have it in part of the control? For example, I have a ListView control that I only need Ajax ability in the InsertTemplate. I tried it once before inside an EditTemplate but got strange results in the Update command. What are the pros and cons and if only inside part of a web control then what do I have to be aware of when inserting or editing? Thanks. -- David Using an update panel, you can register the events that the update panel should manage from a particular c...

Child Window Cannot Receive Messages
i have an application, that follows the View/Doc Architecture, i have a Frame Window, a View, and in addition, i define another child winodw of CButton , the problem is that the last child window doesnot receive any mouse messages/? The default OnBnClicked is never called. What is wrong?? I don't see a problem:- 1) Create an SDI doc/view app 2) subclassed CButton and created CMyButton and then added the reflect handler =BN_CLICKED. void CMyButton::OnBnClicked() { AfxMessageBox("test"); } 3) Add member variables in the view of the type CMyButton. CMyButton m...