|
Jose Lamas Rios wrote:
No cookies but more coffe for me.
Sir, Then please pass that Cookie to me, I am Hungry at this moment .
"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
|
|
|
|
|
caykahve wrote:
, I need to get the CWnd pointer of the program window I opened.
There is no direct Method for getting Window Handle from the process ID, but this link may help:-
Is it possible to get info between HWND and Process handle?[^]
"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
|
|
|
|
|
.. this is another way to say Hi!! to u . but this is the only way now ..he he
V
|
|
|
|
|
Hi,
I want to create a custom control (which looks like a AND or OR gate) and place it ina docable window. These controls can be dragged and dropped in the client area, and used (Like MFC controls).I know how to create a docable window. I would like to know how to crearte a custom ActiveX control and add dragging and dropping feature in it. If anybody help, I wil be highly oblized.
Thanks
Lalit...
|
|
|
|
|
Dear All,
I bought a D-Link DFM-562E External Modem to develop IVR applications; unfortunately, I can not get the Device ID for wave in to play a wave file on it.
The TAPI function "LineGetId()" always fails with "LINEERR_NODEVICE" returned error.
Please give me a solution to this problem.
Note: the modem driver came with the modem is not a Microsoft digitally signature.
Thanks
|
|
|
|
|
( I'm having a bad week ..., so this might simply be a rant instead of a question )
I know that I cannot be certain that a value stored in a double will ever be internally represented like it is on paper, or as I type it in a text box and convert the string to a double.
for example for the value 2.5
I can either have ( not sure about the "real" decimal precision, so YMMV )
d = 2.50000000001;
or
d = 2.49999999999;
wich is acceptable if the desired precision is small.
now, the question is, and it's what is bugging me.
Is there a way to ensure better precision, or to round up to a precisison ?
also, can there be an issue when using the same DLL with debug or release version ? I have two different results with the same input when I build in debug or in release; I don't have access to the dll source code.
Thanks.
Max.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I don't think there is a way to ensure precision on the way the value is stored, unless the desired precision is small enough to convert it to an integer (so you would store 2.5 as 250 and know that you have to divide by 100 to get the actaul value), but you can implement the desired precision in your code checking, assuming the variance in the way the value is stored is less than the desired precision.
For example, if you are testing monetary values and you only need to be precise to 0.01 then equality is checked by something like fabs(a-b)<0.01 which is roughly equivalent to a==b. When checking for limits and you would ideally want, for example a<=100, just use a<100.01, etc.
|
|
|
|
|
Hi,
if you want to round up to a precision, try this one:
// Rounds a double to the nearest multiple of the passed seed.
double round(double Num, double Seed)
{
// get rational factor
double fac = Num / Seed;
// get natural factor
fac = (fac < 0) ? (static_cast<int>(fac - 0.5)) : (static_cast<int>(fac + 0.5));
// return multiple
return fac * Seed;
}
|
|
|
|
|
reason:
the FPU internally uses a higher precision. The "last digits" depend on how long the optimizer keeps a value in the FPU before writing it back to memory.
Builds are not even guaranteed to be "stable", i.e. the code generated may differ from build to build.
Always use an eps comparison ( fabs(a-b) < eps, where eps must be sufficiently small compared to the OOM of a and b)
Pandoras Gift #44: Hope. The one that keeps you on suffering. aber.. "Wie gesagt, der Scheiss is' Therapie" boost your code || Fold With Us! || sighist | doxygen
|
|
|
|
|
I'm trying to debug a problem where multiple applications (exe's) are loading a common dll. I have some debug output in the InitInstance() and ExitInstance() of the dll's CWinApp class. I'd really like to know which app is loading/unloading for each line of debug output (I'm writing lines to a file) but have not found a way to do this. The m_pszExeName and m_pszAppName variables are always the name of the dll - so that's no help. The m_lpCmdLine is always blank so that's no help either.
Is there a way to do this?
|
|
|
|
|
I don't know if that is feasible, it depends on the complexity of your project, but you could add the executable's name as an extra variable to some key calls to the dll and have the executables just provide their name to the dll for logging/debugging purposes.
|
|
|
|
|
This is not possible to found from the dll itself.
Dll's are loaded (mapped in process address space) by the loader,
so there could be a place to found which process load the dll.
But I can't provide more help for you, my knowledge is limited
to what I said.
|
|
|
|
|
Bummer. Unfortunately, not all of the app's that call my dll are written by my company. I guess I can add something to detect my app but the rest will have to remain unidentified.
Thanks anyway.
|
|
|
|
|
lynchspawn wrote:
I can add something to detect my app but the rest will have to remain unidentified.
Call the GetModuleFileName in your Code!
"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
|
|
|
|
|
::GetModuleFileName(GetModuleHandle(NULL), ...);
...cmk
Save the whales - collect the whole set
|
|
|
|
|
Even though MFC's DllMain() is calling your app's InitInstance() method, can you not use GetProcess() or GetProcessId() ?
"One must learn from the bite of the fire to leave it alone." - Native American Proverb
|
|
|
|
|
Hi
I am trying to learn MFC and Visual C++ while working on a project. I want to do a simple task in a function.
It is when the function is called I need to spawn a separate thread, pop up a message box in that thread and when the user presses OK or Cancel in that message Box, kill the spawned thread and pass control back to the main thread.
I am clueless how to do this. A simple code example will really help.
Thanks a Ton..
|
|
|
|
|
I could mail you a simple examlpe.
It popups message dialogs after a specified time span. Abortion is also included...
|
|
|
|
|
Here is a useful link: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmfc98/html/_mfc_afxbeginthread.asp
Try something like this to get you started:
INT MyThread( LPVOID ptr );
int main( int argc, char** argv )
{
CWinThread* T;
DWORD dwWait;
T = AfxBeginThread( MyThread, NULL );
dwWait = WaitForSingleObject( T->m_hThread, INFINITE );
return 0;
}
/* main() */
INT MyThread( LPVOID ptr )
{
AfxMessageBox( "Hello, world!" );
return 0;
}
|
|
|
|
|
create a worker thread..
UINT ClassName ::Thread1(LPVOID lp)
{
ClassName *cn = (ClassName*)lp;
cn->Thread1();
}
//// define the functionality inside the thread
void ClassName::Thread1()
{
while(1)
{
AfxMessageBox("In thread");
Sleep(millisec);
}
}
in the function,
Anyfun()
{
CWinThread *cwt;
cwt=AfxBeginThread(Thread1,this);
}
you can suspend the thread by cwt->SuspendThread();
resume by cwt->ResumeThread();
ExitInstance() will delete it
Regards,
V
|
|
|
|
|
to have a better look on a Thread... click on [View Thread] Below!!
jus fr fun,
V............v
|
|
|
|
|
Vivekuniq wrote:
click on [View Thread] Below!!
I have Clicked [View Thread] and................... I got nothing............:->
"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
|
|
|
|
|
This[^] article may help. Specifically, the section titled "Responding to user input while performing a long task".
/ravi
My new year's resolution: 2048 x 1536
Home | Music | Articles | Freeware | Trips
ravib(at)ravib(dot)com
|
|
|
|
|
Thanks for all the help. I could accomplish what I wanted to do with all your help.
Thank Again
|
|
|
|
|
The function call in the bold line always returns 0.
Isn't StretchBlt() able to transfer data between two memory DCs ?
CDC* ZoomBitmap(CBitmap* pBitmap, CWnd* pWindow)
{
// get source size
CSize srcSize = doGetSize(pBitmap);
// get destination size (client rect)
CSize dstSize = doGetZoomedSize(pBitmap, pWindow);
// create memory device contexts
CDC* pDC = pWindow->GetDC();
CDC* mem1 = new CDC; mem1->CreateCompatibleDC(pDC);
CDC* mem2 = new CDC; mem2->CreateCompatibleDC(pDC);
pWindow->ReleaseDC(pDC);
// select bitmap in original size
CBitmap* old = mem1->SelectObject(pBitmap);
// stretch bitmap
mem2->SetStretchBltMode(HALFTONE);
mem2->StretchBlt(0, 0, dstSize.cx, dstSize.cy, mem1, 0, 0, srcSize.cx, srcSize.cy, SRCCOPY);
// reselect old bitmap
mem1->SelectObject(old);
// delete temporary device context
delete mem1;
// use for future BitBlt() operations
return mem2;
}
|
|
|
|