|
Hello.
I have an idea for a program I would like to design and implement using C++. This program will produce a list of websites based on what the user wants to search. For example, let say the user enters "c++ programming." The program will log onto Google.com and conduct a search for "c++ programming." It will browse all responses pages and save all websites into a text file (one line per website URL). One done, the user will have a list of relevant websites.
From an implementation perspective, is the program above simple enough using C++ and Winsock? I should be able to setup a socket to connect to a search engine such as Google and/or Yahoo. That is about all I know right now. I do not know how to gather the information after I have connected to, say, a website. Please include a possible implementation using Winsock if you know of one.
Thanks,
Kuphryn
|
|
|
|
|
try ravi's webresourcegrabber class )on the front page of cp)
it looks like a good place to start
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
kuphryn wrote:
From an implementation perspective, is the program above simple enough using C++ and Winsock? I should be able to setup a socket to connect to a search engine such as Google and/or Yahoo. That is about all I know right now. I do not know how to gather the information after I have connected to, say, a website. Please include a possible implementation using Winsock if you know of one
I don't think winsock is a good idea for this. It is to low level, it'll force you to learn HTTP protocol (not to complicated, but still waste of time). I recommend WinInet, it's high level library which comes with IE and gives more comfortable access to HTTP.
As for information gathering, it is search engine dependent. Most use syntax like www.google.com/search?something or similar.
Felix.
|
|
|
|
|
Thanks.
I have never heard of WinInet. Is that part of MFC and IE? The authors of the network programming (Windows) I am reading have not mentioned WinInet.
Kuphryn
|
|
|
|
|
kuphryn wrote:
I have never heard of WinInet. Is that part of MFC and IE?
It comes with IE. It's a C based DLL. But there are plenty classes wrapping it. For more check http://msdn.microsoft.com/library/default.asp?url=/workshop/networking/wininet/wininet.asp
Felix.
|
|
|
|
|
Thanks.
I will continue studying Winsock for now. I will look into WinInet after Winsock.
Kuphryn
|
|
|
|
|
hRsrc = FindResource(hInst, lpString, "AVI")
I'm confused about the third parameter. In the MSDN page for FindResource I see things like this for the 3rd param:
RT_ACCELERATOR Accelerator table
RT_ANICURSOR Animated cursor
RT_ANIICON Animated icon
RT_BITMAP Bitmap resource
... etc.
However, I can't find anything about using "AVI", "IMAGE", etc. for the third param.
The reason I ask is because I'm getting this error:
cannot convert parameter 3 from 'char [6]' to 'const unsigned short *'
When I use this statment:
HRSRC hRsrc = ::FindResource(hInst,
MAKEINTRESOURCE(nIDRes),
"IMAGE"); // type
Thanks!
|
|
|
|
|
are you compiling with
#define _UNICODE
?
situations to avoid #37: "good morning ... how many sugars do you take in your coffee ... and what was your name again?"
coming soon: situations to avoid #38: "...and the dog was there too?"
|
|
|
|
|
No, I am not using #define _UNICODE. Should I be?
|
|
|
|
|
The error message says the compiler is expecting a unsigned short* , which indicates a Unicode string. If you don't know what Unicode is, you shouldn't be using it.
Now, the APIs that accept strings can be built for either ANSI or Unicode strings. To use the ANSI APIs, #define _MBCS either in your main header file before all #include statements, or (better) in your compiler options.
--Mike--
Buy me stuff! (Link fixed now)
Like the Google toolbar? Then check out UltraBar, with more features & customizable search engines!
My really out-of-date homepage
Big fan of Alyson Hannigan and Jamie Salé.
|
|
|
|
|
Hello,
I'm using MFC dialog based app. In it I have two dialog boxes Dialog1 and Dialog2. There is a Combo Box in Dialog2 that I want to populate with integer values obtained from Dialog1. The following explains what I want to do.
Dialog1.cpp
#include "Dialog2.h"
clear all contents from the Combo Box in Dialog2
while (number < 10)
{
...
if(some condition)
{
write whatever the 'number' value is to the
combo box in Dialog2
}
...
number++;
}
Does anyone know how I can do this or know of any document explaining this.
Thanks in advance,
Aoife
|
|
|
|
|
Use ResetContent() to clear the contents of a combobox. To add elements, use AddString() or InsertString() .
/ravi
"There is always one more bug..."
http://www.ravib.com
ravib@ravib.com
|
|
|
|
|
Hello!
I am working on a custom control derived from CWnd, which I was hoping to put on CodeProject until I tried the control with the Create function (two step creation) in debug mode and it errored out. I then tried the control in Release mode and everything worked fine. Here is what my create function looks like:
//Function: Create
//Job: creates the NavBarCtrl
BOOL CNavBarCtrl::Create(const RECT& rect, CWnd* parent, UINT nID, DWORD dwStyle /* = WS_CHILD | WS_BORDER | WS_TABSTOP | WS_VISIBLE*/)
{
//Make sure variables are valid:
ASSERT(parent && IsWindow(parent->GetSafeHwnd())); //parent must be a valid window
ASSERT(parent->GetDlgItem(nID) == NULL); //must be a unique dialog item
//Create the window:
if(!CWnd::Create(NAVBARCTRL_CLASSNAME, NULL, dwStyle, rect, parent, nID))
return false;
//Done:
return true;
}
The program crashes in debug mode sometime within the call to CWnd::Create. I have properly initialized the class name contained in NAVBARCTRL_CLASSNAME, since I used the same code Chris Maunder does in his grid control. Just a side note, I tried this code in debug mode first on a Windows XP machine, and was unable to get into the heart of the CWnd call to see what was wrong. Then I tried the code on a Windows 2000 machine and was able to debug enough to see that apparently the code was ASSERTing in the call to CWnd::Attach, on this line:
ASSERT(m_hWnd == NULL)
I examined the values for m_hWnd and found that, while it did not point to any place in memory (pointer had not been initialized), the value was not NULL. So I tried setting m_hWnd to NULL right before the call to CWnd::Create, but that didn't help. I am hoping someone can shed some light on this situation because it is really annoying to have to run all the programs that use this control in Release mode, and frankly, I hate miscellaneous errors. I would rather not send the code, but if it will help to solve this problem then I will do whatever.
Thanks in advance!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Alexander, how are you instantiating CNavBarCtrl? If m_hWnd is erroneous then it sounds like the instance of CNavBarCtrl might not be valid.
I don't understand why you couldn't step into the code CWnd::Create on XP.
Neville Franks, Author of ED for Windows. www.getsoft.com
|
|
|
|
|
Hi Neville,
Thanks for your response. I am creating a pointer to a CNavBarCtrl and then using the 'new' operator to create a new object of the class. Then in the create call, the program crashes in debug mode (it runs fine in release mode). Here is the code I use to create it:
//somewhere in .h file of a view class:
CNavBarCtrl *m_nav;
//in .cpp file:
m_nav = new CNavBarCtrl();
if(!m_nav->Create( /* variables */ )) //crashes in debug mode
I couldn't step into the code of CWnd::Create on XP because every time I was in debug mode and reached that line and then pressed the button to step into the next function, the program crashes as soon as I did (in other words, it threw an exception as soon as I tried to step into the function).
If you could shed some light on this I would be very appreciative!
Thanks in advance!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Hello!
Just in case anyone was wondering, I found the solution to the problem. Stepping through the code didn't work on my machine for some reason, but the actual problem was a line fo code in PreSubclassWindow. Just goes to show how you should really know your window creation process; I din't remember when it was called and so when I manually stepped through the code I found the error in that function.
Thanks for your time!
Sincerely,
Alexander Wiseman
Est melior esse quam videri
It is better to be than to seem
|
|
|
|
|
Hi Guys,
how to get the Current installed fonts ??? I am already usinf the EnumFontFamilies() Function, but i want to use an another function ! Maybe somebody knows one )
Thanks for your help
Best Regards
Sonu
|
|
|
|
|
In the MSDN article, "Enumerating the Installed Fonts", it states that to do what you want you need to utilize the EnumFonts and EnumFontFamilies functions. If you're looking for an alternative, you'll need to let us know what exactly you're looking to do that these functions don't.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
As mentioned i already use the Enumfontfamilies. I dont know what i am doing wrong but the function is very slow in my app. Actually i want to draw all installed fonts in my app !! The EnumFontFamilies does this but its slow, maybe its a bug in my app but i cant find it. If you want i can send you my app to your email id. Just let me know.
Thanks for your Help
Best Regards
Sonu
|
|
|
|
|
sonu wrote:
I dont know what i am doing wrong but the function is very slow in my app
This was the part you didn't mention, which was why nobody could help you - we didn't know what the problem was - just that you didn't want to use EnumFamilyFonts. Go ahead and send me the app and I'll take a look at it as time permits.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
What is the best way to get the number of items from a 'branch' of a tree control, so I can put a number in brackets behind the name of the parent.
ROOT
- People (2)
* Paul
* John
- Kids (3)
* Jack
* Tom
* William
So in this case I want to know how many items have "people" as parent. (that's two)
GetCount() returns the total number of counts, so that's useless.
Also, how can I change the name of an already existing item in a treeview?
Who can help me out?
Cheers!
|
|
|
|
|
|
While many of us know the solution, it would be great if you could share your solution as well. That way, another person searching for this will find a complete solution. Besides, you might have come up with a unique way of completing the task that would teach us all.
Cheers,
Tom Archer
Author, Inside C#
Author, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|
|
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
CBitmap bitmap;
CBrush brush;
bitmap.LoadBitmap(IDB_BACKG);
int nCtrl = pWnd->GetDlgCtrlID();
pDC->SetBkColor(RGB_VALUE);
if ( NULL != brush.m_hObject )
::DeleteObject(brush);
brush.CreatePatternBrush(&bitmap);
hbr = brush;
return hbr;
This is not written by me though, I read something like this somewhere else.
|
|
|
|
|
Um...what does this have to do with getting the children of a HTREEITEM
Cheers,
Tom Archer
Author - Inside C#, Visual C++.NET Bible
A total abstainer is one who abstains from everything but abstention, and especially from inactivity in the af
|
|
|
|