|
Rather than adding the http:// if not present, I believe you should strip it off if it is, and content after any subsequent slash (including the slash should be stripped. For example, given a url http://www.codeproject.com/script, the actual host name is www.codeproject.com.
|
|
|
|
|
THANKS ALOT!!!!
It was really bugging me.
-Steven
By reading this message you are held fully responsible for any of the mispelln's or grammer, issues, found on, codeproject.com.
For those who were wondering, actual (Linux) Penguins were harmed in creating this message.
|
|
|
|
|
THANKS ALOT!!!!
It was really bugging me.
-Steven
CP Addict
By reading this message you are held fully responsible for any of the mispelln's or grammer, issues, found on, codeproject.com.
For those who were wondering, actual (Linux) Penguins were harmed in creating this message.
|
|
|
|
|
..Do you know what function retrieves all the text of a MS Word document via automation in VC++? Thanks in advance for saving me an hour and half of searching on MSDN!
|
|
|
|
|
There's a Delphi sample in SoftMosis Delphi/MSWord Automation FAQ[^]. It's done via the IDataObject interface.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
How can i get an image (for example 100x100) under curent position of mouse pointer ?
|
|
|
|
|
|
Is it possible to set tab stops with a list view control in report mode as can be done with a list box, akin to LBS_USETABSTOPS?
If the answer to the above is no, let me explain what I'm trying to accomplish and I would welcome suggestions as to what would be a better approach. The application I'm working on has a live display of commands, events, and data packets to and from a hardware device. It can also write a log file with that information. The user needs to be able to open that log file and view it in a variation on the live log window. The log file can grow to be arbitrarily large. The log file is parsed once to determine a "packet" count and line count, and then a virtual list control is created (LVS_OWNERDATA). The log file is subsequently re-parsed on demand to cache a range of packets around the current view position. The user can enable and disable details display on all packets. Without details, the list would lend itself well to columns, but with details display, it wouldn't, since the details need to be formatted as:
1/1/03 9:39:59.321____usb_____Command___Reset
____Data = [03 0C 00]
1/1/03 9:39:59.321____usb_____Event______Command Complete
____Data = [0E 04]: 01 03 0C 00
____Num_HCI_Command_Packets = 0x01
____Command_Opcode = 0xC03 ("Reset")
____Status = 0x00 ("Success")
____^______________^_______^_________^
The packet header lines need to be column-aligned, but the details, when shown, run across column boundaries. Therefore, I need the list control to have a single column, but use tab stops to align the fields at the positions indicated with carets.
So...should I switch to a list box with owner draw style to avoid bringing all of the packets into memory instead? Ideally, I'd like to stick with a list view control and somehow get it to respect tabs instead of just showing a
box character.
Thanks in advance,
Brian
|
|
|
|
|
|
Thanks, but I'm trying to avoid a fully customized control. I can do what I need to if I switch to list box instead of list view and take advantage of the owner draw property to manage which packets are cached in memory and when to fetch them from disk. I'd like to stick with the list view though so I don't have to reinvent the wheel in terms of the having to render everything. I'd prefer to let the system-provided controls just do their job. Unfortunately, if the list view really doesn't support tabs (a huge oversight on microsoft's part IMHO) I'll have no choice. Still hoping someone knows how to get the list view control to respect tabs...
|
|
|
|
|
Well, no. The list view control supports columns. The list control supports tabs. That's about the size of it.
You *can* use custom draw and the header control to implement columns on a list control, or custom draw and a bit of creativity to implement tabs on a list view control.
I'd put the choice at this: if you need columns, and you don't need variable-height rows, go with the list control. If you need variable-height rows, you'll need either a completely custom control or a customized list control.
---
Shog9
The siren sings a lonely song - of all the wants and hungers
The lust of love a brute desire - the ledge of life goes under
|
|
|
|
|
I don't even need the columns per se. I need a column effect to lend readability to the packet display without details. But I need to cross multiple columns for the detail lines. That would suggest that the list box control with LBS_USETABSTOPS is the way to go. Problem is there could potentially be way too much content. I wanted to take advantage of the explicitly intended virtual property of the list view control and the ease-of-use of the API to add an icon to the heading lines (better visual cues for each packet to further enhance readability). But if it ties my hands in terms of the columns and won't do tabs (I was intending to use the list view control with a single column and tabs to provide alignment) then I may be out of luck and have to go with an owner-draw list box. I didn't want to have to go that far in the interest of time. If I could forget the icons and go with a list box instead of list view control, I still need the "virtual" property. Looking at the documentation, it sounds like I need the LBS_OWNERDRAWFIXED property. Unless it's there under layers of documentation silt, I don't see anything about being able to leave off the LBS_HASSTRINGS property, but also not use the LBS_OWNERDRAWFIXED property, let the list box take care of the rendering and I provide the strings on demand by a callback as with a virtual list view control. Is that possible? The documentation would suggest not: "By default, all list boxes except owner-drawn list boxes have this style. You can create an owner-drawn list box either with or without this style."
|
|
|
|
|
List boxes weren't meant to be used in the same way that list views were, and so "virtual" support is somewhat lacking. You *can* avoid string storage, but you still need to add items one-by-one and manually handle drawing and measuring them.
List views are *fairly* easy to use, and when drawing them yourself you can optionally ignore columns when you want to... but you can't have variable height items - whatever height you decide on, that's what it's gonna be for them all.
So if your plan calls for each item being two lines, the first tab separated and the second free-form, go with the list view. If you're gonna need more/less than two lines per item depending on content, go with either list box or completely custom control.
As far as raw speed goes, you really can't do better than a completely custom control, written to your exact needs. But these *do* take time to write and maintain... in the end, you need to decide whether it's worth it or not.
---
Shog9
The siren sings a lonely song - of all the wants and hungers
The lust of love a brute desire - the ledge of life goes under
|
|
|
|
|
Hey I really appreciate all of your input. One last question and I think I'll have all the answers I need to move forward. You said "List views are *fairly* easy to use, and when drawing them yourself you can optionally ignore columns when you want to." How do you draw them yourself? The "List View Controls" section of the documentation in MSDN library makes no mention of it: the documentation deals solely with the API for using the built-in functionality. I see no mention of anything akin to WM_DRAWITEM for list boxes as pertains to list view controls. And that page, which I found by pure luck, naturally doesn't have any sort of up or next links to try to find documentation on the owner-draw functionality you said exists... If you can point me to the right section of the documentation (preferrably a URL in the MSDN web pages) that should suffice...
By the way, fixed height is perfect for this implementation. The design is that I have a total packet count, a range of cached packets, a detail line count for pre-cached packets, and a detail line count for post-cached packets. With details turned off, I set the item count to packet count, with details turned on, I set the item count to total line count. Wherever the view sits, I have the packets cached and provide via callbacks the text for each line (heading lines only with details off, heading lines interleaved with detail lines with details on). Instead, I'll need to draw the lines myself. So...where is it documented how to do that, or can you give me a constant that I can use as a keyword in a search (like LBS_OWNERDRAWFIXED, but it's cousin for list view controls).
Thanks again,
Brian
|
|
|
|
|
Brian Tietz wrote:
So...where is it documented how to do that
Why, on CP of course!
http://www.codeproject.com/listctrl/lvcustomdraw.asp[^]
(yeah, ok - it's in MSDN too, but there it's confusing and wrong)
---
Shog9
The siren sings a lonely song - of all the wants and hungers
The lust of love a brute desire - the ledge of life goes under
|
|
|
|
|
In what is turning out to be a nightmare, I've been handed a project that has been pushed off for 5+ years.
My company has a large (500000+ line) legacy product that now needs to have full multilanguage features added. I've figured out the basic part of the work, changing the display code and refactoring the database, but I'm running into an issue with the sheer volume of possible problems within the functional part of the code.
For instance, all uses of isdigit, tolower, toupper, atol, isalpha, etc. all have to be looked out and replaced with their wide character versions when required. While tedious, this is doable. The problem is needing to flag things like this:
// Just a quick example
int foobar( char* foo)
{
if ((strlen(foo) >= 10) && (foo[0] >= '2'))
{
// entry won't fit in an int, raise error
}
else
return atoi(foobar);
}
Obviously changing the char to wchar_t, strlen and atoi functions isn't enough, but I'm hoping someone knows of software that might help flag these questionable constructs so that at least some of the need for visually inspecting all of the code can be minimized.
I may take a shot at writing an parser & analysis tool for this task, a week spent on the tool may save me time if nobody knows of anything available. Commercial or free, doesn't matter at this point...
|
|
|
|
|
I'm not sure of any tools that do this, but I had thought of writing one a couple months ago, when faced with a similar situation. It turned out that it wasn't even that hard to transform the project I was working on, but it wasn't a 500KLOC project either.
I think it would probably take about 1 day to write a really really simple lexer, and a pretty simple parser to take care of this situation for you. And it could probably chew through 500KLOC in a minute or two. Think about how simple it is to replace "char" with "TCHAR", and "strlen" with "_tcslen", and a simple character string "'a'", with "_T('a')"?. I know, since I've done the conversion, that there are a lot of cases, but I still don't think it would take that long to write the lexer/parser to do it.
At any rate, good luck.
Chris Richardson
Programmers find all sorts of ingenious ways to screw ourselves over. - Tim Smith
|
|
|
|
|
I have a basic Dialog Application .
After the MFC wizard exits after creating the classes i do the following :
1. Add ATL support to my project that adds the InitATl code to the App class TEST : Code compiles and Dialog displays !
2. Include the definition
#define _WIN32_WINNT 0x0400 to the Stdafx.h file to support Mulithreaded COM .because the InitATl function performs the following :
#if _WIN32_WINNT >= 0x0400<br />
HRESULT hRes = CoInitializeEx(NULL,COINIT_MULTITHREADED);<br />
#else<br />
HRESULT hRes = CoInitialize(NULL);<br />
#endif
TEST : Code Compiles and runs
3. Now if I add an Active X Control on the Dialog say a Microsoft Flexgrid Control .
TEST : Code Compiles and doesnt run .
DEBUG reports the following
Warning: OleInitialize returned scode = RPC_E_CHANGED_MODE ($80010106).<br />
Warning: CreateDlgControls failed during dialog init.
I am not able to figure out where I am going wrong and why the code does not run ? Please help (
|
|
|
|
|
Hi
I'm a VC beginner.I'm trying to insert a new class into my project and i wanted to set the base class of the new class as CObject but the option is not available in the combo box. Why is that so?
And i noticed that CStatic is frequently chosen as the base class of new classes. Why is that so? I've read up on the MSDN help file but i'm still very confused abt the features of CStatic class.
thks thks n Happy New Year!
|
|
|
|
|
In VC6 (Don't know how's in VS.NET) you choose the class type as the first parameter in the New Class dialog. The default value is MFC Class - it supports deriving your class from one of the offered MFC classes (with some extended function - message map and DDX macros for dialogs and windows are generated etc.).
If you need to derive your class from other class, use Generic class type. You can enter any parent class name. And of course you can create your class manually as the only "bonus" in this mode is, that the cpp and header files are created and added to the project.
You only need to derive from CObject, if you want to use MFC functionality like Serialization or some MFC collections with your class.
CStatic is label control for dialogs, derive your class from it only if you want to extend it's functionality.
Pavel
Sonork 100.15206
|
|
|
|
|
i see..so i just choose Generic Format and type in CObject myself?
ya..i've read that CStatic is for static label which is why i'm surprised so many complicatd classes in the sample programs are derived from them!
Thks alot!
|
|
|
|
|
I have a class derived from CMultiDocTemplate, where I have overloaded the OpenDocumentFile and InitialUpdateFrame functions.
I am adding this class as a member to my App Class.
When I try and compile this bare bones MFC app, the linker is complaining that ::
emo_test error LNK2005: "public: __thiscall CWorkSpaceDocTemplate::CWorkSpaceDocTemplate(unsigned int,struct CRuntimeClass *,struct CRuntimeClass *,struct CRuntimeClass *)" (??0CWorkSpaceDocTemplate@@QAE@IPAUCRuntimeClass@@00@Z) already defined in ChildFrm.obj
as well as the destructor and the other functions i have overloaded? What is causing this?
Ryan Baillargeon
|
|
|
|
|
Did you overloaded these functions with the Class Wizzard or did you write the functions manually? If you did them manually maybe you're missing something, I would go back and overload them using the wizzard.. Not sure just an idea..
|
|
|
|
|
The obvious problem is that you have actually defined the routine twice (rare). The usual problem is that you defined the routine in your H file outside of the class scope and didn't make the function "inline".
Tim Smith
I'm going to patent thought. I have yet to see any prior art.
|
|
|
|
|
... speechless
(takes brick and smashes over head)
... thank you
Ryan Baillargeon
|
|
|
|
|