|
sophia2288 wrote:
thanks a lot!
My Pleasure!
"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
|
|
|
|
|
Hello All,
Recently our VC++ application is ported to .Net. I don't the why appliaction is started crashiing.Please could any one help me on this.
Error - Buffer over run at atlsimpstr.h - IAtlStringMgr* pNewStringMgr = pData->pStringMgr->Clone();
see the Code below.
static CStringData* __cdecl CloneData( CStringData* pData )
{
CStringData* pNewData = NULL;
IAtlStringMgr* pNewStringMgr = pData->pStringMgr->Clone();
if( !pData->IsLocked() && (pNewStringMgr == pData->pStringMgr) )
{
pNewData = pData;
pNewData->AddRef();
}
}
Thanks in Advance,
Chandu
|
|
|
|
|
when using windows media player to play a ".mpg(mpeg4)"video ,i always want to capture it into a file directly from screen.but i tried lots of software such as "windows media encorder" "Snagit" ,finaly i haven't yet seen what i want.help me to solved this problem
|
|
|
|
|
atemperman wrote:
i tried lots of software such as "windows media encorder" "Snagit"
Are you looking for Software or Source code? , Please Clarify!
"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
|
|
|
|
|
I am currently teaching myself c++ as a sort of hobby. I have no prior programming experience, but will have to program in the future. I have set a short term goal of learning cpp to the point that I am able to write an application that will interface with an instant messaging client and give automatic responses to certain incoming messages. Not necessarily a full blown chatbot, nothing fancy yet, but just for the learning experience of making one running program interact with another running program. I have no idea how this is done. I'm wondering if anybody has any input on what sort of subjects I should read up on? Can anybody describe how something like this is done in general?
Anything is appreciated
|
|
|
|
|
|
Thank you much
|
|
|
|
|
Hi,
I want to know how to create a "Task scheduler service" remotlely on
another computer in a network?
Thanks.
Every new thing you learn,Gives you a new personality.
|
|
|
|
|
Code ia attached in the reply to the reply below
hi, i want to read a file for an ftp application from a remote location. so i used the CInternetFile::Read method to do so. but if i try to read more than 1 byte (say 512 bytes in one read ) then i get the number of bytes read through the return value as only. but the buffer in which i read the contents contains the numbe rof bytes specified and also contains some extra characters. eg:- i have a text file having only 42 characters when i read it by passing 50 as the number of bytes to be read to the Read method then the return value is 1 but the buffer contains the 42 bytes plus some extra characters. how can i solve this problem. Also i want to know the size of the file being copied . is there any function for the filesize. i tried using seekToEnd but it gave me an exception.
aditya
|
|
|
|
|
|
hi this is the codewhich i have written for the Download button handler
void CSmartFTP2View::OnDownload()
{
// TODO: Add your control notification handler code here
int i = m_list.GetCurSel( ) ; // get selection from list box
CString srcfile;
m_list.GetText ( i, srcfile ) ;
CString str;
CInternetFile * pfile;
CFile fp;
localtarget = localpath;
localtarget+= srcfile;
srcfile = remotepath + srcfile;
srcfile+='\0';
localtarget+='\0';
try
{
pfile = m_pftp->OpenFile(srcfile.operator LPCTSTR(), GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, 1);
fp.Open(localtarget, CFile::modeCreate |CFile::modeReadWrite);
long size = pfile->Seek(0, CFile::end);
int pos=0, writebytes=0;
while( writebytes = pfile -> Read ( (void *)str.operator LPCTSTR(), 50 )!=0 )
{
fp.Write ( str, writebytes) ;
}
MessageBox("Download Successful");
}
catch ( CInternetException * pex )
{
MessageBox ( "Error in file copy" ) ;
pex -> Delete() ;
}
pfile -> Close( ) ;
fp.Close( ) ;
}
the localtarget will contain the local path and the srcfile has the remote path eg:- ftp://homepc/test.txt
aditya
|
|
|
|
|
Read ( (void *)str.operator LPCTSTR(), 50 )!=0 )
(void *)str.operator LPCTSTR() this has to be a buffer,whose size is 50, which stores the the contents of the bytes read
pls make it TCHAR buff[50];
Read ( (LPVOID)buf, 50 )!=0 )
pfile = m_pftp->OpenFile(srcfile.operator LPCTSTR(), GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, 1);
//No need to write it like this srcfile.operator LPCTSTR()
(LPCTSTR)srcfile it will return back the pointer of the null-terminated C string contained in a CString object
|
|
|
|
|
Aditya Rao wrote:
CString str;
.
.
.
while( writebytes = pfile -> Read ( (void *)str.operator LPCTSTR(), 50 )!=0 )
Besides what sunit5 already told you about the way of using the operator (i.e.: you could just write (LPCTSTR)str instead of str.operator LPCTSTR() ) I see a far worse problem in your code.
That operator returns a constant pointer to the internal buffer of the CString object. It stops being constant because you then cast it to a (void*), but that's not the problem, either. The first problem is that you don't know the size of that buffer, and can't be sure it has enough space to hold the 50 chars you are asking to put there. You might be causing a buffer overrun with code like that. For a buffer size as small of 50, you can just allocate it as follows:
const int nBufferSize = 50;
BYTE buffer[nBufferSize];
The second problem is the way you wrote the loop condition. The count of bytes read is being compared to 0, and the result of that comparison is then assigned to writebytes. I'm sure that's not what you meant to write. You need to add some parenthesis to change the order of evaluation.
So, try changing the loop to the following and see if that helps,
const int nBufferSize = 50;
BYTE buffer[nBufferSize];
while ((writebytes = pfile->Read((void *)buffer, nBufferSize)) != 0)
{
fp.Write(buffer, writebytes);
}
Hope that helps,
On another note, please send your response, if any, posting again to the forum, and not by mail.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
hi ,
thanks jose . what you said was write, the result of the comparison was being assigned to the writebytes. i changed that and it is working fine. i removed the operator as sunit5 had told and now everything is working fine.
in same application i want to add drag and drop from the remote location to the local directories. for this i am using two list controls ( one for each). can you tell how to list the contents of the drives in the list controls ( for the local ones). and i am not able to use the combo box in my application ( my application is a SDI application with the view class derived from CFormView. Is that a constraint for using combo box. i get an exception everytime i am trying to add something in the combo box) .
thanks
aditya
|
|
|
|
|
Aditya Rao wrote:
can you tell how to list the contents of the drives in the list controls ( for the local ones).
To obtain the files in a given directory, you can use FindFirstFile[^], FindNextFile[^], and FindClose[^]. For each file you find you can add an item to the list.
Aditya Rao wrote:
and i am not able to use the combo box in my application ( my application is a SDI application with the view class derived from CFormView. Is that a constraint for using combo box. i get an exception everytime i am trying to add something in the combo box
I don't think it has anything to do with your application being SDI or your view being a CFormView. Rather, the problem may be at what point in time you are trying to access the combobox. I seem to remember reading in some other post that you are trying to add an item to the combobox from your view's OnCreate function. At that point, the combobox is most likely not already created, and thus you won't be able to add any item. If that's the case, try accessing the combobox from your view's OnInitialUpdate , after calling the base class implementation.
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
|
Ivan Cachicatari wrote:
How to hide/show items of CMenu in runtime?
For that you have to Dynamically Delete them and Then Add them again Runtime!, But remember during addition and deletion there ID should be persistence!.
See MSDN for Help of CMenu::RemoveMenu and CMenu::ModifyMenu
"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
|
|
|
|
|
CMenu *pMenu=GetMenu();
pMenu->EnableMenuItem(ID_SEARCHINLISTCONTINUE, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED);
pMenu->EnableMenuItem( ID_COMEBACK_MBR, MF_BYCOMMAND | MF_ENABLED);
|
|
|
|
|
Hi all, I have a call to GetConsoleWindow() in my program. According to the MSDN I define the _WIN32_WINNT >= 0x0500, and I also include the windows.h header. But the error saying undeclared identifier on the GetConsoleWindow() still appears when I compile. I am compiling the code under Windows 2000 Professional and the macro defined should be corret according to the MSDN. Can anyone tell me what am I doing wrong and how can I fix it? Thanks.
|
|
|
|
|
chiyinhk wrote:
Can anyone tell me what am I doing wrong and how can I fix it?
How and where did you define _WIN32_WINNT ?
Where are you including windows.h ?
--
jlr
http://jlamas.blogspot.com/[^]
|
|
|
|
|
|
D3DXCreateTextureFromFile(g_pD3DDevice,"Texture.bmp",&g_pTexture);
如果要把讀.bmp改成讀CBitmap的話,要如何改?
How to I change that input .bmp replace as input CBitmap For CreateTexture?
|
|
|
|
|
Hello,
I am a newbie to MFC programming in VC++. I can't seem to create more than one splitter in my MFC application.
I need to create a window similar to windows explorer but on the right I want 2 panes not 1. So instead of the right pane I want 2 horizontal panes (one on top of the other). Ultimately what I want to do is:
1)display a directory tree in the left pane
2)display files and/or directories (of selected directory from tree) in the right-top pane.
3)display contents of selected file (from above pane) in right-bottom pane.
So I can get the first vertical splitter - Visual Studio actually makes it for me cause in the application creation wizard, under visual interface features, for toolbars i selected "standard docking" with "browser style". But I can't seem to add another one.
I would appreciate if anyone could tell me how to code for this second splitter and where to code this (what class and function).
TraileR ParK LifE 4Ever >:{
|
|
|
|
|
Add another CSplitterWnd variable to your CMainFrame class, e.g. m_RightSplitter.
Replace CMainFrame::OnCreateClient with code similar to:
if (!m_wndSplitter.CreateStatic(this, 1, 2))
{
m_wndSplitter.DestroyWindow();
return FALSE;
}
if( ! m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), pContext) )
return(FALSE);
m_RightSplitter.CreateStatic( &m_wndSplitter, 2, 1, WS_CHILD | WS_VISIBLE, m_wndSplitter.IdFromRowCol(0,1) );
if( ! m_RightSplitter.CreateView(0, 0, RUNTIME_CLASS(CTopRightView), CSize(100, 100), pContext) ||
! m_RightSplitter.CreateView(1, 0, RUNTIME_CLASS(CBottomRightView), CSize(100, 100), pContext) )
{
return(FALSE);
}
|
|
|
|
|
Hi Bill,
Thanks for the reply. When I try your code I get these errors :
error: C2039: 'classCTopRightView': is not a member of 'CTopRightView'
error: C2065: 'classCTopRightView': undeclared identifier
<<another 2="" errors="" like="" above="" but="" relating="" to="" cbottomrightview="">>
I added CTopRightView and CBottomRightView as 'Generic C++ classes' (did not code them though - dont know how ). I have no idea why its adding the word 'class' in front of the 2 class names.
TraileR ParK LifE 4Ever >:{
|
|
|
|
|