|
Hello!
I need to have a thread that can modify a Form.. I tried passing a form pointer as a param, but AfxBeginThread(...,LPVOID) says it cannot convert from Form1 __gc* to LPVOID. And I cannot make a unmanaged structure that contains a Form*..
How can I overcome this problem?
Alin Stoian
|
|
|
|
|
try this please
<br />
void CMyAnswer::RunThread()<br />
{<br />
CWinThread* m_Thread;<br />
<br />
m_Thread=AfxBeginThread ( MyThread, this,THREAD_PRIORITY_NORMAL,0,CREATE_SUSPENDED);<br />
if (m_Thread != NULL)<br />
m_Thread->ResumeThread();<br />
}<br />
<br />
<br />
UINT MyThread( LPVOID pv )<br />
{<br />
CMyAnswer* m_Answer = (CMyAnswer*) pv;<br />
<br />
m_Answer->Modify();<br />
<br />
return 0;<br />
}<br />
<br />
void CMyAnswer::Modify()<br />
{<br />
}<br />
<br />
WhiteSky
|
|
|
|
|
Thanx, I tried what you've recomended. The problomem still persists because I can't transform a managed pointer into a void one... maybe I missed something.
Anyway, your code works perfectly when using unmanaged classes like CMyAnswer.
Alin Stoian
|
|
|
|
|
If you're using managed objects, I recommend you use managed threads - delegates. It makes life a bit easier.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
Yes, it is easier to use managed threads.
Thanx,
Alin Stoian
|
|
|
|
|
|
Hi
any one help me for make video conferencing aplication in lan network
Sen
|
|
|
|
|
Hi,
I have been working on a project which requires getting the deleted files. Can someone please help me.
Thanks in advance
Ranjan
|
|
|
|
|
|
I want to get the files which are not present even in the recycle bin.(There are third party applications to do the same.)
|
|
|
|
|
//Modify the mortgage program to input the amount of the mortgage, the term of the mortgage,
//and the interest rate of the mortgage. Display the mortgage payment amount. Allow the user
//to loop back and enter new data or quit. Display and ammortization chart showing the Balance
//and Interest paid monthly. Pause to keep the information from scrolling off of the screen
//Insert thorough comments in the program to document the purpose of the program, the programmer,
//modifications, etc. When displaying money, always include a dollar sign and appropriate decimal
//output.
#include <iostream>
#include <math.h>
using namespace std;
int main() // beginning of main function
{ // starting brackets
//Local Variables
double LoanAmount=0; // shows amount of loan
double InterestRate=0; // rate
int Term=0; // terms of mortgage in months
char quit; //determines if user wants to quit
do
{
//Declare Variables
double InterestRate; // format in decimals
double MonthlyInterestRate; // monthly interest rate
int Months=12; //months in year
int TotalPayment; //number of payment on term
double Payment; //monthly payment amount
int PaymentCounter; // track number of payment
double LoanBalance; //loan balance
double MonthlyIntPymt; //monthly interest paid
double Principal; //principal paid monthly
int DivideList; //partial list
char ListMore; //keep viewing
//cin= provides for input from the terminal (keyboard)
//cout= provides for output to the screen.
cout << "Please enter your Loan Amount: ";
cin >> LoanAmount;
cout << "Enter the Interest Rate: ";
cin >> InterestRate;
cout << "How many years of loan: ";
cin >> Term;
//CALCULATIONS
InterestRate = InterestRate /100; //shows decimal
TotalPayment = Term * Months; //shows number of payments
MonthlyInterestRate=InterestRate / Months; // monthly APR
//CALCULATE MONTHLY AMOUNT
Payment = (LoanAmount*
pow(MonthlyInterestRate + 1, TotalPayment)
* MonthlyInterestRate)/(pow(MonthlyInterestRate + 1,
TotalPayment) - 1);
cout << "" << endl;
//OUTPUT
cout << "What is the Loan Amount: $" << LoanAmount << endl;
cout << "What is the Interest Rate: %" << InterestRate << endl;
cout << "Length of Loan: " << Term << endl;
cout << "Monthly Payment: " << Term << "Years" << endl;
cout << "" << endl;
cout << "Total Payment\tLoan Balance\tInterest Paid" <<;
cout << "" << endl;
//OUTPUT TOTAL PAYMENT, LOAN BALANCE, and INTEREST RATE
for(PaymentCounter=1; PaymentCounter<=TotalPayment; ++ PaymentCounter)
{
MonthlyIntPymt = LoanBalance * MonthlyInterestRate;
Principal = Payment - (LoanBalance * InterestRate);
LoanBalance = LoanBalance - Payment;
//Partial list choose to continue viewing, enter loan amount, or exit
if (DivideList == 12)
{
cout <<"Enter 'c' to continue viewing the list";
<<'L' to enter loan, or 'E' to exit: ";
cin >> ListMore;
if ((ListMore == 'c') || (ListMore == 'C'))
DivideList = 0;
else if ((ListMore == 'l') || (ListMore == 'L'))
break;
else if ((ListMore == 'e') || (ListMore == 'E'))
return 0;
}
//Display outcome of payments
cout<< Payment <<"\t\"
<< LoanBalance <<"\t"
<< MonthlyIntPymt <<"\t\tn";
++DivideList;
}
//Choose to LOOP or QUIT
cout<< "" << endl;
cout<< "Enter C to continue, Q to quit" <<;
cin>> quit;
cout<< "" << end1;
}
while (((quit!= 'q')));
return 0; // Causes the main function to finish
}
I'm having trouble getting my program to compile. I'm using Visual C++ Express Edition
|
|
|
|
|
DARJA- mortgage program wrote: I'm having trouble getting my program to compile.
When your program does not compile it is because you have errors in your code. The compiler will tell you what those errors are and where they are. You can easily read those for yourself, you do not need us for that.
If you have a specific question about what one of those error messages mean then post the error message and the line of code that it occured on, and maybe we can help you.
Just dumping your code on this message board and saying it does not compile is the lazy man's way of doing things and will get you no where.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I corrected my errors that were displayed but I didn't know if the order (calculations) of my program could be the cause of it not compiling. I am new to this and have been working on it for the past week but I'm not by any means taking the lazy man's route.
|
|
|
|
|
I have an application in MFC. I use the MFC Grid Control.
One of the column is type CheckBox, but I don't know how to check
if the cell is checked or not.
Regards
|
|
|
|
|
There are lots of MFC Grid controls around. Be specific as to which one you are using.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
I am using MFC Grid Control 2.25 (2.26)
Chris Maunder
http://www.codeproject.com/miscctrl/gridctrl.asp
Regards
|
|
|
|
|
The CGridCellCheck check class has a GetCheck() member that you can call.
BOOL IsCellChecked(CGridCtrl &Grid, int row, int col)
{
BOOL IsChecked = FALSE;
CGridCell *pCell = Grid.GetCell(row, col);
if (pCell != NULL)
{
CGridCellCheck *pCheck = dynamic_cast<CGridCellCheck *>(pCell);
if (pCheck != NULL)
{
IsChecked = pCheck->GetCheck();
}
}
return IsChecked;
}
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Hi!
Look at this code:
Graphics graphics(hdc) ;
Image * img ;
img = Image::FromFile("FileName") ;
graphics.DrawImage(img, 0, 0) ;
When I want to show Image in the Client Area The picture is larger than it should be. Why is that ?
I'm trying to load picture which size is 256x256, but when I use DrawImage, the picture that is drawn within the client area is larger(about 30%).
|
|
|
|
|
The DrawImage function has many overloads. Us the one where you also specify the width of the destination rectangle.
graphics.DrawImage(img, 0, 0, width, height);
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
Thank you very much!
But to be honest, I've found it later on
I was just unsure why it was like that, as I thought the function gets it's width and height from the Image structure.
|
|
|
|
|
1980soyo wrote: I'm trying to load picture which size is 256x256, but when I use DrawImage, the picture that is drawn within the client area is larger(about 30%).
Just a little ?, Do u know GDI+ library is very heavy,if you loading general FORMAT like jpeg,gif etc, then you can try your HAND in IPicture Interface, which provide light way to Display picture in your Program!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
I wrote on example from Graphic for you but I suggest if you need to open jpeg file and draw use CImage
whitesky
|
|
|
|
|
Hi guys,
i need some help, how can i make that the user not be able to undock the toolbars from the mainframe?
thanks in advance...
|
|
|
|
|
Removing the CBRS_GRIPPER style from the toolbar should do it.
You may be right
I may be crazy
-- Billy Joel --
Within you lies the power for good - Use it!
|
|
|
|
|
or remove this function DockControlBar(&m_wndToolBar);
whitesky
|
|
|
|