|
Now I got the solution.
m_pDC->BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &memDC, 0, 0,SRCCOPY);
dc.BitBlt(0, 0, bm.bmWidth, bm.bmHeight, &memDC, 0, 0,SRCCOPY);
I replaced m_pDC with dc. and now it works.
THANKS A LOT INDEED FOR YOUR CONTINOUS HELP
|
|
|
|
|
Hi..
Basically I am working with CPP console application. Could any one update me, to capture screenshot of Desktop (by using the code mentioned in this thread).. whether I need to use MFC project or ATL based Project.
Any guidelines will help me a lot.
Thanks in advance.
|
|
|
|
|
Hi all,
I just got a new simple USB framegrabber which uses emBDA.sys (pretty common driver used by many USB frame grabbers/TV tuners these days) and when I try to access it in my MFC program, it BSODs right away with emBDA.sys error (8E code). But when I use their application to capture with the framegrabber, it works fine. I tried it on couple of systems with same result.
It happens as soon as I call capDlgVideoSource(GetSafeHwnd()); command.
Does anyone came accross this problem with accessing this driver before??
Any suggestions for using alternate drivers??
thanks,
PKNT
|
|
|
|
|
Hi,
how can i get the fixed border or proportional border for a rect...
|
|
|
|
|
i'm now wanna to convert the matlab left matrix division \ into cv++ with opencv.
i have no ideal about it. the matlab help file also not help me a lot to understand the algorithm.anyone can help me or gv me the suggestion? I'm waiting your reply.Thank you!
|
|
|
|
|
Hi all,
I write a MFC program that will execute a drawing circle in another thread when I click on somewhere in client area and I got it.
My problem is when I click various time (and quickly) it sometime gives me an "Assertion Failed" error.
here is my code:
void CGSimView::OnLButtonDown(UINT nFlags, CPoint point)
{
...
DCPOINT info;
PTPOINT3D currentPoint = pDoc->m_graph.GetNode(point.x,point.y);
if(currentPoint != NULL)
{
this->m_nodeIndex = currentPoint->index;
info.hwnd = this->GetSafeHwnd();
this->GetClientRect(&info.rect);
info.point = currentPoint;
AfxBeginThread(onGetFocus,&info);
}
CView::OnLButtonDown(nFlags, point);
}
UINT onGetFocus(LPVOID param)
{
DCPOINT *info = (DCPOINT*)param;
HDC hdc = GetDC(info->hwnd);
PTPOINT3D p = info->point;
int i, temp;
CRect rect = info->rect;
HPEN hPen, hOldPen;
hPen = CreatePen(PS_SOLID,1,RGB(225,0,0));
hOldPen = (HPEN)SelectObject(hdc, hPen);
for(i=0;i<9;i++)
{
temp = 10+i;
Ellipse(hdc,p->x - temp,p->y - temp,p->x + temp, p->y + temp);
Sleep(10);
}
SelectObject(hdc, hOldPen);
DeleteObject(hPen);
return 0;
}
please help me to solve this.
Thank in advance.
|
|
|
|
|
When it gives "Assert failed", click "Retry" to debug the program.
The code around the Assert statement usually gives a clue as to why it is failing. Sometimes there's a comment that tells explicitly why it might fail.
|
|
|
|
|
Thank Richard,
I have followed as your advise and the Debugger points to this line of my code:
Ellipse(hdc, p->x - temp, p->y - temp, p->x + temp, p->y + temp);
It says "Access violation".
I guess that it has some conflict between threads on the device context I've used. But I don't know how to solve it.
Please help!
|
|
|
|
|
When you debug it, inspect the variable "p" to be sure that it points to a valid object.
That may be the source of the access violation.
|
|
|
|
|
I failed to notice something serious:
You're trying to draw in the window with a secondary thread.
This is not allowed in MFC.
You must do all your drawing with the same thread that owns the window.
|
|
|
|
|
Thank Richard,
I greatly appreciate your help to me.
But now I'm completely surprised that drawing in the window with a secondary thread is not allowed in MFC.
Actually I'm writing a simple game, when my user selects an object on screen, I want my user take focus on that object by a moving circle around it. How people do that with MFC?
Thank
|
|
|
|
|
|
One thing I see that could also be part of your problem is that you do a GetDC() in your thread, and then you properly select the new pen, use it, select the old pen and delete it, but I don't see anywhere that you do a ReleaseDC().
This probably isn't the entire problem, but you should always release the DC after you use it that way.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
[moved to C++/CLI forum]
dev
modified on Wednesday, July 29, 2009 10:51 PM
|
|
|
|
|
You might have better luck posting this question in the C++/CLI forum.
|
|
|
|
|
When I compile my program, this is the error I get:
Compiling...
test proj.cpp
c:\program files\microsoft visual studio 8\vc\include\time.h(6) : fatal error C1083: Cannot open include file: 'stdafx.h': No such file or directory
it is a simple program without any errors, is there anyone that knows how I can fix this?
|
|
|
|
|
Easiest fix would be to create a new header file in your project called "stdafx.h".
You could make it blank, just as long as it is there.
|
|
|
|
|
good day,
here is my problem on how to link the commandbutton to radio buttons (mfc) in c++:
i inserted 3 radiobuttons inside a groupbox with a caption "Mode of payments";
radio1 with a caption "1. Cash (10% discount)";
radio2 with a caption "2. Two payments (5 % interest)";
radio3 with a caption "3. Three payments (10% interest);
i also have two editboxes; editbox1 and editbox2.
1. with a static text "enter tuition fee:" value will be accepted in the first editbox.
2. with a static text "Your total tuition fee is:" will be displayed in the second editbox.
and one command button with a caption "Compute"
supposing i will select the second radio button which is "two payments (5% interest)" upon clicking
the command button "compute" the result should be displayed in the second editbox under "your total tuition
fee:" which is the computation on the value of the first editbox and on the second radiobutton and so on...
if i will not use a commandbutton "compute" caption (to do the calculation) i can do the code and get the right result by
calculating the value of the first editbox and on the radiobutton values, but when i will use commandbutton to do
the calculation on the value of the first editbox to the radiobuttons that is now my problem since i cannot link the radiobuttons
and the commandbutton...
Please anybody help me in solving this problem...i need sample code as guide in solving this problem and on my future related
projects...
code experts please help me...
thank again and thank you in advance...
neil
|
|
|
|
|
Could you please restate more clearly what it is you want to do?
Do you want it to calculate the answer without having to click on the button?
|
|
|
|
|
i will select first on one of the radio buttons then by clicking on the command button which has a caption "compute" c++ will give an answer and it will be displayed in the second editbox.
|
|
|
|
|
So you want it to give a different answer depending upon which radio button is chosen?
|
|
|
|
|
yes sir if supposing i will select the first radio button which is "cash (10 % discount)" the calculated amount is the amount of the "enter tuition fee editbox1" * .90 since 10% will be deducted to the tuition fee. If radiobutton2 is selected "two payments (5% interest)" the calculated amount is the amount of the "enter tuition fee editbox1" + 5% interest. Please sir help me on this problem.
neil
|
|
|
|
|
All you have to do is use the GetCheck() function:
if ( radiobutton1.GetCheck() == BST_CHECKED )
{
}
if ( radiobutton2.GetCheck() == BST_CHECKED )
{
}
|
|
|
|
|
i will try this one sir...thank you very much for the help
neil
|
|
|
|
|
<big>thank you very much</big> chard your code solve my problem. I posted this problem because i dont have the sample code on how to connect the radiobutton to the command button. Spider and chandru never gave me the sample code to solve my problem.
here is now my code in c++
void CTuition1Dlg::OnButton1()
{
// TODO: Add your control notification handler code here
UpdateData();
if ( m_button1.GetCheck() == BST_CHECKED )
{
m_edit2 = m_edit1 * .9;
UpdateData(false);
}
if ( m_button2.GetCheck() == BST_CHECKED )
{
double x;
x = m_edit1 * .05;
m_edit2 = m_edit1 + x;
UpdateData(false);
}
if ( m_button3.GetCheck() == BST_CHECKED )
{
double x;
x = m_edit1 * .10;
m_edit2 = m_edit1 + x;
UpdateData(false);
}
UpdateData(false);
}
if its not for your code I cannot solve it...thank you very much
do you have ym sir chard?
i would like to ym you if i have a problem on programming and i wish that you will still help me.
Once again thank you...
neil
|
|
|
|