|
followait wrote: Is there a function like OnInitDialog for CScrollView?
OnInitialUpdate()
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
It isn't called when it isn't in the doc-view frame.
|
|
|
|
|
So where is your view then?
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
followait wrote: It isn't called when it isn't in the doc-view frame.
It isn't called because you haven't attached the view to a document. OnInitialUpdate is called after a view is first attached to a document.
These view classes are specifically meant for document view architecture.
Nibu thomas
Software Developer
|
|
|
|
|
NOTIFYICONDATA nidData;<br />
HICON hIcon = LoadImage(...IMAGE_ICON...LR_LOADFROMFILE)<br />
if (hIcon)<br />
{<br />
nidData.hIcon = hIcon;<br />
Shell_NotifyIcon(dwMessage, &nidData);<br />
DestroyIcon(hIcon); // now can Destroy the icon? but the icon Destroy, the tray how to get the icon ?
}
|
|
|
|
|
I don't think you should be calling DestroyIcon - If you do the shell will be holding onto an invalid handle.
Steve
|
|
|
|
|
but icon not Destroy, happed leak.
now not happen something
|
|
|
|
|
Well, destroy it when your window is destroyed (WM_DESTROY handler). There can be no leak of memory associated with the icon this way UNLESS your application is terminated ungracefully, and even then most probably Windows will perform the necessary cleanup.
Not to say that a leak of several kilobytes isn't much of a problem compared to what gigabytes of software out there manage to leak...
|
|
|
|
|
Thank you very much. I only wish my code is strong and safe, and this is good custom.
|
|
|
|
|
HOW WHAT wrote: DestroyIcon(hIcon); // now can Destroy the icon? but the icon Destroy, the tray how to get the icon ?
What happens after you do that? Does the Icon get displayed in the tray.
Nibu thomas
Software Developer
|
|
|
|
|
As of now, not happen something, the icon dispalyed in the tray.
|
|
|
|
|
Take a look at the remarks section of this topic:
Click Here[^]
Nibu thomas
Software Developer
|
|
|
|
|
When you are finished using a bitmap, cursor, or icon you loaded without specifying the LR_SHARED flag, you can release its associated memory by calling one of the functions in the following table.
Resource Release function
Bitmap DeleteObject
Cursor DestroyCursor
Icon DestroyIcon
The system automatically deletes these resources when the process that created them terminates, however, calling the appropriate function saves memory and decreases the size of the process's working set.
|
|
|
|
|
So what do you think now?
Nibu thomas
Software Developer
|
|
|
|
|
Does anyone know how to instantiate an array in a __gc structure?
e.g
__gc struct epdata
{
__int61 count;
__int64 val __gc[]; // an array of integers
} x;
The compiler won't allow the array to be sized such as
__int64 val __gc[10]; // an array of integers
it gives this error message
e:\xf\Form1.h(12): error C3616: '10': a size cannot be specified in a __gc array declaration
This question came up when attempting to read data from the array that had been stored in the array previously.
e.g
x->val[0] = 2; // no error is generated on this line
__int64 y = x->val[0]; // this line gives " Object reference not set to an instance of an object."
|
|
|
|
|
You'll have to use new to allocate the array after the structure has been allocated.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
JimWDurbin wrote: x->val[0] = 2; // no error is generated on this line
Humble Request pls Post Managed C++ related Question in C++/CLI[^]
"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
|
|
|
|
|
Thanks Alok, It has been a while since I posted anything at all. I did not know that is where question on Managed C++ questions should be posted.
BTW, after a lot of hacking, the problem has been resolved.
|
|
|
|
|
What is a good size for a buffer with the multi-select option for the OpenFileName Dlg? Right now it is 0x7FFF. Too much? Too little?
- thanks
|
|
|
|
|
|
Per MSDN:
Note, when selecting multiple files, the total character limit for the file names depends on the operating system and the version of the function:
Windows 95/98/Me: (only ANSI is supported) no restriction
Windows NT4 and earlier: 32k limit
Windows 2000/XP: (ANSI) 32k limit, (Unicode) no restriction
"Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain
"There is no death, only a change of worlds." - Native American Proverb
|
|
|
|
|
*******Update********
Thanks everyone, I found the problem...I mispelled the directory during one variable initialization. Thanks again for your help.
*******Update********
Everytime I run the code below (Visual Studio .NET 2003), it tells me that a debug assertion has failed. Then when I go into the code to debug it...it goes to "filecore.cpp" and points out the error in the following filecore.cpp function....
***************
void CFile::Write(const void* lpBuf, UINT nCount)<br />
{<br />
ASSERT_VALID(this);<br />
ASSERT(m_hFile != INVALID_HANDLE_VALUE); < - - - - **Debug Assertion Error**<br />
<br />
if (nCount == 0)<br />
return;
<br />
ASSERT(lpBuf != NULL);<br />
ASSERT(AfxIsValidAddress(lpBuf, nCount, FALSE));<br />
<br />
DWORD nWritten;<br />
if (!::WriteFile(m_hFile, lpBuf, nCount, &nWritten, NULL))<br />
CFileException::ThrowOsError((LONG)::GetLastError(), m_strFileName);<br />
<br />
if (nWritten != nCount)<br />
AfxThrowFileException(CFileException::diskFull, -1, m_strFileName);<br />
}
***********
The function wherein the problem occurs is as follows...
***********
<br />
void CGCS1View::OnFileSave()<br />
{<br />
UpdateData();<br />
<br />
CGCS1Doc *pDoc = GetDocument();<br />
<br />
CreateDirectory(_T("J:\\Software Development\\Georgetown Cleaning Serivces"), NULL);<br />
<br />
CTime DateLeft, TimeLeft, DateExpected, TimeExpected;<br />
this->m_DateLeft.GetTime(DateLeft);<br />
this->m_TimeLeft.GetTime(TimeLeft);<br />
this->m_DateExpected.GetTime(DateExpected);<br />
this->m_TimeExpected.GetTime(TimeExpected);<br />
<br />
CString strDate = DateLeft.Format(_T("%Y %B"));<br />
<br />
CString strPath = CString("C:\\Documents and Settings\\user\\My Documents\\Georgetown Cleaning Services\\") + strDate;<br />
CreateDirectory(strPath, NULL);<br />
<br />
CString strReceiptNumber = this->m_ReceiptNumber;<br />
CString strFileName = this->m_ReceiptNumber + ".gcs";<br />
CString strFilePath = strPath + CString("\\") + strFileName;<br />
<br />
CFileFind fndFile;<br />
BOOL exists = fndFile.FindFile(strFilePath);<br />
<br />
if(exists == TRUE)<br />
{<br />
AfxMessageBox("A file with that receipt number exists already\n"<br />
"Please enter a different receipt number");<br />
return;<br />
}<br />
else<br />
{<br />
CString strItem1, strItem2, strItem3, strItem4;<br />
this->m_Item1.GetWindowText(strItem1);<br />
this->m_Item2.GetWindowText(strItem2);<br />
this->m_Item3.GetWindowText(strItem3);<br />
this->m_Item4.GetWindowText(strItem4);<br />
<br />
pDoc->CustomerName = m_CustomerName;<br />
pDoc->CustomerPhone = m_CustomerPhone;<br />
pDoc->DateLeft = DateLeft;<br />
pDoc->TimeLeft = TimeLeft;<br />
pDoc->DateExpected = DateExpected;<br />
pDoc->TimeExpected = TimeExpected;<br />
pDoc->ShirtsUnitPrice = m_ShirtsUnitPrice;<br />
pDoc->ShirtsQuantity = m_ShirtsQuantity;<br />
pDoc->ShirtsSubTotal = m_ShirtsSubTotal;<br />
pDoc->PantsUnitPrice = m_PantsUnitPrice;<br />
pDoc->PantsQuantity = m_PantsQuantity;<br />
pDoc->PantsSubTotal = m_PantsSubTotal;<br />
pDoc->strItem1 = strItem1;<br />
pDoc->UnitPrice1 = m_UnitPrice1;<br />
pDoc->Quantity1 = m_Quantity1;<br />
pDoc->SubTotal1 = m_SubTotal1;<br />
pDoc->strItem2 = strItem2;<br />
pDoc->UnitPrice1 = m_UnitPrice2;<br />
pDoc->Quantity2 = m_Quantity2;<br />
pDoc->SubTotal2 = m_SubTotal2;<br />
pDoc->strItem3 = strItem3;<br />
pDoc->UnitPrice3 = m_UnitPrice3;<br />
pDoc->Quantity3 = m_Quantity3;<br />
pDoc->SubTotal3 = m_SubTotal3;<br />
pDoc->strItem4 = strItem4;<br />
pDoc->UnitPrice4 = m_UnitPrice4;<br />
pDoc->Quantity4 = m_Quantity4;<br />
pDoc->SubTotal4 = m_SubTotal4;<br />
pDoc->CleaningOrder = m_CleaningOrder;<br />
pDoc->TaxRate = m_TaxRate;<br />
pDoc->TaxAmount = m_TaxAmount;<br />
pDoc->OrderTotal = m_OrderTotal;<br />
pDoc->ReceiptNumber = m_ReceiptNumber;<br />
<br />
<br />
<br />
CFile fleOrder;<br />
<br />
fleOrder.Open(strFilePath, CFile::modeCreate | CFile::modeWrite);<br />
CArchive ar(&fleOrder, CArchive::store);<br />
pDoc->Serialize(ar);<br />
<br />
ar.Close();<br />
<br />
fleOrder.Close();<br />
<br />
UpdateData(FALSE);<br />
<br />
this->OnBnClickedReset();<br />
}<br />
<br />
}
***************
Any help you can provide would be greatly appreciated.
Thanks,
-- modified at 8:39 Monday 27th February, 2006
|
|
|
|
|
It's telling you the CFile object doesn't have a valid file handle. You're not checking the return values from CreateDirectory() or CFile::Open() - one or more of those are failing.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Thanks Mike. I'm going to check it out. Since it creates the directory, it must be that the CFile::Open() method is failing...although I wonder why.
|
|
|
|
|
It tells me that my m_cause = 0 and that OS Error = m_lOsError
What does that mean? This is, of course due to the open mehtod.
Thanks for any help you can provide
|
|
|
|