Greetings, I am relatively new to WPF and have an issue relating to validation with DataGrid control. I have read this article (http://msdn.microsoft.com/en-us/magazine/ff714593.aspx) which covers three different ways to validate, but none of them seem to address how to prevent setting a value or calling a undo/redo command before all validation is carried out. I want to ensure that only positive numbers can be entered into the cells. I have set a validation rule that checks if the cell contains a negative number, and I handle the DataGrid's CellEditEnding event to know when to actually change the number used in the model layer. The problem is that CellEditEnding is called before the validation rule. By the time the validation rule catches the problem, the number in the model has already been set. What I need is CellEditEnded, but it appears this event only exist in the Silvelight version of DataGrid. Any ideas? :confused: Thanks
greekgoddj
Posts
-
Validation 'before' setting value or issuing command -
Use of Narrator and other screen readersGreetings, I have the "joy" of trying to make my ActiveX controls act as Accessibility servers, so that they provide information about the value, role, and desrciption (how to be used) to potential screen readers. The "joy" comes from the lack of information on accessibility, and the bit that there is out there is not clear. I am hoping that somebody on this list has some experience with this area and can help me out with the following. I have a custom slider in the form of an ActiveX Control. Everytime the value of the slider changes, I want the new value to be read by the screen reader. At the moment I am call the following code everytime the slider value has changed. CComPtr pAccPropSrv; HRESULT hr; hr = pAccPropSrv.CoCreateInstance(CLSID_AccPropServices); if(hr == S_OK) { COleVariant varValue(m_sPositionText); COleVariant varRole((long)ROLE_SYSTEM_SLIDER, VT_I4); COleVariant varDescr("Some description"); pAccPropSrv->SetHwndProp(m_hWnd, OBJID_CLIENT, 0, PROPID_ACC_VALUE, varValue); pAccPropSrv->SetHwndProp(m_hWnd, OBJID_CLIENT, 0, PROPID_ACC_ROLE, varRole); pAccPropSrv->SetHwndProp(m_hWnd, OBJID_CLIENT, 0, PROPID_ACC_DESCRIPTION, varDescr); } This actually results in the screen reader reading the Role and Value, and not the Description. More importantly it only reads it the first time that the slider gets focus. No matter how many times I click on the slider and move it arround after that, the screen reader does not read the new value. If I then click on another control, and then back on the slider again, then it reads the value once more. I thought this was a problem with my ActiveX slider control but it is also how default controls such as radio buttons of Windows, work, they will onyl read out their value once until they regain focus again. However, the standard windows slider control, has the exception that it will read out the value everytime the slider changes due to the user pressing the arrow keys. In my ActiveX control slider, the same code as above is called whenever the slider position changes, regardless of whether it changed my the mouse or keys. I guess in summary, what I need help with is: 1) Why does the screen reader not read out my ActiveX control's description. 2) Why does the value of my ActiveX control only get read once until it regains focus. 3) How does the standard windows slider manage to read its new value when the value has changed due to the user pressing the arrow
-
MFC events, in ATL with MFC support controlsGreetings... I have been working on some ATL controls which have MFC support. I can view the property page of the ATL classes and see the events they can handle, which are a partial list of those available to pure MFC classes. However I need to handle the event WM_SETTINGCHANGE and that is not listed as a possible event. I can manually type it under:
BEGIN_MSG_MAP(CSomeClass) ... MESSAGE_HANDLER(WM_SETTINGCHANGE, OnSettingChange) ... END_MSG_MAP()
but this doesn't work..the debugger never stops in the OnSettingChange function. However, if I make a new purely MFC project, WM_SETTINGCHANGE is listed under the events tap of the classe's property page, and it all works just fine. The question I guess is, how can it be that ATL "with MFC support" has only some of the events? also what is the work arround, especially as in pure MFC the event handling function is in the form ofOnSettingChange(UINT uFlags, LPCTSTR lpszSection)
and in ATL control project with MFC support it is in the form of:OnSettingChange(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/)
Thanks, Aristotel :confused: -
virtual function override intended?Hello Larry...(sorry for the delay)... The code is part of a rather large commercial project..so i need to try and trim it down to the simplset level so that i can email you the relevant parts. Regards, Aristotel :)
-
virtual function override intended?Hi Larry, Unfortunately that didn't do it. Very strange...such a different arguement list yet it thinks its meant to be an over ride...hmmm... Do let me know if any other ideas come arround. I will keep looking as well. Thanks, Aristotel
-
virtual function override intended?Greetings, I am getting the following warnings. I have some classes whch overide the Create function, but with very different arguement lists. Somehow though the compiler thinks they might be meant to be the same.The arguement lists look very different to me, how can it be assuming they are smiliar? thanks in advance, Aristotel :-D
BOOL Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle /*=WS_VISIBLE*/, int nMinVal, int nMaxVal);
warning #1125: function "CWnd::Create(LPCTSTR={LPCSTR={const CHAR={char} *}}, LPCTSTR={LPCSTR={const CHAR={char} *}}, DWORD={unsigned long}, const RECT &, CWnd *, UINT={unsigned int}, CCreateContext *)" is hidden by "CLevelMeter::Create" -- virtual function override intended? BOOL Create(CWnd* pParentWnd, const RECT& rect, UINT nID, DWORD dwStyle /*=WS_VISIBLE*/, int nMinVal, int nMaxVal);BOOL Create(CWnd *pParentWnd, const RECT &rect, UINT nID, DWORD dwStyle);
warning #1125: function "CWnd::Create(LPCTSTR={LPCSTR={const CHAR={char} *}}, LPCTSTR={LPCSTR={const CHAR={char} *}}, DWORD={unsigned long}, const RECT &, CWnd *, UINT={unsigned int}, CCreateContext *)" is hidden by "CMultitapControl::Create" -- virtual function override intended? BOOL Create(CWnd *pParentWnd, const RECT &rect, UINT nID, DWORD dwStyle); Edit/Delete Message -
Bitmap of CBitmapButton not workingHi Ryan... I managed to track down CBitmapButton::DrawItem() and look at its code inside. So at least now I don't have to worry about taking care of the actual bitmap selection and drawing depending on the state. I did however notice that that function never gets called. Setting breakpoints shows that it never gets called. Thanks, Aristotel
-
Bitmap of CBitmapButton not workingHello, I am trying to use CBitmapButton with four bitmaps but it is not working. The button shows up, but not the bitmaps. When I set the control's style to BS_OWNERDRAW as it has been suggested then the bitmaps still don't show..but also what used to be the button now becomes a flat grey area on the screen. I have also tried BS_OWNERDRAWN without and without BS_PUSHBUTTON and no luck.
CWnd* parent = CWnd::FromHandle(this->m_hWnd); BOOL success = m_BitmapButton.Create(("Play Section"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON|BS_OWNERDRAW, CRect(10,10,44,44), parent, 1); success = m_BitmapButton.LoadBitmaps(IDB_PLAYSECTIONU, IDB_PLAYSECTIOND, IDB_PLAYSECTIONF, IDB_PLAYSECTIONX);
Another even more important question is, why does CBitmapbutton need to be ownerdrawn? isn't the whole idea that I give the control four bitmaps and it takes care of applying the appropriate one according to wether the mouse moves over it, presses it etc? Thanks Aristotel -
Stock Font in ATL ActiveX Control using VS.NETGot it! thanks :)
-
Stock Font Persist?Goodmorning! As the subject line suggests I am having a hard time with the persistance of my ATL ActiveX control's Font Stock Property and the selection being remembered once its made. I thought I was doing it all wrong but then to make sure I had the code right, I made a brand new project with a brande new control that had the Font stock property as a feature from the very beginning. I also told the wizard to add the background colour property for testing sake. So i compile it and then try to use it in another project....I insert it into the dialog and then right click to get the properties. I can select the background colour, and the setting remains. I click on the font property, the font window comes up with the collection of fonts..i make the selection...hit OK/apply but the font field in the properties shows up as empty...it does not actually remember the font I chose. Like I said, I thought i might be doing something wrong and therefore tried it out on a brand new control where the font property was added by Visual Studio's wizard. Is this a little "bug"? and if so...how does one exterminate/wack it. Thanks! Aristotel
-
Stock Font in ATL ActiveX Control using VS.NETSo it turnes out the only way to achive the above is to manualy create a new project where you state the stock properties from the vary begining, and then copy the code segments over to your existing project code.... tsk tsk tsk :wtf: And now the latest problem for the past 2 hours has been that I have added the font stock property and a member variable CComPtr m_pFont; which gets set at OnFontChanged(). Now in my OnDraw() function I would like to select this font and use it, however I cannot simply do pdc.SelectObject(m_pFont) as m_pFont is not a CFont. In the MFC only version of ActiveX I could call SelectStockFont(pDC); but this is no longer suitable in ATL ActiveX. I cannot figure out how to convert a font refered to by IFontDisp to a CFont so that I can select it for the drawing code. Could somebody point me in the right direction please? Thanks
-
Stock Font in ATL ActiveX Control using VS.NETHello... I have been trying to add a font stock property to my ATL ActiveX control in VS.NET. I go by the examples and documentation at MSDN but its not quite possible. They suggest to right click on the interface of my class under the class view, and select ADD->Properties.... Then apparrently there will be a drop down menu where I will be able to choose the type of stock property, in this case FONT. But no..there is no such drop down menu...only a text fields.. I tried to manually type in Font, but nothing... I tried to manually copy and paste the code shown in the example in the corresponding sections of the project but it won't even compile. How on earth does one add a FOnt stock property to an ATL ActiveX control in VS.NET? Thanks!
-
oleacc link issuesAnyone? :|
-
oleacc link issuesGreetings! I am trying to implement the Active Accessibility capabbilities to my ATL ActiveX control.I have added #include #include #include and the paths to where oleacc.lib AND oleacc.dll are present in the settings of VS 2003. However I am getting the following errors when I try to compile. Knob.obj : error LNK2001: unresolved external symbol _PROPID_ACC_ROLE Knob.obj : error LNK2001: unresolved external symbol _PROPID_ACC_VALUE Knob.obj : error LNK2001: unresolved external symbol _CLSID_AccPropServices Debug/Controls.dll : fatal error LNK1120: 3 unresolved externals Any ideas as to what is going wrong? :confused: Thanks in advance, Aristotel
-
Control's window not ready even in FinalConstruct()Yup....the solution is... LRESULT CKnob::OnShowWindow(UINT /*uMsg*/, WPARAM wParam, LPARAM /*lParam*/, BOOL& /*bHandled*/) Thats where the window is already created and ready. Needed to overide that and add my code inside there. Thanks! ;P
-
Focus issuesHello hello, So...I am working on a ActiveX control, where when the user clicks the mouse and lets go of the mouse with the cursor over a specific area in the control, a CEdit control is made visible at the position of the ActiveX control. The user can enter a number into the CEdit control, and then when clucking outside the CEdit control, that value entered gets stored in a variable and the CEdit control becomes invinsible. The problem comes when trying to click on that area of the ActiveX control again. the CEdit control will apear but can no longer enter any values. I cannot get that vertical line in the CEdit box that allows me to type in characters/numbers. If I run it in debugging mode, with breakpoints at the point where the CEdit is to be shown, and where the CEdit is to be hidden, then it works pefrectly as many times as I like. I can keep clicking on that area of the control, showing the CEdit, entering a number, clicking elsehwere and hiding the CEdit, and so on and so forth. It turns out that the reason why it works when debugging and not when not debugging is that when I have breakpoints in parts of the code, the focus leaves my control in the ActiveX control container, and goes to the VS window to show me the break point. Then when I press F5 and return back to the ActiveX container then it all works again. Similarly, when I run the control out of debug mode, clicking on other windows or applications solves it and makes the control work. so a sequence like this works: 1)click on the area over which the CEdit should appear, 2)CEdit appears 3)Enter a value 4)click outside the CEdit 5)CEdit disapears 6) >>click on other window/application/desktop etc<< 7)click back on ActiveX container 8) Go to step 1. Without step 6, I canot get step 2 to happen more than once. We thought it maybe a matter of focus. So, the code was changed so that when the CEdit control appears it also gets the focus, and when the user clicks elsewhere and the CEdit hides, that the parent control gets the focus. I have put the code below...anybody who has actually read so far into this post might as well have a look at it. thanks! :-D
LRESULT CKnob::OnLButtonUp(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM lParam, BOOL& /*bHandled*/) { m_bMouseDown = false; RECT tempRect; GetClientRect(&tempRect); int nLeft = (tempRect.right - tempRect.left) / 2 - KNOBSIZE / 2; int nTop = (tempRect.bottom - tempRect.top) / 2 + KNOBSIZE / 2; //If mouse Up WITHIN the text area if((LOWORD(lParam)
-
Control's window not ready even in FinalConstruct()Hello, Things only seem to get stranger everyday. If I am not mistaken, in an ATL ActiveX Control, the aim of FinalConstruct is that by the time the program reaches there, the object has alreay been created. however that does not seem to be the case. In FinalConstructor() m_hWnd in the next statement is NULL. CWnd* parent = CWnd::FromHandle(this->m_hWnd); How can the control's window not exist after the constructor has been completed? Placing the same statment in the OnDraw function works, but not in FinalConstruct()? Am I missing something? Is there some sort of FinalNoReallyThisOneIsTheFinalConstruct() ? :wtf: Thanks
-
Creating a CEdit in ATL ActiveX control with MFC Support?Well...finally got this one figured out. Must add [code]AFX_MANAGE_STATE(AfxGetStaticModuleState());[/code] before [code]CWnd* parent = CWnd::FromHandle(this->m_hWnd); myEdit.Create(ES_CENTER | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, CRect(10, 10, 100, 40), parent, 1);[/code] Ciao ;P
-
Creating a CEdit in ATL ActiveX control with MFC Support?I have an ATl ActiveX control I am writing which has support for MFC. I want to add a CEdit in my control so that the user can enter values. How do I create this? I have spent all yesterday (literraly) trying and no luck. I construct by CEdit myEdit; Followed by CWnd* parent = CWnd::FromHandle(this->m_hWnd); myEdit.Create(ES_CENTER | ES_NUMBER | WS_CHILD | WS_VISIBLE | WS_TABSTOP | WS_BORDER, CRect(10, 10, 100, 40), parent, 1); This causes assertion...I cannot even find or understnad where the assertion is caused as when i look at the call stack in the debugger, there are no comments or ASSERT(...) around. Has anybody sucessfully added a CEdit to an ATL ActiveX control which supports MFC? If so...how? Thanks
-
why ATL based ACTIVEX control got flicker when RedrawOk...quite embarrasing but basically I had forgotten to add MESSAGE_HANDLER(WM_ERASEBKGND, OnEraseBkgnd) So onEraseBkgnd was not being called at all. Silly me... :~