|
Then you simply have to make sure that your edit-control is created before you call SetWindowText() .
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
|
pWnd = GetDlgItem(IDC_EDIT1);
if(::IsWindow(pWnd->GetSafeHWND()))
pWnd->SetWindowText("text");
This should work.
But I suggest you creating a function in a dialog that will do this thing for you, read my post above.
regards
modified 12-Sep-18 21:01pm.
|
|
|
|
|
Okay, with this code I don't get the error, but I never get the text either, because it seems that it's never a window. Why? I have created the modeless dialog with Create:
BOOL bCreaDialog=pDialog->Create(IDD_DIALOG2,this);
I have tried with the function in the dialog code, but I have the same problem. No change. It seems that the control does not exist????????
ANy ideas, pleazzze!
|
|
|
|
|
Have a IsInitialized() function in your dialog-class, returning a bool . That bool variable is set to false in the constructor, to true at the end of OnInitDialog() .
Now, before you call SetWindowText() you check that IsInitialized() is true.
Better still, you use the 'Gregor S method'.
My opinions may have changed, but not the fact that I am right.
|
|
|
|
|
|
Using MSDEV6 I run a tool, redirecting the tools standard output to the MSDEV output pane. I find this output pane is limited in the number of lines (a few thousand, as it seems).
Does anyone know what the limit is, and more to the point does anyone know how to increase the number of lines the output pane can hold?
TIA
Bernd
|
|
|
|
|
Hi,
I have to pass a BSTR string which is read from a xml file(using simple C-style fopen,fgetws methods) to a COM method. Within the COM method this BSTR string is to be passed further to a method that takes _bstr_t as a parameter. The problem arises when the BSTR string is to be passed further to the method contained within the COM method. The conversion from BSTR to _bstr_t converts only a portion of the string and not the complete string.
Since _bstr_t is just a wrapper over BSTR, it must take BSTR and form a object of _bstr_t,but the object is not showing the complete string passed to it. How do I solve this problem??
Thanks and Regards,
Abhishek.
Learning is a never ending process of Life.
|
|
|
|
|
Try using the BSTR in the _bstr_t's constructor, e.g. _bstr_t stuff(/*BSTR here*/);
This should solve your problem
When I was young my mother told me to clean up my room, I told her -1!
|
|
|
|
|
In MFC, I want to pass an IP ADDRESS to the next dialog. But there are some problems. I am creating a variable (CString ipad) in CProjDoc then
DWORD m_ipsource;
CView* v;
CProj1Doc* pd=GetDocument();
ASSERT_VALID(pd);
m_add.GetAddress(m_ipsource ) ;
pd->ipad=m_ipsource;
class2 c2;
CDialog::OnOK();
c2.DoModal();
Plz help me out or tell me a better way of doing so.
Reply me soon
|
|
|
|
|
Use a private member within your CProj1Doc class for your CString ipad variable, and implement a getter and setter method for it; then you can access the member within your class2 like this: m_newcstring = pd->Getipad();
When I was young my mother told me to clean up my room, I told her -1!
|
|
|
|
|
Hi All,
First Off, I've been reading the articles here for a while, but have never ventured as far as making a post. So I should say thanx to all for some exceedingly good articles, they have helped me a lot.
Now the fawning is out of the way .. My Question....
I'm building from the command line using .NET with a batch file.
"C:\Program Files\Microsoft Visual Studio .NET\Common7\IDE\devenv.exe" "d:\Dev\proj\proj.sln" /build "All Debug" /out "d:\Dev\proj\proj.txt"<br />
type "d:\Dev\proj\proj.txt"
Unfortunaly this does not allow me to see the log file being generated until the build is finished, even various tail utils fail to open the file (I'm assuming due to the file being held open by .NET).
I'm sure VC6 outputted to stdout, but .NET does not, any ideas how I could get to see an output in progress?
Thanx
DAve
|
|
|
|
|
dear all,
i'm getting this exception while debugging in debug window :-
First-chance exception in Schd Tasks_D.exe: 0xC0000005: Access Violation.
when a function in my program returns FALSE.
but the programs runs successfully.
if the function returns true, i do not get this exception and program still runs successfully.
i don't know why
plz. help
regards
|
|
|
|
|
The Discription you gave is very Abstract.Generally "0xC0000005: Access Violation." error arises due to many reasons..one of that is invalid memory access or looking into other process's memory with having sufficient privileges.Give some more details..
|
|
|
|
|
following is the piece of code
(i check File Modification Time Of a File With Another Time which comes from an INI File and return TRUE / FALSE accordingly)
BOOL CreateTasks()
{
BOOL bret;
DWORD dwError;
CErrorLog oErr;
CConfig oConf;
CString sTCDate(oConf.GetTaskCreationStamp());
int len = sTCDate.GetLength();
if ( len = 12 )
{
SYSTEMTIME stTCStamp;
FILETIME ftTCStamp;
try
{
stTCStamp.wYear = (WORD)atol (sTCDate.Mid (0,4) );
stTCStamp.wMonth = (WORD)atol( sTCDate.Mid (4,2) );
stTCStamp.wDay = (WORD)atol(sTCDate.Mid (6,2) );
stTCStamp.wHour = (WORD)atol(sTCDate.Mid (8,2) );
stTCStamp.wMinute = (WORD)atol( sTCDate.Mid (10,2) );
stTCStamp.wSecond =0;
stTCStamp.wMilliseconds =0;
//stTCStamp.wDayOfWeek = 2;
//bret = SystemTimeToTzSpecificLocalTime(NULL, &stTCStamp, &stTCStamp);
bret = SystemTimeToFileTime(&stTCStamp , &ftTCStamp);
dwError = GetLastError();
FILETIME ftModTime;
CString filename = oConf.InputFilePath();
filename.ReleaseBuffer();
HANDLE hFile = CreateFile(filename,GENERIC_READ,FILE_SHARE_READ | FILE_SHARE_WRITE,0,OPEN_EXISTING,0,0);
bret = GetFileTime(hFile,NULL,NULL, &ftModTime);
bret = FileTimeToSystemTime(&ftModTime , &stTCStamp);
bret = SystemTimeToTzSpecificLocalTime(NULL, &stTCStamp, &stTCStamp);
bret = CompareFileTime(&ftTCStamp, &ftModTime);
dwError = GetLastError();
CloseHandle(hFile);
}
catch(...)
{
oErr.LogErrors(-1, "Exception Occurred While Comparing Modification Time For Input File With Value In Config File. Deleting And Re-Creating Tasks.");
return false;
}
}
else
{
oErr.LogErrors(-1, "Invalid Value Specified For TimeStamp In Config File. Deleting And Re-Creating Tasks."); return FALSE;
}
if (bret < 0)
{
oErr.LogErrors(-1, "Input File Modified. Re-Creating Tasks.");
return FALSE;
}
else
{
oErr.LogErrors(-1, "\n\r\nInput File UnModified. Tasks Not Re-Created.\n\r\n*********************************************************\n\r\n");
return TRUE;
}
}
sorry for the indentation
but i get error where function returns TRUE (last 3rd line of the code)
i hope now u can help me out
regards
|
|
|
|
|
Hello,
I'm looking for the mean to open a dialog which let the user to select a directory. I want a similar dialog box than the one of Winzip when it ask the user to select the folder in a tree, to extract files.
Is there a class available in MFC?
Thanks
|
|
|
|
|
|
CString result;
TCHAR rootPath[MAX_PATH];
BROWSEINFO bi;
LPITEMIDLIST pidl;
LPMALLOC pMalloc;
if (SUCCEEDED(SHGetMalloc(&pMalloc)))
{
ZeroMemory(&bi,sizeof(bi));
bi.hwndOwner = NULL;
bi.pszDisplayName = 0;
bi.lpszTitle="Choose directory";
bi.pidlRoot = 0;
bi.ulFlags = BIF_RETURNONLYFSDIRS | BIF_DONTGOBELOWDOMAIN;
pidl = SHBrowseForFolder(&bi);
if (pidl)
{
if (SHGetPathFromIDList(pidl,rootPath))
{
result=rootPath; }
pMalloc->Free(pidl);
pMalloc->Release();
}
}
and you have the path in variable result.
Adapted from Mike's FAQ. [^]
~RaGE();
|
|
|
|
|
Oh yes, thanks a lot every one.
|
|
|
|
|
Iam doing a MFC project .I need to launch the diaolog box which prompts the user to create the DSN ( which is normally done by manually clicking control panel->Administrative Tools->ODBC).
How do i launch the Dialog box which prompts the user to create a new USER DSN .
"Nothing worthwhile is ever achived without Deep thought and hardwork "-JRD Tata
|
|
|
|
|
From the top of my head there are a couple of ways to do it:
- SQLDriverConnect() in the ODBC API
- CDatabase::Open() / OpenEx()
It is probably possible to get it from other database APIs as well...
Hope it helps!
|
|
|
|
|
HJo,
CDatabase::Open gives an option to OPEN .But it also gives an option to SELECT the DSN too .WHat i require is the dialog box which prompts the user to ADD,Remove ,COnfigure DSNs.
ANyway ,thanks a lot for the suggestion
|
|
|
|
|
Check out the function named ConfigDSN
Regards,
BB
|
|
|
|
|
Hi I am looking to send my own udp packet
please anyone can help me wih code or website any helping material.
Reply me soon
|
|
|
|
|
What's wrong with send or sendto ?
Not that I see how this connects to VisualC++?
|
|
|
|