According to the code sample on MSDN (http://msdn.microsoft.com/en-us/library/hh552522.aspx) any custom property data that you need to get out of your control should be in a semicolon delimited string in the AccessibleObject's Description property. This does not seem right to me at all. This seems like just a quick and dirty trick to get it working. What is the correct way to get the value of properties from custom controls? And if this actually is how you're supposed to do it, then how are you supposed to set those properties using the SetPropertyValue method? The example in the link above just throws a NotImplementedException in SetPropertyValue.
Since the IAccessible interface has only a limited number of properties the best solution is to cram any extra information into the Description property (that's what they do at the company I work at, and our developers don't work quick and dirty :) ). To modify the return value of this property you have to implement the Iaccessible interface on your control. Or, since you only want to modify the Description property you only need to modify that property and leave the rest to the proxy (I'm not sure how this works exactly but there are tutorials for it on MSDN).
The SetPropertyValue method in the UITestPropertyProvider is for the UItestControls. By overwriting it you can modify the way CUIT interacts with the control during playback. For example, if you overwrite SetPropertyValue for the Text property you can change the way CUIT types strings into the control.
There is an application on Lotus notes 5. The getdocumentbykey function is not working if the view is open. If some other view is open or if the Database is closed then the function is working correctly and finding the document. How can we make it work even if the view is open? I have given the part of the code below. Thank you.
BillNo2 = cdoc.fieldgettext("Bill_No2")
Set view = db2.GetView("Bill No.")
Set doc = view.getdocumentbykey(BillNo2)
If Not doc Is Nothing Then
doc.DOdone = "Done"
doc.LorryNo = cdoc.fieldgettext("Lorry_No")
doc.TripNo = cdoc.fieldgettext("Trip_No")
Call doc.save(True, True)
End If
While debugging, its skipping the line "If Not doc is Nothing" and ends the loop even there is document. The same code works fine if the view is not open. Kindly help me. Thanks.
Working backwards, if fieldGetText is not returning what you expect, your getDocumentByKey call will fail. Have you checked the value of BillNo2 in the debugger prior to the call?
Working backwards further, a reason that fieldGetText would not return what you expect would be that cdoc isn't what you expect. How are you running this code? And what is the code for setting cdoc? Since you use fieldGetText, I presume it is a NotesUIDocument, and guessing from the name I'll bet you're getting it from NotesUIWorkspace.currentDocument. Perhaps the currentDocument in the context that your code is running isn't quite what you expect. I.e., if your code is running in the context of the view, instead of in the context of the document that you're reading from, I would not expect it to work.
This sounds like a bug, which is entirely possible given that we're talking about a version that came out 13 years ago. But a few things to check first:
Make sure the first column of the Bill No. view is sorted.
Make sure the view is not a private view type.
If neither of those are true, or you can't change that view for business reasons, I think Anders's suggested workaround of using a hidden view is an excellent idea and should solve the problem.
Dear All We had developed a hr application(winform) which consist of almost 98 forms .And its in testing in our organisation .
But the problem now is the management wants all the data inputs to be in UPPERCASE .we had not set any character casing in any of our controls and now its almost very hazardous to change the character casing to all controls
Can anyone suggest any idea to do restrict the input to uppercase only ?.I had tried some thing at the Program.cs file.but it seems not working
Also tried to overide textbox.textchanged event it seems to be a foolish idea any more ideas please considering us as new bie in development
Although this is a weird requirement, you could use LINQ to "upper-text" all TextBox-Controls:
var allTxt = from form in Application.OpenForms.Cast<Form>()
from txt in form.Controls.OfType<TextBoxBase>()
select txt;
foreach (var txt in allTxt)
txt.Text = txt.Text.ToUpper();
Application.OpenForms returns all open forms owned by the application and TextBoxBase is the base class of text-controls(TextBox, RichTextBox). Enumerable.OfType filters for TextBoxBase.
Note that this doesn't search recursively for controls. Only the top control-container is searched currently. If you need a recursive search implement something like this.
Have a look at the KeyPreview event, it may allow you to control all input for the app, regardless of where the focus is.
I would say that by far the best solution would be to replace all the textboxes with your own implementation of the textbox - making changes like this more simple, but if that's not practical, KeyPreview should work.
I inherited an very old application that I am in the process of updating it (I know, we should have rewrote it in VS 2008, but we purchased a company, which is how I was stuck with the relic). Using UpdateData(TRUE) to retrieve the changes made in the dialog controls, nothing is being updated. I have an edit control, with an integer variable, and an edit control with a string variable, assigned using the class wizard. Upon pressing the OK button, the UpdateData(TRUE) is executed to retrieve the new values from the disalog.
I seem to remember having a similar problem back when VS C++ 6.0 first came out, but have not used it since VS 2003 and C# became prevalent.
Thanks for any help in advance!
Bill
Check the DoDataExchange() method. It should have the logic for writing data to or reading it from the controls. If the programmers used the default implementastion, then there will be a DDX_... macro for each control that is being read/written. Just look at any other MFC dialogs (in your code or google) to see how the DDX commands should be written if they are missing.
Alternatively, if it's only 1 or 2 values you can easily just get the control and read it directly if you don't mind doing validation etc yourself. Get the ID of the control from the form designer and use something along the lines of:
CEditWnd *pWnd = GetDlgItem(ID_THECONTROL);
CString newValue = pWnd->GetWindowText();
...
You'll need to look at the content of the DoDataExchange method and see what it is doing. There is not sufficient information here to tell what could be going wrong other than that.
How can we restrict a user from saving the page?
Please provide some tips to disable File->Save and View Source options
EDIT: Obviously it can't be done, and probably shouldn't be attempted. But possibly a more interesting variant on this question is how can we make is sufficiently hard for a user to save a page in a usable format such that it is not worth their while doing so? The question doesn't pose a value, but say we were protecting an article subscription site where the user is paying a few hundred dollars per annum for continued access to text.
Since the page has been sent to the client, there will always be a way to get that information. Trying to stop a user from doing this will only frustrate them.
The only way to have a user not be able to save a file is to not send it to them.
While the best answer is "Don't do this," there are ways to make it more difficult for them. And since the point of this site is actually answer the question even if it's bad, here is the best way:
First you'll need to have the page open in a new window where you turn off the address bar and toolbar and everything else. That will make it so the user can't easily get to the File menu at all. To do this you'll need a "splash" page that the user loads to and then when they click a link, it opens the popup that serves the main content of your page. Details on how to create popups without things like the toolbar are here:
http://blazonry.com/javascript/windows.php
Then you'll want to add some javascript to each page that prevents the user from right clicking. Here is one method:
http://javascript.about.com/library/blnoright.htm
Finally, if it's your Javascript code that you don't want to be seen, then obfuscating your code is a pretty effective way to do that. They can still see the code if they have much know-how, but the obfuscated code would be a gigantic pain to actually interpret. There are lots of obfuscators out there; here is a free web-based one:
http://www.javascriptobfuscator.com/
This is far from foolproof. It will stop all "casual" users, but any power user will probably be able to easily figure out a way around it. Still if the idea is to at least prevent a good majority of it then this should suffice.
Update for updated question:
To address your new expanded question, I would say the best way to accomplish what you're saying is to use a format that supports DRM. Adobe Acrobat would probably be the best choice because almost everyone has the reader installed. You can prevent PDF files from being saved to the computer so that they can only be loaded from the webpage by a logged in user. The user could still do a screen capture of the document itself which I don't believe is preventable (unless Adobe Reader has some security in place for this, which they might) but it should be sufficient security for most uses.
Don't do it.
Seriously, if the user can see the page in their browser they can see the source code and/or save it to their computer.
You are fighting a losing battle here.
What about the browser's cache? It can be saved from there.
What about a print screen? That could also save the page.
The only way to prevent a user from saving something is to not show it to them in the first place.
It's really a waste of time and resources to try and do this in html as any method you use can be trivially circumvented.
Instead I would use some other technology to display the data - you can never get around a screen capture. but if you're for instance displaying text and you want to make it hard for the use to save that text for use elsewhere then possible options include
PDF - which can disable save and print. There are extensions to most popular web languages that will write a pdf on the fly. Indeed you might be as well just to go down the DRM route with Adobe and embed a document
Flash - most probably via Flex which could be used to write a general-purpose app to display text and images. The advantage of Flash is that it's easier to set up links than pdf.
Or something else, a custom java applet, or even a vrml plugin and display the text in 3D!
In all cases you could display text against a disruptive background to make OCR more difficult, and images could be watermarked. However nothing is going to stop a determined and resourceful viewer, although you can possibly make it sufficiently hard that it's not worth their time.
The least you can do is... the content is generated dynamically by Javascript. In that way, they cannot simply save it. Of course, in FX, they can still view the generated code and then copy&paste. however, normally people cannot save the page.
It shouldn't be an issue, but if you really don't want a user from seeing your code (javascript, css or html) for some reason, than you could use some obfuscation tool which makes the code less readable.
Try javascript "encoding" and obfuscation.
Something like
if(document.location == 'mydomain.com') {
content = getAjax('mycontent.xml');
// content will hold something like 72, 94, 81, 99, ... - encoded ASCII codes
document.write(String.fromCharCode(content));
}
It will always be possible to save the page, but for non-technical guys it will be harder to make it work.
There are 2 protections
domain name
converting ASCII
It's only pseudocode, but I think you get the idea.
add these to code sets in script tag
document.addEventListener('contextmenu', function (e) {
e.preventDefault();
});
document.onkeydown = function (e) {
return false;
};
I'd like to add one more method which, imho, is hard to circumvent: Ctrl+S! (for me, Apple+S)
how can we make is sufficiently hard for a user to save a page in a usable format such that it is not worth their while doing so
Nothing hard: add on every page: "Personal property of John Stealer, company Zetabeta, paid with credit card 756890987654, billing address ..., subscription expires 12/20".
This is an "extended text format" that I just invented... it has an amazing property: though it looks like a regular text, user is much less willing to print it out and give to others...