|
I have been working on a project (c++) and have noticed that one of the com ports drops out for no reason (as far as I can see). Does anyone have any ideas to why a com port would drop out without an explicit command telling it to?
thanks,
mcb36
|
|
|
|
|
It could be faulty hardware. I've seen COM ports fail before.
Try running your app on a different PC and see if it does any better.
|
|
|
|
|
Recently I use the MFC's Spliter class to split main frame as like such layout ( |- ), left pane and right pane containing top and bottom sub-pane, but I want to fix the left pane size even thought user drags the vertical border between left pane and right pane.Has any body some ideals to perform that? thanks in advance!
|
|
|
|
|
Temp83 wrote: ...but I want to fix the left pane size even thought user drags the vertical border between left pane and right pane.Has any body some ideals to perform that?
See here.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
Please help me
I have problem communicating bluetooth in visual c++ MFC
|
|
|
|
|
can u detail that!where is the problem which part of teh code?
cheerz!
dont want,dont want thinking,climbing on head and jumping grass!
(venda venda ennu vicharikumbol thellayill keyaree chadunnoda pulle!)
|
|
|
|
|
mahesh_patil166 wrote: I have problem communicating bluetooth in visual c++ MFC
Hi Mahesh,
Please Elobrate your question.. How can we know which class are you using to communicate between bluetooth devices or you have proper hardware for same...
or you have get struck on a particular state!..
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
It appears that when you have a scrollbar in a dialog or property page, the scrollbar steals the WM_MOUSEWHEEL messages. If you have two scrollbars it's worse. One takes most of the messages when the mouse is over the dialog window unless the mouse is hovering over the other scrollbar. Is there any way to intercept or change this?
|
|
|
|
|
hi all,
i m working on an application where i want to create two document and views and want to pass data from one documnt to another.do i need to add childframe,view,document class to the MDI .i m not getting exact idea
sourabh jain
patni computers system
|
|
|
|
|
Hi all,
first of all thanks for this great site.
It has helped me a lot in the last weeks, but now i`m stuck in
a serious problem. I have a derived class of CListCtrl
In it is a custom draw method.
void CExtendedListCtrl::OnCustomdrawList ( NMHDR* pNMHDR, LRESULT* pResult )
{
NMLVCUSTOMDRAW* pLVCD = reinterpret_cast<NMLVCUSTOMDRAW*>( pNMHDR );
*pResult = 0;
if ( CDDS_PREPAINT == pLVCD->nmcd.dwDrawStage )
{
*pResult = CDRF_NOTIFYITEMDRAW;
}
else if ( CDDS_ITEMPREPAINT == pLVCD->nmcd.dwDrawStage )
{
int iRow = pLVCD->nmcd.dwItemSpec;
if ((int)GetItemData(iRow) == 1)
pLVCD->clrTextBk = RGB(60,179,113);
}
*pResult = CDRF_DODEFAULT;
}
This is working fine when i add a item to the extended ListCtrl over
m_List.InsertItem and then setting the itemData to m_List.SetItemdata(1)
Now i have a huge amount of data (>100000) in the extended ListCtrl and
the insertion is getting really slow.
So i want to use OnGetDispInfo to just draw the "visibles" entries.
void CEvtlParseDlg::OnGetdispinfoList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;
LV_ITEM* pItem= &(pDispInfo)->item;
if(pItem->mask & LVIF_TEXT)
{
if (pItem->iSubItem == 0)
{
pItem->mask=LVIF_TEXT | LVIF_PARAM;
pDispInfo->item.lParam=1;
lstrcpyn(pItem->pszText,"TEST",pItem->cchTextMax);
}
}
*pResult = 0;
}
This nearly works. I get the "TEST" text in my ListCtrl. OnCustomDrawList of
the extended List is still called, but the GetItemData always returns 0;
I also tried to get pLVCD->nmcd.lItemlParam but this value is also always 0
So how can i set itemData in the OnGetDispinfoList or is there only the way of using
InsertItem?
thx alot
t2x
|
|
|
|
|
t2x wrote: pDispInfo->item.lParam=1;
That doesn't change the actual item data, you're just modifying an LVITEM that the control set up for you to look at.. Call SetItemData() .
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
But SetItemData is not working.
Whenever i call it in the OnGetDispinfoList
m_List.SetItemData(pItem->iItem,1);
or in an other program part i get an ASSERTION in WINCTRL2.CPP
BOOL CListCtrl::SetItem(int nItem, int nSubItem, UINT nMask, LPCTSTR lpszItem,
int nImage, UINT nState, UINT nStateMask, LPARAM lParam)
{
ASSERT(::IsWindow(m_hWnd));
ASSERT((GetStyle() & LVS_OWNERDATA)==0); <--- This one gives me the assertion
.
.
.
I can`t imagine that there is no way to set the ItemData during the virtual ListCtrl
call OnGetdispinfoList
thx t2x
|
|
|
|
|
Oh ok, you didn't mention that you were using a virtual list control. From the docs:A virtual list-view control maintains very little item information itself. Except for the item selection and focus information, the owner of the control must manage all item information. You'll need to keep the data somewhere else, a virtual list control doesn't support per-item data.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Just to let you know... I have this exact same problem and I've yet to track down the solution.
OnGetDispInfoList() is never invoked with a request to provide LVIF_PARAM nor does the system accept the value if you set the value manually as you are doing. My only solution was to rewrite the code in OnCustomDraw() to calculate the value of the lParam member on the fly - not elegant, but workable for my application.
Surely someone out there has (a) made this work, or (b) found the MSDN webpage where Microsoft admits they just forgot to make the virtual list ctrl's ask for the lParam value. At this point I'll be happy with either (a) or (b).
Sigh...
Dan
Remember kids, we're trained professionals. Don't try this at home!
|
|
|
|
|
Hm O.K. than i have to deal with this.
This is not really nice but it works.
Another short question. Is there any chance to set the "selected" State
in the OnGetDispInfoList without calling SetItemState.
Because this is terrible slow if i want to select all items.
thx t2x
|
|
|
|
|
Gee, I don't know right off the bat. My app only needs 'single' select. You'd really think that there ought to be, then again that sort of thinking about the LPARAM value is what got us here.
Sigh... all of those programmer-hours spent cobbling together work arounds for things like this.
Later,
Dan
Remember kids, we're trained professionals. Don't try this at home!
|
|
|
|
|
I have some code that I want to split off into it's own dll. Can I have the following method in the DLL and call it from a Client, like this?
void DllFunction (std::vector<int> &B)
{
B.push_back(1);
}
----------------------
void SomeFunction ()
{
std::vector<int> A;
DllFunction(A);
}
This works fine when all the code is in the same project but when I split off the DllFunction into it's own Dll, I get errors. I get a runtime error in _CrtIsValidHeapPointer (dbgheap.c) when SomeFunction returns. I suppose the problem is that the DLL allocates the memory and the Client is trying to free it and that's bad.
So, what do people do when they want to pass an STL vector as a reference parameter to a DLL? Cannot such a basic thing as this be done? Do I have to redesign things now that the code is in a Dll? I've looked at MS Knowledge Base Q168958 but it doesn't seem to help me.
I've made sure my runtime libraries are the same for the dll and the client (/MTd), but that didn't fix the problem.
|
|
|
|
|
You should never count on being able to alloc memory in one module, and free it in another module, using the CRT. You can use a process-wide allocator like CoTaskMemAlloc() .
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi, I'm not an expert, but I recently ran across a similar problem. Try switching your projects to use the DLL version of the run-time libraries and see if that resolves the issue.
--
jthomps
|
|
|
|
|
Another solution (from Jeff's) would be to make an allocator that uses, say, CoTaskMemAlloc . Then you would create all your colloections using this allocator.
Steve
|
|
|
|
|
Try to do vector:reserve in *.exe before any push_back in *.dll to ensure all memory allocation activities are done in the executable.
Sonork 100.41263:Anthony_Yio
|
|
|
|
|
Assume the following code:
#CODEBEGINS
int main( void )
{
CCPU CPU; // For CPU querys
HLint64 Begin, End; // To keep CPU times
int i, j; // Counters
tVar<int> *tvTest; // Test material
for ( i=1 ; i<500 ; i++ ) {
for ( j=0 ; j<i ; j++ ) {
// Begin counting
Begin = CPU.rdtsc();
tvTest = new tVar<int>;
delete tvTest;
// Stop counting
End = CPU.rdtsc();
// Calculations & output
printf( "[%d:%d]:(delta)TSC: %ld\n", i, j, ( End.Hi - Begin.Hi ) + ( End.Lo - Begin.Lo ) );
}
putchar( '\n' );
}
return 0;
}
#CODEENDS
This is suppose to test how fast the computer allocs and frees a class (note: this class has no constructor). I got the following results:
[1 ]:(delta)TSC: 3234
[2 ]:(delta)TSC: 1385
[2:1]:(delta)TSC: 1212
[3:1]:(delta)TSC: 1189
[45:10]:(delta)TSC: 1230
[48:37]:(delta)TSC: 1240
[52:4]:(delta)TSC: 1571
[53:6]:(delta)TSC: 409762 // WOW!
[53:7]:(delta)TSC: 1375
[55:10]:(delta)TSC: 1296
[58:7]:(delta)TSC: 1239
[448:338]:(delta)TSC: 1177 // Almost all not shown so far are 1177
[448:339]:(delta)TSC: 10015
[448:340]:(delta)TSC: 1263
[448:341]:(delta)TSC: 1157
[448:342]:(delta)TSC: 1194 // Almost all from now on are 1194 (this only happned in one of the tests, all the others still had a HUGE majority of 1177)
Can anyone explain these small (sometimes not that small!) variations?
regards
hint_54
-- modified at 14:27 Tuesday 14th February, 2006
Oh.. I forgot, assume this is the CPU.rdtsc() function:
HLint64 CCPU::rdtsc( void )
{
HLint64 i64StampRead;
// Read time stamp counter
__asm {
rdtsc; // ReaD Time Stamp Counter
mov [i64StampRead.Lo], eax // Copy the low DWORD
mov [i64StampRead.Hi], edx // Copy the high DWORD
}
return i64StampRead;
}
regards, once again
|
|
|
|
|
hint_54 wrote: Can anyone explain these small (sometimes not that small!) variations?
Read here.
"The greatest good you can do for another is not just to share your riches but to reveal to him his own." - Benjamin Disraeli
|
|
|
|
|
"QueryPerformanceCounter returns a reasonably accurate rendering of time, at least on Intel platforms. This is because on Intel platforms it returns the contents of a "cycle counter", converted to timing units based on the processor frequency. Because the cycle counter actually counts the number of CPU cycles, it gives a reasonable approximation of real time. However, executing the same loop twice may give different results because the presence or absence of data in the cache will change the number of cycles required to execute the program. So it is at best an approximation, and you have to do some more careful statistical analysis to figure out what is really going on."
This was quoted from the link that you have provided earlier.
Does this mean it is all about cache? If so, please assume the following code then:
int main( void )
{
int *ptr, i;
for ( i=0 ; i<100 ; i++ ) {
ptr = new int;
delete ptr;
}
return 0;
}
So, after "i=0", "i" gets in the cache. After the first time it executs "ptr = new int" "ptr" gets in cache too. From now on, all the 100 cicles will use "i" and "ptr" and these are supposed to be already cached, right? The only thing that I can see that is not cached is "*i", but I never access it directly (or do I? ). So, I understand why the first values show a small variation (after the first 4 or 5 cicles it stabilizes), but I still don't understand why those variations keep showing up along the whole test (unless I'm really accessing "*i").
Anyone?
regards
hint_54
|
|
|
|
|
That's a big variation, I don't think this can be written off to the fact that Windows is not a real time OS. I'd put timing around ever line in the loop so I've got a breakdown and try to narrow down the problem.
Steve
|
|
|
|