|
Hi all,
I want to write a plug-in for windows media player.
And I am almost a begiiner in this codes.
Please help me , Maybe an article.
Thank you .
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
Hi all could any one tell me what is the the equivelent the following visual basic 6 code. txtURl holds a url of a perticuler website.Thanks
RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)
|
|
|
|
|
There is no direct equivalent. Try calling InternetOpenUrl() followed by InternetReadFile() .
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
thank u for u reply. could u tell me how to sue these 2 . where to specify the url ? i want the html to be placed inside editbox. could u just show me how.Thanks
|
|
|
|
|
method007 wrote: could u just show me how
Googling: MSDN InternetReadFile
produced hits where the second one listed is titled "Building an Internet Browser Using the Win32 Internet Functions". The following sample code is contained in that article which you could have easily found for yourself.
HINTERNET hNet = ::InternetOpen("MSDN SurfBear",
PRE_CONFIG_INTERNET_ACCESS,
NULL,
INTERNET_INVALID_PORT_NUMBER,
0) ;
HINTERNET hUrlFile = ::InternetOpenUrl(hNet,
"http://www.microsoft.com",
NULL,
0,
INTERNET_FLAG_RELOAD,
0) ;
char buffer[10*1024] ;
DWORD dwBytesRead = 0;
BOOL bRead = ::InternetReadFile(hUrlFile,
buffer,
sizeof(buffer),
&dwBytesRead);
::InternetCloseHandle(hUrlFile) ;
::InternetCloseHandle(hNet) ;
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
Thank u for u reply. so how to use the html code and display it in a textbox ?
I tried this to place the html in textbox and gives me 17 errors!!
void CFindUserDlg::OnButton4() <br />
{<br />
<br />
HINTERNET hNet = ::InternetOpen("MSDN SurfBear",PRE_CONFIG_INTERNET_ACCESS,NULL,INTERNET_INVALID_PORT_NUMBER,0) ;<br />
HINTERNET hUrlFile = ::InternetOpenUrl(hNet,"http://www.cnn.com",NULL,0,INTERNET_FLAG_RELOAD,0) ;<br />
<br />
char buffer[10*1024] ;<br />
DWORD dwBytesRead = 0;<br />
BOOL bRead = ::InternetReadFile(hUrlFile,buffer,sizeof(buffer),&dwBytesRead);<br />
<br />
SetDlgItemText(IDC_EDIT2,buffer);<br />
<br />
::InternetCloseHandle(hUrlFile) ;<br />
::InternetCloseHandle(hNet) ;<br />
<br />
<br />
}
-- modified at 13:00 Wednesday 12th July, 2006
|
|
|
|
|
from the sample the "char" array named "buffer" would contain the HTML. In C/C++ char arrays are "strings" so basicaly you can copy that buffer into the edit control.
I don't know why you are doing this in C++ from a VB background but things are very different in C/C++ from VB. There are so many different ways to get a char array into a windows edit control depending on "how" you are developing your solution. If using MFC you have classes that you are using that simplify these operations. If not you must send messages to windows controls to interact with them. This is a small part of the fundamental knowledge needed for windows development in C/C++. Asking questions in a forum about using API's when you don't have basic C/C++ experience will be a very slow and tiresome process.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
well i have done this in visual basic 6 but i am working in a project that is only possible in visual c++ and this has to be done in visual C++ as well
Any ways still i did not get my asnwer.!! i want to place the html code of the url inside a variable and editbox but adding SetDlgItemText(IDC_EDIT2,buffer); to your code did not compile and gave me 16 erros!!
could u just help me fix that problem
errors:
--------------------Configuration: FindUser - Win32 Debug--------------------<br />
Compiling...<br />
FindUserDlg.cpp<br />
C:\visualC\FindUser\FindUserDlg.cpp(330) : error C2065: 'HINTERNET' : undeclared identifier<br />
C:\visualC\FindUser\FindUserDlg.cpp(330) : error C2146: syntax error : missing ';' before identifier 'hNet'<br />
C:\visualC\FindUser\FindUserDlg.cpp(330) : error C2065: 'hNet' : undeclared identifier<br />
C:\visualC\FindUser\FindUserDlg.cpp(330) : error C2039: 'InternetOpen' : is not a member of '`global namespace''<br />
C:\visualC\FindUser\FindUserDlg.cpp(330) : error C2065: 'InternetOpen' : undeclared identifier<br />
C:\visualC\FindUser\FindUserDlg.cpp(330) : error C2065: 'PRE_CONFIG_INTERNET_ACCESS' : undeclared identifier<br />
C:\visualC\FindUser\FindUserDlg.cpp(330) : error C2065: 'INTERNET_INVALID_PORT_NUMBER' : undeclared identifier<br />
C:\visualC\FindUser\FindUserDlg.cpp(331) : error C2146: syntax error : missing ';' before identifier 'hUrlFile'<br />
C:\visualC\FindUser\FindUserDlg.cpp(331) : error C2065: 'hUrlFile' : undeclared identifier<br />
C:\visualC\FindUser\FindUserDlg.cpp(331) : error C2039: 'InternetOpenUrl' : is not a member of '`global namespace''<br />
C:\visualC\FindUser\FindUserDlg.cpp(331) : error C2065: 'InternetOpenUrl' : undeclared identifier<br />
C:\visualC\FindUser\FindUserDlg.cpp(331) : error C2065: 'INTERNET_FLAG_RELOAD' : undeclared identifier<br />
C:\visualC\FindUser\FindUserDlg.cpp(335) : error C2039: 'InternetReadFile' : is not a member of '`global namespace''<br />
C:\visualC\FindUser\FindUserDlg.cpp(335) : error C2065: 'InternetReadFile' : undeclared identifier<br />
C:\visualC\FindUser\FindUserDlg.cpp(339) : error C2039: 'InternetCloseHandle' : is not a member of '`global namespace''<br />
C:\visualC\FindUser\FindUserDlg.cpp(339) : error C2065: 'InternetCloseHandle' : undeclared identifier<br />
Error executing cl.exe.<br />
<br />
FindUser.exe - 16 error(s), 0 warning(s)
code that give me 16 errors:
void CFindUserDlg::OnButton4() <br />
{<br />
<br />
HINTERNET hNet = ::InternetOpen("MSDN SurfBear",PRE_CONFIG_INTERNET_ACCESS,NULL,INTERNET_INVALID_PORT_NUMBER,0) ;<br />
HINTERNET hUrlFile = ::InternetOpenUrl(hNet,"http://www.cnn.com",NULL,0,INTERNET_FLAG_RELOAD,0) ;<br />
<br />
char buffer[10*1024] ;<br />
DWORD dwBytesRead = 0;<br />
BOOL bRead = ::InternetReadFile(hUrlFile,buffer,sizeof(buffer),&dwBytesRead);<br />
<br />
SetDlgItemText(IDC_EDIT2,buffer);<br />
<br />
::InternetCloseHandle(hUrlFile) ;<br />
::InternetCloseHandle(hNet) ;<br />
<br />
<br />
}
My whole intention is to extract data once i get the html of perticuler url .
I want to extract the bold parts of html as below.could u show me how to collect the bold part data from a webbrowser controle html . I want to collect those data and place them in a listview and use the color code to color the name in listview.
Note: i want to extract the name and color1 and color2 data from webbrowsser controle as shown in pic
[IMG]http://i5.photobucket.com/albums/y180/method007/extractData.jpg[/IMG]
webbrowser html code:
<html><br />
<br />
<head><br />
<meta http-equiv="refresh" content="60"><br />
</head><br />
<br />
<br />
<p><ul><table border=1 cellpadding=4<br />
<br />
<tr><th>Name</th> <th> color </th> <th> color2 </th> </tr><br />
<tr><td><font color="0800">tony</font></td> <td>32768</td> <td>0800</td><br />
<br />
<tr><td><font color="FF0FF">cindy</font></td> <td>16711935</td> <td>FF0FF</td><br />
<br />
<tr><td><font color="800FF">sarah</font></td> <td>16711808</td> <td>800FF</td> <br />
<br />
</table><br />
</body><br />
</html>
-- modified at 13:24 Wednesday 12th July, 2006
|
|
|
|
|
method007 wrote: is only possible in visual c++
Why? A .NET application would seem to be a much better choice.
method007 wrote: code did not compile and gave me 16 erros!!
this is exactly what I meant about not having C/C++ basic experience. It could take you months and hundreds of posts to finsish your job using a forum.
method007 wrote: error C2065: 'HINTERNET' : undeclared identifier
That means you have not included a required header file. That is basic C/C++ knowledge. A perfect example of what I am telling you. If you are going to develop using VC++ you better go back to the start and learn some basics, jumping into an actual project when you don't even know about including header files is completely insane.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
i know man i need to learn the basic and i do not know how to defind a header for it !! (
|
|
|
|
|
Buy a book for beginner C++ . Don't do a project until you actually understand everything in the book. Once you understand everything in the beginner C++ book you will have scratched the surface.
Then repeat for Windows Development.
Then repeat for HTTP and HTML ( of course this book may not exist ).
Of course there is the famous book "Learn Visual C++ in 21 days". You could try that one... and if in 21 days you have actually learned Visual C++ "completely" you should donate half your salary for the next 5 years to the author.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
man i have the book Learn Visual C++ in 21 days and i read first few chapters. so u think your solution will allow me get the dynamic html that i need for further process corectly? The reason i want to make sure is that the html that i am after is dynamic and i need to retrive it every one min so i do not want to get the old html for each request.
Furthermor, could u tell me what chapter of that books talkes about retriving html ?
|
|
|
|
|
I must apologize. My comments about that book are pure sarcasm. No one can learn Visual C++ in 21 days. I have no idea what is in the book because the title is so stupid I would never read it or recommend it.
"Just about every question you've asked over the last 3-4 days has been "urgent". Perhaps a little planning would be helpful?" Colin Angus Mackay in the C# forum
led mike
|
|
|
|
|
led i want to thank u i fixed that code it works good! )
|
|
|
|
|
First, I thank those who provided their feedback from earlier post.
I need some tweaking once again
As stated earlier, I have a program that should accept only keyboard input of integers from 1 to 12.
Someone suggested I try the scanf() function. I did something with it as shown below. Currently, it allows all integers as valid input and no other characters (letters, punctuatation, symbols, ect . . .).
This is fine. But, how can I further restrict user input with the scanf() function to allow only integers 1 thru 12? Or should I use another method? This is my first time using scanf. I've already tried the while conditions
while (data >=0 || data <= 13), (data >=0 && data <= 13) with not much luck. At this point I'm not sure if I should change how I'm retrieving the data (thru cin or getline). This is a very pivotable part of the program and the whole program is dependent on this functionality. Help is appreciated.
char buff[1024];
unsigned int value;
int charsRead;
bool validEntry = false;
while (!validEntry)
{
cout << "Please enter the number of subunits: ";
cin.getline(buff, 1023, '\n');
if (sscanf(buff, "%u%n",&value,&charsRead)==1)
validEntry = true;
}
-- modified at 11:13 Wednesday 12th July, 2006
|
|
|
|
|
Does this not work:
do
{
cout << "Please ... ";
cin >> value;
} while (value < 1 || value > 12); It's certainly a lot simpler than all of that other stuff (e.g., validentry , sscanf() ).
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
I ended up doing this instead:
char buff[1024];
unsigned int value;
int charsRead;
bool validEntry = false;
while (!validEntry)
{
cout << "Please enter the number of subunits: ";
cin.getline(buff, 1023, '\n');
if (sscanf(buff, "%u%n",&value,&charsRead)==1)
validEntry = true;
if (validEntry == true)
if (value >= 1 && value <= 12)
break;
else
validEntry =false;
}
It seems to work in main() but I still need to test it in the function I created since that is where I want it. I've had some issues when passing data between functions.
Thanks
-- modified at 11:40 Wednesday 12th July, 2006
|
|
|
|
|
Harold_Wishes wrote: I ended up doing this instead:
And this is acceptable? It sure seems like a bunch of unnecessary code.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Since I've had so many runtime errors with my output, I decided to leave it as is. I've spent too much time on it already. For me, the scanf() seems to work the best although I'm not very familiar with it. If there is a better solution ( as I'm not an experienced programmer) I would appreciate the feedback.
Thanks
-- modified at 12:28 Wednesday 12th July, 2006
I might mention that the code below does not test for non-numeric values which causes my screen output to scroll endlessly with text. I need the input to be an integer because I'm using it as a counter in the rest of my program.
do{
cout << "Please ... ";
cin >> data2;
} while (data2 < 1 || data2 > 12);
-- modified at 12:31 Wednesday 12th July, 2006
|
|
|
|
|
Harold_Wishes wrote: I might mention that the code below does not test for non-numeric values...
True. If that is a requirement, then I would use getchar() instead.
"The largest fire starts but with the smallest spark." - David Crow
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
You are doing far too much work for this.
int getInput(int range_min, int range_max)
{
int ret = range_min - 1;
do
{
char buffer[100] = {0};
cout << "Enter a value: ";
cin.getline(buffer, 99, '\n');
ret = atoi(buffer);
if (range_min > ret || ret > range_max)
{
cout << "Invalid entry!" << endl;
}
} while (range_min > ret || ret > range_max);
return ret;
}
int main()
{
int count = getInput(1, 11);
cout << "You entered: " << count << endl;
}
If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week
Zac
|
|
|
|
|
Harold, what I would do is:
<br />
char buff[1024];<br />
unsigned int value;<br />
int charsRead;<br />
<br />
bool validEntry = false;<br />
while (!validEntry){ <br />
cout << "Please enter the number of subunits: ";<br />
cin.getline(buff, 1023, '\n');<br />
<br />
if (sscanf(buff, "%u%n",&value,&charsRead)==1 && value >=1 && value <= 12)<br />
validEntry = true;<br />
}<br />
Otherwise, if you want to use c++ style stuff (I rarely do because I mostly work with windows programs and text strings), you could do sth like this:
<br />
int test;<br />
std::string dump;<br />
<br />
bool valid = false;<br />
while(!valid) {<br />
cout << "Please enter a number: ";<br />
cin >> test;<br />
<br />
if (!cin.fail())<br />
valid = true;<br />
else {<br />
cin.clear();<br />
cin >> dump;
}<br />
<br />
if (valid && (test < 1 || test > 12)) {<br />
valid = false;<br />
cout << "Out of range" << endl;<br />
}<br />
<br />
}<br />
cout << "You entered " << test << endl;<br />
PS: how does everyone get code to not remove all spacing?
earl
-- modified at 14:53 Wednesday 12th July, 2006
|
|
|
|
|
I think this code below compiles. I only reformatted. I shortened the logic in the program as suggested and it works. The only problem I'm having is duplicate output (something I encountered last week). Below the user is prompted to enter data twice in sequence. The first time the user is prompted to make a selection from a menu screen (no big deal).
But, after the user hits the ENTER key, the user will see duplicates of the second prompt. It is as if the user hit the enter key twice.
How do I prevent this from happening? Better question . . . Why is it happening?
I know the compiler is taking me thru the while loop an extra time which is printing the duplicate prompt (confirmed by the debugger).
#include <cstring>
#include <string>
#include <iostream>
using namespace std;
int main()
{
int data2;
char buff[1024];
unsigned int value;
int charsRead;
char selection;
cout << "A) Complete B) Partial C) UNKNOWN" << endl;
cin >> selection;
bool validEntry = false;
while (!validEntry)
{
cout << "Please enter the number of subunits: ";
cin.getline(buff, 1023, '\n');
if (sscanf(buff, "%u%n",&value,&charsRead)==1 && value >=1 && value <= 12)
validEntry = true;
}
data2 = value;
return 0;
}
-- modified at 21:56 Wednesday 12th July, 2006
|
|
|
|
|
I include pthread.h but the compiler produced an error which was ( fatal error C1083: Cannot open include file: 'pthread.h': No such file or directory) why was this error produced?
|
|
|
|
|
pthread is a header you wrote ?
i doubt it exists on visual C++ compiler.
aren't you compiling a source you found on the internet with a wrong compiler ?
TOXCCT >>> GEII power
[VisualCalc 3.0 updated ][Flags Beginner's Guide new! ]
|
|
|
|