|
I am using the ClistCtrl control to display packet traffic on a serial I/O line. I use Scroll() so the
most recent packet appers on the bottom of the list. Once I reach an upper limit I call
DeleteItem(0) to keep the total rows at a fixed limit. The code shown below works but once the
upper limit is reached the CListCtrl scrolls the header off the screen which is weird. The only way
I've been able to get around this is to call RedrawItems() but this causes way to much flicker. I'm
I missing something? I used to do this with ListBox() without any problems. Oh there also seems
to be an upper limit to how many characters I can put into a cell of about 200 chars and if I exceed
this the cpu activity shoots to 99 and locks the app - fyi.
void CCListCtrlAdv::SetColumnData(CStringListEx& strlist, int nIndex)
{
if(strlist.GetCount())
{
if(GetItemCount() >= m_nMaxItemCount)
{
DeleteItem(INDEX_0);
RedrawItems(0, GetItemCount()); // causes to much flicker
}
int column = 0;
POSITION pos = strlist.GetHeadPosition();
if(nIndex == INVALID)
{
nIndex = GetItemCount();
}
while(pos)
{
CString& str = strlist.GetNext(pos);
if(column == COLUMN_0)
{
SET_LV_ITEM(lvi);
lvi.mask = LVIF_TEXT;
lvi.iItem = nIndex;
lvi.pszText = str.GetBuffer(0);
lvi.cchTextMax = str.GetLength();
InsertItem(&lvi);
}
else
{
SetItemText(nIndex, column, str.GetBuffer(0));
}
column++;
}
if(nIndex > GetCountPerPage()-1)
{
CRect rect;
GetItemRect(GetTopIndex(), rect, LVIR_BOUNDS);
CSize size;
size.cx = 0;
size.cy = rect.Height();
Scroll(size);
}
}
}
|
|
|
|
|
Do you really have to redraw every item? If not, call Invalidate() on the list control to have it repaint the visible portions.
|
|
|
|
|
How to get the sent/received values from dial-up connection?
|
|
|
|
|
I'm working on the same thing
You could get a handle to the DUN window etc
Or its possible to use the performance statistics,
If you care to know more e-mail me.
Regardz
Colin Davies
taxpaid@bigfoot.com
|
|
|
|
|
What is the proper way to throw and catch exceptions without using MFC?
I am supposed to derive my own class from std::exception, use with win32 command RaiseException() or do I just create my own exception class?
Which is the preferred method?
|
|
|
|
|
What is needed to draw on a device context
CDC dc;
dc.LineTo(10,10);
i'm new to this so how should this peace of code look like ... what am i missing
|
|
|
|
|
Well where are you getting the DC from??
Typically if you use an override of the virtual CView::OnDraw(CDC* pDC) method, the framework provides you the device context. From there you simply use it!
CMyView::OnDraw(CDC* pDC)
{
pDC->MoveTo(50, 50); // Line start
pDC->LineTo(10, 10); // Line end
pDC->Ellipse(0,0,100,100); // Draw a circle.
|
|
|
|
|
isn't it possible to create my own device context to play around with ... in any member function
void MyClass::myfunc(int i,int a)
{
CDC dc;
dc.LineTo(10,10);
}
|
|
|
|
|
Usually, you will want to draw in a window's device context. As Paul said above, you will get such a DC in handlers like OnPaint() or in OnDraw() for views.
If you have a window, you can get the window's DC using GetDC(), draw into it, then use ReleaseDC().
As a rule of thumb, at least for the beginning, try to keep the painting stuf in OnDraw(). You can call from there helper functions, giving them a pointer to the provided DC (pDC is fine).
Also, you can create a "memory DC", which basically behaves like a normal DC, but you will not see the results. However, you can copy (blit) the contents of such a DC into a normal window DC. Also, you can use a memory DC to draw on a bitmap.
For example:
CDC dc;
dc.CreateCompatibleDC(NULL); // creates a mem DC compatible with the display.
... // paint here, etc.
dc.DeleteDC();
Other device context are related to printers, metafiles, etc.
|
|
|
|
|
thank you all for your replies ...
all i wanted to do is have a memory DC on which i would put a bitmap and manipulate it around and then put it on the device context i get in the OnDraw() ... the problem i ran into was that the memory context is 1x1 (as it should be i guess) but how can i do LineTo or FloodFill if it is of that size
|
|
|
|
|
You have to create a bitmap and select it in the memory DC first. Once you selected your bitmap, all drawing changes it directly.
See also the GDI section for examples of usage.
|
|
|
|
|
Add the GetDC() call from a CWnd derived class or you will have to pass it a windows handle.
void MyClass::myfunc(int i,int a)
{
CDC * pDC = GetDC();
if ( pDC )
pDC->LineTo(10,10);
}
|
|
|
|
|
What is needed to draw on a device context
CDC dc;
dc.LineTo(10,10);
i'm new to this so how should this peace of code look like ... what am i missing
|
|
|
|
|
How to make a button on a toolbar pushed in to stay that way until otherwise needed ... like ie. paint in windows where the brush stays pushed while in use
|
|
|
|
|
Give the button the TBSTYLE_CHECK style. (Note - that constant was renamed to BTNS_CHECK in SDKs that shipped after VC 6.)
|
|
|
|
|
Hi, I'm using ImageList_Duplicate() to duplicate an Image List. This works fine on Win98 however on W2K the duplicated image list is incorrect. ie. It is not an exact copy of the source Image List. So far I've only seen this on W2K with the IE5.5 Beta installed so it is possibly that the IE5.5 beta has installed a bugy common controls DLL. I've not been able to try it on W2K without the IE5.5 beta yet.
Any help much appreciated.
|
|
|
|
|
In Visual Basic,put TabCtrl ocx on the form,and you can
put other ocx on the TabCtrl ocx, but VC don't.
Mustn't I create other ocx on TabCtrl dynastily?
if so,it is too terrible? anybody know?
|
|
|
|
|
The computers my app runs on are set for 8 bit color. I am able to display images and simple
line graphics just fine. Now I want to add a dialog box which uses the same colormap. I want
to display different sections of text on the dialog in different colors with different color
backgrounds. Of course, all colors come from the same colormap as the main app.
When I override the OnCtrlColor for the dialog, I select and realize the same palette as the
application. But it does not make a difference. The colors appear wrong. Sometimes they
appear dithered. Any ideas?
Thanks,
Mike
|
|
|
|
|
Hi !!
I am facing a wiered problem . When I copy all the files (.cpp, .h . rc, all files in res & debug folder) of a VC++ application created by one pof my friendsto my PC from a different PC , the VC++ Intelligent editor is not providing me the help. Whereas if I create a blank workspace and add the project file of the copied files to this blank workspace the help is available !! Can any \body tell me WHy is this SO ?? Is there any project setting needs to be done before distributing the source code ??
Thanks in advance,
Manjunath
|
|
|
|
|
You need to also copy the .dsw and .dsp files which contain the Workspace and Project informatio. The use File|Open Workspace to open the project.
|
|
|
|
|
Whenever I have IntelliSense problems, I can usually fix it by closing the workspace, deleting the .NCB file, and then reopening the workspace.
|
|
|
|
|
Is your friend also including the .clw (class wizard ) file?
|
|
|
|
|
Greetings,
I am new to Visual C++. I would like to know the naming conventions of the controls.
For example, in the sources on this site, the button controls are called m_button1 or something.
I would like to also know what p before a variable is and what b is.
Thanks
Rob
|
|
|
|
|
The Hungarian prefixes are:
p = pointer, eg pu = pointer to a UINT
b = boolean (Microsoft uses f instead, meaning "flag". MS uses b for byte. If you use b for boolean, use by for byte.)
As for naming of controls, what I do is make the name short but descriptive. Eg, if I have a list control I might call it m_FilenameList or m_ItemList. I don't like using Hungarian for controls, but that's just my personal preference. m_listItems just seems awkward to me.
--Mike--
|
|
|
|
|
Typically I use a modified form of Hungarian Notation.
As an example a if I have a dialog with a button
resource ID of IDC_APPLY and a label of Apply, I would have a tendency to call the variable m_wndApplyButton
the "m_" means it is a member of the class (a dialog class in this case).
"wnd" most controls are actually windows of one sort or another
"Apply" which is its function
and finally "Button" because it is.
Note: The specifics of a Naming Convention are really unimportant. What is important is that there is ONLY ONE Convention, that it is well documented, it is supported by all users and it must be consistently applied to all projects.
|
|
|
|