|
mpallavi wrote:
But its so boring programming the whole day
I Know, thats why me and some programmer here learn new way of TYPING
BY the Way [OT] any buddy on YM
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
BY the Way [OT] any buddy on YM
U r so lucky.. We do not have access to YM here our company.. Only to Programming Forums.. he he
..BTW.. there also u type by ur NOSE.. its must be very slow dear..
|
|
|
|
|
|
ya sure..
see you
regards
pallavi
|
|
|
|
|
I didn't know I had so much 'control' over you .
BTW, remove the Mr., I', not that old
|
|
|
|
|
cedric moonen wrote:
I didn't know I had so much 'control' over you
Not That Much
cedric moonen wrote:
remove the Mr., I', not that old
Yeah, Cedric
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Hi all
I am using CFile class.. here is my code..
........................
void CCNPhoneDlg::OnSave()
{this->UpdateData();
CFile source;
CFile dest;
char strFilter[] = { "Log Files (*.log)|*.log|" };
CFileDialog FileDlg(FALSE, ".log", NULL, 0, strFilter);
if( source.Open("LogFile.log", CFile::modeRead | CFile::shareDenyWrite ) == FALSE )
return;
if( FileDlg.DoModal() == IDOK )
{
if( dest.Open(FileDlg.GetPathName(),CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate)==FALSE)
return;
CString fl;
fl=FileDlg.GetPathName();
char c[1000];
int len;
len=strlen("LogFile.txt");
do
{
source.Read(c,1000);
dest.Write(c,len);
}
while (!EOF);
source.Close();
dest.Close();
}
}
..................
But file is not getting created.. whats wrong with the code..?
pallavi
|
|
|
|
|
mpallavi wrote:
But file is not getting created.. whats wrong with the code..?
I was able to execute and save file with it, Your code is working fine!
<bold>- Nilesh
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
hi Nilesh..
yupp .. the code is working .. i was checking in a wrong dir..
but all the contents are not getting copied..
is your file getting copied properly?
regards
pallavi
|
|
|
|
|
I've corrected the code, try this out..
<br />
CFile source;<br />
CFile dest;<br />
char strFilter[] = { "Log Files (*.log)|*.log|" };<br />
CFileDialog FileDlg(FALSE, ".log", NULL, 0, strFilter);<br />
<br />
if( source.Open("LogFile.log", CFile::modeRead | CFile::shareDenyWrite ) == FALSE )<br />
return false;<br />
<br />
if( FileDlg.DoModal() == IDOK )<br />
{<br />
if( dest.Open(FileDlg.GetPathName(),CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate)==FALSE)<br />
return false;<br />
CString fl;<br />
fl=FileDlg.GetPathName();<br />
<br />
char c[1000];<br />
int ncount = 0;<br />
do<br />
{<br />
memset(c,0,1000);<br />
ncount = source.Read(c,1000);<br />
if(ncount > 0)<br />
dest.Write(c,ncount);<br />
}<br />
while(ncount>0);<br />
<br />
source.Close();<br />
dest.Close();<br />
}<br />
<bold>- Nilesh
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Thank you so much dear..
its working fine now..
regards
pallavi
|
|
|
|
|
Dear All,
I'm a newcomer, and now I have a problem in VC++.
I used VC6.0 to create a SDI application.
Then, defined a new user message (WM_USER +1) in CMyProjectView using macro ON_MESSAGE. Then, I write a function in CMainFrame and used SendMessage method to send message (WM_USER+1) to CMyProjectView.
Result: The message I sent couldn't receive in CMyProjectView.
But, I send a message from CMyProjectView to CMainFrame, is Ok.
Can you interpret this for me.
Thanks alot.
quangthien
|
|
|
|
|
quangcanh wrote:
Then, defined a new user message (WM_USER +1) in CMyProjectView using macro ON_MESSAGE. Then, I write a function in CMainFrame and used SendMessage method to send message (WM_USER+1) to CMyProjectView.
Result: The message I sent couldn't receive in CMyProjectView.
But, I send a message from CMyProjectView to CMainFrame, is Ok.
Have you declared TWO ON_MESSAGE Handller for WM_USER+1 , i.e. One in CMyProjectView and One in CMainFrame?
In that case, Above mentioned Behavoiur is correct as View always recieve message before MainFrame class.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Dear ThaksAlok,
I declared one handler WM_USER+1 in CMyProjectView class only, and I sent a message from CMainFrame to CMyProjectView, but in CMyProjectView couldn't receive this message.
Can you describe more clearly, if you have one project to demo, you send it to me.
Thanks and best regards!
quangthien
|
|
|
|
|
quangcanh wrote:
sent a message from CMainFrame to CMyProjectView, but in CMyProjectView couldn't receive this message.
Use CMainFrame::GetActiveView( ) to send Message i.e.
((Your View Class *) this->GetActiveView())->PostMessage(WM_USER+1,0,0);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
Check here[^]
<bold>- Nilesh
<italics>
"Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw
|
|
|
|
|
Hi,
You should understand how sendmessage and postmessage works.
If you post a message, that message is send to application message queue and mfc framework gets that message from the application message queue and dispatch it to appropriate window. Where you will define your message handlers to process the message. Windows uses virtual functions to call to your overrided functions. In case of SendMessage, that message is send to the Windows procdure not the application queue. So you won't get the message.
Thanks & Regards,
Gopal
" Action without vision is only passing time,
Vision without action is merely day dreaming,
But vision with action can change the world "
- Words from Nelson Mandela
Thanks & Regards,
Gopalakrishnan
|
|
|
|
|
I create a MFC project with Dialog based and I put a CRichEditCtrl into the dialog.
when I run the project,it has nothing.
Should I do before running the project?
Do I initialize the CRichEditCtrl?
Thank you!
|
|
|
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vclib/html/_mfc_CRichEditCtrl.asp[^]
The short version:
If you are using a rich edit control in a dialog box (regardless whether your application is SDI, MDI, or dialog-based), you must call AfxInitRichEdit once before the dialog box is displayed. A typical place to call this function is in your program's InitInstance member function. You do not need to call it for each time you display the dialog box, only the first time. You do not have to call AfxInitRichEdit if you are working with CRichEditView.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
According to your hint,the question was solved!
The window would be showed after running program.
Thank you very much!
|
|
|
|
|
Guys,
Sorry if this is a FAQ
I am looing for exampe source code of a Windows service that can listen on a given port and efficiently communicate with (possibly) multiple client.
The APP should be developped under visual C++ version 6.0 and upwards, and would preferbly have a management aplette associated with it. Desktop interaction is a definate +
Youd help is much appreiated. My e-mail is worldentropy@yahoo.co.uk
|
|
|
|
|
prof.hell wrote:
Youd help is much appreiated. My e-mail is worldentropy@yahoo.co.uk
As Mr. Archer Says
"I don't think you're going to get much help with an "email me for better understanding" post. This forum is not meant for people to do other's work. Rather we help people who are facing specific problems that they've defined during their development.
Do you have a specific question or are you looking for someone to basically write your application for you? "
Hope so you got my point
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
I'm trying to create a toolbar with 256 color icons. I tried creating an ImageList and loading the images with LoadImage, but everything I tried either show the icon's transparant parts as black or white, or it changes the colors to what I'm guessing is Window's defualt 256 color palette. So, how do you go about creating a toolbar that show icons with transparency and with it's own palette?
- thanks.
|
|
|
|
|
I am trying to use ADO in C++ and am having problems. From several sources, including the help files, I have gotten this simple means of instantiating of a Connection object:
#import "C:\Program Files\Common Files\System\ado\msado15.dll" \
rename ( "EOF", "adoEOF" )
#include "DEBUG\msado15.tlh"
#include "DEBUG\msado15.tli"
/////////////////////////////////////////////////////////////////////
//
/////////////////////////////////////////////////////////////////////
BOOL ADODB_OpenDatabase(HWND hWnd)
{
ADODB::_ConnectionPtr conn;
HRESULT hr;
BOOL bRet = FALSE;
int err;
hr = CoInitialize(NULL);
if(FAILED(hr))
{ MessageBox(hWnd, "CoInitialize() failed", "OpenDatabase", MB_OK|MB_TOPMOST);
break;
}
// Create connection. (here is where I get the error 340)........
hr = conn.CreateInstance(__uuidof(ADODB::_Connection));
if(FAILED(hr))
{ err = HRESULT_CODE(hr);
ErrorMessage("Failed to create connection", "OpenDatabase", err);
goto FINISHED;
}
// Success.......................................................
bRet = TRUE;
// Cleanup.......................................................
FINISHED:
return bRet;
}
void ErrorMessage(TCHAR *szMsg, TCHAR *szCaption, int err)
{
LPVOID lpMsgBuf = 0;
TCHAR szErr[2001];
int nError;
if(err < 1)
nError = GetLastError();
else
nError = err;
if(!nError)
wsprintf(szErr, "%s. Error: %d", szMsg, nError);
else
{
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
nError,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL);
wsprintf(szErr, "%s. Error: %d. \r%s", szMsg, nError, (LPCTSTR)lpMsgBuf);
}
MessageBox(NULL, szErr, szCaption, MB_OK|MB_TOPMOST);
}
When I try to instantiate the connection object "conn" it get a bad HRESULT that is converted to Win32 error 340 which is not defined in the help files.
Any help would be greatly appreciated.
Rick C.
Thanks
Rick C.
|
|
|
|
|
Sorry, I put this together too quickly. Here is a better (valid) ADODB_OpenDatabase function. (same problem)
BOOL ADODB_OpenDatabase(HWND hWnd)
{
ADODB::_ConnectionPtr conn;
HRESULT hr;
BOOL bRet = FALSE;
int err;
hr = CoInitialize(NULL);
if(FAILED(hr))
{ MessageBox(hWnd, "CoInitialize() failed", "OpenDatabase", MB_OK|MB_TOPMOST);
goto FINISHED;
}
// Create connection.............................................
hr = conn.CreateInstance(__uuidof(ADODB::_Connection));
if(FAILED(hr))
{ err = HRESULT_CODE(hr);
ErrorMessage("Failed to create connection", "OpenDatabase", err);
goto FINISHED;
}
// Success.......................................................
bRet = TRUE;
// Cleanup.......................................................
FINISHED:
CoUninitialize();
return bRet;
}
Thanks
Rick C.
|
|
|
|
|