Solved

I am losing context help when I use m_cEdit.ModifyStyleEx( NULL, WS_TABSTOP);

Posted on 2004-09-13
6
536 Views
Last Modified: 2013-11-20
Hello.

I have an few edit box on the screen of an MFC dialog and property page. I have to sometimes dynamically make a few controls "readonly" due to business logic. Because of this read only state, it is also required that the control is dynamically remove from the tab sequence. But when I do this, I noticed that the context help is lose. ie when I press the dialog's help button then move the help cursor onto the control and click, no help message pops up.

the code for disable the control is as follows
m_cEdit.SetReadOnly(TRUE);
m_cEdit.ModifyStyleEx( NULL, WS_TABSTOP);

Note: I do not wish to make the control "disable", as the text goes grey, I only wish to make it "readonly"!!

So why is the help lost when I called
m_cEdit.ModifyStyleEx( NULL, WS_TABSTOP); ??

When I comment the above line out, and leave the m_cEdit.SetReadonly(TRUE) the context helps works fine! Also I have a few other controls on the page which I have non-dynamically set the TabStop to be false and SetReadonly to be true, but the context helps works fine on them. it is only when I do it dynamicall that the problem arise.

Another question while i am here, the documentation says ModifyStyle(DWord Remove, DWord Add) but I find that
m_cEdit.ModifyStyleEx( NULL, WS_TABSTOP); removes the tab stop and
m_cEdit.ModifyStyleEx( WS_TABSTOP, NULL); sets it. ??? shouldn't it be the other way around??

Any comments/explanation would be much appreciated.

0
Comment
Question by:santuon
6 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 12051721
m_cEdit.ModifyStyleEx( NULL, WS_TABSTOP); removes the tab stop and
m_cEdit.ModifyStyleEx( WS_TABSTOP, NULL); sets it. ??? shouldn't it be the other way around??

There are TWO functions ModifyStyle and ModifyStyleEx, one for the window styles the other for the extended window styles.  Try using ModifyStyle (no Ex) and see if that makes any difference.
0
 
LVL 15

Expert Comment

by:lakshman_ce
ID: 12053069

BOOL ModifyStyleEx(
   DWORD dwRemove,
   DWORD dwAdd,
   UINT nFlags = 0
);

BOOL ModifyStyle(
   DWORD dwRemove,
   DWORD dwAdd,
   UINT nFlags = 0
);

Styles specified in the first parameter should be removed and styles specified in the second parameter should be set.

As Andy suggested, use
ModifyStyle(WS_TABSTOP,0) to remove the edit box from the tab order list.
ModifyStyle(0,WS_TABSTOP) to add the edit box to the tab order list.
0
 
LVL 16

Expert Comment

by:nonubik
ID: 12053270
To add some more to above said:

Using ModifyStyleEx with WS_TABSTOP is in fact the same as calling ModifyStyleEx(WS_EX_CONTROLPARENT,..) (WS_TABSTOP and WS_EX_CONTROLPARENT have the same value, 0x1000).
WS_EX_CONTROLPARENT   Allows the user to navigate among the child windows of the window by using the TAB key.
So it looks like WS_TABSTOP... :)

And, from MSDN:
"WS_TABSTOP
You can turn this style on and off to change dialog box navigation. To change this style after a window has been created, use *SetWindowLong*."
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:santuon
ID: 12060397
Great feedback. I appreciate everyone's comment but since AndyAinscow was first to reply,  I accepted his answer, thought everyone's answer would have achieved the same results.

It seems that using
ModifyStyle(WS_TABSTOP,0) removes the Tab order unlike ModifyStyleEx(WS_TABSTOP, 0) which adds it. Not only that, but the ModifyStyle method also does lose context help. So using this fixed my original problem!!!

Great!


0
 
LVL 44

Expert Comment

by:AndyAinscow
ID: 12062573
Be careful (I get the feeling you don't appreciate the following).

ModifyStyle and ModifyStyleEx are TWO separate functions that perform different actions.  They are not interchangable.  The second is not an extension to the first.
0
 
LVL 16

Expert Comment

by:nonubik
ID: 12062587
And the funny thing that ModifyStyleEx(WS_TABSTOP, 0) means ModifyStyleEx(WS_EX_CONTROLPARENT, 0)  :o)
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
ORA-01403: no data found 43 82
Define unique primary key 9 81
countEvens challenge 2 58
canBalance challenge 34 65
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now