|
Ok, then I think the best way to go in this case would be subscribing the form to the AfterSelect event (I guess you have inherited the TreeView control) and call the method on your B control whithin this handler.
I am telling you this becouse this way you will be able to reuse your custom treeView in other future projects where, maybe, you might need to populate a different set of controls with some different information.
|
|
|
|
|
Hello guys,
I have an app made that worked with the old Google Keywords Tool External. It worked perfectly until a few days ago when they dropped the new interface. Now I can't seem to crack this myself, and I need some help.
Using opera dragonfly (helps debug http requests) I managed to see how everything looks "in the background" but I don't understand a thing now. With the old site,everything was crystal clear, but now it's not.
The new website is located here:https://adwords.google.com/o/Targeting/Explorer?__u=1000000000&__c=1000000000&ideaRequestType=KEYWORD_IDEAS#search.none
When you want to get keyword results (enter a keyword and press enter), google makes a POST request here:
https://adwords.google.com/o/Targeting/g?__u=1000000000&__c=1000000000
The request headers are:
Host adwords.google.com
User-Agent Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.11) Gecko/20101012 Firefox/3.6.11
Accept text/html,application/xhtml+xml,application/xml;q=0.9,*
Now I don't understand what X-GWT-Permutation is (anx all the other x-gwt). I know it's google web toolkit ... but how the hell can I make a "call"to this website from c# .net (using httprequest) ?
The post content sent is:
6|1|69|https:
How should I send this? Like "uploading" a file? It's not a normal http post, because it has no variables, it's a simple text that it's sent.
So to make things short, I want to "download" the google keyword tool external page, and get the results in C# .net so I can process them.
Can anybody help?
Thanks in advance,
Vlad
|
|
|
|
|
Hi,
I'm not familiar with the Google interfaces, however I managed to do some other POSTs a few weeks ago, and basically this page[^] was all I needed.
sodevrom wrote: It's not a normal http post, because it has no variables, it's a simple text that it's sent.
It doesn't matter what the post data is, just write it to the stream, then proceed with accepting the result using HttpWebRequest.GetResponse() and HttpWebResponse.GetResponseStream() .
So if it worked for you earlier, there should not be a major problem (unless you want to understand what it is you are posting).
|
|
|
|
|
Hello,
I know how to use the httpwebrequest/response I am not really a "noob" in programming.
Now I decided to take a totally different approach, and get the text that I need by using a WebBrowser control. This is the best way to go I think, because it takes care of all the problems.
I have only one issue. For example to complete a field I use this:
HtmlElement username = this.wb.Document.All["username"];
username.SetAttribute("value", "aaaaa");
But how do I get the entire text of the webbrowser? It seems that if I use webBrowser1.DocumentText , it does not retrieve all the HTML code (it does not return everything that is visible). I think the problem is with dynamic code (javascript)
How do I get everything?
Thanks,
Vlad
|
|
|
|
|
Vlad,
you should receive the KeywordsTool data (keywords, CPC etc) using such code:
CComQIPtr<IHTMLElement, &IID_IHTMLElement> pBody;
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc2;
CComPtr<IDispatch> pDisp = NULL;
CHECKPTR(pDisp = objExplorer.get_Document());
CHECKPTR(pDoc2 = pDisp);
HRESULT hr;
hr = pDoc2->get_body( &pBody);
BSTR BSTR_Page = NULL;
if (pBody){
hr = pBody->get_innerHTML( &BSTR_Page );
}
/
if (BSTR_Page){
sPage= (LPWSTR) BSTR_Page;
SysFreeString(BSTR_Page);
}
|
|
|
|
|
to set certain HTML elements in the page, you could iterate through the page element collection and check for the class name / id etc you need.
Note after DISPID_DOCUMENTCOMPLETE the KeywordTool's JavaScript starts to amend the document. So you would need to poll the page content every X milliseconds to check if the elements you require have been created.
VariantInit(&index);
V_VT(&index) = VT_I2;
V_I2(&index) = 0;
CComPtr<IHTMLElementCollection> pEltColl = NULL;
CComPtr<IDispatch> pEltDisp = NULL;
CComQIPtr<IHTMLDocument2, &IID_IHTMLDocument2> pDoc2;
CComPtr<IDispatch> pDisp = NULL;
CHECKPTR(pDisp = objExplorer.get_Document());
CHECKPTR(pDoc2 = pDisp);
HRESULT hResult,hr;
hResult = pDoc2->get_all(&pEltColl);
if (SUCCEEDED(hResult) && pEltColl)
{
// Search by value (manual search with a loop on all HTML Elements in document - could be long!)
long intElements = 0;
pEltColl->get_length(&intElements);
for (int intElement = 0; intElement < intElements; intElement++)
{
CComPtr<IDispatch> pCurrentDispatch = NULL;
VARIANT vElementIndex;
VariantInit(&vElementIndex);
V_VT(&vElementIndex) = VT_I4;
V_I4(&vElementIndex) = intElement;
hResult = pEltColl->item(vElementIndex, index, &pCurrentDispatch);
if (SUCCEEDED(hResult)) {
CComQIPtr<IHTMLElement, &IID_IHTMLElement> pCur_Element = pCurrentDispatch;
|
|
|
|
|
Last time I used an event handler was to detect when a given track that is being played by the media element had ended, which was not difficult simply because the media element has an event called media ended. (http://msdn.microsoft.com/en-us/library/system.windows.controls.mediaelement.mediaended.aspx[^])
However what if the class your working with don't have events, I am working with the socket class and would like to set an event handler to listen for any incoming connection. So for as you can see from the code below I am using a button click event to trigger the application to begin listneing, which isn't that I want. I would like the application to start listening for in coming connections from the get go. How to I do this:
private void BtnListen_Click(object sender, RoutedEventArgs e)
{
Socket listener = new Socket(AddressFamily.InterNetwork,
SocketType.Stream,
ProtocolType.Tcp);
listener.Bind(new IPEndPoint(IPAddress.Any, 2112));
listener.Listen(10);
while (true)
{
Socket socket = listener.Accept();
string receivedValue = string.Empty;
byte[] receivedBytes = new byte[1024];
int numBytes = socket.Receive(receivedBytes);
receivedValue = Encoding.ASCII.GetString(receivedBytes,
0, numBytes);
if (receivedValue.Length < -1)
{
break;
}
else
{
MessageBox.Show(receivedValue);
break;
}
listener.Shutdown(SocketShutdown.Both);
listener.Close();
}
listener.Close();
Another problem I am having is that once the listen button is clicked, the application freezes until it receives something.
}
|
|
|
|
|
Look at Socket.BeginReceive (MSDN)[^] It should solve both problems if you read the documentation.
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
Hi,
1.
I didn't look at your code as it isn't formatted properly. Please use PRE tags for code snippets.
2.
Communication stuff should not be handled synchronously on the main thread; either use asynchronous "non-blocking" calls, or, better yet, use a separate thread. That will stop your GUI freezing problem.
3.
When you want your button-click code to execute right away, then don't put it in a button_click handler! Why not put it in your Form's constructor, its Load event handler, or, best, its Shown handler.
|
|
|
|
|
Have a look at this article hosted here in CP.
The while(true) within the main application thread is what freezes your application.
Bye
|
|
|
|
|
I think you will find it's not:
int numBytes = socket.Receive(receivedBytes); Receive is a blocking call, so it will not return until the receive is complete. He has a break on each of the if and else conditions which would terminate his loop, if it ever got that far...
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
You are absolutely right. I was just trying to avoid the next question once he finds out how to receive asynchronously: Why is my application still freezing?
Ok, just kidding. The truth is that I did not pay attention to the code.
|
|
|
|
|
Real men don't use instructions. They are only the manufacturers opinion on how to put the thing together.
|
|
|
|
|
hey
- Windows mobile 6.5
- net 2.0
- Form with the x or the ok at the rigth upper corner
what i want to do
- start the program and the button = OK
- if you use a menu the button change to X
all that works but now it comme
if that button = X and i hit it then the program minimize
i want to change this to close the menu
i tryed already wndproc but this don't work in mobile or i don't find it
if any one has suggestions or solutions , links thanks therefore
thanks
|
|
|
|
|
Hi,
I have following string.
"sdate=2,edate=3,,frq=price(sdate=0,,),curn=usd"
I would like to split the above string as below.
string[0]="sdate=2"
string[1]="edate=3"
string[2]="frq=price(sdate=0,,)"
string[3]="curn=usd"
I tried to split based on ',', but I didn't get as above?
Please help.
|
|
|
|
|
SRKSHOME wrote: edate=3,,frq
The thing is you have two ,'s here.
Based on this string[2] will be "".
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
modified on Thursday, October 21, 2010 2:29 PM
|
|
|
|
|
no..string[1] would be edate=3 and string[2] would be ""
|
|
|
|
|
Missed that - thanks.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Look into Regular Expressions.
Also see what I did here[^].
|
|
|
|
|
A simple Split will work for every ',' character into the original string, and it seems that it should ignore the ones which are between parenthesis. You can use regular expressions to achieve this. First of all, replace every ',' character which is between parenthesis with another character easy to replace back when split is finished ('|' could be a good choice). Then make a normal split, and then replace back. This code would work for the sample given:
string originalString = "sdate=2,edate=3,,frq=price(sdate=0,,),curn=usd";
Regex r=new Regex("\\(.+\\)");
string modified = r.Replace(originalString, m =>
{
return m.Value.Replace(',', '|');
});
string[] vector = modified.Split(',');
for (int i = 0; i < vector.Length; i++)
vector[i] = vector[i].Replace('|', ',');
Though vector[3] would be an empty string due to the two consecutive commas after the edate=3. If you want to ignore several consecutive commas into the string, you should make this before the split and after the replacement made by the Regex object:
while (modified.Contains(",,"))
modified = modified.Replace(",,", ",");
Hope this helps. See you
|
|
|
|
|
Hi Erik,
This is realy helpful...Thank you very much.
Thanks.
|
|
|
|
|
hello
i am working on a project "Face Detection" in live video without OpenCv, EmguCV etc. so the first thing that I want to access the RGB values of each pixel and then set them back after some plus minus calculation. but the problem is that i can't use GetPixel and SetPixel methods because they are too slow. and i need heigh speed. in one second i have to process many frames. my question is that is there any other way to get the rgb values and set them back more faster than GetPixel and SetPixel, which full fill my requirements?
thaks
|
|
|
|
|
See here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Sir I don't have words to say thanks to you. you solved a very big problem of mine. God bless you..thank you very much..
i would like to ask one another question and that is.
"Is BitmapData and lockBits and then Unlock bits through pointers is the fastest way to access bits or do we have more faster method then this as well?".
thanks
|
|
|
|
|
Hi all,
There are all these nice types of columns you can add to a DataGridView - ex. DataGridViewCheckBoxColumn and DataGridViewButtonColumn
Is there a way to define my own type for such a column?
What I'd like to do is this; I have a DataGridView on my form in which I display the various values of a list of attributes (I'm not using data binding). The different attributes have different types of values, some are strings, some are integers, some are dates and some are byte values that represent a bit field.
These bit fields I'd like to display in the DataGridView as a group of checkboxes . So I had in mind to create a control that consists of a panel containing 8 check boxes (or something like that) and then display that control in the DataGridView cell. But how?
Any ideas or suggestions would be appreciated.
TIA
|
|
|
|
|