|
I copy-pasted the OnSetValue1 function of a project of mine, and forgot to edit the class name, so CSurveyUpdateDlg::OnSetValue1 should be CThreadDlg::OnSetValue1
And don't forget to add the function prototype in the ThreadDlg.h header file too:
afx_msg LRESULT OnSetValue1(WPARAM wParam, LPARAM lParam);
The WMU_SETVALUE1 error is caused by a missing
#include "Thread.h"
in the file where you're calling PostMessage(WMU_SETVALUE1, ...)
That should do it.
|
|
|
|
|
Hi, have got the crash at BOOL AFXAPI AfxAssertFailedLine(LPCSTR lpszFileName, int nLine)
{
#ifndef _AFX_NO_DEBUG_CRT
// we remove WM_QUIT because if it is in the queue then the message box
// won't display
MSG msg;
BOOL bQuit = PeekMessage(&msg, NULL, WM_QUIT, WM_QUIT, PM_REMOVE);
BOOL bResult = _CrtDbgReport(_CRT_ASSERT, lpszFileName, nLine, NULL, NULL);
if (bQuit)
Thanks
Mehran
|
|
|
|
|
merh wrote: 'CSurveyUpdateDlg' : is not a class or namespace name
'WMU_SETVALUE1' : undeclared identifier
If these basic errors are troubling you, perhaps multithreaded applications should be postponed for a while. They're not a trivial concept.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi, I need how I can use PostMessage for sending the message with some parameters to main thread(window) and then how I can read the data from It.
Best regards
Mehran
|
|
|
|
|
Thanks a lot it works.
Have a nice weekend
M.H
|
|
|
|
|
See here.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
can anybody tell me how i can call a vb activex dll from c++
|
|
|
|
|
Follow this steps
1) Click on Tools->OLE/COM Object Viewer.
2) Press View TypeLib.
3) Select your VB dll location.
4) This will show you coclass and interfaces of the VB dll.
5) Save this file.This file is an IDL file.
6) Add this IDL file in your project.
7) Right click on IDL file and compile it.This will create a header
file of the IDL file.Now include this file where you want.
8) Use this file which has defination of the coclass and its interfaces.
ritz1234
|
|
|
|
|
philiptabraham wrote: can anybody tell me how i can call a vb activex dll from c++
Find the physical location of the VB file on the disk and use the #import directive to get the declarations into your program. I think if you use a recent enough version of Visual C++, you can #import by lib id.
Nathan
|
|
|
|
|
They can.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
|
|
|
|
|
Hi,
i am saving a HDC in one fuction of a class by using the following code
<br />
MyClass::MyFunction()<br />
{<br />
CDC dc;<br />
AfxGetApp()->CreatePrinterDC(dc);<br />
m_Hdc = dc.GetSafeHdc( );<br />
dc.Detach();<br />
}
Now in some other classes i am Creating a CDC class objcet using this HDC.
CDC *pDC = CDC::FromHandle(MyClasss::getMyHDC());
But some time it is causing my application to crash. But if i replace FromHandle() by Attach() and detach() the application is working fine.
So, i just want to know whether it is safe to use FromHandle() or not. If not should i replace all my FromHandle() by Attach and detach.
Thanks Ashwani
|
|
|
|
|
ashtwin wrote: CDC *pDC = CDC::FromHandle(MyClasss::getMyHDC());
Are you storing the pDC beyond a function call, CDC::FromHandle returns a temporary CDC object if HDC is not already attached. CDC::DeleteTempMap will delete the temporary CDC objects in idle processing. so if you using the object beyond a function call and there by alowing the idle processing to delete the object, application can crash if you access the temp object.
CDC::FromHandle() is less error-prone in the sense you do not have to remember to "detach". but remember it is used only in immediate processing.
In your MyClass::MyFunction(), you are Detaching the CDC, so it is sure that FromHandle creates temp map object, and possibly you are storing beyond a function call.
I suggest you to Keep attached the Printer DC with a member variable CDC and use it everywhere or use attach detach you should match the two calls then, or use FromHandle but with in a function call.
If the frequency of the call is high reduce the number of attach - detach.
modified on Friday, March 14, 2008 8:50 AM
|
|
|
|
|
Hi,
Currently i am using the pDC within the same fuction call though i am calling a seperate function to create it which is returning this pDC to the parent function and again from the parent function i am calling a seperate function which has pDC as one of its parameter.
<br />
CDC* dc = myPrintObj.createDCForPrint(printRect);<br />
doPrintWfReport(dc, printJob);<br />
The Funtion where i am getting the CDC object is as follows
<br />
CDC* PrintJob::PrintJobToPrinterType::createDCForPrint(const NcWfPrintJob& client, const CRect& printRect)<br />
{<br />
REQUIRE(!printRect.IsRectEmpty());<br />
<br />
DOCINFO DI;<br />
ZeroMemory(&DI, sizeof(DOCINFO));<br />
DI.cbSize = sizeof(DOCINFO);<br />
DI.lpszDocName = NcCommonResources().getWFReportDocName();<br />
<br />
CDC* pDC = CDC::FromHandle(client.getPrintInfo().hDC);<br />
pDC->SetMapMode(MM_HIMETRIC);<br />
<br />
pDC->StartDoc(&DI);<br />
pDC->StartPage();<br />
<br />
return pDC;<br />
}<br />
In the current design it is not possible for me to have a CDC object as a member varaible. Is it OK to use FromHandlePermanent() instead of FromHandle().
Thanks
|
|
|
|
|
Do you have FromHandlePermanent for CDC, i think it is for CWnd::FromHandlePermanent.
ashtwin wrote: Currently i am using the pDC within the same fuction call
I assume this is your new change, and works without crash.
ashtwin wrote: In the current design it is not possible for me to have a CDC object as a member varaible
why it is not possible, in createDCForPrint why don't you attach the printer DC to a member variable CDC::Attach and when you done printing you can call cleanup function like DeleteDCForPrint and detach and delete the DC stored in member variable. If you are using the DC within the function call as said above it is ok, make sure the idle processing which deletes the temp DC object not allowed to execute in between.
|
|
|
|
|
Sorry, u r right CDC don't have FromHandlePermanent(). Now the question is whether we can return a temporary object pointer from a function or not?
Thanks
Ashwani
|
|
|
|
|
ashtwin wrote: Now the question is whether we can return a temporary object pointer from a function or not?
That i answered repeatedly, if you are sure the idle processing is not allowed to execute that is used CDC within a function callstack which is running in the same thread as of the Message loop ad you are not doing windows message processing in between.
|
|
|
|
|
Ok, thanks.
I think
dc.StartDoc;
is the culprit. Because after prompting Save as dialogue the system will become idle and temporary objects are getting deleted during this call only.
|
|
|
|
|
Then what about returning an object which is attached using CDC::Attach not CDC::FromHandle.
CDC *CreatePrinterDC()
{
....
CDC *pdcPrinter = new CDC;
pdcPrinter ->Attach(hdcPrinter);
....
return pdcPrinter;
}
clean up
delete pdcPrinter; in main function;
|
|
|
|
|
Hi,
i think the solution which u r suggesting will definately work.
But i have overridden createDCForPrint() and in one function i am already using new to create CMetaFileDC object.
I will try to implement ur solution if possible.
Thanks
|
|
|
|
|
Hi
How can I read a selected file propetry sheet objects (info in propery pages)?
|
|
|
|
|
Your question is too vague. Please explain.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
If there are 10 files of same extension.In run time there is change in no of file how to get size of all files and sum it up as we dosent know the names of file.For vc++ dialog based application.give a sample code if possible
|
|
|
|
|
Check the following article[^]
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Ah, in addition to my other reply post check this[^]
Demian.
"I have always wished that my computer would be as easy to use as my
telephone. My wish has come true. I no longer know how to use my telephone."
-Bjarne Stroustrup, computer science professor, designer of C++
programming language (1950- )
|
|
|
|
|
Hi All,
I have a dialog based app..It has some buttons on it.
When I click a button, a Modal Dialog Box pops up.
Now, how do I position the Modal Dialog Box so that it is drawn over the button... ??
I want to draw the dialog boxws right over the corresponding buttons..
I have used SetWindowPos but it positions the dialog box relative to the top left of the screen.
I want to position it relative to the upper left vertex of the application's main dialog box
Hope I have clearly stated my problem
Regards,
AbbyIndian
...A Programmer may or may not be the master of the programming language grammar...
|
|
|
|