|
BOOL FEinstellungenView::OnEraseBkgnd(CDC* pDC)
{
CRect rcClient;
GetClientRect( &rcClient );
pDC->FillRect(rcClient, &CBrush(*MyColor)); // On the click i change the MyColor Value
return TRUE;
}
Thats the easiest way i think
I found it after a long Google Research
Thanks nevertheless
|
|
|
|
|
Or you can use pDC->FillRect(rcClient, &CBrush(MyColor));
|
|
|
|
|
Hi,
try this, it worked very well by me. hope it helps
HBRUSH CPickOColorDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
{
HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
switch( nCtlColor )
{
case CTLCOLOR_BTN:
break;
case CTLCOLOR_STATIC: //if you have some static text
pDC->SetBkMode( TRANSPARENT );
return static_cast<hbrush>( m_brBack.GetSafeHandle() );
break;
case CTLCOLOR_DLG: // for the form view / dialog view
return static_cast<hbrush>( m_brBack.GetSafeHandle() );
break;
case CTLCOLOR_EDIT:
break;
}
return hbr;
}
void CPickOColorDlg::OnBnClickedButtonColor()
{
m_brBack.DeleteObject();
m_brBack.CreateSolidBrush(RGB(255,0,0));//red
Invalidate(TRUE);
}
pasnad
|
|
|
|
|
In my application when i press a button a file open dialog box with files of particular type will open and from that if i select a item and press open button in that file open dialog box i am getting an error "I_Flapp MFC Application has encountered a problem and needs to close. We are sorry for the inconvenience.".Can any one knows why this error comes and how can we rectify it.
Thanks.
|
|
|
|
|
Did you try debugging and find where exactly the error occurs? And can you post the code here?
|
|
|
|
|
I have written the code like this to open the document files when button is pressed,
static TCHAR BASED_CODE szFilter[] = "Windows Setup file (*.pdf;*.xml)|*.pdf;*.xml||";
CFileDialog oFileDlg(TRUE,"pdf","",OFN_FILEMUSTEXIST|OFN_NOCHANGEDIR, szFilter);
oFileDlg.m_ofn.lpstrTitle = "Select the Installable Application";
if(oFileDlg.DoModal() == IDOK)
{
m_install.m_strSetup = oFileDlg.GetPathName();
GetDlgItem(IDC_SETUP)->SetWindowText(m_install.m_strSetup);
}
|
|
|
|
|
This code is alright. Did you not try debugging? What is m_install? Comment the last line and see if it works.
|
|
|
|
|
when i dedugged the error is coming after that line.It is working in one system and but not in the other.
Thanks.
|
|
|
|
|
radhika28 wrote: when i dedugged the error is coming after that line.
Which line? Am I supposed to guess it?
radhika28 wrote: It is working in one system and but not in the other.
Check out the dependencies.
The nail that stands out will be hammered down
|
|
|
|
|
I asked you what is m_install. Is that a CString or char* or what? Did you try using a CString variable there, instead of a member variable?
|
|
|
|
|
After m_install.m_strSetup = oFileDlg.GetPathName();.
m_install is a Cstring variable of another class.Now i hav e defined a cString variable in the same class.
|
|
|
|
|
<br />
CString str;<br />
<br />
static TCHAR BASED_CODE szFilter[] = "Windows Setup file (*.pdf;*.xml)|*.pdf;*.xml||";<br />
<br />
CFileDialog oFileDlg(TRUE,"pdf","",OFN_FILEMUSTEXIST|OFN_NOCHANGEDIR, szFilter);<br />
oFileDlg.m_ofn.lpstrTitle = "Select the Installable Application";<br />
<br />
if(oFileDlg.DoModal() == IDOK)<br />
{<br />
str = oFileDlg.GetPathName();<br />
AfxMessageBox(str);<br />
}<br />
Do you get the path displayed properly? Does the window crash after that?
|
|
|
|
|
Now I remember, I already answered you previously. I asked you to use your debugger to provide us more information. Did you follow that advice ? Where does the code crash exactly ? What is the value returned by GetDlgItem, are you sure you don't access an NULL pointer ?
Man, I won't say it enough time: you have to learn how to use your debugger !It doesn't take a lot of time to understand how it work (for basic debugging), but this will save you hours of time (your problem could already been solved now).
|
|
|
|
|
The only answer we can give you is that you did something wrong in your program. This can happens for a million of different reasons, so without more information, you'll not get a lot of answers.
First of all: a thing that you REALLY need to do is to learn to use your debugger. You cannot imagine how faster it is to solve a problem than posting a message on a forum. Press F5 to start your debugger, this will allow you to narrow the problem a little bit more. Then, you can set breakpoints in your program with F9 and check the value of your variables.
I cannot imagine developping programs without using a debugger, it's like repairing your car without using any tools
|
|
|
|
|
The application is working in my system.But when i run it on the other system it is not coming.I have debugged the application.The error comes after the line of getting path name.
Thanks.
|
|
|
|
|
It seems this code it good maybe your problem after IDOK did you use of debugger
|
|
|
|
|
|
so this problem isnt of CFileDialog.did you use of breakpoint and what is m_install and IDC_SETUP is valid
<br />
m_install.m_strSetup = oFileDlg.GetPathName();<br />
GetDlgItem(IDC_SETUP)->SetWindowText(m_install.m_strSetup);<br />
|
|
|
|
|
m_install is a CString variable of another class.Now i have defined the variable in the same class and i have removed the edit box which displays the path and the code for that line.Now it is working.Thanks
|
|
|
|
|
So how to create editbox if it has error
|
|
|
|
|
|
This is probably the wrong forum for this question. You code looks like Cpp/CLI to me
One problem here is that your array is not typed. Why dont you use a Generic::List<char^>?
You'll probably want to loop through your collection and append each char to a StringBuilder object and then get the string from it when your done.
|
|
|
|
|
Well, thank for the help... haven't thought of that,
"....You'll probably want to loop through your collection and append each char to a StringBuilder object and then get the string from it when your done....."
"...This is probably the wrong forum for this question...." Strange .... I'm using VS2K5 VC++ and this is a Visual C++ / MFC right ???
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|
|
This code...
array^ buffer = gcnew array(10000);
is without a doubt CPP/CLI. You might be mixing it with MFC but its not standard c++ or MFC
|
|
|
|
|
My bad ....
But VS2K5 works with dotNet right??
The only programmers that are better than C programmers are those who code in 1's and 0's.....
Programm3r
|
|
|
|