|
What is the value of GetUpperBound ?
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
In Adding Function (I added 2 items to array):
GetSize() is 2, and GetUpperBound() is 1
In Using Function:
GetSize() is 0, and GetUpperBound() is -1
Best Regards,
Hadi
|
|
|
|
|
Are you absolutely sure that the functions are called in this order? By any chance are you not clearing the array between the calls? (this is weired)
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
Yes, I'm sure ...
As you can see the code is so simple, and I didn't clear any item ...
Best Regards,
Hadi
|
|
|
|
|
Got it! Most of the times, we have to read MFC's source code to know whais is happening. Look:
AFX_INLINE int CArray<TYPE, ARG_TYPE>::Add(ARG_TYPE newElement)
{ int nIndex = m_nSize;
SetAtGrow(nIndex, newElement);
return nIndex; }
.
.
.
template<class TYPE, class ARG_TYPE>
void CArray<TYPE, ARG_TYPE>::SetAtGrow(int nIndex, ARG_TYPE newElement)
{
ASSERT_VALID(this);
ASSERT(nIndex >= 0);
if (nIndex >= m_nSize)
SetSize(nIndex+1, -1);
m_pData[nIndex] = newElement;
}
The code is using a reference type (ARG_TYPE ) to add the objects, that you are passing as unnamed temporaries (when are these being deleted?). Try something like this:
void CMyDialog::SomeFunc1()
{
SomeStruct a(0,0);
a = SomeStruct( 1, 2 );
m_MrOdd.Add( a );
a = SomeStruct( 10, 2 );
m_MrOdd.Add( a );
a = SomeStruct( 1, 212 );
m_MrOdd.Add( a );
}
I know it looks odd, but try it.
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
I tried this way:
OrderItems item(0, 0);<br />
item = OrderItems( 10, 96 );<br />
m_OrderItems.Add( item );<br />
item = OrderItems( 5, 13 );<br />
m_OrderItems.Add( item );
But ......
Regards,
Hadi
|
|
|
|
|
Man, this is maddening! What SDK are you using?
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
Yes I know but what can i say ?
I'm using eVC++ 4.0 SP3, PPC 2003 SDK, WinCE 4.2 SDK is also installed.
PS: I just stop the project, don't know what the hell is this
Anyway thanks alot for your time
Regards,
Hadi
|
|
|
|
|
I forgot to say that i got thease warnings in compiling:
e:\windows ce tools\wce420\pocket pc 2003\mfc\include\afxtempl.h(65) : warning C4291: 'void *__cdecl operator new(unsigned int,void *)' : no matching operator delete found; memory will not be freed if initialization throws an exception<br />
e:\windows ce tools\wce420\pocket pc 2003\mfc\include\wcealt.h(235) : see declaration of 'new'<br />
e:\windows ce tools\wce420\pocket pc 2003\mfc\include\afxtempl.h(334) : see reference to function template instantiation 'void __cdecl ConstructElements(class OrderItems *,int)' being compiled<br />
OrderListDialog.cpp<br />
e:\windows ce tools\wce420\pocket pc 2003\mfc\include\afxtempl.h(65) : warning C4291: 'void *__cdecl operator new(unsigned int,void *)' : no matching operator delete found; memory will not be freed if initialization throws an exception<br />
e:\windows ce tools\wce420\pocket pc 2003\mfc\include\wcealt.h(235) : see declaration of 'new'<br />
e:\windows ce tools\wce420\pocket pc 2003\mfc\include\afxtempl.h(334) : see reference to function template instantiation 'void __cdecl ConstructElements(class OrderItems *,int)' being compiled<br />
ReportPage.cpp<br />
ShamsiDate.cpp<br />
Visitor.cpp<br />
e:\windows ce tools\wce420\pocket pc 2003\mfc\include\afxtempl.h(65) : warning C4291: 'void *__cdecl operator new(unsigned int,void *)' : no matching operator delete found; memory will not be freed if initialization throws an exception<br />
e:\windows ce tools\wce420\pocket pc 2003\mfc\include\wcealt.h(235) : see declaration of 'new'<br />
e:\windows ce tools\wce420\pocket pc 2003\mfc\include\afxtempl.h(334) : see reference to function template instantiation 'void __cdecl ConstructElements(class OrderItems *,int)' being compiled<br />
Generating Code...<br />
Linking...
|
|
|
|
|
This may well be the source of this problem. To diagnose it, I would have to take a look at your entire project.
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
Here's the story:
class OrderItems<br />
{<br />
public:<br />
OrderItems(){}<br />
OrderItems(int code, int count)<br />
{<br />
m_nCode = code; <br />
m_nCount = count;<br />
}<br />
<br />
int m_nCode;<br />
int m_nCount;<br />
};<br />
<br />
class CMainPage : public CPropertyPage<br />
{<br />
.<br />
.<br />
.<br />
void UseOrders();
<br />
public:<br />
CArray < OrderItems, OrderItems& > m_OrderItems;<br />
}
And somewhere, in one of CMainPage methods I show another dialog and i add the items in that:
void COrderListDialog::OnOK() <br />
{<br />
CMainPage* dlgMain = (CMainPage*) GetParent();<br />
<br />
OrderItems item(0, 0);<br />
item = OrderItems( 10, 96 );<br />
dlgMain->m_OrderItems.Add( item );<br />
item = OrderItems( 5, 13 );<br />
dlgMain->m_OrderItems.Add( item );<br />
<br />
CDialog::OnOK();<br />
}
And then when i back to Main form i call UseOrders() to read the items but the problem occrues
I hope it's clear ...
Regards,
Hadi
|
|
|
|
|
Please make sure that this:
CMainPage* dlgMain = (CMainPage*) GetParent();
does return the pointer you want. If not, all is explained...
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
Yessss, That's it
You solved the problem ! Thank you very much !
I changed code to this:
CAppSheet *pAppSheet = (CAppSheet *) GetParent();<br />
CMainPage *dlgMain = (CMainPage *) pAppSheet->GetPage(0);
And now it works fine ...
Best Regards,
Hadi
|
|
|
|
|
I did some new tests on the code that the results are strange too.
1- I declared m_OrderItems as a pointer variable and then use new, when i want to add items it shows me an error: "Out Of Memory.", But the program doesn't crash.
2- I used vector instead of CArray and i get same result. (No Item !)
Regards,
Hadi
|
|
|
|
|
Hey all, I'm working with a Phillips LPC2129 chip using a Keil compiler. In viewing the example code supplied by Keil, I noticed that they returned an 'int' from a call to a function sending a char out a UART configured as ab RS232 port.
To write to the UART the following is requiredL U1THR = <the char="" to="" be="" written="">.
The problem I have is that in the sample code provided by Keil they return that value in the 'putchar' call and I have no clue how to determine the value of the return. Moreover the manner in which a byte is written to the UART is a register write, not a function call. For example:
return( U1THR = ch );
where ch is the char to be sent. Regardless of what value ch = the return value is 'H' (0x48). I reckon my question lies in how to determine the return value of an assignment?
-any got any input on this?
---------------------------------------------
Help... I'm embedded and I can't get out!
It's amazine how simeple life can be when one get's his head out of his ass...embly
If they don't get the basic research and learning skills down then they'll end up having a very hard life (Either that or they'll become managers) - Micheal P Butler
|
|
|
|
|
is there any free IDE for the .net compact framework?
|
|
|
|
|
Hi,
I'm developing an application using vb.net for PDA's. How should i store the data in the pocket PC access db. .NET CF does not have classes to support this.
|
|
|
|
|
Check out InTheHand's website[^].
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
HI
I would like to add AfterCollapse handler to the treeView object using compact framework. However, it seems that CF does not support aftercollaspse event handle. Is there any other ways to add this event handler?
Thanks~
|
|
|
|
|
Hi folks,
How can I change the BackColor of a ListViewItem in a ListView Control in .NET Compact Framework? I know that the ListViewItem.BackColor Property is available on "Desktop" .NET.
|
|
|
|
|
I am trying to write/read from a .dat file as part of a much larger C# application. The application was written using the .Net Compact Framework, and everything runs fine on my WinXp desktop. However, I am having trouble writing to file on the Pocket Pc, because I know very little about their directory structure. I would like the file I am writing to to be someplace where multiple users can access it, so not in My Documents. So my question is: what should i change this line System.IO.StreamReader file = new System.IO.StreamReader("c:\\mobile.dat"); to, in order not to get this exception A managed DirectoryNotFoundException occurred at Application::Run+0xf. I tried using "\\mobile.dat", but to no avail.
Thanks,
Justin
|
|
|
|
|
The pocketpc does not use multiple user folders like windows.
The "\My Documents" folder is accessible by anyone using the PDA.
(Also, there are no drive letters)
"For all of our languages, we cannot communicate" - Christy Moore, Natives
|
|
|
|
|
Hi all,
I would like to store a BLOB ( signature item ) in SQLCE. I followed the steps given in MSDN sites. Application stops when I encounter the declaration of ISequentialStream interface. In the ssceoledb.h, there is no implemenation of ISequentialstream or Ilockbytes. I am using SQLCE 2.0 and PocketPc 2002 emulation as well as device.
Please help
I tried with the latest download of the header from Microsoft site. Yet it is the same as wht i have now. Please indicate me where do I fail.
Thanks in advance
Mallee
|
|
|
|
|
Please wait for my upcoming article about this subject. It should be published here in a couple of days.
Regards,
João Paulo Figueira
Embedded MVP
|
|
|
|
|
Hi Paulo,
Thanks for ur interest in helping me. But since it is very urgent I am forced to ask you the help immediately.
Let me explain in brief as wht i have done.
1) I call GetSignature method which will return a single row with the BLOB item (IMAGE datatype) as the first and only column in the rowset. The input to this method is an object whose class definition is as follows:
public:
unsigned char m_SignatureData[8192];
unsigned int m_SignatureLength;
/********************************************************************/
This m_SignatureData array stores the activated pixels constituting the IMAGE drawn on the screen.
2) GetSignature after retrieving the rowset will call update signature. The empty BLOB item is now filled with this m_SignatureData array . m_SignatureData array is actually converted into ISequentialStream pointer and then only passed to the SetData method of the IRowsetChange.
I have few questions
1) Which HROW is to be used in the IROwsetChange::SetData method ?
2) Which Accessor interface is to be used ? (One associated with the IRowset or IRowsetChange)?
Please help. (although the mail is lengthy)
void CTransactionRec::GetSignature(CSignature *m_Signature)
{
HRESULT m_QueryResult= NOERROR;
CString szQuery=L"select Signature from tblTransaction where Type='"+ m_stType +"'";
m_QueryResult = m_DbConnection.m_pIDBCrtCmd->CreateCommand(NULL,IID_ICommandText,(IUnknown**)&m_pICmdTextForList);
m_QueryResult = m_pICmdTextForList->SetCommandText(DBGUID_SQL,szQuery);
if(!FAILED(m_QueryResult)) {
if(!FAILED(m_pICmdTextForList->Execute(NULL,IID_IRowset,NULL,NULL,(IUnknown**)&m_pIRowset))) {
UpdateSignature(m_Signature);
}
}
else {
MessageBox(GetActiveWindow(),L"Query not executed",L"Database Session",0);
}
return ;
}
/**********************************************************************/
HRESULT CTransactionRec::UpdateSignature(CSignature *m_Signature)
{
IRowsetChange * pIRowsetChange;
IAccessor * pIAccessor;
ISequentialStream *pISeqStr;
HROW hrow;
HROW *pRows = &hrow;
ULONG lNumRowsRetrieved = 0;
HACCESSOR hAccessor;
DBBINDSTATUS rgStatus[1];
DBOBJECT ObjectStruct;
ObjectStruct.dwFlags = STGM_READWRITE ;
ObjectStruct.iid = IID_ISequentialStream;
DBBINDING rgBinding[1] = {
1, // Column 1
0, // Offset to data
sizeof(IUnknown*), // obLength length field
0, // Ignore status field
NULL, // No type info
&ObjectStruct, // Object structure
NULL, // Ignore binding extension
DBPART_VALUE|DBPART_LENGTH, // Bind value and length
DBMEMOWNER_CLIENTOWNED, // Consumer owned memory
DBPARAMIO_NOTPARAM, // Not a parameter binding
0, // Ignore maxlength
0, // Reserved
DBTYPE_IUNKNOWN, // Type DBTYPE_IUNKNOWN
0, // Precision not applicable
0, // Scale not applicable
};
m_pIRowset->QueryInterface(IID_IAccessor, (void**) &pIAccessor);
pIAccessor->CreateAccessor(DBACCESSOR_ROWDATA, 1, rgBinding, sizeof(IUnknown *),&hAccessor,
NULL);
pIAccessor->Release();
m_pIRowset->GetNextRows(NULL,
0,
1,
&lNumRowsRetrieved,
&pRows);
BYTE* pData=(BYTE*)CoTaskMemAlloc(sizeof(IUnknown*)+sizeof(ULONG));
// Value - pass ISequentialStream pointer to the provider
pISeqStr = *(ISequentialStream **)(m_Signature->m_SignatureData);
*(ISequentialStream**)(pData+rgBinding[0].obValue)=pISeqStr;
// LENGTH - Some providers need to know the length of the
// stream ahead of time...
*(ULONG*)(pData+rgBinding[0].obLength)=(ULONG)m_Signature->m_SignatureLength;
// SetData - The provider will then do an ISequentialStream::Read
// on the pISeqStr pointer passed in...
pIRowsetChange->SetData(*pRows, hAccessor, pData);
CoTaskMemFree(pData);
return 0;
}
Thank You
Mallee
|
|
|
|
|