How do I access an URL from within the VB or VC++ code. my requirement is, I need to create a DLL which accesses an URL, and parses the XML returned(the url I'm accessing returns XML, not HTML).How can I do that in VC++/VB? Also, are there any classes in VC++/VB for parsing XML returned. Any sample code would be appreciated.
One of the easiest ways to access web resources is using the MFC WinInet wrapper classes. Take a look at CInternetConnection and related classes. If that does not appeal to you can use the WinInet API directly or even the Winsock2 API to retrieve the web resource.
XML parsers are abundant. To see a large if not complete list of them go to xml.com. Perhaps the most prevalently used parser in Win32 from C++ is the Microsoft MSXML ActiveX control. I have been using it for around 4 years in C++ development. If you are familiar with ATL and _com_ptr_t class using MSXML with the #import directive is a snap.
Watch out! I'm a CPian on the edge! I have a new Gold rating and I'm not afraid to use it!
Being the person I am who pays attention to minor details, I was wondering if you could explain me in as much detail as you can why is it that MFC and some Win32 interface methods instead of using the standard C++ bool data-type, use BOOL (which maps to the plain old int) ?
Any insights you could provide would be much apreciated.
Yeah I was told about that before. Only thing I wonder, though, is that why they used an int not an BYTE, to represent such a type that merely needs to maintain "yes or no", but then I guess we've all used to that already.
Depending on your CPU, access to anything of less than an int may be very slow. Alpha for instance (which windows NT ran on) didn't give you easy access to a single byte, it could be done, but the code was fairly high.
This is going to sound like a strange question, but I'm wondering if there is any way to statically link an activex control into an app. Basically, I would like my app to use one particular version of an ActiveX control, and one version only. If a subsequent installation installs a newer version of said control and registers it into a different location, I would like for my app to continue using the one it knows about. I want to do this to reduce the dependencies between different apps that use the same control.
Is this possible? Basically, what I'm looking for is a way to bypass CWnd::CreateControl, and get a CWnd* for an activeX control that's linked into the project. Or, alternatively, call LoadLibrary with a particular path, and get the CWnd* for th control that way. I'm thinking maybe LoadLibrary, DllGetClassFactory and some other magic might make this possible. How does CWnd::CreateControl manage to do it? I would think it basicaly looks in the registry for the location of the control, calls LoadLibrary, then DlGetClassFactory, creates an instance of the object given the control's CSLID, and then . . . . what?
I have a CScrollView containing a large document. When I scroll horizontally and get to a horizontal scroll position of around 32760 pixels the scroll snaps back to the zero horizontal position. This only happens if I scroll by dragging the scrollbar itself. If I click on the little arrow at the end of the scrollbar there is no problem and it can scroll horizontally beyond 32760 pixels.
Does anybody know what could be causing this behaviour? My scrollview class does not override any of the basic scrolling functions so I feel confident it's not a bug that I've programmed in myself.
I just tested this by building a new mdi application in visual studio.net, using cscrollview as the base view class. The only change I made after the initial files were created by the ide was to set the horizontal scroll width to 35000 pixels in the view's "oninitialupdate" function. True enough, when you scroll towards the end of the view past around 32000 pixels, it hops straight back to zero!
I'd be really grateful if anybody could suggest a way of overcoming this limitation.
Basically I want to loop through a link list that I have. It wouldnt be hard if in the link list their might be classes with different data types. So I am trying to use the void pointer. Because I dont know the data type of the class and I want to try and make a function that returns the address of the last class in the link list. I am able to use templates but everything works well until I try to get the void pointer in a class to equal the void pointer of the next class in the link list. I dont see why it doesnt work because I keep getting the error error C2227: left of '->NextObject' must point to class/struct/union. I am pointing to a class void pointer and Node is suppose to be a class so I dont understand why I am getting the error. I tried casting to fix this problem either I dont know how to do it well or it doesnt work to fix this.If anyone can help I would be extremly greatful.
Ummm... static_cast would suffice (and in general is preferrable to reinterpret_cast.)
tmpRoom will be null if the cast fails.
Oh, this behavior is only provided by dynamic_cast, and this type of cast can only be applied to convert from a virtual class to a virtual class, which is not the case. So, IMHO static_cast should be used, and the cast does not fail ever (of course, if Node didn't point to an actual Room object, then the program could crash or whatever.)
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Joaquín M López Muñoz Telefónica, Investigación y Desarrollo
Sorry I didnt see the post before I posted my last message and I tried to fix my program using the advice. I am still receiving the same runtime problem which stops at while (tmpRoom->Next!=0) Node shouldn't be NULL because Node would be a pointer to Room *RoomHead. Which is a global object. RoomHead->Next should = 0 because in the room constructure Next = 0; So FindEndObject should just return the value of tmpRoom because their is only one object in the link list. I tried every way to use the static_cast and I still cant get it to work. I am not even sure if I am doing it 100% correct. I dont want anyone to give me the code for the function because I will like to learn exactly how to do it my self. But if anyone could give me a little more detail hints I would appreciate it alot because right now I am not 100% sure how to implement the advice I am getting to my code. I guess because of the fact I never used void pointer or used any form of cast. This is how my program looks so far