|
Thank you. That was the problem. It works now.
|
|
|
|
|
Hello,
I have a CMDIChildWnd which has CRichEditCtrl window over it.Now there are 4 windows of CRichEditCtrl on CMDIChildWnd.
When these CRichEditCrl windows appear on the CMDIChildWnd the background color of CMDIChildWNd changes or sometimes whatever is in the background of the window is seen on the window.
This problem is not on my PC but when i transfer my .exe on another PC then there is a problem
Prithaa
|
|
|
|
|
I'm not sure what your problem is, but in general you should not create windows directly on CMDIChildWnd. Try making your own view class inheriting from CRichEditView, and then put then in the CChildFrame using splitters. There are plenty of resources searchable on CSplitterWnd, including loads on CP.
If you do things in a standard way, it increases their chances of working. I break the rules too, but you need to do it with your eyes open, and only if you can't avoid it.
Good luck,
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job!
|
|
|
|
|
Hello,
Thanks for your reply.
Your explanation was very useful.
Let me try to explain the problem.
I have a project without Doc-View Architecture and the child window is created typically with the CreateNewChild().
Now I have a CView derived class and the OnDraw of this CView class displays text on the child window.
Also the CRichEditCtrl is displayed on the screen. This works fine with my PC.
But when I transfer the application it doesnt work. On the other PC when the childwindow opens it opens properly but when the window is resized the childwindow displays the contents that are there on the background of the child window.
For now lets forget CRichEditCtrl.
When I resize the childwindow should special care be taken to redraw the background of the window and I have not done that.
Any ideas of the problem.
Thanks
Prithaa
|
|
|
|
|
There are user settings like redraw-window-when-dragging that may be different from pc-pc, and from user-user, so it's perfectly possible to see differing behaviour.
Are you handling WM_ERASEBKGND in your view?
Have you done anything strange in PreCreateWindow to change the WNDCLASS of the view to use a NULL brush?
Can you make a brand new project, and in the new view's OnDraw, do the following:
void CMyNewView::OnDraw (CDC *dc)
{
CRect rc;
GetClientRect (&rc);
dc->FillSolidRect (&rc, RGB(255,0,0));
dc->MoveTo (rc.TopLeft ());
dc->LineTo (rc.BottonRight ());
}
This is from memory, so you many need the odd change. But this should made a solid red view, with a line from one corner to the other.
If this works (and it had better!) on both PCs, then you are doing something "clever" that is breaking it in your application. Just comment out loads of code, see when things start working, and work your way forward again.
Iain.
In the process of moving to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Hello,
Thanks for this wonderful insight.I ll check all your points.
Prithaa
|
|
|
|
|
Hi,
I have created Button on my Dialog Box using following code.
CButton *m_myButton;
m_myButton = new CButton();
m_myButton->Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(800,y1,900,(y1+25)),this, 1);
How should I add Event handler to this button.
|
|
|
|
|
I think you can use CMyButton instead of CButton:
class CMyButton: public CButton{
};
you can add Event handler(massage handler) to this class.
|
|
|
|
|
Do I need to insert a class for an event?no.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
one easy way is to create a button at design time, and double click on it to add the handler to know what all is needed..
Otherwise also, it is not a mammoth task. You have to declare a function, define it and add an entry for the button click to the message map.
Also you may be interested ON_CONTROL_RANGE
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
modified on Tuesday, April 14, 2009 4:02 AM
|
|
|
|
|
thanks for your reply.I have declared one function.I have added entry in message map.
It is working for me.
|
|
|
|
|
You can insert this code on your code and then if you want you can make your button.
#define IDC_DYNAMICBUTTON 3000
BEGIN_MESSAGE_MAP(CMFCDlg, CDialog)
ON_BN_CLICKED(IDC_DYNAMICBUTTON,&CMFCDlg::OnBnClickedbutton)
END_MESSAGE_MAP()
void CMFCDlg::OnBnClickedbutton()
{
}
//header file
public:
afx_msg void OnBnClickedbutton();
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
I need to catch the 0xC0000005 Exception in my code. I've tried try{}catch(CException *e){}, but it didn't work.
|
|
|
|
|
I think you are on the look out for First and Second chance exception[^]
You need to google first, if you have "It's urgent please" mentioned in your question.
_AnShUmAn_
|
|
|
|
|
Well, I've already searched Google, And I found using SEH could resolve this problem. But in my case, the code which throw the Exception is a dll. So the SEH didn't work for me.
|
|
|
|
|
normal C++ not handling "0xC0000005 Access Violation Error"" exception, you need to give more compiler option to handle it.
but you can try "__try __except", exception handling of C, it will help you. Usage[^]
Parag Patel
|
|
|
|
|
Thanks for your suggestion!
I tried it before, but it didn't work. Anyway, I found it is better to fix this problem in the dll file which throw the exception using __try__catch.
|
|
|
|
|
I am writing a code to do a long time draw like:
void MyDialog::DoSlowDraw(DWORD tDelay){
while(notFinished){
DrawNextLine();
Sleep(tDelay);
}
}
And it's better to have a "cancel button" because it may take a long time according to tDelay.
---------------------
My try:
To handle "cancle button clicked Message" , Drawing must be done by another thread.
UINT DrawProc( LPVOID pParam )
{
CMyDialog* pform = (CMyDialog*)pParam;
int timeDelay = pform->timeD;
Line_list* pLines = pform->m_pLines;
CClientDC cdc(pform);
It's worked, but as far as I know
1. Work thread should not touch the GUI ---- (Do the drawing).
2. MFC object should not passed to another thread ---- (passing drawing data by CMyDialog*)
Is there a good way to cancle long time drawing.
|
|
|
|
|
fitatc wrote: Is there a good way to cancle long time drawing.
See here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
|
fitatc wrote: May be You misunderstanding my qustion because of my poor english.
I understood you perfectly. If you are drawing in a worker thread and you need to cancel that thread, my advice is the way to go. Using a message pump is an antiquated and largely unused 16-bit Windows solution.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
Sorry for my late response,(I am in a busy work now)
You are right, but before that,
Do you think it is OK to draw in the work thread?
I mean, a good design? because drawing is touching the GUI I thought, maybe I was wrong.
|
|
|
|
|
fitatc wrote: Do you think it is OK to draw in the work thread?
I would think not. Have the worker thread post a message to the main thread (that owns the UI).
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
I am writing a code to read the bits from the file. Starting from first bit, i can read the whole file, and can retrieve the whole data as well. But if i want to retrieve the bits from somewhere between the file, how should i do this? One more thing, i am doing a string comparision of a module(and that module repeats several times in the file) and then i am retrieving the bits hence i can,t apply character counting.
It was a woman who drove me to drink but I never got opportunity to thank her
|
|
|
|
|
dubeypankaj wrote: But if i want to retrieve the bits from somewhere between the file, how should i do this?
It depends on how you are reading your file. Are you using an ifstream, a FILE, a CFile, ... ? Typically, you can set the file pointer (e.g. CFile::Seek, ifstream::seekg, ...). You should look at the documentation for more information.
|
|
|
|