|
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
|
|
|
|
|
Hello...
I would like to make the background of a window invisible, it is a CWnd that I've derived from a CStatic and I paint some rectangles over it, but I want to show only the rectangles showing the background dialog image...
Is this possible?
and if so, could you tell me how to do it?
thank you very much...
|
|
|
|
|
Do the drawing in OnEraseBkgnd without calling CStatic::OnEraseBkgnd in your overriden handler. Also, invalidate the corresponding portion of the parent window every time the drawing changes.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hello,
I have a splitter with 2 CRichEditViews.. From with in one of the views I do a SetSel(-1,-1) to put my caret at the end of the edit control.. Next I do a SendMessage(EM_SCROLLCARET) to scroll the view to the end of the control.. The control receives the message but the view isn't scrolled until it gets focus.. This is a work around but I don't want to throw the focus around.
GetRichEditCtrl().SendMessage(EM_SCROLLCARET);
CMainFrame* pMain = (CMainFrame*)AfxGetMainWnd();
if(pMain)
{
pMain->m_wndSplitter.SetActivePane(0,0);
pMain->m_wndSplitter.SetActivePane(1,0);
}
Is there any way to force the control or view to do what it's supposed to do with out messing with the focus\active pane? I've tried Invalidate RedrawWindow etc.. on both the view and the control..
Rob
|
|
|
|
|
I overriden DTN_DATETIMECHANGE of my datetimepicker control.When I change the time with arrow key it does not call and each 3 time it does not called.I overriden ONKEYUP and change time with scrollbar have the same problem.
Mazy
"And the carpet needs a haircut, and the spotlight looks like a prison break
And the telephone's out of cigarettes, and the balcony is on the make
And the piano has been drinking, the piano has been drinking...not me...not me-Tom Waits
|
|
|
|
|
Hy people!
I have a RichEditCtrl, and sometimes I add some lines of text into it. For each line I have one CHARFORMAT struct, and it works fine when I insert the first line.
But when I try to insert more lines, the first loses his format.
And the new one works fine.
I'll post my code here, it makes things more easy if someone could help me. I call this function every time that I have to insert a line into de Edit.
thanks all.
nPosTextIni = m_strRichEdit.GetLength();
m_strRichEdit += (strRemetente + " ("+tmp+") :\n");
UpdateData(FALSE);
UpdateData(TRUE);
nPosTextEnd = m_strRichEdit.GetLength();
m_ctrlRichEdit.SetSel(nPosTextIni, nPosTextFim);
if(bSomething)
m_ctrlRichEdit.SetWordCharFormat(cf_usrOrigem);
else
m_ctrlRichEdit.SetWordCharFormat(cf_usrDestino);
nPosTextIni = m_strEditHistorico.GetLength();
m_strRichEdit += strMsg;
m_strRichEdit += "\n";
UpdateData(FALSE);
UpdateData(TRUE);
nPosTextFim = m_strRichEdit.GetLength();
m_ctrlRichEdit.SetSel(nPosTextIni, nPosTextFim);
m_ctrlRichEdit.SetWordCharFormat(cf_texto);
Ricky
|
|
|
|
|
Are you sure your SetSel is only selecting what you want to change? If it selects the whole control then everything will get changed.. I would double check the setsel
|
|
|
|
|
Yes Rob,
I'm selecting ok!
Does have an function or something that must be overriding?
Must I reformat all my RichEdit every time that I insert a new line?
I'm confused because all that I'm doing is inserting a new line with different colors, and this crashs the other lines already formated...
well, I'll continue searching for something here, thanks for your help
Ricky
|
|
|
|
|
Just a thought.. you might try using SetSelectionCharFormat() instead of SetWordCharFormat().. Not sure if that will help..
I am assuming your making some type of chat program. I have had the same problems in the past, I wanted to color my name blue and leave the other persons name default so I had to create a loop and re-color each occurance of my name each time a new line was added. I have seen some syntax color edit controls here on codeproject and on codeguru.. you may check them out, they might be doing something that you are missing..
You might alos look into stream in and stream out.. Then when you receive a message you could color the whole line one color and when you send messages color it a different color.. Just a thought..
Good luck,
Rob
|
|
|
|
|
That's right Rob, I'm doing a chat program
I'm studing some code samples that I take from codeguru.
Thanks very much for your Help Rob,
cheers!
Ricky
|
|
|
|
|
Can someone tell me how I can rotate some text i am putting on a CDC?
Im currently creating the font, then using TextOut() to draw the text when displaying and printing, is there a way to rotate the text 45 degrees?
thanks in advance for any suggestions!
still a newb.. cut me some slack :P
-dz
|
|
|
|